27 #define XTEA_NUM_TESTS 6
30 { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
31 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
32 { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
33 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
34 { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
35 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
36 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
38 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
40 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
45 { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 },
46 { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 },
47 { 0x5a, 0x5b, 0x6e, 0x27, 0x89, 0x48, 0xd7, 0x7f },
48 { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 },
49 { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 },
50 { 0x70, 0xe1, 0x22, 0x5d, 0x6e, 0x4e, 0x76, 0x55 }
54 { 0x49, 0x7d, 0xf3, 0xd0, 0x72, 0x61, 0x2c, 0xb5 },
55 { 0xe7, 0x8f, 0x2d, 0x13, 0x74, 0x43, 0x41, 0xd8 },
56 { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 },
57 { 0xa0, 0x39, 0x05, 0x89, 0xf8, 0xb8, 0xef, 0xa5 },
58 { 0xed, 0x23, 0x37, 0x5a, 0x82, 0x1a, 0x8c, 0x2d },
59 { 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41 }
67 crypt(ctx, dst, src, len, iv, dir);
68 if (memcmp(dst, ref, 8*len)) {
70 printf(
"%s failed\ngot ", test);
71 for (i = 0; i < 8*
len; i++)
72 printf(
"%02x ", dst[i]);
73 printf(
"\nexpected ");
74 for (i = 0; i < 8*
len; i++)
75 printf(
"%02x ", ref[i]);
86 static const uint8_t src[32] =
"HelloWorldHelloWorldHelloWorld";
96 for (j = 0; j < 4; j++)
99 for (j = 0; j < 2; j++) {
107 memcpy(iv,
"HALLO123", 8);
111 memcpy(iv,
"HALLO123", 8);
114 memcpy(iv,
"HALLO123", 8);
118 printf(
"Test encryption/decryption success.\n");
static const uint8_t xtea_test_ct[XTEA_NUM_TESTS][8]
static const uint8_t crypt[]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void av_xtea_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context, in big endian format...
static const uint8_t xtea_test_pt[XTEA_NUM_TESTS][8]
static int ref[MAX_W *MAX_W]
void av_xtea_init(AVXTEA *ctx, const uint8_t key[16])
Initialize an AVXTEA context.
static void test(const char *pattern, const char *host)
Public header for libavutil XTEA algorithm.
void av_xtea_le_init(AVXTEA *ctx, const uint8_t key[16])
Initialize an AVXTEA context.
static void test_xtea(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, const uint8_t *ref, int len, uint8_t *iv, int dir, const char *test, void(*crypt)(AVXTEA *, uint8_t *, const uint8_t *, int, uint8_t *, int))
static const uint8_t xtea_test_key[XTEA_NUM_TESTS][16]
void av_xtea_le_crypt(AVXTEA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context, in little endian format...