2 * Written in 2013 by Gregor Pintar <grpintar@gmail.com>
4 * To the extent possible under law, the author(s) have dedicated
5 * all copyright and related and neighboring rights to this software
6 * to the public domain worldwide.
8 * This software is distributed without any warranty.
10 * You should have received a copy of the CC0 Public Domain Dedication.
11 * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
17 #include <kripto/block/xtea.h>
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
30 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
31 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
35 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48
37 const uint8_t ct
[16][8] =
39 {0xA0, 0x39, 0x05, 0x89, 0xF8, 0xB8, 0xEF, 0xA5},
40 {0xB5, 0x6D, 0x5A, 0xA4, 0x70, 0xB6, 0xE0, 0x8C},
41 {0x73, 0x90, 0x10, 0xB4, 0xF3, 0x6A, 0xA9, 0xF1},
42 {0x73, 0x1B, 0xB8, 0x46, 0x45, 0x29, 0x9E, 0x65},
43 {0xB8, 0x4F, 0x4A, 0x9D, 0x30, 0xCB, 0x31, 0x57},
44 {0xD0, 0x4D, 0x97, 0x18, 0xE4, 0x2F, 0x12, 0xD3},
45 {0xC7, 0x32, 0x38, 0x99, 0xEA, 0x99, 0x74, 0xC2},
46 {0xC0, 0x36, 0x07, 0x02, 0x4A, 0xD8, 0xE4, 0x24},
47 {0x29, 0x1F, 0xD6, 0xF3, 0x49, 0x83, 0x79, 0x6E},
48 {0x84, 0x0A, 0x43, 0xD0, 0x73, 0xE0, 0xB1, 0x5B},
49 {0x1E, 0x6C, 0xC1, 0xA9, 0x17, 0x1B, 0x60, 0xF1},
50 {0x51, 0xEA, 0x6A, 0x4D, 0x09, 0x68, 0x79, 0x0F},
51 {0xF8, 0x12, 0xD3, 0xF4, 0xCB, 0xE2, 0x30, 0xB5},
52 {0x2E, 0x02, 0x84, 0xAC, 0x58, 0xB9, 0x34, 0xB5},
53 {0x0D, 0x9E, 0x10, 0x95, 0x83, 0x62, 0x06, 0x60},
54 {0x49, 0x7D, 0xF3, 0xD0, 0x72, 0x61, 0x2C, 0xB5}
57 puts("kripto_block_xtea");
59 for(n
= 1; n
<= 16; n
++)
61 s
= kripto_block_create(kripto_block_xtea
, 0, k
, n
);
64 kripto_block_encrypt(s
, pt
, t
);
65 for(i
= 0; i
< 8; i
++) if(t
[i
] != ct
[n
- 1][i
])
67 printf("%u-bit key encrypt: FAIL\n", n
* 8);
70 if(i
== 8) printf("%u-bit key encrypt: OK\n", n
* 8);
71 kripto_block_decrypt(s
, ct
[n
- 1], t
);
72 for(i
= 0; i
< 8; i
++) if(t
[i
] != pt
[i
])
74 printf("%u-bit key decrypt: FAIL\n", n
* 8);
77 if(i
== 8) printf("%u-bit key decrypt: OK\n", n
* 8);
79 kripto_block_destroy(s
);