From: Andy Polyakov Date: Tue, 18 Jan 2005 00:26:52 +0000 (+0000) Subject: Don't zap AES CBC IV, when decrypting truncated content in place. X-Git-Tag: OpenSSL_0_9_7g~17^2~70 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90cc40911b031d9ae4597fd2b66c6fd24de2f9d9;p=openssl Don't zap AES CBC IV, when decrypting truncated content in place. --- 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); } }