1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-07-11 14:30:22 +02:00

avutil/twofish: Fixed decryption

The previous implementation swapped the two halves of the plaintext. The
existing tests only decrypted data with a plaintext of all zeroes, which is
not affected by swapping the halves. Tests which detect the old buggy behavior
have been added.

Signed-off-by: Sebastian Kirmayer <ffmpeg@kirmayer.eu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Sebastian Kirmayer
2021-08-09 03:26:20 +02:00
committed by Andreas Rheinhardt
parent bb69b734c7
commit dfd06ee710
2 changed files with 16 additions and 7 deletions

View File

@ -260,10 +260,10 @@ static void twofish_decrypt(AVTWOFISH *cs, uint8_t *dst, const uint8_t *src, uin
P[3] ^= AV_RL32(iv + 12);
memcpy(iv, src, 16);
}
AV_WL32(dst, P[2]);
AV_WL32(dst + 4, P[3]);
AV_WL32(dst + 8, P[0]);
AV_WL32(dst + 12, P[1]);
AV_WL32(dst, P[0]);
AV_WL32(dst + 4, P[1]);
AV_WL32(dst + 8, P[2]);
AV_WL32(dst + 12, P[3]);
}
av_cold int av_twofish_init(AVTWOFISH *cs, const uint8_t *key, int key_bits)