summaryrefslogtreecommitdiff
path: root/libavutil/blowfish.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2012-10-02 00:04:38 +0300
committerMartin Storsjö <martin@martin.st>2012-10-03 16:05:23 +0300
commit87f023f2c01e7004618537114e2d53be69b01019 (patch)
treeaef62c1cc6e6e9814abad7469f2b713448008126 /libavutil/blowfish.c
parent0cc9a64b92939adfe4408003ff119607001a88e0 (diff)
blowfish: Fix CBC decryption with dst==src
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil/blowfish.c')
-rw-r--r--libavutil/blowfish.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavutil/blowfish.c b/libavutil/blowfish.c
index 35c546a898..604c0be821 100644
--- a/libavutil/blowfish.c
+++ b/libavutil/blowfish.c
@@ -388,15 +388,15 @@ void av_blowfish_crypt(AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
av_blowfish_crypt_ecb(ctx, &v0, &v1, decrypt);
- AV_WB32(dst, v0);
- AV_WB32(dst + 4, v1);
-
if (iv) {
- for (i = 0; i < 8; i++)
- dst[i] = dst[i] ^ iv[i];
+ v0 ^= AV_RB32(iv);
+ v1 ^= AV_RB32(iv + 4);
memcpy(iv, src, 8);
}
+ AV_WB32(dst, v0);
+ AV_WB32(dst + 4, v1);
+
src += 8;
dst += 8;
}