From fe2d149119063ec3c89fd6db9af8a6970e3e6032 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 23 Jun 2016 10:03:50 -0400 Subject: [PATCH] RT2867: des_ede3_cfb1 ignored "size in bits" flag Code and tests by Steve. Reviewed-by: Dr. Stephen Henson Reviewed-by: Rich Salz --- crypto/evp/e_des3.c | 2 ++ test/evptests.txt | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index e21c045307..a842913658 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -164,6 +164,8 @@ static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, size_t n; unsigned char c[1], d[1]; + if (!EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS)) + inl *= 8; for (n = 0; n < inl; ++n) { c[0] = (in[n / 8] & (1 << (7 - n % 8))) ? 0x80 : 0; DES_ede3_cfb_encrypt(c, d, 1, 1, diff --git a/test/evptests.txt b/test/evptests.txt index c0e906d839..a66a152956 100644 --- a/test/evptests.txt +++ b/test/evptests.txt @@ -201,6 +201,25 @@ Input = "aaaaaaaaaa" Count = 100000 Output = 0C99005BEB57EFF50A7CF005560DDF5D29057FD86B20BFD62DECA0F1CCEA4AF51FC15490EDDC47AF32BB2B66C34FF9AD8C6008AD677F77126953B226E4ED8B01 +# DES EDE3 CFB1 +# echo -n "Hello World" | +# apps/openssl enc -des-ede3-cfb1 \ +# -K 000102030405060708090A0B0C0D0E0F1011121314151617 -iv 0001020304050607 | +# xxd -ps -u + +Cipher = DES-EDE3-CFB1 +Key = 000102030405060708090A0B0C0D0E0F1011121314151617 +IV = 0001020304050607 +Plaintext = "Hello World" +Ciphertext = 3CF55D656E9C0664513358 + +Cipher = DES-EDE3-CFB1 +Key = 000102030405060708090A0B0C0D0E0F1011121314151617 +IV = 0001020304050607 +Operation = DECRYPT +Plaintext = "Hello World" +Ciphertext = 3CF55D656E9C0664513358 + # AES 128 ECB tests (from FIPS-197 test vectors, encrypt) Cipher = AES-128-ECB -- 2.40.0