]> AND Private Git Repository - Cipher_code.git/blob - OneRoundIoT/EnhancedOneRound/Simon_speck/C/tests.c
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new ida
[Cipher_code.git] / OneRoundIoT / EnhancedOneRound / Simon_speck / C / tests.c
1 /*
2  * tests.c
3  * Tests For Simon and Speck Block Ciphers
4  * Copyright 2017 Michael Calvin McCoy
5  * calvin.mccoy@gmail.com
6  * # The MIT License (MIT) - see LICENSE.md
7 */
8
9 #include <stdio.h>
10 #include <stdint.h>
11 #include "simon.h"
12 #include "speck.h"
13
14 // Function Prototypes
15 void cipher_compare(const void *source, void *target, size_t n);
16
17 // Global Test count
18 int test_count = 0;
19
20 // Global Fail count
21 int fail_count = 0;
22
23
24 void cipher_compare(const void *source, void *target, size_t n) {
25     test_count++;
26     for(size_t i=0; i < n; i++) {
27         uint8_t * src_bytes = (uint8_t *)source;
28         uint8_t * trg_bytes = (uint8_t *)target;
29         printf("Byte %02zu: %02x - %02x",i, src_bytes[i], trg_bytes[i]);
30         if (src_bytes[i] != trg_bytes[i]) {
31             printf("  FAIL\n");
32             fail_count++;
33         }
34         else printf("\n");
35     }
36 }
37
38 int main(void){
39
40     // Create reusable cipher objects for each algorithm type
41     SimSpk_Cipher my_simon_cipher;
42     SimSpk_Cipher my_speck_cipher;
43
44     // Create generic tmp variables
45     uint8_t ciphertext_buffer[16];
46     uint32_t result;
47
48     // Initialize IV and Counter Values for Use with Block Modes
49     uint8_t my_IV[] = {0x32,0x14,0x76,0x58};
50     uint8_t my_counter[] = {0x2F,0x3D,0x5C,0x7B};
51
52     printf("***********************************\n");
53     printf("******* Simon Cipher Tests ********\n");
54     printf("***********************************\n");
55
56     // Simon 64/32 Test
57     // Key: 1918 1110 0908 0100 Plaintext: 6565 6877 Ciphertext: c69b e9bb
58     printf("**** Test Simon 64/32 ****\n");
59     uint8_t simon64_32_key[] = {0x00, 0x01, 0x08, 0x09, 0x10, 0x11, 0x18, 0x19};
60     uint8_t simon64_32_plain[] = {0x77, 0x68, 0x65, 0x65};
61     uint8_t simon64_32_cipher[] = {0xBB,0xE9, 0x9B, 0xC6};
62     result = Simon_Init(&my_simon_cipher, cfg_64_32, ECB, simon64_32_key, my_IV, my_counter);
63
64     printf("Encryption Test:\n");
65     Simon_Encrypt(my_simon_cipher, &simon64_32_plain, &ciphertext_buffer);
66     cipher_compare(&ciphertext_buffer, &simon64_32_cipher, sizeof(simon64_32_cipher));
67
68     printf("Decryption Test:\n");
69     Simon_Decrypt(my_simon_cipher, &simon64_32_cipher, &ciphertext_buffer);
70     cipher_compare(&ciphertext_buffer, &simon64_32_plain, sizeof(simon64_32_plain));
71
72     printf("\n");
73
74
75     // Simon 72/48 Test
76     // Key: 121110 0a0908 020100 Plaintext: 612067 6e696c Ciphertext: dae5ac 292cac
77     printf("**** Test Simon 72/48 ****\n");
78     uint8_t simon72_48_key[] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12};
79     uint8_t simon72_48_plain[] = {0x6c, 0x69, 0x6E, 0x67, 0x20, 0x61};
80     uint8_t simon72_48_cipher[] = {0xAC, 0x2C, 0x29, 0xAC, 0xE5, 0xda};
81     result = Simon_Init(&my_simon_cipher, cfg_72_48, ECB, simon72_48_key, my_IV, my_counter);
82
83     printf("Encryption Test:\n");
84     Simon_Encrypt(my_simon_cipher, &simon72_48_plain, &ciphertext_buffer);
85     cipher_compare(&ciphertext_buffer, &simon72_48_cipher, sizeof(simon72_48_cipher));
86
87     printf("Decryption Test:\n");
88     Simon_Decrypt(my_simon_cipher, &simon72_48_cipher, &ciphertext_buffer);
89     cipher_compare(&ciphertext_buffer, &simon72_48_plain, sizeof(simon72_48_plain));
90     printf("\n");
91
92
93     // Simon 96/48 Test
94     // Key: 1a1918 121110 0a0908 020100 Plaintext: 726963 20646e Ciphertext: 6e06a5 acf156
95     printf("**** Test Simon 96/48 ****\n");
96     uint8_t simon96_48_key[] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12, 0x18, 0x19, 0x1a};
97     uint8_t simon96_48_plain[] = {0x6e, 0x64, 0x20, 0x63, 0x69, 0x72};
98     uint8_t simon96_48_cipher[] = {0x56, 0xf1, 0xac, 0xa5, 0x06, 0x6e};
99     result = Simon_Init(&my_simon_cipher, cfg_96_48, ECB, simon96_48_key, my_IV, my_counter);
100
101     printf("Encryption Test:\n");
102     Simon_Encrypt(my_simon_cipher, &simon96_48_plain, &ciphertext_buffer);
103     cipher_compare(&ciphertext_buffer, &simon96_48_cipher, sizeof(simon96_48_cipher));
104
105     printf("Decryption Test:\n");
106     Simon_Decrypt(my_simon_cipher, &simon96_48_cipher, &ciphertext_buffer);
107     cipher_compare(&ciphertext_buffer, &simon96_48_plain, sizeof(simon96_48_plain));
108
109     printf("\n");
110
111
112     // Simon 96/64 Test
113     // Key: 13121110 0b0a0908 03020100 Plaintext: 6f722067 6e696c63 Ciphertext: 5ca2e27f 111a8fc8
114     printf("**** Test Simon 96/64 ****\n");
115     uint8_t simon96_64_key[] = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, 0x10, 0x11, 0x12, 0x13};
116     uint8_t simon96_64_plain[] = {0x63, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x72, 0x6f};
117     uint8_t simon96_64_cipher[] = {0xc8, 0x8f, 0x1a, 0x11, 0x7f, 0xe2, 0xa2, 0x5c};
118     result = Simon_Init(&my_simon_cipher, cfg_96_64, ECB, simon96_64_key, my_IV, my_counter);
119
120     printf("Encryption Test:\n");
121     Simon_Encrypt(my_simon_cipher, &simon96_64_plain, &ciphertext_buffer);
122     cipher_compare(&ciphertext_buffer, &simon96_64_cipher, sizeof(simon96_64_cipher));
123
124     printf("Decryption Test:\n");
125     Simon_Decrypt(my_simon_cipher, &simon96_64_cipher, &ciphertext_buffer);
126     cipher_compare(&ciphertext_buffer, &simon96_64_plain, sizeof(simon96_64_plain));
127
128     printf("\n");
129
130
131     // Simon 128/64 Test
132     // Key: 1b1a1918 13121110 0b0a0908 03020100 Plaintext: 656b696c 20646e75 Ciphertext: 44c8fc20 b9dfa07a
133     printf("**** Test Simon 128/64 ****\n");
134     uint8_t simon128_64_key[] = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, 0x10, 0x11, 0x12, 0x13, 0x18, 0x19, 0x1A, 0x1B};
135     uint8_t simon128_64_plain[] = {0x75, 0x6e, 0x64, 0x20, 0x6c, 0x69, 0x6b, 0x65};
136     uint8_t simon128_64_cipher[] = {0x7a, 0xa0, 0xdf, 0xb9, 0x20, 0xfc, 0xc8, 0x44};
137     result = Simon_Init(&my_simon_cipher, cfg_128_64, ECB, simon128_64_key, my_IV, my_counter);
138     printf("Encryption Test:\n");
139     Simon_Encrypt(my_simon_cipher, &simon128_64_plain, &ciphertext_buffer);
140     cipher_compare(&ciphertext_buffer, &simon128_64_cipher, sizeof(simon128_64_cipher));
141
142     printf("Decryption Test:\n");
143     Simon_Decrypt(my_simon_cipher, &simon128_64_cipher, &ciphertext_buffer);
144     cipher_compare(&ciphertext_buffer, &simon128_64_plain, sizeof(simon128_64_plain));
145
146     printf("\n");
147
148
149     // Simon 96/96 Test
150     // Key: 0d0c0b0a0908 050403020100 Plaintext: 2072616c6c69 702065687420 Ciphertext: 602807a462b4 69063d8ff082
151     printf("**** Test Simon 96/96 ****\n");
152     uint8_t simon96_96_key[] = {0x00, 0x01, 0x02, 0x03,0x04,0x05, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D};
153     uint8_t simon96_96_plain[] = {0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x69, 0x6c, 0x6c, 0x61, 0x72, 0x20};
154     uint8_t simon96_96_cipher[] = {0x82, 0xf0, 0x8f, 0x3d, 0x06, 0x69, 0xb4, 0x62, 0xa4, 0x07, 0x28, 0x60};
155     result = Simon_Init(&my_simon_cipher, cfg_96_96, ECB, simon96_96_key, my_IV, my_counter);
156     printf("Encryption Test:\n");
157     Simon_Encrypt(my_simon_cipher, &simon96_96_plain, &ciphertext_buffer);
158     cipher_compare(&ciphertext_buffer, &simon96_96_cipher, sizeof(simon96_96_cipher));
159
160     printf("Decryption Test:\n");
161     Simon_Decrypt(my_simon_cipher, &simon96_96_cipher, &ciphertext_buffer);
162     cipher_compare(&ciphertext_buffer, &simon96_96_plain, sizeof(simon96_96_plain));
163
164     printf("\n");
165
166
167     // Simon 144/96 Test
168     // Key: 151413121110 0d0c0b0a0908 050403020100 Plaintext: 746168742074 73756420666f Ciphertext: ecad1c6c451e 3f59c5db1ae9
169     printf("**** Test Simon 144/96 ****\n");
170     uint8_t simon144_96_key[] = {0x00, 0x01, 0x02, 0x03,0x04,0x05, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15};
171     uint8_t simon144_96_plain[] = {0x6f, 0x66, 0x20, 0x64, 0x75, 0x73, 0x74, 0x20, 0x74, 0x68, 0x61, 0x74};
172     uint8_t simon144_96_cipher[] = {0xe9, 0x1a, 0xdb, 0xc5, 0x59, 0x3f, 0x1e, 0x45, 0x6c, 0x1c, 0xad, 0xec};
173     result = Simon_Init(&my_simon_cipher, cfg_144_96, ECB, simon144_96_key, my_IV, my_counter);
174     printf("Encryption Test:\n");
175     Simon_Encrypt(my_simon_cipher, &simon144_96_plain, &ciphertext_buffer);
176     cipher_compare(&ciphertext_buffer, &simon144_96_cipher, sizeof(simon144_96_cipher));
177
178     printf("Decryption Test:\n");
179     Simon_Decrypt(my_simon_cipher, &simon144_96_cipher, &ciphertext_buffer);
180     cipher_compare(&ciphertext_buffer, &simon144_96_plain, sizeof(simon144_96_plain));
181
182     printf("\n");
183
184
185     // Simon 128/128 Test
186     // Key: 0f0e0d0c0b0a0908 0706050403020100 Plaintext: 6373656420737265 6c6c657661727420 Ciphertext: 49681b1e1e54fe3f 65aa832af84e0bbc
187     printf("**** Test Simon 128/128 ****\n");
188     uint8_t simon128_128_key[] = {0x00, 0x01, 0x02, 0x03,0x04, 0x05, 0x06,0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
189     uint8_t simon128_128_plain[] = {0x20, 0x74, 0x72, 0x61, 0x76, 0x65, 0x6c, 0x6c, 0x65, 0x72, 0x73, 0x20, 0x64, 0x65, 0x73, 0x63};
190     uint8_t simon128_128_cipher[] = {0xbc, 0x0b, 0x4e, 0xf8, 0x2a, 0x83, 0xaa, 0x65, 0x3f, 0xfe, 0x54, 0x1e, 0x1e, 0x1b, 0x68, 0x49};
191     result = Simon_Init(&my_simon_cipher, cfg_128_128, ECB, simon128_128_key, my_IV, my_counter);
192     printf("Encryption Test:\n");
193     Simon_Encrypt(my_simon_cipher, &simon128_128_plain, &ciphertext_buffer);
194     cipher_compare(&ciphertext_buffer, &simon128_128_cipher, sizeof(simon128_128_cipher));
195
196     printf("Decryption Test:\n");
197     Simon_Decrypt(my_simon_cipher, &simon128_128_cipher, &ciphertext_buffer);
198     cipher_compare(&ciphertext_buffer, &simon128_128_plain, sizeof(simon128_128_plain));
199
200     printf("\n");
201
202
203     // Simon 192/128 Test
204     // Key: 1716151413121110 0f0e0d0c0b0a0908 0706050403020100 Plaintext: 206572656874206e 6568772065626972 Ciphertext: c4ac61effcdc0d4f 6c9c8d6e2597b85b
205     printf("**** Test Simon 192/128 ****\n");
206     uint8_t simon192_128_key[] = {0x00, 0x01, 0x02, 0x03,0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17};
207     uint8_t simon192_128_plain[] = {0x72, 0x69, 0x62, 0x65, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x72, 0x65, 0x20};
208     uint8_t simon192_128_cipher[] = {0x5b, 0xb8, 0x97, 0x25, 0x6e, 0x8d, 0x9c, 0x6c, 0x4f, 0x0d, 0xdc, 0xfc, 0xef, 0x61, 0xac, 0xc4};
209     result = Simon_Init(&my_simon_cipher, cfg_192_128, ECB, simon192_128_key, my_IV, my_counter);
210     printf("Encryption Test:\n");
211     Simon_Encrypt(my_simon_cipher, &simon192_128_plain, &ciphertext_buffer);
212     cipher_compare(&ciphertext_buffer, &simon192_128_cipher, sizeof(simon192_128_cipher));
213
214     printf("Decryption Test:\n");
215     Simon_Decrypt(my_simon_cipher, &simon192_128_cipher, &ciphertext_buffer);
216     cipher_compare(&ciphertext_buffer, &simon192_128_plain, sizeof(simon192_128_plain));
217
218     printf("\n");
219
220
221     // Simon 256/128 Test
222     // Key: 1f1e1d1c1b1a1918 1716151413121110 0f0e0d0c0b0a0908 0706050403020100 Plaintext: 74206e69206d6f6f 6d69732061207369 Ciphertext: 8d2b5579afc8a3a0 3bf72a87efe7b868
223     printf("**** Test Simon 256/128 ****\n");
224     uint8_t simon256_128_key[] = {0x00, 0x01, 0x02, 0x03,0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1d, 0x1e, 0x1f};
225     uint8_t simon256_128_plain[] = {0x69, 0x73, 0x20, 0x61, 0x20, 0x73, 0x69, 0x6d, 0x6f, 0x6f, 0x6d, 0x20, 0x69, 0x6e, 0x20, 0x74};
226     uint8_t simon256_128_cipher[] = {0x68, 0xb8, 0xe7, 0xef, 0x87, 0x2a, 0xf7, 0x3b, 0xa0, 0xa3, 0xc8, 0xaf, 0x79, 0x55, 0x2b, 0x8d};
227     result = Simon_Init(&my_simon_cipher, cfg_256_128, ECB, simon256_128_key, my_IV, my_counter);
228     printf("Encryption Test:\n");
229     Simon_Encrypt(my_simon_cipher, &simon256_128_plain, &ciphertext_buffer);
230     cipher_compare(&ciphertext_buffer, &simon256_128_cipher, sizeof(simon256_128_cipher));
231
232     printf("Decryption Test:\n");
233     Simon_Decrypt(my_simon_cipher, &simon256_128_cipher, &ciphertext_buffer);
234     cipher_compare(&ciphertext_buffer, &simon256_128_plain, sizeof(simon256_128_plain));
235
236     printf("\n");
237
238     printf("***********************************\n");
239     printf("******* Speck Cipher Tests ********\n");
240     printf("***********************************\n");
241
242     printf("**** Test Speck 64/32 ****\n");
243     uint8_t speck64_32_key[] = {0x00, 0x01, 0x08, 0x09, 0x10, 0x11, 0x18, 0x19};
244     uint8_t speck64_32_plain[] = {0x4c, 0x69, 0x74, 0x65};
245     uint8_t speck64_32_cipher[] = {0xf2, 0x42, 0x68, 0xa8};
246     result = Speck_Init(&my_speck_cipher, cfg_64_32, ECB, speck64_32_key, my_IV, my_counter);
247
248     printf("Encryption Test:\n");
249     Speck_Encrypt(my_speck_cipher, &speck64_32_plain, &ciphertext_buffer);
250     cipher_compare(&ciphertext_buffer, &speck64_32_cipher, sizeof(speck64_32_cipher));
251
252     printf("Decryption Test:\n");
253     Speck_Decrypt(my_speck_cipher, &speck64_32_cipher, &ciphertext_buffer);
254     cipher_compare(&ciphertext_buffer, &speck64_32_plain, sizeof(speck64_32_plain));
255
256     printf("\n");
257
258     printf("**** Test Speck 72/48 ****\n");
259     uint8_t speck72_48_key[] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12};
260     uint8_t speck72_48_plain[] = {0x72, 0x61, 0x6c, 0x6c, 0x79, 0x20};
261     uint8_t speck72_48_cipher[] = {0xdc, 0x5a, 0x38, 0xa5, 0x49, 0xc0};
262     result = Speck_Init(&my_speck_cipher, cfg_72_48, ECB, speck72_48_key, my_IV, my_counter);
263
264     printf("Encryption Test:\n");
265     Speck_Encrypt(my_speck_cipher, &speck72_48_plain, &ciphertext_buffer);
266     cipher_compare(&ciphertext_buffer, &speck72_48_cipher, sizeof(speck72_48_cipher));
267
268     printf("Decryption Test:\n");
269     Speck_Decrypt(my_speck_cipher, &speck72_48_cipher, &ciphertext_buffer);
270     cipher_compare(&ciphertext_buffer, &speck72_48_plain, sizeof(speck72_48_plain));
271
272     printf("\n");
273
274     printf("**** Test Speck 96/48 ****\n");
275     uint8_t speck96_48_key[] = {0X00,0X01,0X02,0X08,0X09,0X0A,0X10,0X11,0X12,0X18,0X19,0X1A};
276     uint8_t speck96_48_plain[] = {0X74, 0X68, 0X69, 0X73, 0X20, 0X6D};
277     uint8_t speck96_48_cipher[] = {0X5D, 0X44, 0XB6, 0X10, 0X5E, 0X73};
278     result = Speck_Init(&my_speck_cipher, cfg_96_48, ECB, speck96_48_key, my_IV, my_counter);
279
280     printf("Encryption Test:\n");
281     Speck_Encrypt(my_speck_cipher, &speck96_48_plain, &ciphertext_buffer);
282     cipher_compare(&ciphertext_buffer, &speck96_48_cipher, sizeof(speck96_48_cipher));
283
284     printf("Encryption Test:\n");
285     Speck_Decrypt(my_speck_cipher, &speck96_48_cipher, &ciphertext_buffer);
286     cipher_compare(&ciphertext_buffer, &speck96_48_plain, sizeof(speck96_48_plain));
287
288     printf("\n");
289
290     printf("**** Test Speck 96/64 ****\n");
291     uint8_t speck96_64_key[] = {0x00, 0x01, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0b, 0x10, 0x11, 0x12, 0x13};
292     uint8_t speck96_64_plain[] = {0X65, 0X61, 0X6E, 0X73, 0X20, 0X46, 0X61, 0X74};
293     uint8_t speck96_64_cipher[] = {0X6c, 0X94, 0X75, 0X41, 0XEC, 0X52, 0X79, 0X9F};
294     result = Speck_Init(&my_speck_cipher, cfg_96_64, ECB, speck96_64_key, my_IV, my_counter);
295
296     printf("Encryption Test:\n");
297     Speck_Encrypt(my_speck_cipher, &speck96_64_plain, &ciphertext_buffer);
298     cipher_compare(&ciphertext_buffer, &speck96_64_cipher, sizeof(speck96_64_cipher));
299
300     printf("Decryption Test:\n");
301     Speck_Decrypt(my_speck_cipher, &speck96_64_cipher, &ciphertext_buffer);
302     cipher_compare(&ciphertext_buffer, &speck96_64_plain, sizeof(speck96_64_plain));
303
304     printf("\n");
305
306     printf("**** Test Speck 128/64 ****\n");
307     uint8_t speck128_64_key[] = {0x00,0x01,0x02,0x03,0x08,0x09,0x0a,0x0b,0x10,0x11,0x12,0x13,0x18,0x19,0x1a,0x1b};
308     uint8_t speck128_64_plain[] = {0X2D,0X43,0X75,0X74,0X74,0X65,0X72,0X3B};
309     uint8_t speck128_64_cipher[] = {0X8B,0X02,0X4E,0X45,0X48,0XA5,0X6F,0X8C};
310     result = Speck_Init(&my_speck_cipher, cfg_128_64, ECB, speck128_64_key, my_IV, my_counter);
311
312     printf("Encryption Test:\n");
313     Speck_Encrypt(my_speck_cipher, &speck128_64_plain, &ciphertext_buffer);
314     cipher_compare(&ciphertext_buffer, &speck128_64_cipher, sizeof(speck128_64_cipher));
315     printf("Decryption Test:\n");
316     Speck_Decrypt(my_speck_cipher, &speck128_64_cipher, &ciphertext_buffer);
317     cipher_compare(&ciphertext_buffer, &speck128_64_plain, sizeof(speck128_64_plain));
318
319     printf("\n");
320
321     printf("**** Test Speck 96/96 ****\n");
322     uint8_t speck96_96_key[] = {0X00, 0X01, 0X02, 0X03, 0X04, 0X05, 0X08, 0X09, 0X0A, 0X0B, 0X0C, 0X0D};
323     uint8_t speck96_96_plain[] = {0X20, 0X75, 0X73, 0X61, 0X67, 0X65, 0X2C, 0X20, 0X68, 0X6F, 0X77, 0X65};
324     uint8_t speck96_96_cipher[] = {0XAA, 0X79, 0X8F, 0XDE, 0XBD, 0X62, 0X78, 0X71, 0XAB, 0X09, 0X4D, 0X9E};
325     result = Speck_Init(&my_speck_cipher, cfg_96_96, ECB, speck96_96_key, my_IV, my_counter);
326
327     printf("Encryption Test:\n");
328     Speck_Encrypt(my_speck_cipher, &speck96_96_plain, &ciphertext_buffer);
329     cipher_compare(&ciphertext_buffer, &speck96_96_cipher, sizeof(speck96_96_cipher));
330     printf("Decryption Test:\n");
331     Speck_Decrypt(my_speck_cipher, &speck96_96_cipher, &ciphertext_buffer);
332     cipher_compare(&ciphertext_buffer, &speck96_96_plain, sizeof(speck96_96_plain));
333
334     printf("\n");
335
336     printf("**** Test Speck 144/96 ****\n");
337     uint8_t speck144_96_key[] = {0X00, 0X01, 0X02, 0X03, 0X04, 0X05, 0X08, 0X09, 0X0A, 0X0B, 0X0C, 0X0D, 0X10, 0X11, 0X12, 0X13, 0X14, 0X15};
338     uint8_t speck144_96_plain[] = {0X76, 0X65, 0X72, 0X2C, 0X20, 0X69, 0X6E, 0X20, 0X74, 0X69, 0X6D, 0X65};
339     uint8_t speck144_96_cipher[] = {0XE6, 0X2E, 0X25, 0X40, 0XE4, 0X7A, 0X8A, 0X22, 0X72, 0X10, 0XF3, 0X2B};
340     result = Speck_Init(&my_speck_cipher, cfg_144_96, ECB, speck144_96_key, my_IV, my_counter);
341
342     printf("Encryption Test:\n");
343     Speck_Encrypt(my_speck_cipher, &speck144_96_plain, &ciphertext_buffer);
344     cipher_compare(&ciphertext_buffer, &speck144_96_cipher, sizeof(speck144_96_cipher));
345
346     printf("Decryption Test:\n");
347     Speck_Decrypt(my_speck_cipher, &speck144_96_cipher, &ciphertext_buffer);
348     cipher_compare(&ciphertext_buffer, &speck144_96_plain, sizeof(speck144_96_plain));
349
350     printf("\n");
351
352     printf("**** Test Speck 128/128 ****\n");
353     uint8_t speck128_128_key[] = {0X00, 0X01, 0X02, 0X03, 0X04, 0X05, 0X06, 0X07, 0X08, 0X09, 0X0A, 0X0B, 0X0C, 0X0D, 0X0E, 0X0F};
354     uint8_t speck128_128_plain[] = {0X20, 0X6D, 0X61, 0X64, 0X65, 0X20, 0X69, 0X74, 0X20, 0X65, 0X71, 0X75, 0X69, 0X76, 0X61, 0X6C};
355     uint8_t speck128_128_cipher[] = {0X18, 0X0D, 0X57, 0X5C, 0XDF, 0XFE, 0X60, 0X78, 0X65, 0X32, 0X78, 0X79, 0X51, 0X98, 0X5D, 0XA6};
356     result = Speck_Init(&my_speck_cipher, cfg_128_128, ECB, speck128_128_key, my_IV, my_counter);
357
358     printf("Encryption Test:\n");
359     Speck_Encrypt(my_speck_cipher, &speck128_128_plain, &ciphertext_buffer);
360     cipher_compare(&ciphertext_buffer, &speck128_128_cipher, sizeof(speck128_128_cipher));
361     printf("Decryption Test:\n");
362     Speck_Decrypt(my_speck_cipher, &speck128_128_cipher, &ciphertext_buffer);
363     cipher_compare(&ciphertext_buffer, &speck128_128_plain, sizeof(speck128_128_plain));
364
365     printf("\n");
366
367     printf("**** Test Speck 192/128 ****\n");
368     uint8_t speck192_128_key[] = {0X00, 0X01, 0X02, 0X03, 0X04, 0X05, 0X06, 0X07, 0X08, 0X09, 0X0A, 0X0B, 0X0C, 0X0D, 0X0E, 0X0F, 0X10, 0X11, 0X12, 0X13, 0X14, 0X15, 0X16, 0X17};
369     uint8_t speck192_128_plain[] = {0X65, 0X6E, 0X74, 0X20, 0X74, 0X6F, 0X20, 0X43, 0X68, 0X69, 0X65, 0X66, 0X20, 0X48, 0X61, 0X72};
370     uint8_t speck192_128_cipher[] = {0X86, 0X18, 0X3C, 0XE0, 0X5D, 0X18, 0XBC, 0XF9, 0X66, 0X55, 0X13, 0X13, 0X3A, 0XCF, 0XE4, 0X1B};
371     result = Speck_Init(&my_speck_cipher, cfg_192_128, ECB, speck192_128_key, my_IV, my_counter);
372
373     printf("Encryption Test:\n");
374     Speck_Encrypt(my_speck_cipher, &speck192_128_plain, &ciphertext_buffer);
375     cipher_compare(&ciphertext_buffer, &speck192_128_cipher, sizeof(speck192_128_cipher));
376     printf("Decryption Test:\n");
377     Speck_Decrypt(my_speck_cipher, &speck192_128_cipher, &ciphertext_buffer);
378     cipher_compare(&ciphertext_buffer, &speck192_128_plain, sizeof(speck192_128_plain));
379
380     printf("\n");
381
382     printf("**** Test Speck 256/128 ****\n");
383     uint8_t speck256_128_key[] = {0X00, 0X01, 0X02, 0X03, 0X04, 0X05, 0X06, 0X07, 0X08, 0X09, 0X0A, 0X0B, 0X0C, 0X0D, 0X0E, 0X0F, 0X10, 0X11, 0X12, 0X13, 0X14, 0X15, 0X16, 0X17, 0X18, 0X19, 0X1A, 0X1B, 0X1C, 0X1D, 0X1E, 0X1F};
384     uint8_t speck256_128_plain[] = {0X70, 0X6F, 0X6F, 0X6E, 0X65, 0X72, 0X2E, 0X20, 0X49, 0X6E, 0X20, 0X74, 0X68, 0X6F, 0X73, 0X65};
385     uint8_t speck256_128_cipher[] = {0X43, 0X8F, 0X18, 0X9C, 0X8D, 0XB4, 0XEE, 0X4E, 0X3E, 0XF5, 0XC0, 0X05, 0X04, 0X01, 0X09, 0X41};
386     result = Speck_Init(&my_speck_cipher, cfg_256_128, ECB, speck256_128_key, my_IV, my_counter);
387
388     printf("Encryption Test:\n");
389     Speck_Encrypt(my_speck_cipher, &speck256_128_plain, &ciphertext_buffer);
390     cipher_compare(&ciphertext_buffer, &speck256_128_cipher, sizeof(speck256_128_cipher));
391     printf("Decryption Test:\n");
392     Speck_Decrypt(my_speck_cipher, &speck256_128_cipher, &ciphertext_buffer);
393     cipher_compare(&ciphertext_buffer, &speck256_128_plain, sizeof(speck256_128_plain));
394
395     printf("\n");
396
397
398     printf("Total Test Count: %d\n", test_count);
399     printf("Total Fail Count: %d\n", fail_count);
400
401     return fail_count;
402 }