Commit 8c3ee93b authored by Giorgio Vazzana's avatar Giorgio Vazzana Committed by Michael Niedermayer

xtea: fix CBC mode when src=dst

In CBC mode, when src=dst and we are decrypting a block different
from the first one, we need to save the current block of ciphertext
(which will constitute the initialization vector for the next block)
before we overwrite it.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent a0321dad
......@@ -152,14 +152,21 @@ void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count,
uint8_t *iv, int decrypt)
{
int i;
uint8_t iv_tmp[8];
if (decrypt) {
while (count--) {
if (src == dst)
memcpy(iv_tmp, src, 8);
xtea_crypt_ecb(ctx, dst, src, decrypt);
if (iv) {
for (i = 0; i < 8; i++)
dst[i] = dst[i] ^ iv[i];
if (src == dst)
memcpy(iv, iv_tmp, 8);
else
memcpy(iv, src, 8);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment