summaryrefslogtreecommitdiff
path: root/libavutil/twofish.c
diff options
context:
space:
mode:
authorSebastian Kirmayer <ffmpeg@kirmayer.eu>2021-08-09 03:26:20 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-19 01:02:59 +0100
commitdfd06ee710b547e0027a38f63cabe868e9ef1a3c (patch)
treee38fc1510f0a7daca4f0fd7871c745ffccc4f0bb /libavutil/twofish.c
parentbb69b734c74cc22301a4fa2c3263077ffe7064b1 (diff)
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>
Diffstat (limited to 'libavutil/twofish.c')
-rw-r--r--libavutil/twofish.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavutil/twofish.c b/libavutil/twofish.c
index d84fa4f363..649b4bc41b 100644
--- a/libavutil/twofish.c
+++ b/libavutil/twofish.c
@@ -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)