From 90cc40911b031d9ae4597fd2b66c6fd24de2f9d9 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Tue, 18 Jan 2005 00:26:52 +0000 Subject: [PATCH] Don't zap AES CBC IV, when decrypting truncated content in place. --- crypto/aes/aes_cbc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crypto/aes/aes_cbc.c b/crypto/aes/aes_cbc.c index f909aaf47a..d2ba6bcdb4 100644 --- a/crypto/aes/aes_cbc.c +++ b/crypto/aes/aes_cbc.c @@ -120,9 +120,11 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, } if (len) { memcpy(tmp, in, AES_BLOCK_SIZE); - AES_decrypt(tmp, tmp, key); + AES_decrypt(tmp, out, key); for(n=0; n < len; ++n) - out[n] = tmp[n] ^ ivec[n]; + out[n] ^= ivec[n]; + for(n=len; n < AES_BLOCK_SIZE; ++n) + out[n] = tmp[n]; memcpy(ivec, tmp, AES_BLOCK_SIZE); } } -- 2.40.0