diff options
author | Matt Braithwaite <mab@google.com> | 2015-08-18 20:27:03 -0700 |
---|---|---|
committer | Skrilax_CZ <skrilax@gmail.com> | 2016-02-15 01:18:43 -0800 |
commit | e7d1294b4fba014f16e35b924584dcd8f81956e9 (patch) | |
tree | f4be905bf15a67dda22726fabf6fb002dc34b0a0 /src/crypto/cipher/e_des.c | |
parent | 1035653b65b940ee8fb0449b1eddafeb8fbd62de (diff) | |
download | external_boringssl-e7d1294b4fba014f16e35b924584dcd8f81956e9.zip external_boringssl-e7d1294b4fba014f16e35b924584dcd8f81956e9.tar.gz external_boringssl-e7d1294b4fba014f16e35b924584dcd8f81956e9.tar.bz2 |
Add |EVP_des_ecb| from OpenSSL at fd682e4c.
|DES_ecb_encrypt| was already present.
This benefits globalplatform.
Change-Id: I2ab41eb1936b3026439b5981fb27e29a12672b66
Reviewed-on: https://boringssl-review.googlesource.com/5723
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'src/crypto/cipher/e_des.c')
-rw-r--r-- | src/crypto/cipher/e_des.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/crypto/cipher/e_des.c b/src/crypto/cipher/e_des.c index 74e1fce..d7bef92 100644 --- a/src/crypto/cipher/e_des.c +++ b/src/crypto/cipher/e_des.c @@ -96,6 +96,30 @@ static const EVP_CIPHER des_cbc = { const EVP_CIPHER *EVP_des_cbc(void) { return &des_cbc; } +static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, + size_t in_len) { + if (in_len < ctx->cipher->block_size) { + return 1; + } + in_len -= ctx->cipher->block_size; + + EVP_DES_KEY *dat = (EVP_DES_KEY *) ctx->cipher_data; + for (size_t i = 0; i <= in_len; i += ctx->cipher->block_size) { + DES_ecb_encrypt((DES_cblock *) (in + i), (DES_cblock *) (out + i), + &dat->ks.ks, ctx->encrypt); + } + return 1; +} + +static const EVP_CIPHER des_ecb = { + NID_des_ecb, 8 /* block_size */, 8 /* key_size */, + 0 /* iv_len */, sizeof(EVP_DES_KEY), EVP_CIPH_ECB_MODE, + NULL /* app_data */, des_init_key, des_ecb_cipher, + NULL /* cleanup */, NULL /* ctrl */, }; + +const EVP_CIPHER *EVP_des_ecb(void) { return &des_ecb; } + + typedef struct { union { double align; |