]> granicus.if.org Git - openssl/commitdiff
Don't zap AES CBC IV, when decrypting truncated content in place.
authorAndy Polyakov <appro@openssl.org>
Tue, 18 Jan 2005 00:26:52 +0000 (00:26 +0000)
committerAndy Polyakov <appro@openssl.org>
Tue, 18 Jan 2005 00:26:52 +0000 (00:26 +0000)
crypto/aes/aes_cbc.c

index f909aaf47a19a1be0da7267206f3d7497432b393..d2ba6bcdb4659d1ed9c6a01a898b08e167e0f2ef 100644 (file)
@@ -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);
                }
        }