summaryrefslogtreecommitdiff
path: root/libavutil/xtea.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-09-30 17:36:01 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-09-30 17:51:45 +0200
commita4dcdd04d7dc2fce0a0f683d361d6d4760a152f9 (patch)
tree0dbc537aceb3e27eba26a4b8c0662855eee5af9c /libavutil/xtea.c
parent8c3ee93be5ef757b12da81d14029f74c78b942ee (diff)
downloadffmpeg-a4dcdd04d7dc2fce0a0f683d361d6d4760a152f9.tar.gz
xtea-test: test inplace decryption
Based on test code by: Giorgio Vazzana <mywing81@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/xtea.c')
-rw-r--r--libavutil/xtea.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavutil/xtea.c b/libavutil/xtea.c
index f2dfe99a46..c952042531 100644
--- a/libavutil/xtea.c
+++ b/libavutil/xtea.c
@@ -231,8 +231,11 @@ static const uint8_t xtea_test_ct[XTEA_NUM_TESTS][8] = {
int main(void)
{
AVXTEA ctx;
- uint8_t buf[8];
+ uint8_t buf[8], iv[8];
int i;
+ const uint8_t src[32] = "HelloWorldHelloWorldHelloWorld";
+ uint8_t ct[32];
+ uint8_t pl[32];
#define CHECK(dst, src, ref, len, iv, dir, error) \
av_xtea_crypt(&ctx, dst, src, len, iv, dir);\
@@ -247,7 +250,18 @@ int main(void)
CHECK(buf, xtea_test_pt[i], xtea_test_ct[i], 1, NULL, 0, "Test encryption failed.\n");
CHECK(buf, xtea_test_ct[i], xtea_test_pt[i], 1, NULL, 1, "Test decryption failed.\n");
+ /* encrypt */
+ memcpy(iv, "HALLO123", 8);
+ av_xtea_crypt(&ctx, ct, src, 4, iv, 0);
+
+ /* decrypt into pl */
+ memcpy(iv, "HALLO123", 8);
+ CHECK(pl, ct, src, 4, iv, 1, "Test IV decryption failed.\n");
+
+ memcpy(iv, "HALLO123", 8);
+ CHECK(ct, ct, src, 4, iv, 1, "Test IV inplace decryption failed.\n");
}
+
printf("Test encryption/decryption success.\n");
return 0;