diff options
author | Richard Levitte <levitte@openssl.org> | 2003-10-15 09:00:18 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2003-10-15 09:00:18 +0000 |
commit | fa5846e58b2caecbb33460a7d6f78b02719d312e (patch) | |
tree | 03d915778d8faba58a1a93dc143ec655705daab9 /crypto/aes | |
parent | 79e4022a331b6632946bf0f68fd0f64b3bcd283d (diff) |
Correct serious bug in AES-CBC decryption when the message length isn't
a multiple of AES_BLOCK_SIZE.
Optimize decryption of all complete blocks in AES-CBC by removing an
unnecessary memcpy().
The error was notified by James Fernandes <jf210032@exchange.DAYTONOH.NCR.com>.
The unnecessary memcpy() was found as an effect of investigating that error.
Diffstat (limited to 'crypto/aes')
-rw-r--r-- | crypto/aes/aes_cbc.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/aes/aes_cbc.c b/crypto/aes/aes_cbc.c index 86b27b10d6..0a28ab8d34 100644 --- a/crypto/aes/aes_cbc.c +++ b/crypto/aes/aes_cbc.c @@ -91,21 +91,20 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, } } else { while (len >= AES_BLOCK_SIZE) { - memcpy(tmp, in, AES_BLOCK_SIZE); AES_decrypt(in, out, key); for(n=0; n < AES_BLOCK_SIZE; ++n) out[n] ^= ivec[n]; - memcpy(ivec, tmp, AES_BLOCK_SIZE); + memcpy(ivec, in, AES_BLOCK_SIZE); len -= AES_BLOCK_SIZE; in += AES_BLOCK_SIZE; out += AES_BLOCK_SIZE; } if (len) { memcpy(tmp, in, AES_BLOCK_SIZE); - AES_decrypt(tmp, tmp, key); + AES_decrypt(in, tmp, key); for(n=0; n < len; ++n) - out[n] ^= ivec[n]; - memcpy(ivec, tmp, AES_BLOCK_SIZE); + out[n] = tmp[n] ^ ivec[n]; + memcpy(ivec, in, AES_BLOCK_SIZE); } } } |