[FFmpeg-cvslog] Merge commit 'ded4a6543dfb5a2f1d9f7fb8d3ab27a1872c22b3'

Clément Bœsch git at videolan.org
Fri Jun 24 11:16:21 CEST 2016


ffmpeg | branch: master | Clément Bœsch <clement at stupeflix.com> | Fri Jun 24 11:16:52 2016 +0200| [b77f62e27fd777ce0fd4eb2766ccc13ab91df957] | committer: Clément Bœsch

Merge commit 'ded4a6543dfb5a2f1d9f7fb8d3ab27a1872c22b3'

* commit 'ded4a6543dfb5a2f1d9f7fb8d3ab27a1872c22b3':
  xtea-test: Use struct allocation functions from the API

Merged-by: Clément Bœsch <clement at stupeflix.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b77f62e27fd777ce0fd4eb2766ccc13ab91df957
---

 libavutil/tests/xtea.c |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/libavutil/tests/xtea.c b/libavutil/tests/xtea.c
index a974600..6a8c647 100644
--- a/libavutil/tests/xtea.c
+++ b/libavutil/tests/xtea.c
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
 #include "libavutil/xtea.h"
 
 #define XTEA_NUM_TESTS 6
@@ -80,42 +81,45 @@ static void test_xtea(AVXTEA *ctx, uint8_t *dst, const uint8_t *src,
 
 int main(void)
 {
-    AVXTEA ctx;
     uint8_t buf[16], iv[8];
     int i, j;
     static const uint8_t src[32] = "HelloWorldHelloWorldHelloWorld";
     uint8_t ct[32];
     uint8_t pl[32];
+    AVXTEA *ctx = av_xtea_alloc();
+    if (!ctx)
+        return 1;
 
     for (i = 0; i < XTEA_NUM_TESTS; i++) {
-        av_xtea_init(&ctx, xtea_test_key[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", av_xtea_crypt);
-        test_xtea(&ctx, buf, xtea_test_ct[i], xtea_test_pt[i], 1, NULL, 1, "decryption", av_xtea_crypt);
+        test_xtea(ctx, buf, xtea_test_pt[i], xtea_test_ct[i], 1, NULL, 0, "encryption", av_xtea_crypt);
+        test_xtea(ctx, buf, xtea_test_ct[i], xtea_test_pt[i], 1, NULL, 1, "decryption", av_xtea_crypt);
 
         for (j = 0; j < 4; j++)
             AV_WL32(&buf[4*j], AV_RB32(&xtea_test_key[i][4*j]));
-        av_xtea_le_init(&ctx, buf);
+        av_xtea_le_init(ctx, buf);
         for (j = 0; j < 2; j++) {
             AV_WL32(&ct[4*j], AV_RB32(&xtea_test_ct[i][4*j]));
             AV_WL32(&pl[4*j], AV_RB32(&xtea_test_pt[i][4*j]));
         }
-        test_xtea(&ctx, buf, pl, ct, 1, NULL, 0, "encryption", av_xtea_le_crypt);
-        test_xtea(&ctx, buf, ct, pl, 1, NULL, 1, "decryption", av_xtea_le_crypt);
+        test_xtea(ctx, buf, pl, ct, 1, NULL, 0, "encryption", av_xtea_le_crypt);
+        test_xtea(ctx, buf, ct, pl, 1, NULL, 1, "decryption", av_xtea_le_crypt);
 
         /* encrypt */
         memcpy(iv, "HALLO123", 8);
-        av_xtea_crypt(&ctx, ct, src, 4, iv, 0);
+        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", av_xtea_crypt);
+        test_xtea(ctx, pl, ct, src, 4, iv, 1, "CBC decryption", av_xtea_crypt);
 
         memcpy(iv, "HALLO123", 8);
-        test_xtea(&ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption", av_xtea_crypt);
+        test_xtea(ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption", av_xtea_crypt);
     }
 
     printf("Test encryption/decryption success.\n");
+    av_free(ctx);
 
     return 0;
 }


======================================================================

diff --cc libavutil/tests/xtea.c
index a974600,8fd76dd..6a8c647
--- a/libavutil/tests/xtea.c
+++ b/libavutil/tests/xtea.c
@@@ -109,13 -112,13 +112,14 @@@ int main(void
  
          /* decrypt into pl */
          memcpy(iv, "HALLO123", 8);
-         test_xtea(&ctx, pl, ct, src, 4, iv, 1, "CBC decryption", av_xtea_crypt);
+         test_xtea(ctx, pl, ct, src, 4, iv, 1, "CBC decryption", av_xtea_crypt);
  
          memcpy(iv, "HALLO123", 8);
-         test_xtea(&ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption", av_xtea_crypt);
+         test_xtea(ctx, ct, ct, src, 4, iv, 1, "CBC inplace decryption", av_xtea_crypt);
      }
 +
      printf("Test encryption/decryption success.\n");
+     av_free(ctx);
  
      return 0;
  }



More information about the ffmpeg-cvslog mailing list