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/camellia.h>
27 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
28 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10,
29 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
30 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
32 const uint8_t ct
[32][16] =
35 0x57, 0xBE, 0x21, 0x31, 0xB9, 0x24, 0x64, 0x9E,
36 0xC5, 0x98, 0x26, 0x99, 0xA5, 0xF8, 0x7F, 0x37
39 0x01, 0x7F, 0x1B, 0xB7, 0xDF, 0x32, 0xC3, 0x8F,
40 0x7D, 0x53, 0x32, 0xFF, 0xE5, 0x51, 0x32, 0x99
43 0x8B, 0xE8, 0xEF, 0x99, 0xFA, 0x9F, 0x9F, 0x81,
44 0x27, 0x16, 0xC1, 0x8B, 0xCB, 0xE0, 0x33, 0x8C
47 0x9E, 0x98, 0xCF, 0xB1, 0xB8, 0x6C, 0x83, 0xEC,
48 0x71, 0xCE, 0xC0, 0xE1, 0xB1, 0x62, 0x42, 0x5B
51 0x59, 0x44, 0x94, 0x84, 0x7D, 0xAA, 0xBB, 0xF9,
52 0xA7, 0xE7, 0xC4, 0x8F, 0x2F, 0x64, 0x61, 0x4E
55 0x77, 0x56, 0xAF, 0x26, 0x99, 0xD6, 0x73, 0xD8,
56 0x32, 0x2A, 0xBA, 0x7C, 0x79, 0x28, 0xA2, 0x04
59 0x17, 0x18, 0x50, 0x22, 0xF0, 0x7A, 0x0A, 0x1B,
60 0xF9, 0x30, 0x60, 0x83, 0x42, 0xCF, 0x17, 0x69
63 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
64 0x08, 0x57, 0x06, 0x56, 0x48, 0xEA, 0xBE, 0x43
67 0x22, 0x6D, 0x9F, 0x87, 0x81, 0x06, 0xE5, 0xAD,
68 0x35, 0x93, 0x48, 0xDF, 0x59, 0x01, 0xE8, 0x5D
71 0x6D, 0x6E, 0xEA, 0x4F, 0x0B, 0x9C, 0x56, 0xF1,
72 0x1E, 0x20, 0xF9, 0x48, 0xA9, 0xFE, 0xB7, 0xC1
75 0x82, 0x78, 0xD5, 0x68, 0x2F, 0x2C, 0x6E, 0xDA,
76 0xCA, 0xBB, 0x5B, 0x0C, 0xFE, 0x64, 0x53, 0x6C
79 0xF3, 0x92, 0x4C, 0xBB, 0x6A, 0x33, 0x06, 0x1F,
80 0xDA, 0xA9, 0xB3, 0xD0, 0x05, 0x41, 0x3A, 0xC6
83 0xE0, 0x34, 0xC5, 0xEF, 0x1A, 0x27, 0x13, 0x4A,
84 0x23, 0x4A, 0xB7, 0xE6, 0xB8, 0x63, 0x7F, 0x34
87 0xE5, 0x8A, 0x49, 0x57, 0xE4, 0xA6, 0x4F, 0x74,
88 0x49, 0xF0, 0x98, 0xFC, 0x78, 0xBF, 0xA0, 0xBD
91 0x66, 0xD2, 0x8F, 0x27, 0x3F, 0xE0, 0xA7, 0xB3,
92 0x65, 0x15, 0xA8, 0x0A, 0x5F, 0x83, 0xF2, 0x4B
95 0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
96 0x08, 0x57, 0x06, 0x56, 0x48, 0xEA, 0xBE, 0x43
99 0x4C, 0x73, 0x2A, 0xDC, 0x66, 0x30, 0x3A, 0x4E,
100 0x91, 0x05, 0x8E, 0x19, 0xE4, 0xD3, 0x64, 0x59
103 0xA7, 0xAA, 0x8A, 0x4C, 0x9D, 0xA8, 0x71, 0x83,
104 0xA2, 0x97, 0x47, 0xA8, 0xF3, 0x94, 0x66, 0x6C
107 0xFE, 0xF2, 0xFA, 0x71, 0x5F, 0x2B, 0xBA, 0x7B,
108 0xAE, 0xCE, 0x67, 0x86, 0x8F, 0xFE, 0x8B, 0xC4
111 0x69, 0x9C, 0x78, 0xFC, 0xE7, 0xB7, 0xA8, 0x24,
112 0x6E, 0x97, 0x99, 0xED, 0x68, 0x0A, 0x4C, 0xB5
115 0xBD, 0x09, 0x85, 0xF5, 0xA2, 0xB9, 0xA8, 0xB5,
116 0x0E, 0x13, 0xA7, 0x29, 0x17, 0x67, 0x87, 0x14
119 0x62, 0x03, 0x8D, 0x06, 0x73, 0x4A, 0xB4, 0x45,
120 0xC6, 0x8F, 0x1A, 0xFF, 0x91, 0x24, 0x4D, 0x67
123 0x82, 0x69, 0x14, 0x48, 0x67, 0x5E, 0x85, 0xDD,
124 0x8E, 0x57, 0x2E, 0x51, 0x95, 0x39, 0xCF, 0xCD
127 0xB4, 0x99, 0x34, 0x01, 0xB3, 0xE9, 0x96, 0xF8,
128 0x4E, 0xE5, 0xCE, 0xE7, 0xD7, 0x9B, 0x09, 0xB9
131 0x6F, 0x5F, 0x63, 0x52, 0x65, 0x3D, 0x9A, 0x50,
132 0x41, 0x1A, 0x45, 0x3D, 0xC6, 0x76, 0x46, 0xDC
135 0x68, 0xF0, 0xD4, 0x13, 0x7E, 0x07, 0x7D, 0xD7,
136 0x18, 0xA1, 0x03, 0xE6, 0xB4, 0xED, 0xF9, 0x99
139 0x8F, 0xF2, 0x6B, 0xF2, 0x6E, 0xCE, 0xCD, 0x2D,
140 0xC6, 0x93, 0x80, 0xD2, 0xA6, 0x86, 0xB7, 0x82
143 0x84, 0x49, 0x3C, 0xB8, 0xF6, 0xCE, 0x35, 0xF3,
144 0xB4, 0x16, 0x49, 0x1E, 0x9B, 0x30, 0x84, 0x67
147 0xFE, 0xA6, 0x02, 0x21, 0xF8, 0x68, 0xBA, 0x7C,
148 0xFE, 0x4A, 0x37, 0x0F, 0x60, 0x7F, 0xF5, 0x2D
151 0x40, 0xD4, 0x0A, 0xF3, 0xDE, 0x81, 0xE5, 0x6B,
152 0x2C, 0xD7, 0xCF, 0x8E, 0x58, 0x33, 0xF9, 0xB7
155 0xAE, 0x86, 0xC0, 0x35, 0x9E, 0xE6, 0xEF, 0x6D,
156 0x55, 0x0D, 0x18, 0x58, 0xB0, 0xA2, 0x98, 0x26
159 0x9A, 0xCC, 0x23, 0x7D, 0xFF, 0x16, 0xD7, 0x6C,
160 0x20, 0xEF, 0x7C, 0x91, 0x9E, 0x3A, 0x75, 0x09
164 puts("kripto_block_camellia");
166 for(n
= 1; n
<= 32; n
++)
168 s
= kripto_block_create(kripto_block_camellia
, 0, k
, n
);
169 if(!s
) puts("error");
171 kripto_block_encrypt(s
, k
, t
);
172 for(i
= 0; i
< 16; i
++) if(t
[i
] != ct
[n
- 1][i
])
174 printf("%u-bit key encrypt: FAIL\n", n
* 8);
177 if(i
== 16) printf("%u-bit key encrypt: OK\n", n
* 8);
179 kripto_block_decrypt(s
, ct
[n
- 1], t
);
180 for(i
= 0; i
< 16; i
++) if(t
[i
] != k
[i
])
182 printf("%u-bit key decrypt: FAIL\n", n
* 8);
185 if(i
== 16) printf("%u-bit key decrypt: OK\n", n
* 8);
187 kripto_block_destroy(s
);