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/aria.h>
25 const uint8_t pt
[16] =
27 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA,
28 0x11, 0x11, 0x11, 0x11, 0xBB, 0xBB, 0xBB, 0xBB
32 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
33 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
34 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
35 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
37 const uint8_t ct
[32][16] =
40 0x7B, 0xC4, 0xB9, 0x28, 0xC0, 0x0C, 0xAC, 0x31,
41 0x3E, 0xF5, 0x83, 0x33, 0xC4, 0x8D, 0x3D, 0x4F
44 0x1A, 0x2E, 0x39, 0x22, 0xDD, 0x3A, 0xBD, 0x9E,
45 0xE0, 0x51, 0xFA, 0x70, 0xC6, 0x9F, 0xAF, 0x1B
48 0x22, 0x74, 0x51, 0xF3, 0x7F, 0xC4, 0x0E, 0x65,
49 0x71, 0xF7, 0xF8, 0xDB, 0xB9, 0xC4, 0xD4, 0x43
52 0xD3, 0xD9, 0x69, 0x3F, 0xB2, 0x45, 0x30, 0xB5,
53 0xFE, 0xDA, 0xD1, 0x77, 0xAA, 0xF5, 0x6A, 0x33
56 0x96, 0x87, 0x96, 0x5B, 0x61, 0x4F, 0xBC, 0x83,
57 0x75, 0x7B, 0x83, 0xD5, 0x5E, 0xD0, 0x06, 0x65
60 0x8F, 0x6F, 0x35, 0xD2, 0x6B, 0x0E, 0x15, 0x98,
61 0xF4, 0x5C, 0x4D, 0x4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, 0x8C, 0x37, 0xEE, 0xC9
108 0xB4, 0xE4, 0x60, 0x02, 0xBD, 0xD2, 0xC6, 0x44,
109 0xDA, 0xEE, 0x96, 0x4C, 0xE2, 0x7D, 0xDA, 0x11
112 0x02, 0x89, 0x69, 0xDC, 0x6E, 0xF0, 0xE3, 0x1A,
113 0x6D, 0xAC, 0x18, 0x23, 0x28, 0xC6, 0x77, 0x9D
116 0xEA, 0x94, 0x71, 0x51, 0xD0, 0x7B, 0xDF, 0x7A,
117 0x18, 0x69, 0x4F, 0x67, 0x21, 0xB3, 0xCB, 0x7A
120 0x2B, 0x75, 0x2D, 0x13, 0xF1, 0x4E, 0x02, 0x70,
121 0xC3, 0xDE, 0x86, 0xEA, 0x8E, 0x89, 0x24, 0xC7
124 0xF7, 0x31, 0xDC, 0x0A, 0x74, 0xA8, 0x44, 0xF5,
125 0xD0, 0x98, 0xA8, 0x3D, 0x52, 0x3D, 0xED, 0xC2
128 0xE3, 0x68, 0xD5, 0xF7, 0xE3, 0xEF, 0xA1, 0x83,
129 0x55, 0x60, 0xD7, 0x9B, 0xF9, 0x98, 0x27, 0x6C
132 0x8D, 0x14, 0x70, 0x62, 0x5F, 0x59, 0xEB, 0xAC,
133 0xB0, 0xE5, 0x5B, 0x53, 0x4B, 0x3E, 0x46, 0x2B
136 0x3D, 0xAD, 0xD9, 0x9E, 0xD1, 0x23, 0xD1, 0xCF,
137 0x3C, 0x3C, 0x16, 0x17, 0x92, 0x56, 0x88, 0x4C
140 0x1D, 0x3F, 0xD8, 0x2A, 0xAE, 0xD5, 0xF0, 0x75,
141 0xA7, 0x00, 0x8C, 0xDB, 0x70, 0x40, 0x1C, 0x8B
144 0xAF, 0x4E, 0x6A, 0x00, 0x70, 0x60, 0x68, 0x60,
145 0x08, 0x93, 0x92, 0x60, 0x02, 0xFF, 0xDF, 0xF2
148 0x08, 0x63, 0x19, 0xDE, 0x5D, 0xBC, 0x18, 0x9F,
149 0x68, 0x00, 0x9D, 0xA2, 0xDD, 0x11, 0xA7, 0x28
152 0x9F, 0x70, 0x90, 0xEA, 0x7E, 0xC6, 0xAB, 0xF5,
153 0xAF, 0xE1, 0x67, 0xDA, 0x4C, 0x6D, 0xA5, 0x3C
156 0xD1, 0x6C, 0x97, 0xC6, 0x78, 0x87, 0x86, 0x51,
157 0x65, 0x90, 0xF4, 0x0A, 0xD8, 0x78, 0x20, 0x6C
160 0x56, 0x8A, 0x63, 0x6B, 0x44, 0x4F, 0xD5, 0x62,
161 0x78, 0x30, 0x0B, 0xDE, 0x13, 0x35, 0x8B, 0x78
164 0x58, 0xA8, 0x75, 0xE6, 0x04, 0x4A, 0xD7, 0xFF,
165 0xFA, 0x4F, 0x58, 0x42, 0x0F, 0x7F, 0x44, 0x2D
169 puts("kripto_block_aria");
171 for(n
= 1; n
<= 32; n
++)
173 s
= kripto_block_create(kripto_block_aria
, 0, k
, n
);
174 if(!s
) puts("error");
176 kripto_block_encrypt(s
, pt
, t
);
177 for(i
= 0; i
< 16; i
++) if(t
[i
] != ct
[n
- 1][i
])
179 printf("%u-bit key encrypt: FAIL\n", n
* 8);
182 if(i
== 16) printf("%u-bit key encrypt: OK\n", n
* 8);
184 kripto_block_decrypt(s
, ct
[n
- 1], t
);
185 for(i
= 0; i
< 16; i
++) if(t
[i
] != pt
[i
])
187 printf("%u-bit key decrypt: FAIL\n", n
* 8);
190 if(i
== 16) printf("%u-bit key decrypt: OK\n", n
* 8);
192 kripto_block_destroy(s
);