diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-09-30 17:19:54 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-09-30 17:51:45 +0200 |
commit | a0321dadfde0e000de4e67cf9c709b8c667a02f8 (patch) | |
tree | a03f254dd907d5092c76269f70f0ea6e14ad5aa5 /libavutil/xtea.c | |
parent | 3fa100244fb95ae3730e67d0b05bdc328a1d0a7b (diff) | |
download | ffmpeg-a0321dadfde0e000de4e67cf9c709b8c667a02f8.tar.gz |
xtea-test: factorize test code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/xtea.c')
-rw-r--r-- | libavutil/xtea.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/libavutil/xtea.c b/libavutil/xtea.c index d9c2858a5c..bfc613dc47 100644 --- a/libavutil/xtea.c +++ b/libavutil/xtea.c @@ -227,20 +227,19 @@ int main(void) uint8_t buf[8]; int i; +#define CHECK(dst, src, ref, len, iv, dir, error) \ + av_xtea_crypt(&ctx, dst, src, len, iv, dir);\ + if (memcmp(dst, ref, 8*len)) {\ + printf(error);\ + return 1;\ + } + for (i = 0; i < XTEA_NUM_TESTS; i++) { av_xtea_init(&ctx, xtea_test_key[i]); - av_xtea_crypt(&ctx, buf, xtea_test_pt[i], 1, NULL, 0); - if (memcmp(buf, xtea_test_ct[i], 8)) { - printf("Test encryption failed.\n"); - return 1; - } + 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"); - av_xtea_crypt(&ctx, buf, xtea_test_ct[i], 1, NULL, 1); - if (memcmp(buf, xtea_test_pt[i], 8)) { - printf("Test decryption failed.\n"); - return 1; - } } printf("Test encryption/decryption success.\n"); |