From f0fce9f33e604544c678b6de4c29301ed4d0751f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 30 Sep 2012 17:36:01 +0200 Subject: xtea: Test inplace decryption MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on test code by: Giorgio Vazzana Signed-off-by: Martin Storsjö --- libavutil/xtea.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libavutil/xtea.c') diff --git a/libavutil/xtea.c b/libavutil/xtea.c index cf63670dbe..f3357ce544 100644 --- a/libavutil/xtea.c +++ b/libavutil/xtea.c @@ -160,14 +160,28 @@ static void test_xtea(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, 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]; for (i = 0; i < XTEA_NUM_TESTS; i++) { av_xtea_init(&ctx, xtea_test_key[i]); test_xtea(&ctx, buf, xtea_test_pt[i], xtea_test_ct[i], 1, NULL, 0, "encryption"); test_xtea(&ctx, buf, xtea_test_ct[i], xtea_test_pt[i], 1, NULL, 1, "decryption"); + + /* encrypt */ + memcpy(iv, "HALLO123", 8); + av_xtea_crypt(&ctx, ct, src, 4, iv, 0); + + /* decrypt into pl */ + memcpy(iv, "HALLO123", 8); + test_xtea(&ctx, pl, ct, src, 4, iv, 1, "CBC decryption"); + + memcpy(iv, "HALLO123", 8); + test_xtea(&ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption"); } printf("Test encryption/decryption success.\n"); -- cgit v1.2.3