PolarSSL v1.1.4
test_suite_aes.c
Go to the documentation of this file.
1 #include "fct.h"
2 
3 #include <polarssl/aes.h>
4 
5 #include <polarssl/config.h>
6 
7 #ifdef _MSC_VER
8 #include <basetsd.h>
9 typedef UINT32 uint32_t;
10 #else
11 #include <inttypes.h>
12 #endif
13 
14 /*
15  * 32-bit integer manipulation macros (big endian)
16  */
17 #ifndef GET_ULONG_BE
18 #define GET_ULONG_BE(n,b,i) \
19 { \
20  (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
21  | ( (unsigned long) (b)[(i) + 1] << 16 ) \
22  | ( (unsigned long) (b)[(i) + 2] << 8 ) \
23  | ( (unsigned long) (b)[(i) + 3] ); \
24 }
25 #endif
26 
27 #ifndef PUT_ULONG_BE
28 #define PUT_ULONG_BE(n,b,i) \
29 { \
30  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
31  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
32  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
33  (b)[(i) + 3] = (unsigned char) ( (n) ); \
34 }
35 #endif
36 
37 int unhexify(unsigned char *obuf, const char *ibuf)
38 {
39  unsigned char c, c2;
40  int len = strlen(ibuf) / 2;
41  assert(!(strlen(ibuf) %1)); // must be even number of bytes
42 
43  while (*ibuf != 0)
44  {
45  c = *ibuf++;
46  if( c >= '0' && c <= '9' )
47  c -= '0';
48  else if( c >= 'a' && c <= 'f' )
49  c -= 'a' - 10;
50  else if( c >= 'A' && c <= 'F' )
51  c -= 'A' - 10;
52  else
53  assert( 0 );
54 
55  c2 = *ibuf++;
56  if( c2 >= '0' && c2 <= '9' )
57  c2 -= '0';
58  else if( c2 >= 'a' && c2 <= 'f' )
59  c2 -= 'a' - 10;
60  else if( c2 >= 'A' && c2 <= 'F' )
61  c2 -= 'A' - 10;
62  else
63  assert( 0 );
64 
65  *obuf++ = ( c << 4 ) | c2;
66  }
67 
68  return len;
69 }
70 
71 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
72 {
73  unsigned char l, h;
74 
75  while (len != 0)
76  {
77  h = (*ibuf) / 16;
78  l = (*ibuf) % 16;
79 
80  if( h < 10 )
81  *obuf++ = '0' + h;
82  else
83  *obuf++ = 'a' + h - 10;
84 
85  if( l < 10 )
86  *obuf++ = '0' + l;
87  else
88  *obuf++ = 'a' + l - 10;
89 
90  ++ibuf;
91  len--;
92  }
93 }
94 
104 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
105 {
106  size_t i;
107 
108  if( rng_state != NULL )
109  rng_state = NULL;
110 
111  for( i = 0; i < len; ++i )
112  output[i] = rand();
113 
114  return( 0 );
115 }
116 
122 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
123 {
124  if( rng_state != NULL )
125  rng_state = NULL;
126 
127  memset( output, 0, len );
128 
129  return( 0 );
130 }
131 
132 typedef struct
133 {
134  unsigned char *buf;
135  size_t length;
136 } rnd_buf_info;
137 
149 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
150 {
151  rnd_buf_info *info = (rnd_buf_info *) rng_state;
152  size_t use_len;
153 
154  if( rng_state == NULL )
155  return( rnd_std_rand( NULL, output, len ) );
156 
157  use_len = len;
158  if( len > info->length )
159  use_len = info->length;
160 
161  if( use_len )
162  {
163  memcpy( output, info->buf, use_len );
164  info->buf += use_len;
165  info->length -= use_len;
166  }
167 
168  if( len - use_len > 0 )
169  return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
170 
171  return( 0 );
172 }
173 
181 typedef struct
182 {
183  uint32_t key[16];
184  uint32_t v0, v1;
186 
195 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
196 {
197  rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
198  uint32_t i, *k, sum, delta=0x9E3779B9;
199  unsigned char result[4];
200 
201  if( rng_state == NULL )
202  return( rnd_std_rand( NULL, output, len ) );
203 
204  k = info->key;
205 
206  while( len > 0 )
207  {
208  size_t use_len = ( len > 4 ) ? 4 : len;
209  sum = 0;
210 
211  for( i = 0; i < 32; i++ )
212  {
213  info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
214  sum += delta;
215  info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
216  }
217 
218  PUT_ULONG_BE( info->v0, result, 0 );
219  memcpy( output, result, use_len );
220  len -= use_len;
221  }
222 
223  return( 0 );
224 }
225 
226 
228 {
229 #ifdef POLARSSL_AES_C
230 
231 
232  FCT_SUITE_BGN(test_suite_aes)
233  {
234 
235  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_1)
236  {
237  unsigned char key_str[100];
238  unsigned char src_str[100];
239  unsigned char dst_str[100];
240  unsigned char output[100];
241  aes_context ctx;
242  int key_len;
243 
244  memset(key_str, 0x00, 100);
245  memset(src_str, 0x00, 100);
246  memset(dst_str, 0x00, 100);
247  memset(output, 0x00, 100);
248 
249  key_len = unhexify( key_str, "00000000000000000000000000000000" );
250  unhexify( src_str, "f34481ec3cc627bacd5dc3fb08f273e6" );
251 
252  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
253  if( 0 == 0 )
254  {
255  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
256  hexify( dst_str, output, 16 );
257 
258  fct_chk( strcmp( (char *) dst_str, "0336763e966d92595a567cc9ce537f5e" ) == 0 );
259  }
260  }
261  FCT_TEST_END();
262 
263 
264  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_2)
265  {
266  unsigned char key_str[100];
267  unsigned char src_str[100];
268  unsigned char dst_str[100];
269  unsigned char output[100];
270  aes_context ctx;
271  int key_len;
272 
273  memset(key_str, 0x00, 100);
274  memset(src_str, 0x00, 100);
275  memset(dst_str, 0x00, 100);
276  memset(output, 0x00, 100);
277 
278  key_len = unhexify( key_str, "00000000000000000000000000000000" );
279  unhexify( src_str, "9798c4640bad75c7c3227db910174e72" );
280 
281  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
282  if( 0 == 0 )
283  {
284  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
285  hexify( dst_str, output, 16 );
286 
287  fct_chk( strcmp( (char *) dst_str, "a9a1631bf4996954ebc093957b234589" ) == 0 );
288  }
289  }
290  FCT_TEST_END();
291 
292 
293  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_3)
294  {
295  unsigned char key_str[100];
296  unsigned char src_str[100];
297  unsigned char dst_str[100];
298  unsigned char output[100];
299  aes_context ctx;
300  int key_len;
301 
302  memset(key_str, 0x00, 100);
303  memset(src_str, 0x00, 100);
304  memset(dst_str, 0x00, 100);
305  memset(output, 0x00, 100);
306 
307  key_len = unhexify( key_str, "00000000000000000000000000000000" );
308  unhexify( src_str, "96ab5c2ff612d9dfaae8c31f30c42168" );
309 
310  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
311  if( 0 == 0 )
312  {
313  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
314  hexify( dst_str, output, 16 );
315 
316  fct_chk( strcmp( (char *) dst_str, "ff4f8391a6a40ca5b25d23bedd44a597" ) == 0 );
317  }
318  }
319  FCT_TEST_END();
320 
321 
322  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_4)
323  {
324  unsigned char key_str[100];
325  unsigned char src_str[100];
326  unsigned char dst_str[100];
327  unsigned char output[100];
328  aes_context ctx;
329  int key_len;
330 
331  memset(key_str, 0x00, 100);
332  memset(src_str, 0x00, 100);
333  memset(dst_str, 0x00, 100);
334  memset(output, 0x00, 100);
335 
336  key_len = unhexify( key_str, "e0000000000000000000000000000000" );
337  unhexify( src_str, "00000000000000000000000000000000" );
338 
339  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
340  if( 0 == 0 )
341  {
342  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
343  hexify( dst_str, output, 16 );
344 
345  fct_chk( strcmp( (char *) dst_str, "72a1da770f5d7ac4c9ef94d822affd97" ) == 0 );
346  }
347  }
348  FCT_TEST_END();
349 
350 
351  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_5)
352  {
353  unsigned char key_str[100];
354  unsigned char src_str[100];
355  unsigned char dst_str[100];
356  unsigned char output[100];
357  aes_context ctx;
358  int key_len;
359 
360  memset(key_str, 0x00, 100);
361  memset(src_str, 0x00, 100);
362  memset(dst_str, 0x00, 100);
363  memset(output, 0x00, 100);
364 
365  key_len = unhexify( key_str, "f0000000000000000000000000000000" );
366  unhexify( src_str, "00000000000000000000000000000000" );
367 
368  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
369  if( 0 == 0 )
370  {
371  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
372  hexify( dst_str, output, 16 );
373 
374  fct_chk( strcmp( (char *) dst_str, "970014d634e2b7650777e8e84d03ccd8" ) == 0 );
375  }
376  }
377  FCT_TEST_END();
378 
379 
380  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_6)
381  {
382  unsigned char key_str[100];
383  unsigned char src_str[100];
384  unsigned char dst_str[100];
385  unsigned char output[100];
386  aes_context ctx;
387  int key_len;
388 
389  memset(key_str, 0x00, 100);
390  memset(src_str, 0x00, 100);
391  memset(dst_str, 0x00, 100);
392  memset(output, 0x00, 100);
393 
394  key_len = unhexify( key_str, "f8000000000000000000000000000000" );
395  unhexify( src_str, "00000000000000000000000000000000" );
396 
397  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
398  if( 0 == 0 )
399  {
400  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
401  hexify( dst_str, output, 16 );
402 
403  fct_chk( strcmp( (char *) dst_str, "f17e79aed0db7e279e955b5f493875a7" ) == 0 );
404  }
405  }
406  FCT_TEST_END();
407 
408 
409  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_7)
410  {
411  unsigned char key_str[100];
412  unsigned char src_str[100];
413  unsigned char dst_str[100];
414  unsigned char output[100];
415  aes_context ctx;
416  int key_len;
417 
418  memset(key_str, 0x00, 100);
419  memset(src_str, 0x00, 100);
420  memset(dst_str, 0x00, 100);
421  memset(output, 0x00, 100);
422 
423  key_len = unhexify( key_str, "fffffffffffff0000000000000000000" );
424  unhexify( src_str, "00000000000000000000000000000000" );
425 
426  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
427  if( 0 == 0 )
428  {
429  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
430  hexify( dst_str, output, 16 );
431 
432  fct_chk( strcmp( (char *) dst_str, "7b90785125505fad59b13c186dd66ce3" ) == 0 );
433  }
434  }
435  FCT_TEST_END();
436 
437 
438  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_8)
439  {
440  unsigned char key_str[100];
441  unsigned char src_str[100];
442  unsigned char dst_str[100];
443  unsigned char output[100];
444  aes_context ctx;
445  int key_len;
446 
447  memset(key_str, 0x00, 100);
448  memset(src_str, 0x00, 100);
449  memset(dst_str, 0x00, 100);
450  memset(output, 0x00, 100);
451 
452  key_len = unhexify( key_str, "fffffffffffff8000000000000000000" );
453  unhexify( src_str, "00000000000000000000000000000000" );
454 
455  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
456  if( 0 == 0 )
457  {
458  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
459  hexify( dst_str, output, 16 );
460 
461  fct_chk( strcmp( (char *) dst_str, "8b527a6aebdaec9eaef8eda2cb7783e5" ) == 0 );
462  }
463  }
464  FCT_TEST_END();
465 
466 
467  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_9)
468  {
469  unsigned char key_str[100];
470  unsigned char src_str[100];
471  unsigned char dst_str[100];
472  unsigned char output[100];
473  aes_context ctx;
474  int key_len;
475 
476  memset(key_str, 0x00, 100);
477  memset(src_str, 0x00, 100);
478  memset(dst_str, 0x00, 100);
479  memset(output, 0x00, 100);
480 
481  key_len = unhexify( key_str, "fffffffffffffc000000000000000000" );
482  unhexify( src_str, "00000000000000000000000000000000" );
483 
484  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
485  if( 0 == 0 )
486  {
487  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
488  hexify( dst_str, output, 16 );
489 
490  fct_chk( strcmp( (char *) dst_str, "43fdaf53ebbc9880c228617d6a9b548b" ) == 0 );
491  }
492  }
493  FCT_TEST_END();
494 
495 
496  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_10)
497  {
498  unsigned char key_str[100];
499  unsigned char src_str[100];
500  unsigned char dst_str[100];
501  unsigned char output[100];
502  aes_context ctx;
503  int key_len;
504 
505  memset(key_str, 0x00, 100);
506  memset(src_str, 0x00, 100);
507  memset(dst_str, 0x00, 100);
508  memset(output, 0x00, 100);
509 
510  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffc000" );
511  unhexify( src_str, "00000000000000000000000000000000" );
512 
513  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
514  if( 0 == 0 )
515  {
516  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
517  hexify( dst_str, output, 16 );
518 
519  fct_chk( strcmp( (char *) dst_str, "70c46bb30692be657f7eaa93ebad9897" ) == 0 );
520  }
521  }
522  FCT_TEST_END();
523 
524 
525  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_11)
526  {
527  unsigned char key_str[100];
528  unsigned char src_str[100];
529  unsigned char dst_str[100];
530  unsigned char output[100];
531  aes_context ctx;
532  int key_len;
533 
534  memset(key_str, 0x00, 100);
535  memset(src_str, 0x00, 100);
536  memset(dst_str, 0x00, 100);
537  memset(output, 0x00, 100);
538 
539  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffe000" );
540  unhexify( src_str, "00000000000000000000000000000000" );
541 
542  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
543  if( 0 == 0 )
544  {
545  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
546  hexify( dst_str, output, 16 );
547 
548  fct_chk( strcmp( (char *) dst_str, "323994cfb9da285a5d9642e1759b224a" ) == 0 );
549  }
550  }
551  FCT_TEST_END();
552 
553 
554  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_12)
555  {
556  unsigned char key_str[100];
557  unsigned char src_str[100];
558  unsigned char dst_str[100];
559  unsigned char output[100];
560  aes_context ctx;
561  int key_len;
562 
563  memset(key_str, 0x00, 100);
564  memset(src_str, 0x00, 100);
565  memset(dst_str, 0x00, 100);
566  memset(output, 0x00, 100);
567 
568  key_len = unhexify( key_str, "fffffffffffffffffffffffffffff000" );
569  unhexify( src_str, "00000000000000000000000000000000" );
570 
571  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
572  if( 0 == 0 )
573  {
574  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
575  hexify( dst_str, output, 16 );
576 
577  fct_chk( strcmp( (char *) dst_str, "1dbf57877b7b17385c85d0b54851e371" ) == 0 );
578  }
579  }
580  FCT_TEST_END();
581 
582 
583  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_13)
584  {
585  unsigned char key_str[100];
586  unsigned char src_str[100];
587  unsigned char dst_str[100];
588  unsigned char output[100];
589  aes_context ctx;
590  int key_len;
591 
592  memset(key_str, 0x00, 100);
593  memset(src_str, 0x00, 100);
594  memset(dst_str, 0x00, 100);
595  memset(output, 0x00, 100);
596 
597  key_len = unhexify( key_str, "00000000000000000000000000000000" );
598  unhexify( src_str, "ffffffffffffffc00000000000000000" );
599 
600  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
601  if( 0 == 0 )
602  {
603  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
604  hexify( dst_str, output, 16 );
605 
606  fct_chk( strcmp( (char *) dst_str, "3a4d354f02bb5a5e47d39666867f246a" ) == 0 );
607  }
608  }
609  FCT_TEST_END();
610 
611 
612  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_14)
613  {
614  unsigned char key_str[100];
615  unsigned char src_str[100];
616  unsigned char dst_str[100];
617  unsigned char output[100];
618  aes_context ctx;
619  int key_len;
620 
621  memset(key_str, 0x00, 100);
622  memset(src_str, 0x00, 100);
623  memset(dst_str, 0x00, 100);
624  memset(output, 0x00, 100);
625 
626  key_len = unhexify( key_str, "00000000000000000000000000000000" );
627  unhexify( src_str, "ffffffffffffffe00000000000000000" );
628 
629  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
630  if( 0 == 0 )
631  {
632  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
633  hexify( dst_str, output, 16 );
634 
635  fct_chk( strcmp( (char *) dst_str, "d451b8d6e1e1a0ebb155fbbf6e7b7dc3" ) == 0 );
636  }
637  }
638  FCT_TEST_END();
639 
640 
641  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_15)
642  {
643  unsigned char key_str[100];
644  unsigned char src_str[100];
645  unsigned char dst_str[100];
646  unsigned char output[100];
647  aes_context ctx;
648  int key_len;
649 
650  memset(key_str, 0x00, 100);
651  memset(src_str, 0x00, 100);
652  memset(dst_str, 0x00, 100);
653  memset(output, 0x00, 100);
654 
655  key_len = unhexify( key_str, "00000000000000000000000000000000" );
656  unhexify( src_str, "fffffffffffffff00000000000000000" );
657 
658  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
659  if( 0 == 0 )
660  {
661  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
662  hexify( dst_str, output, 16 );
663 
664  fct_chk( strcmp( (char *) dst_str, "6898d4f42fa7ba6a10ac05e87b9f2080" ) == 0 );
665  }
666  }
667  FCT_TEST_END();
668 
669 
670  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_16)
671  {
672  unsigned char key_str[100];
673  unsigned char src_str[100];
674  unsigned char dst_str[100];
675  unsigned char output[100];
676  aes_context ctx;
677  int key_len;
678 
679  memset(key_str, 0x00, 100);
680  memset(src_str, 0x00, 100);
681  memset(dst_str, 0x00, 100);
682  memset(output, 0x00, 100);
683 
684  key_len = unhexify( key_str, "00000000000000000000000000000000" );
685  unhexify( src_str, "ffffffffffffffffffffffffe0000000" );
686 
687  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
688  if( 0 == 0 )
689  {
690  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
691  hexify( dst_str, output, 16 );
692 
693  fct_chk( strcmp( (char *) dst_str, "082eb8be35f442fb52668e16a591d1d6" ) == 0 );
694  }
695  }
696  FCT_TEST_END();
697 
698 
699  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_17)
700  {
701  unsigned char key_str[100];
702  unsigned char src_str[100];
703  unsigned char dst_str[100];
704  unsigned char output[100];
705  aes_context ctx;
706  int key_len;
707 
708  memset(key_str, 0x00, 100);
709  memset(src_str, 0x00, 100);
710  memset(dst_str, 0x00, 100);
711  memset(output, 0x00, 100);
712 
713  key_len = unhexify( key_str, "00000000000000000000000000000000" );
714  unhexify( src_str, "fffffffffffffffffffffffff0000000" );
715 
716  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
717  if( 0 == 0 )
718  {
719  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
720  hexify( dst_str, output, 16 );
721 
722  fct_chk( strcmp( (char *) dst_str, "e656f9ecf5fe27ec3e4a73d00c282fb3" ) == 0 );
723  }
724  }
725  FCT_TEST_END();
726 
727 
728  FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_18)
729  {
730  unsigned char key_str[100];
731  unsigned char src_str[100];
732  unsigned char dst_str[100];
733  unsigned char output[100];
734  aes_context ctx;
735  int key_len;
736 
737  memset(key_str, 0x00, 100);
738  memset(src_str, 0x00, 100);
739  memset(dst_str, 0x00, 100);
740  memset(output, 0x00, 100);
741 
742  key_len = unhexify( key_str, "00000000000000000000000000000000" );
743  unhexify( src_str, "fffffffffffffffffffffffff8000000" );
744 
745  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
746  if( 0 == 0 )
747  {
748  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
749  hexify( dst_str, output, 16 );
750 
751  fct_chk( strcmp( (char *) dst_str, "2ca8209d63274cd9a29bb74bcd77683a" ) == 0 );
752  }
753  }
754  FCT_TEST_END();
755 
756 
757  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_1)
758  {
759  unsigned char key_str[100];
760  unsigned char src_str[100];
761  unsigned char dst_str[100];
762  unsigned char output[100];
763  aes_context ctx;
764  int key_len;
765 
766  memset(key_str, 0x00, 100);
767  memset(src_str, 0x00, 100);
768  memset(dst_str, 0x00, 100);
769  memset(output, 0x00, 100);
770 
771  key_len = unhexify( key_str, "00000000000000000000000000000000" );
772  unhexify( src_str, "db4f1aa530967d6732ce4715eb0ee24b" );
773 
774  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
775  if( 0 == 0 )
776  {
777  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
778  hexify( dst_str, output, 16 );
779 
780  fct_chk( strcmp( (char *) dst_str, "ff000000000000000000000000000000" ) == 0 );
781  }
782  }
783  FCT_TEST_END();
784 
785 
786  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_2)
787  {
788  unsigned char key_str[100];
789  unsigned char src_str[100];
790  unsigned char dst_str[100];
791  unsigned char output[100];
792  aes_context ctx;
793  int key_len;
794 
795  memset(key_str, 0x00, 100);
796  memset(src_str, 0x00, 100);
797  memset(dst_str, 0x00, 100);
798  memset(output, 0x00, 100);
799 
800  key_len = unhexify( key_str, "00000000000000000000000000000000" );
801  unhexify( src_str, "a81738252621dd180a34f3455b4baa2f" );
802 
803  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
804  if( 0 == 0 )
805  {
806  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
807  hexify( dst_str, output, 16 );
808 
809  fct_chk( strcmp( (char *) dst_str, "ff800000000000000000000000000000" ) == 0 );
810  }
811  }
812  FCT_TEST_END();
813 
814 
815  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_3)
816  {
817  unsigned char key_str[100];
818  unsigned char src_str[100];
819  unsigned char dst_str[100];
820  unsigned char output[100];
821  aes_context ctx;
822  int key_len;
823 
824  memset(key_str, 0x00, 100);
825  memset(src_str, 0x00, 100);
826  memset(dst_str, 0x00, 100);
827  memset(output, 0x00, 100);
828 
829  key_len = unhexify( key_str, "00000000000000000000000000000000" );
830  unhexify( src_str, "77e2b508db7fd89234caf7939ee5621a" );
831 
832  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
833  if( 0 == 0 )
834  {
835  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
836  hexify( dst_str, output, 16 );
837 
838  fct_chk( strcmp( (char *) dst_str, "ffc00000000000000000000000000000" ) == 0 );
839  }
840  }
841  FCT_TEST_END();
842 
843 
844  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_4)
845  {
846  unsigned char key_str[100];
847  unsigned char src_str[100];
848  unsigned char dst_str[100];
849  unsigned char output[100];
850  aes_context ctx;
851  int key_len;
852 
853  memset(key_str, 0x00, 100);
854  memset(src_str, 0x00, 100);
855  memset(dst_str, 0x00, 100);
856  memset(output, 0x00, 100);
857 
858  key_len = unhexify( key_str, "00000000000000000000000000000000" );
859  unhexify( src_str, "dc43be40be0e53712f7e2bf5ca707209" );
860 
861  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
862  if( 0 == 0 )
863  {
864  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
865  hexify( dst_str, output, 16 );
866 
867  fct_chk( strcmp( (char *) dst_str, "6a118a874519e64e9963798a503f1d35" ) == 0 );
868  }
869  }
870  FCT_TEST_END();
871 
872 
873  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_5)
874  {
875  unsigned char key_str[100];
876  unsigned char src_str[100];
877  unsigned char dst_str[100];
878  unsigned char output[100];
879  aes_context ctx;
880  int key_len;
881 
882  memset(key_str, 0x00, 100);
883  memset(src_str, 0x00, 100);
884  memset(dst_str, 0x00, 100);
885  memset(output, 0x00, 100);
886 
887  key_len = unhexify( key_str, "00000000000000000000000000000000" );
888  unhexify( src_str, "92beedab1895a94faa69b632e5cc47ce" );
889 
890  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
891  if( 0 == 0 )
892  {
893  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
894  hexify( dst_str, output, 16 );
895 
896  fct_chk( strcmp( (char *) dst_str, "cb9fceec81286ca3e989bd979b0cb284" ) == 0 );
897  }
898  }
899  FCT_TEST_END();
900 
901 
902  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_6)
903  {
904  unsigned char key_str[100];
905  unsigned char src_str[100];
906  unsigned char dst_str[100];
907  unsigned char output[100];
908  aes_context ctx;
909  int key_len;
910 
911  memset(key_str, 0x00, 100);
912  memset(src_str, 0x00, 100);
913  memset(dst_str, 0x00, 100);
914  memset(output, 0x00, 100);
915 
916  key_len = unhexify( key_str, "00000000000000000000000000000000" );
917  unhexify( src_str, "459264f4798f6a78bacb89c15ed3d601" );
918 
919  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
920  if( 0 == 0 )
921  {
922  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
923  hexify( dst_str, output, 16 );
924 
925  fct_chk( strcmp( (char *) dst_str, "b26aeb1874e47ca8358ff22378f09144" ) == 0 );
926  }
927  }
928  FCT_TEST_END();
929 
930 
931  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_7)
932  {
933  unsigned char key_str[100];
934  unsigned char src_str[100];
935  unsigned char dst_str[100];
936  unsigned char output[100];
937  aes_context ctx;
938  int key_len;
939 
940  memset(key_str, 0x00, 100);
941  memset(src_str, 0x00, 100);
942  memset(dst_str, 0x00, 100);
943  memset(output, 0x00, 100);
944 
945  key_len = unhexify( key_str, "b69418a85332240dc82492353956ae0c" );
946  unhexify( src_str, "a303d940ded8f0baff6f75414cac5243" );
947 
948  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
949  if( 0 == 0 )
950  {
951  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
952  hexify( dst_str, output, 16 );
953 
954  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
955  }
956  }
957  FCT_TEST_END();
958 
959 
960  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_8)
961  {
962  unsigned char key_str[100];
963  unsigned char src_str[100];
964  unsigned char dst_str[100];
965  unsigned char output[100];
966  aes_context ctx;
967  int key_len;
968 
969  memset(key_str, 0x00, 100);
970  memset(src_str, 0x00, 100);
971  memset(dst_str, 0x00, 100);
972  memset(output, 0x00, 100);
973 
974  key_len = unhexify( key_str, "71b5c08a1993e1362e4d0ce9b22b78d5" );
975  unhexify( src_str, "c2dabd117f8a3ecabfbb11d12194d9d0" );
976 
977  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
978  if( 0 == 0 )
979  {
980  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
981  hexify( dst_str, output, 16 );
982 
983  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
984  }
985  }
986  FCT_TEST_END();
987 
988 
989  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_9)
990  {
991  unsigned char key_str[100];
992  unsigned char src_str[100];
993  unsigned char dst_str[100];
994  unsigned char output[100];
995  aes_context ctx;
996  int key_len;
997 
998  memset(key_str, 0x00, 100);
999  memset(src_str, 0x00, 100);
1000  memset(dst_str, 0x00, 100);
1001  memset(output, 0x00, 100);
1002 
1003  key_len = unhexify( key_str, "e234cdca2606b81f29408d5f6da21206" );
1004  unhexify( src_str, "fff60a4740086b3b9c56195b98d91a7b" );
1005 
1006  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1007  if( 0 == 0 )
1008  {
1009  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1010  hexify( dst_str, output, 16 );
1011 
1012  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1013  }
1014  }
1015  FCT_TEST_END();
1016 
1017 
1018  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_10)
1019  {
1020  unsigned char key_str[100];
1021  unsigned char src_str[100];
1022  unsigned char dst_str[100];
1023  unsigned char output[100];
1024  aes_context ctx;
1025  int key_len;
1026 
1027  memset(key_str, 0x00, 100);
1028  memset(src_str, 0x00, 100);
1029  memset(dst_str, 0x00, 100);
1030  memset(output, 0x00, 100);
1031 
1032  key_len = unhexify( key_str, "ffffffffffffffff0000000000000000" );
1033  unhexify( src_str, "84be19e053635f09f2665e7bae85b42d" );
1034 
1035  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1036  if( 0 == 0 )
1037  {
1038  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1039  hexify( dst_str, output, 16 );
1040 
1041  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1042  }
1043  }
1044  FCT_TEST_END();
1045 
1046 
1047  FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_11)
1048  {
1049  unsigned char key_str[100];
1050  unsigned char src_str[100];
1051  unsigned char dst_str[100];
1052  unsigned char output[100];
1053  aes_context ctx;
1054  int key_len;
1055 
1056  memset(key_str, 0x00, 100);
1057  memset(src_str, 0x00, 100);
1058  memset(dst_str, 0x00, 100);
1059  memset(output, 0x00, 100);
1060 
1061  key_len = unhexify( key_str, "ffffffffffffffff8000000000000000" );
1062  unhexify( src_str, "32cd652842926aea4aa6137bb2be2b5e" );
1063 
1064  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1065  if( 0 == 0 )
1066  {
1067  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1068  hexify( dst_str, output, 16 );
1069 
1070  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1071  }
1072  }
1073  FCT_TEST_END();
1074 
1075 
1076  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_1)
1077  {
1078  unsigned char key_str[100];
1079  unsigned char src_str[100];
1080  unsigned char dst_str[100];
1081  unsigned char output[100];
1082  aes_context ctx;
1083  int key_len;
1084 
1085  memset(key_str, 0x00, 100);
1086  memset(src_str, 0x00, 100);
1087  memset(dst_str, 0x00, 100);
1088  memset(output, 0x00, 100);
1089 
1090  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1091  unhexify( src_str, "fffffffffffffffffffff80000000000" );
1092 
1093  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1094  if( 0 == 0 )
1095  {
1096  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1097  hexify( dst_str, output, 16 );
1098 
1099  fct_chk( strcmp( (char *) dst_str, "156f07767a85a4312321f63968338a01" ) == 0 );
1100  }
1101  }
1102  FCT_TEST_END();
1103 
1104 
1105  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_2)
1106  {
1107  unsigned char key_str[100];
1108  unsigned char src_str[100];
1109  unsigned char dst_str[100];
1110  unsigned char output[100];
1111  aes_context ctx;
1112  int key_len;
1113 
1114  memset(key_str, 0x00, 100);
1115  memset(src_str, 0x00, 100);
1116  memset(dst_str, 0x00, 100);
1117  memset(output, 0x00, 100);
1118 
1119  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1120  unhexify( src_str, "fffffffffffffffffffffc0000000000" );
1121 
1122  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1123  if( 0 == 0 )
1124  {
1125  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1126  hexify( dst_str, output, 16 );
1127 
1128  fct_chk( strcmp( (char *) dst_str, "15eec9ebf42b9ca76897d2cd6c5a12e2" ) == 0 );
1129  }
1130  }
1131  FCT_TEST_END();
1132 
1133 
1134  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_3)
1135  {
1136  unsigned char key_str[100];
1137  unsigned char src_str[100];
1138  unsigned char dst_str[100];
1139  unsigned char output[100];
1140  aes_context ctx;
1141  int key_len;
1142 
1143  memset(key_str, 0x00, 100);
1144  memset(src_str, 0x00, 100);
1145  memset(dst_str, 0x00, 100);
1146  memset(output, 0x00, 100);
1147 
1148  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1149  unhexify( src_str, "fffffffffffffffffffffe0000000000" );
1150 
1151  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1152  if( 0 == 0 )
1153  {
1154  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1155  hexify( dst_str, output, 16 );
1156 
1157  fct_chk( strcmp( (char *) dst_str, "db0d3a6fdcc13f915e2b302ceeb70fd8" ) == 0 );
1158  }
1159  }
1160  FCT_TEST_END();
1161 
1162 
1163  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_4)
1164  {
1165  unsigned char key_str[100];
1166  unsigned char src_str[100];
1167  unsigned char dst_str[100];
1168  unsigned char output[100];
1169  aes_context ctx;
1170  int key_len;
1171 
1172  memset(key_str, 0x00, 100);
1173  memset(src_str, 0x00, 100);
1174  memset(dst_str, 0x00, 100);
1175  memset(output, 0x00, 100);
1176 
1177  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1178  unhexify( src_str, "51719783d3185a535bd75adc65071ce1" );
1179 
1180  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1181  if( 0 == 0 )
1182  {
1183  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1184  hexify( dst_str, output, 16 );
1185 
1186  fct_chk( strcmp( (char *) dst_str, "4f354592ff7c8847d2d0870ca9481b7c" ) == 0 );
1187  }
1188  }
1189  FCT_TEST_END();
1190 
1191 
1192  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_5)
1193  {
1194  unsigned char key_str[100];
1195  unsigned char src_str[100];
1196  unsigned char dst_str[100];
1197  unsigned char output[100];
1198  aes_context ctx;
1199  int key_len;
1200 
1201  memset(key_str, 0x00, 100);
1202  memset(src_str, 0x00, 100);
1203  memset(dst_str, 0x00, 100);
1204  memset(output, 0x00, 100);
1205 
1206  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1207  unhexify( src_str, "26aa49dcfe7629a8901a69a9914e6dfd" );
1208 
1209  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1210  if( 0 == 0 )
1211  {
1212  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1213  hexify( dst_str, output, 16 );
1214 
1215  fct_chk( strcmp( (char *) dst_str, "d5e08bf9a182e857cf40b3a36ee248cc" ) == 0 );
1216  }
1217  }
1218  FCT_TEST_END();
1219 
1220 
1221  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_6)
1222  {
1223  unsigned char key_str[100];
1224  unsigned char src_str[100];
1225  unsigned char dst_str[100];
1226  unsigned char output[100];
1227  aes_context ctx;
1228  int key_len;
1229 
1230  memset(key_str, 0x00, 100);
1231  memset(src_str, 0x00, 100);
1232  memset(dst_str, 0x00, 100);
1233  memset(output, 0x00, 100);
1234 
1235  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1236  unhexify( src_str, "941a4773058224e1ef66d10e0a6ee782" );
1237 
1238  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1239  if( 0 == 0 )
1240  {
1241  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1242  hexify( dst_str, output, 16 );
1243 
1244  fct_chk( strcmp( (char *) dst_str, "067cd9d3749207791841562507fa9626" ) == 0 );
1245  }
1246  }
1247  FCT_TEST_END();
1248 
1249 
1250  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_7)
1251  {
1252  unsigned char key_str[100];
1253  unsigned char src_str[100];
1254  unsigned char dst_str[100];
1255  unsigned char output[100];
1256  aes_context ctx;
1257  int key_len;
1258 
1259  memset(key_str, 0x00, 100);
1260  memset(src_str, 0x00, 100);
1261  memset(dst_str, 0x00, 100);
1262  memset(output, 0x00, 100);
1263 
1264  key_len = unhexify( key_str, "d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3" );
1265  unhexify( src_str, "00000000000000000000000000000000" );
1266 
1267  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1268  if( 0 == 0 )
1269  {
1270  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1271  hexify( dst_str, output, 16 );
1272 
1273  fct_chk( strcmp( (char *) dst_str, "dd619e1cf204446112e0af2b9afa8f8c" ) == 0 );
1274  }
1275  }
1276  FCT_TEST_END();
1277 
1278 
1279  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_8)
1280  {
1281  unsigned char key_str[100];
1282  unsigned char src_str[100];
1283  unsigned char dst_str[100];
1284  unsigned char output[100];
1285  aes_context ctx;
1286  int key_len;
1287 
1288  memset(key_str, 0x00, 100);
1289  memset(src_str, 0x00, 100);
1290  memset(dst_str, 0x00, 100);
1291  memset(output, 0x00, 100);
1292 
1293  key_len = unhexify( key_str, "982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93" );
1294  unhexify( src_str, "00000000000000000000000000000000" );
1295 
1296  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1297  if( 0 == 0 )
1298  {
1299  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1300  hexify( dst_str, output, 16 );
1301 
1302  fct_chk( strcmp( (char *) dst_str, "d4f0aae13c8fe9339fbf9e69ed0ad74d" ) == 0 );
1303  }
1304  }
1305  FCT_TEST_END();
1306 
1307 
1308  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_9)
1309  {
1310  unsigned char key_str[100];
1311  unsigned char src_str[100];
1312  unsigned char dst_str[100];
1313  unsigned char output[100];
1314  aes_context ctx;
1315  int key_len;
1316 
1317  memset(key_str, 0x00, 100);
1318  memset(src_str, 0x00, 100);
1319  memset(dst_str, 0x00, 100);
1320  memset(output, 0x00, 100);
1321 
1322  key_len = unhexify( key_str, "98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9" );
1323  unhexify( src_str, "00000000000000000000000000000000" );
1324 
1325  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1326  if( 0 == 0 )
1327  {
1328  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1329  hexify( dst_str, output, 16 );
1330 
1331  fct_chk( strcmp( (char *) dst_str, "19c80ec4a6deb7e5ed1033dda933498f" ) == 0 );
1332  }
1333  }
1334  FCT_TEST_END();
1335 
1336 
1337  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_10)
1338  {
1339  unsigned char key_str[100];
1340  unsigned char src_str[100];
1341  unsigned char dst_str[100];
1342  unsigned char output[100];
1343  aes_context ctx;
1344  int key_len;
1345 
1346  memset(key_str, 0x00, 100);
1347  memset(src_str, 0x00, 100);
1348  memset(dst_str, 0x00, 100);
1349  memset(output, 0x00, 100);
1350 
1351  key_len = unhexify( key_str, "fffffffffffffffffffffffffff800000000000000000000" );
1352  unhexify( src_str, "00000000000000000000000000000000" );
1353 
1354  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1355  if( 0 == 0 )
1356  {
1357  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1358  hexify( dst_str, output, 16 );
1359 
1360  fct_chk( strcmp( (char *) dst_str, "8dd274bd0f1b58ae345d9e7233f9b8f3" ) == 0 );
1361  }
1362  }
1363  FCT_TEST_END();
1364 
1365 
1366  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_11)
1367  {
1368  unsigned char key_str[100];
1369  unsigned char src_str[100];
1370  unsigned char dst_str[100];
1371  unsigned char output[100];
1372  aes_context ctx;
1373  int key_len;
1374 
1375  memset(key_str, 0x00, 100);
1376  memset(src_str, 0x00, 100);
1377  memset(dst_str, 0x00, 100);
1378  memset(output, 0x00, 100);
1379 
1380  key_len = unhexify( key_str, "fffffffffffffffffffffffffffc00000000000000000000" );
1381  unhexify( src_str, "00000000000000000000000000000000" );
1382 
1383  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1384  if( 0 == 0 )
1385  {
1386  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1387  hexify( dst_str, output, 16 );
1388 
1389  fct_chk( strcmp( (char *) dst_str, "9d6bdc8f4ce5feb0f3bed2e4b9a9bb0b" ) == 0 );
1390  }
1391  }
1392  FCT_TEST_END();
1393 
1394 
1395  FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_12)
1396  {
1397  unsigned char key_str[100];
1398  unsigned char src_str[100];
1399  unsigned char dst_str[100];
1400  unsigned char output[100];
1401  aes_context ctx;
1402  int key_len;
1403 
1404  memset(key_str, 0x00, 100);
1405  memset(src_str, 0x00, 100);
1406  memset(dst_str, 0x00, 100);
1407  memset(output, 0x00, 100);
1408 
1409  key_len = unhexify( key_str, "fffffffffffffffffffffffffffe00000000000000000000" );
1410  unhexify( src_str, "00000000000000000000000000000000" );
1411 
1412  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1413  if( 0 == 0 )
1414  {
1415  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1416  hexify( dst_str, output, 16 );
1417 
1418  fct_chk( strcmp( (char *) dst_str, "fd5548bcf3f42565f7efa94562528d46" ) == 0 );
1419  }
1420  }
1421  FCT_TEST_END();
1422 
1423 
1424  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_1)
1425  {
1426  unsigned char key_str[100];
1427  unsigned char src_str[100];
1428  unsigned char dst_str[100];
1429  unsigned char output[100];
1430  aes_context ctx;
1431  int key_len;
1432 
1433  memset(key_str, 0x00, 100);
1434  memset(src_str, 0x00, 100);
1435  memset(dst_str, 0x00, 100);
1436  memset(output, 0x00, 100);
1437 
1438  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffff000000000000000" );
1439  unhexify( src_str, "bb2852c891c5947d2ed44032c421b85f" );
1440 
1441  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1442  if( 0 == 0 )
1443  {
1444  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1445  hexify( dst_str, output, 16 );
1446 
1447  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1448  }
1449  }
1450  FCT_TEST_END();
1451 
1452 
1453  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_2)
1454  {
1455  unsigned char key_str[100];
1456  unsigned char src_str[100];
1457  unsigned char dst_str[100];
1458  unsigned char output[100];
1459  aes_context ctx;
1460  int key_len;
1461 
1462  memset(key_str, 0x00, 100);
1463  memset(src_str, 0x00, 100);
1464  memset(dst_str, 0x00, 100);
1465  memset(output, 0x00, 100);
1466 
1467  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffff800000000000000" );
1468  unhexify( src_str, "1b9f5fbd5e8a4264c0a85b80409afa5e" );
1469 
1470  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1471  if( 0 == 0 )
1472  {
1473  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1474  hexify( dst_str, output, 16 );
1475 
1476  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1477  }
1478  }
1479  FCT_TEST_END();
1480 
1481 
1482  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_3)
1483  {
1484  unsigned char key_str[100];
1485  unsigned char src_str[100];
1486  unsigned char dst_str[100];
1487  unsigned char output[100];
1488  aes_context ctx;
1489  int key_len;
1490 
1491  memset(key_str, 0x00, 100);
1492  memset(src_str, 0x00, 100);
1493  memset(dst_str, 0x00, 100);
1494  memset(output, 0x00, 100);
1495 
1496  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffc00000000000000" );
1497  unhexify( src_str, "30dab809f85a917fe924733f424ac589" );
1498 
1499  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1500  if( 0 == 0 )
1501  {
1502  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1503  hexify( dst_str, output, 16 );
1504 
1505  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1506  }
1507  }
1508  FCT_TEST_END();
1509 
1510 
1511  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_4)
1512  {
1513  unsigned char key_str[100];
1514  unsigned char src_str[100];
1515  unsigned char dst_str[100];
1516  unsigned char output[100];
1517  aes_context ctx;
1518  int key_len;
1519 
1520  memset(key_str, 0x00, 100);
1521  memset(src_str, 0x00, 100);
1522  memset(dst_str, 0x00, 100);
1523  memset(output, 0x00, 100);
1524 
1525  key_len = unhexify( key_str, "61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79" );
1526  unhexify( src_str, "cfe4d74002696ccf7d87b14a2f9cafc9" );
1527 
1528  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1529  if( 0 == 0 )
1530  {
1531  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1532  hexify( dst_str, output, 16 );
1533 
1534  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1535  }
1536  }
1537  FCT_TEST_END();
1538 
1539 
1540  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_5)
1541  {
1542  unsigned char key_str[100];
1543  unsigned char src_str[100];
1544  unsigned char dst_str[100];
1545  unsigned char output[100];
1546  aes_context ctx;
1547  int key_len;
1548 
1549  memset(key_str, 0x00, 100);
1550  memset(src_str, 0x00, 100);
1551  memset(dst_str, 0x00, 100);
1552  memset(output, 0x00, 100);
1553 
1554  key_len = unhexify( key_str, "b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570" );
1555  unhexify( src_str, "d2eafd86f63b109b91f5dbb3a3fb7e13" );
1556 
1557  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1558  if( 0 == 0 )
1559  {
1560  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1561  hexify( dst_str, output, 16 );
1562 
1563  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1564  }
1565  }
1566  FCT_TEST_END();
1567 
1568 
1569  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_6)
1570  {
1571  unsigned char key_str[100];
1572  unsigned char src_str[100];
1573  unsigned char dst_str[100];
1574  unsigned char output[100];
1575  aes_context ctx;
1576  int key_len;
1577 
1578  memset(key_str, 0x00, 100);
1579  memset(src_str, 0x00, 100);
1580  memset(dst_str, 0x00, 100);
1581  memset(output, 0x00, 100);
1582 
1583  key_len = unhexify( key_str, "ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6" );
1584  unhexify( src_str, "9b9fdd1c5975655f539998b306a324af" );
1585 
1586  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1587  if( 0 == 0 )
1588  {
1589  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1590  hexify( dst_str, output, 16 );
1591 
1592  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1593  }
1594  }
1595  FCT_TEST_END();
1596 
1597 
1598  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_7)
1599  {
1600  unsigned char key_str[100];
1601  unsigned char src_str[100];
1602  unsigned char dst_str[100];
1603  unsigned char output[100];
1604  aes_context ctx;
1605  int key_len;
1606 
1607  memset(key_str, 0x00, 100);
1608  memset(src_str, 0x00, 100);
1609  memset(dst_str, 0x00, 100);
1610  memset(output, 0x00, 100);
1611 
1612  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1613  unhexify( src_str, "275cfc0413d8ccb70513c3859b1d0f72" );
1614 
1615  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1616  if( 0 == 0 )
1617  {
1618  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1619  hexify( dst_str, output, 16 );
1620 
1621  fct_chk( strcmp( (char *) dst_str, "1b077a6af4b7f98229de786d7516b639" ) == 0 );
1622  }
1623  }
1624  FCT_TEST_END();
1625 
1626 
1627  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_8)
1628  {
1629  unsigned char key_str[100];
1630  unsigned char src_str[100];
1631  unsigned char dst_str[100];
1632  unsigned char output[100];
1633  aes_context ctx;
1634  int key_len;
1635 
1636  memset(key_str, 0x00, 100);
1637  memset(src_str, 0x00, 100);
1638  memset(dst_str, 0x00, 100);
1639  memset(output, 0x00, 100);
1640 
1641  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1642  unhexify( src_str, "c9b8135ff1b5adc413dfd053b21bd96d" );
1643 
1644  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1645  if( 0 == 0 )
1646  {
1647  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1648  hexify( dst_str, output, 16 );
1649 
1650  fct_chk( strcmp( (char *) dst_str, "9c2d8842e5f48f57648205d39a239af1" ) == 0 );
1651  }
1652  }
1653  FCT_TEST_END();
1654 
1655 
1656  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_9)
1657  {
1658  unsigned char key_str[100];
1659  unsigned char src_str[100];
1660  unsigned char dst_str[100];
1661  unsigned char output[100];
1662  aes_context ctx;
1663  int key_len;
1664 
1665  memset(key_str, 0x00, 100);
1666  memset(src_str, 0x00, 100);
1667  memset(dst_str, 0x00, 100);
1668  memset(output, 0x00, 100);
1669 
1670  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1671  unhexify( src_str, "4a3650c3371ce2eb35e389a171427440" );
1672 
1673  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1674  if( 0 == 0 )
1675  {
1676  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1677  hexify( dst_str, output, 16 );
1678 
1679  fct_chk( strcmp( (char *) dst_str, "bff52510095f518ecca60af4205444bb" ) == 0 );
1680  }
1681  }
1682  FCT_TEST_END();
1683 
1684 
1685  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_10)
1686  {
1687  unsigned char key_str[100];
1688  unsigned char src_str[100];
1689  unsigned char dst_str[100];
1690  unsigned char output[100];
1691  aes_context ctx;
1692  int key_len;
1693 
1694  memset(key_str, 0x00, 100);
1695  memset(src_str, 0x00, 100);
1696  memset(dst_str, 0x00, 100);
1697  memset(output, 0x00, 100);
1698 
1699  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1700  unhexify( src_str, "b2099795e88cc158fd75ea133d7e7fbe" );
1701 
1702  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1703  if( 0 == 0 )
1704  {
1705  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1706  hexify( dst_str, output, 16 );
1707 
1708  fct_chk( strcmp( (char *) dst_str, "ffffffffffffffffffffc00000000000" ) == 0 );
1709  }
1710  }
1711  FCT_TEST_END();
1712 
1713 
1714  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_11)
1715  {
1716  unsigned char key_str[100];
1717  unsigned char src_str[100];
1718  unsigned char dst_str[100];
1719  unsigned char output[100];
1720  aes_context ctx;
1721  int key_len;
1722 
1723  memset(key_str, 0x00, 100);
1724  memset(src_str, 0x00, 100);
1725  memset(dst_str, 0x00, 100);
1726  memset(output, 0x00, 100);
1727 
1728  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1729  unhexify( src_str, "a6cae46fb6fadfe7a2c302a34242817b" );
1730 
1731  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1732  if( 0 == 0 )
1733  {
1734  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1735  hexify( dst_str, output, 16 );
1736 
1737  fct_chk( strcmp( (char *) dst_str, "ffffffffffffffffffffe00000000000" ) == 0 );
1738  }
1739  }
1740  FCT_TEST_END();
1741 
1742 
1743  FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_12)
1744  {
1745  unsigned char key_str[100];
1746  unsigned char src_str[100];
1747  unsigned char dst_str[100];
1748  unsigned char output[100];
1749  aes_context ctx;
1750  int key_len;
1751 
1752  memset(key_str, 0x00, 100);
1753  memset(src_str, 0x00, 100);
1754  memset(dst_str, 0x00, 100);
1755  memset(output, 0x00, 100);
1756 
1757  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1758  unhexify( src_str, "026a7024d6a902e0b3ffccbaa910cc3f" );
1759 
1760  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
1761  if( 0 == 0 )
1762  {
1763  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
1764  hexify( dst_str, output, 16 );
1765 
1766  fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffff00000000000" ) == 0 );
1767  }
1768  }
1769  FCT_TEST_END();
1770 
1771 
1772  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_1)
1773  {
1774  unsigned char key_str[100];
1775  unsigned char src_str[100];
1776  unsigned char dst_str[100];
1777  unsigned char output[100];
1778  aes_context ctx;
1779  int key_len;
1780 
1781  memset(key_str, 0x00, 100);
1782  memset(src_str, 0x00, 100);
1783  memset(dst_str, 0x00, 100);
1784  memset(output, 0x00, 100);
1785 
1786  key_len = unhexify( key_str, "c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c" );
1787  unhexify( src_str, "00000000000000000000000000000000" );
1788 
1789  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1790  if( 0 == 0 )
1791  {
1792  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1793  hexify( dst_str, output, 16 );
1794 
1795  fct_chk( strcmp( (char *) dst_str, "352065272169abf9856843927d0674fd" ) == 0 );
1796  }
1797  }
1798  FCT_TEST_END();
1799 
1800 
1801  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_2)
1802  {
1803  unsigned char key_str[100];
1804  unsigned char src_str[100];
1805  unsigned char dst_str[100];
1806  unsigned char output[100];
1807  aes_context ctx;
1808  int key_len;
1809 
1810  memset(key_str, 0x00, 100);
1811  memset(src_str, 0x00, 100);
1812  memset(dst_str, 0x00, 100);
1813  memset(output, 0x00, 100);
1814 
1815  key_len = unhexify( key_str, "984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627" );
1816  unhexify( src_str, "00000000000000000000000000000000" );
1817 
1818  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1819  if( 0 == 0 )
1820  {
1821  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1822  hexify( dst_str, output, 16 );
1823 
1824  fct_chk( strcmp( (char *) dst_str, "4307456a9e67813b452e15fa8fffe398" ) == 0 );
1825  }
1826  }
1827  FCT_TEST_END();
1828 
1829 
1830  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_3)
1831  {
1832  unsigned char key_str[100];
1833  unsigned char src_str[100];
1834  unsigned char dst_str[100];
1835  unsigned char output[100];
1836  aes_context ctx;
1837  int key_len;
1838 
1839  memset(key_str, 0x00, 100);
1840  memset(src_str, 0x00, 100);
1841  memset(dst_str, 0x00, 100);
1842  memset(output, 0x00, 100);
1843 
1844  key_len = unhexify( key_str, "b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f" );
1845  unhexify( src_str, "00000000000000000000000000000000" );
1846 
1847  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1848  if( 0 == 0 )
1849  {
1850  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1851  hexify( dst_str, output, 16 );
1852 
1853  fct_chk( strcmp( (char *) dst_str, "4663446607354989477a5c6f0f007ef4" ) == 0 );
1854  }
1855  }
1856  FCT_TEST_END();
1857 
1858 
1859  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_4)
1860  {
1861  unsigned char key_str[100];
1862  unsigned char src_str[100];
1863  unsigned char dst_str[100];
1864  unsigned char output[100];
1865  aes_context ctx;
1866  int key_len;
1867 
1868  memset(key_str, 0x00, 100);
1869  memset(src_str, 0x00, 100);
1870  memset(dst_str, 0x00, 100);
1871  memset(output, 0x00, 100);
1872 
1873  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
1874  unhexify( src_str, "0b24af36193ce4665f2825d7b4749c98" );
1875 
1876  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1877  if( 0 == 0 )
1878  {
1879  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1880  hexify( dst_str, output, 16 );
1881 
1882  fct_chk( strcmp( (char *) dst_str, "a9ff75bd7cf6613d3731c77c3b6d0c04" ) == 0 );
1883  }
1884  }
1885  FCT_TEST_END();
1886 
1887 
1888  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_5)
1889  {
1890  unsigned char key_str[100];
1891  unsigned char src_str[100];
1892  unsigned char dst_str[100];
1893  unsigned char output[100];
1894  aes_context ctx;
1895  int key_len;
1896 
1897  memset(key_str, 0x00, 100);
1898  memset(src_str, 0x00, 100);
1899  memset(dst_str, 0x00, 100);
1900  memset(output, 0x00, 100);
1901 
1902  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
1903  unhexify( src_str, "761c1fe41a18acf20d241650611d90f1" );
1904 
1905  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1906  if( 0 == 0 )
1907  {
1908  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1909  hexify( dst_str, output, 16 );
1910 
1911  fct_chk( strcmp( (char *) dst_str, "623a52fcea5d443e48d9181ab32c7421" ) == 0 );
1912  }
1913  }
1914  FCT_TEST_END();
1915 
1916 
1917  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_6)
1918  {
1919  unsigned char key_str[100];
1920  unsigned char src_str[100];
1921  unsigned char dst_str[100];
1922  unsigned char output[100];
1923  aes_context ctx;
1924  int key_len;
1925 
1926  memset(key_str, 0x00, 100);
1927  memset(src_str, 0x00, 100);
1928  memset(dst_str, 0x00, 100);
1929  memset(output, 0x00, 100);
1930 
1931  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
1932  unhexify( src_str, "8a560769d605868ad80d819bdba03771" );
1933 
1934  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1935  if( 0 == 0 )
1936  {
1937  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1938  hexify( dst_str, output, 16 );
1939 
1940  fct_chk( strcmp( (char *) dst_str, "38f2c7ae10612415d27ca190d27da8b4" ) == 0 );
1941  }
1942  }
1943  FCT_TEST_END();
1944 
1945 
1946  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_7)
1947  {
1948  unsigned char key_str[100];
1949  unsigned char src_str[100];
1950  unsigned char dst_str[100];
1951  unsigned char output[100];
1952  aes_context ctx;
1953  int key_len;
1954 
1955  memset(key_str, 0x00, 100);
1956  memset(src_str, 0x00, 100);
1957  memset(dst_str, 0x00, 100);
1958  memset(output, 0x00, 100);
1959 
1960  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
1961  unhexify( src_str, "ffffff80000000000000000000000000" );
1962 
1963  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1964  if( 0 == 0 )
1965  {
1966  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1967  hexify( dst_str, output, 16 );
1968 
1969  fct_chk( strcmp( (char *) dst_str, "36aff0ef7bf3280772cf4cac80a0d2b2" ) == 0 );
1970  }
1971  }
1972  FCT_TEST_END();
1973 
1974 
1975  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_8)
1976  {
1977  unsigned char key_str[100];
1978  unsigned char src_str[100];
1979  unsigned char dst_str[100];
1980  unsigned char output[100];
1981  aes_context ctx;
1982  int key_len;
1983 
1984  memset(key_str, 0x00, 100);
1985  memset(src_str, 0x00, 100);
1986  memset(dst_str, 0x00, 100);
1987  memset(output, 0x00, 100);
1988 
1989  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
1990  unhexify( src_str, "ffffffc0000000000000000000000000" );
1991 
1992  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
1993  if( 0 == 0 )
1994  {
1995  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
1996  hexify( dst_str, output, 16 );
1997 
1998  fct_chk( strcmp( (char *) dst_str, "1f8eedea0f62a1406d58cfc3ecea72cf" ) == 0 );
1999  }
2000  }
2001  FCT_TEST_END();
2002 
2003 
2004  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_9)
2005  {
2006  unsigned char key_str[100];
2007  unsigned char src_str[100];
2008  unsigned char dst_str[100];
2009  unsigned char output[100];
2010  aes_context ctx;
2011  int key_len;
2012 
2013  memset(key_str, 0x00, 100);
2014  memset(src_str, 0x00, 100);
2015  memset(dst_str, 0x00, 100);
2016  memset(output, 0x00, 100);
2017 
2018  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2019  unhexify( src_str, "ffffffe0000000000000000000000000" );
2020 
2021  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
2022  if( 0 == 0 )
2023  {
2024  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
2025  hexify( dst_str, output, 16 );
2026 
2027  fct_chk( strcmp( (char *) dst_str, "abf4154a3375a1d3e6b1d454438f95a6" ) == 0 );
2028  }
2029  }
2030  FCT_TEST_END();
2031 
2032 
2033  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_10)
2034  {
2035  unsigned char key_str[100];
2036  unsigned char src_str[100];
2037  unsigned char dst_str[100];
2038  unsigned char output[100];
2039  aes_context ctx;
2040  int key_len;
2041 
2042  memset(key_str, 0x00, 100);
2043  memset(src_str, 0x00, 100);
2044  memset(dst_str, 0x00, 100);
2045  memset(output, 0x00, 100);
2046 
2047  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffff8000000000000000000000000000" );
2048  unhexify( src_str, "00000000000000000000000000000000" );
2049 
2050  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
2051  if( 0 == 0 )
2052  {
2053  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
2054  hexify( dst_str, output, 16 );
2055 
2056  fct_chk( strcmp( (char *) dst_str, "45d089c36d5c5a4efc689e3b0de10dd5" ) == 0 );
2057  }
2058  }
2059  FCT_TEST_END();
2060 
2061 
2062  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_11)
2063  {
2064  unsigned char key_str[100];
2065  unsigned char src_str[100];
2066  unsigned char dst_str[100];
2067  unsigned char output[100];
2068  aes_context ctx;
2069  int key_len;
2070 
2071  memset(key_str, 0x00, 100);
2072  memset(src_str, 0x00, 100);
2073  memset(dst_str, 0x00, 100);
2074  memset(output, 0x00, 100);
2075 
2076  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffc000000000000000000000000000" );
2077  unhexify( src_str, "00000000000000000000000000000000" );
2078 
2079  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
2080  if( 0 == 0 )
2081  {
2082  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
2083  hexify( dst_str, output, 16 );
2084 
2085  fct_chk( strcmp( (char *) dst_str, "b4da5df4becb5462e03a0ed00d295629" ) == 0 );
2086  }
2087  }
2088  FCT_TEST_END();
2089 
2090 
2091  FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_12)
2092  {
2093  unsigned char key_str[100];
2094  unsigned char src_str[100];
2095  unsigned char dst_str[100];
2096  unsigned char output[100];
2097  aes_context ctx;
2098  int key_len;
2099 
2100  memset(key_str, 0x00, 100);
2101  memset(src_str, 0x00, 100);
2102  memset(dst_str, 0x00, 100);
2103  memset(output, 0x00, 100);
2104 
2105  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffe000000000000000000000000000" );
2106  unhexify( src_str, "00000000000000000000000000000000" );
2107 
2108  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
2109  if( 0 == 0 )
2110  {
2111  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
2112  hexify( dst_str, output, 16 );
2113 
2114  fct_chk( strcmp( (char *) dst_str, "dcf4e129136c1a4b7a0f38935cc34b2b" ) == 0 );
2115  }
2116  }
2117  FCT_TEST_END();
2118 
2119 
2120  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_1)
2121  {
2122  unsigned char key_str[100];
2123  unsigned char src_str[100];
2124  unsigned char dst_str[100];
2125  unsigned char output[100];
2126  aes_context ctx;
2127  int key_len;
2128 
2129  memset(key_str, 0x00, 100);
2130  memset(src_str, 0x00, 100);
2131  memset(dst_str, 0x00, 100);
2132  memset(output, 0x00, 100);
2133 
2134  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffff00000000000000000" );
2135  unhexify( src_str, "edf61ae362e882ddc0167474a7a77f3a" );
2136 
2137  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2138  if( 0 == 0 )
2139  {
2140  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2141  hexify( dst_str, output, 16 );
2142 
2143  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2144  }
2145  }
2146  FCT_TEST_END();
2147 
2148 
2149  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_2)
2150  {
2151  unsigned char key_str[100];
2152  unsigned char src_str[100];
2153  unsigned char dst_str[100];
2154  unsigned char output[100];
2155  aes_context ctx;
2156  int key_len;
2157 
2158  memset(key_str, 0x00, 100);
2159  memset(src_str, 0x00, 100);
2160  memset(dst_str, 0x00, 100);
2161  memset(output, 0x00, 100);
2162 
2163  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffff80000000000000000" );
2164  unhexify( src_str, "6168b00ba7859e0970ecfd757efecf7c" );
2165 
2166  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2167  if( 0 == 0 )
2168  {
2169  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2170  hexify( dst_str, output, 16 );
2171 
2172  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2173  }
2174  }
2175  FCT_TEST_END();
2176 
2177 
2178  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_3)
2179  {
2180  unsigned char key_str[100];
2181  unsigned char src_str[100];
2182  unsigned char dst_str[100];
2183  unsigned char output[100];
2184  aes_context ctx;
2185  int key_len;
2186 
2187  memset(key_str, 0x00, 100);
2188  memset(src_str, 0x00, 100);
2189  memset(dst_str, 0x00, 100);
2190  memset(output, 0x00, 100);
2191 
2192  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000" );
2193  unhexify( src_str, "d1415447866230d28bb1ea18a4cdfd02" );
2194 
2195  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2196  if( 0 == 0 )
2197  {
2198  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2199  hexify( dst_str, output, 16 );
2200 
2201  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2202  }
2203  }
2204  FCT_TEST_END();
2205 
2206 
2207  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_4)
2208  {
2209  unsigned char key_str[100];
2210  unsigned char src_str[100];
2211  unsigned char dst_str[100];
2212  unsigned char output[100];
2213  aes_context ctx;
2214  int key_len;
2215 
2216  memset(key_str, 0x00, 100);
2217  memset(src_str, 0x00, 100);
2218  memset(dst_str, 0x00, 100);
2219  memset(output, 0x00, 100);
2220 
2221  key_len = unhexify( key_str, "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" );
2222  unhexify( src_str, "a3944b95ca0b52043584ef02151926a8" );
2223 
2224  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2225  if( 0 == 0 )
2226  {
2227  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2228  hexify( dst_str, output, 16 );
2229 
2230  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2231  }
2232  }
2233  FCT_TEST_END();
2234 
2235 
2236  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_5)
2237  {
2238  unsigned char key_str[100];
2239  unsigned char src_str[100];
2240  unsigned char dst_str[100];
2241  unsigned char output[100];
2242  aes_context ctx;
2243  int key_len;
2244 
2245  memset(key_str, 0x00, 100);
2246  memset(src_str, 0x00, 100);
2247  memset(dst_str, 0x00, 100);
2248  memset(output, 0x00, 100);
2249 
2250  key_len = unhexify( key_str, "797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e" );
2251  unhexify( src_str, "a74289fe73a4c123ca189ea1e1b49ad5" );
2252 
2253  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2254  if( 0 == 0 )
2255  {
2256  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2257  hexify( dst_str, output, 16 );
2258 
2259  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2260  }
2261  }
2262  FCT_TEST_END();
2263 
2264 
2265  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_6)
2266  {
2267  unsigned char key_str[100];
2268  unsigned char src_str[100];
2269  unsigned char dst_str[100];
2270  unsigned char output[100];
2271  aes_context ctx;
2272  int key_len;
2273 
2274  memset(key_str, 0x00, 100);
2275  memset(src_str, 0x00, 100);
2276  memset(dst_str, 0x00, 100);
2277  memset(output, 0x00, 100);
2278 
2279  key_len = unhexify( key_str, "6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707" );
2280  unhexify( src_str, "b91d4ea4488644b56cf0812fa7fcf5fc" );
2281 
2282  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2283  if( 0 == 0 )
2284  {
2285  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2286  hexify( dst_str, output, 16 );
2287 
2288  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2289  }
2290  }
2291  FCT_TEST_END();
2292 
2293 
2294  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_7)
2295  {
2296  unsigned char key_str[100];
2297  unsigned char src_str[100];
2298  unsigned char dst_str[100];
2299  unsigned char output[100];
2300  aes_context ctx;
2301  int key_len;
2302 
2303  memset(key_str, 0x00, 100);
2304  memset(src_str, 0x00, 100);
2305  memset(dst_str, 0x00, 100);
2306  memset(output, 0x00, 100);
2307 
2308  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2309  unhexify( src_str, "623a52fcea5d443e48d9181ab32c7421" );
2310 
2311  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2312  if( 0 == 0 )
2313  {
2314  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2315  hexify( dst_str, output, 16 );
2316 
2317  fct_chk( strcmp( (char *) dst_str, "761c1fe41a18acf20d241650611d90f1" ) == 0 );
2318  }
2319  }
2320  FCT_TEST_END();
2321 
2322 
2323  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_8)
2324  {
2325  unsigned char key_str[100];
2326  unsigned char src_str[100];
2327  unsigned char dst_str[100];
2328  unsigned char output[100];
2329  aes_context ctx;
2330  int key_len;
2331 
2332  memset(key_str, 0x00, 100);
2333  memset(src_str, 0x00, 100);
2334  memset(dst_str, 0x00, 100);
2335  memset(output, 0x00, 100);
2336 
2337  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2338  unhexify( src_str, "38f2c7ae10612415d27ca190d27da8b4" );
2339 
2340  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2341  if( 0 == 0 )
2342  {
2343  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2344  hexify( dst_str, output, 16 );
2345 
2346  fct_chk( strcmp( (char *) dst_str, "8a560769d605868ad80d819bdba03771" ) == 0 );
2347  }
2348  }
2349  FCT_TEST_END();
2350 
2351 
2352  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_9)
2353  {
2354  unsigned char key_str[100];
2355  unsigned char src_str[100];
2356  unsigned char dst_str[100];
2357  unsigned char output[100];
2358  aes_context ctx;
2359  int key_len;
2360 
2361  memset(key_str, 0x00, 100);
2362  memset(src_str, 0x00, 100);
2363  memset(dst_str, 0x00, 100);
2364  memset(output, 0x00, 100);
2365 
2366  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2367  unhexify( src_str, "1bc704f1bce135ceb810341b216d7abe" );
2368 
2369  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2370  if( 0 == 0 )
2371  {
2372  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2373  hexify( dst_str, output, 16 );
2374 
2375  fct_chk( strcmp( (char *) dst_str, "91fbef2d15a97816060bee1feaa49afe" ) == 0 );
2376  }
2377  }
2378  FCT_TEST_END();
2379 
2380 
2381  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_10)
2382  {
2383  unsigned char key_str[100];
2384  unsigned char src_str[100];
2385  unsigned char dst_str[100];
2386  unsigned char output[100];
2387  aes_context ctx;
2388  int key_len;
2389 
2390  memset(key_str, 0x00, 100);
2391  memset(src_str, 0x00, 100);
2392  memset(dst_str, 0x00, 100);
2393  memset(output, 0x00, 100);
2394 
2395  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2396  unhexify( src_str, "ddc6bf790c15760d8d9aeb6f9a75fd4e" );
2397 
2398  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2399  if( 0 == 0 )
2400  {
2401  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2402  hexify( dst_str, output, 16 );
2403 
2404  fct_chk( strcmp( (char *) dst_str, "80000000000000000000000000000000" ) == 0 );
2405  }
2406  }
2407  FCT_TEST_END();
2408 
2409 
2410  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_11)
2411  {
2412  unsigned char key_str[100];
2413  unsigned char src_str[100];
2414  unsigned char dst_str[100];
2415  unsigned char output[100];
2416  aes_context ctx;
2417  int key_len;
2418 
2419  memset(key_str, 0x00, 100);
2420  memset(src_str, 0x00, 100);
2421  memset(dst_str, 0x00, 100);
2422  memset(output, 0x00, 100);
2423 
2424  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2425  unhexify( src_str, "0a6bdc6d4c1e6280301fd8e97ddbe601" );
2426 
2427  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2428  if( 0 == 0 )
2429  {
2430  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2431  hexify( dst_str, output, 16 );
2432 
2433  fct_chk( strcmp( (char *) dst_str, "c0000000000000000000000000000000" ) == 0 );
2434  }
2435  }
2436  FCT_TEST_END();
2437 
2438 
2439  FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_12)
2440  {
2441  unsigned char key_str[100];
2442  unsigned char src_str[100];
2443  unsigned char dst_str[100];
2444  unsigned char output[100];
2445  aes_context ctx;
2446  int key_len;
2447 
2448  memset(key_str, 0x00, 100);
2449  memset(src_str, 0x00, 100);
2450  memset(dst_str, 0x00, 100);
2451  memset(output, 0x00, 100);
2452 
2453  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2454  unhexify( src_str, "9b80eefb7ebe2d2b16247aa0efc72f5d" );
2455 
2456  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == 0 );
2457  if( 0 == 0 )
2458  {
2459  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
2460  hexify( dst_str, output, 16 );
2461 
2462  fct_chk( strcmp( (char *) dst_str, "e0000000000000000000000000000000" ) == 0 );
2463  }
2464  }
2465  FCT_TEST_END();
2466 
2467 
2468  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_1)
2469  {
2470  unsigned char key_str[100];
2471  unsigned char iv_str[100];
2472  unsigned char src_str[100];
2473  unsigned char dst_str[100];
2474  unsigned char output[100];
2475  aes_context ctx;
2476  int key_len, data_len;
2477 
2478  memset(key_str, 0x00, 100);
2479  memset(iv_str, 0x00, 100);
2480  memset(src_str, 0x00, 100);
2481  memset(dst_str, 0x00, 100);
2482  memset(output, 0x00, 100);
2483 
2484  key_len = unhexify( key_str, "fffffffffffff8000000000000000000" );
2485  unhexify( iv_str, "00000000000000000000000000000000" );
2486  data_len = unhexify( src_str, "00000000000000000000000000000000" );
2487 
2488  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2489  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2490  if( 0 == 0 )
2491  {
2492  hexify( dst_str, output, data_len );
2493 
2494  fct_chk( strcmp( (char *) dst_str, "8b527a6aebdaec9eaef8eda2cb7783e5" ) == 0 );
2495  }
2496  }
2497  FCT_TEST_END();
2498 
2499 
2500  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_2)
2501  {
2502  unsigned char key_str[100];
2503  unsigned char iv_str[100];
2504  unsigned char src_str[100];
2505  unsigned char dst_str[100];
2506  unsigned char output[100];
2507  aes_context ctx;
2508  int key_len, data_len;
2509 
2510  memset(key_str, 0x00, 100);
2511  memset(iv_str, 0x00, 100);
2512  memset(src_str, 0x00, 100);
2513  memset(dst_str, 0x00, 100);
2514  memset(output, 0x00, 100);
2515 
2516  key_len = unhexify( key_str, "fffffffffffffc000000000000000000" );
2517  unhexify( iv_str, "00000000000000000000000000000000" );
2518  data_len = unhexify( src_str, "00000000000000000000000000000000" );
2519 
2520  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2521  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2522  if( 0 == 0 )
2523  {
2524  hexify( dst_str, output, data_len );
2525 
2526  fct_chk( strcmp( (char *) dst_str, "43fdaf53ebbc9880c228617d6a9b548b" ) == 0 );
2527  }
2528  }
2529  FCT_TEST_END();
2530 
2531 
2532  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_3)
2533  {
2534  unsigned char key_str[100];
2535  unsigned char iv_str[100];
2536  unsigned char src_str[100];
2537  unsigned char dst_str[100];
2538  unsigned char output[100];
2539  aes_context ctx;
2540  int key_len, data_len;
2541 
2542  memset(key_str, 0x00, 100);
2543  memset(iv_str, 0x00, 100);
2544  memset(src_str, 0x00, 100);
2545  memset(dst_str, 0x00, 100);
2546  memset(output, 0x00, 100);
2547 
2548  key_len = unhexify( key_str, "fffffffffffffe000000000000000000" );
2549  unhexify( iv_str, "00000000000000000000000000000000" );
2550  data_len = unhexify( src_str, "00000000000000000000000000000000" );
2551 
2552  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2553  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2554  if( 0 == 0 )
2555  {
2556  hexify( dst_str, output, data_len );
2557 
2558  fct_chk( strcmp( (char *) dst_str, "53786104b9744b98f052c46f1c850d0b" ) == 0 );
2559  }
2560  }
2561  FCT_TEST_END();
2562 
2563 
2564  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_4)
2565  {
2566  unsigned char key_str[100];
2567  unsigned char iv_str[100];
2568  unsigned char src_str[100];
2569  unsigned char dst_str[100];
2570  unsigned char output[100];
2571  aes_context ctx;
2572  int key_len, data_len;
2573 
2574  memset(key_str, 0x00, 100);
2575  memset(iv_str, 0x00, 100);
2576  memset(src_str, 0x00, 100);
2577  memset(dst_str, 0x00, 100);
2578  memset(output, 0x00, 100);
2579 
2580  key_len = unhexify( key_str, "e37b1c6aa2846f6fdb413f238b089f23" );
2581  unhexify( iv_str, "00000000000000000000000000000000" );
2582  data_len = unhexify( src_str, "00000000000000000000000000000000" );
2583 
2584  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2585  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2586  if( 0 == 0 )
2587  {
2588  hexify( dst_str, output, data_len );
2589 
2590  fct_chk( strcmp( (char *) dst_str, "43c9f7e62f5d288bb27aa40ef8fe1ea8" ) == 0 );
2591  }
2592  }
2593  FCT_TEST_END();
2594 
2595 
2596  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_5)
2597  {
2598  unsigned char key_str[100];
2599  unsigned char iv_str[100];
2600  unsigned char src_str[100];
2601  unsigned char dst_str[100];
2602  unsigned char output[100];
2603  aes_context ctx;
2604  int key_len, data_len;
2605 
2606  memset(key_str, 0x00, 100);
2607  memset(iv_str, 0x00, 100);
2608  memset(src_str, 0x00, 100);
2609  memset(dst_str, 0x00, 100);
2610  memset(output, 0x00, 100);
2611 
2612  key_len = unhexify( key_str, "6c002b682483e0cabcc731c253be5674" );
2613  unhexify( iv_str, "00000000000000000000000000000000" );
2614  data_len = unhexify( src_str, "00000000000000000000000000000000" );
2615 
2616  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2617  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2618  if( 0 == 0 )
2619  {
2620  hexify( dst_str, output, data_len );
2621 
2622  fct_chk( strcmp( (char *) dst_str, "3580d19cff44f1014a7c966a69059de5" ) == 0 );
2623  }
2624  }
2625  FCT_TEST_END();
2626 
2627 
2628  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_6)
2629  {
2630  unsigned char key_str[100];
2631  unsigned char iv_str[100];
2632  unsigned char src_str[100];
2633  unsigned char dst_str[100];
2634  unsigned char output[100];
2635  aes_context ctx;
2636  int key_len, data_len;
2637 
2638  memset(key_str, 0x00, 100);
2639  memset(iv_str, 0x00, 100);
2640  memset(src_str, 0x00, 100);
2641  memset(dst_str, 0x00, 100);
2642  memset(output, 0x00, 100);
2643 
2644  key_len = unhexify( key_str, "143ae8ed6555aba96110ab58893a8ae1" );
2645  unhexify( iv_str, "00000000000000000000000000000000" );
2646  data_len = unhexify( src_str, "00000000000000000000000000000000" );
2647 
2648  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2649  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2650  if( 0 == 0 )
2651  {
2652  hexify( dst_str, output, data_len );
2653 
2654  fct_chk( strcmp( (char *) dst_str, "806da864dd29d48deafbe764f8202aef" ) == 0 );
2655  }
2656  }
2657  FCT_TEST_END();
2658 
2659 
2660  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_7)
2661  {
2662  unsigned char key_str[100];
2663  unsigned char iv_str[100];
2664  unsigned char src_str[100];
2665  unsigned char dst_str[100];
2666  unsigned char output[100];
2667  aes_context ctx;
2668  int key_len, data_len;
2669 
2670  memset(key_str, 0x00, 100);
2671  memset(iv_str, 0x00, 100);
2672  memset(src_str, 0x00, 100);
2673  memset(dst_str, 0x00, 100);
2674  memset(output, 0x00, 100);
2675 
2676  key_len = unhexify( key_str, "00000000000000000000000000000000" );
2677  unhexify( iv_str, "00000000000000000000000000000000" );
2678  data_len = unhexify( src_str, "6a118a874519e64e9963798a503f1d35" );
2679 
2680  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2681  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2682  if( 0 == 0 )
2683  {
2684  hexify( dst_str, output, data_len );
2685 
2686  fct_chk( strcmp( (char *) dst_str, "dc43be40be0e53712f7e2bf5ca707209" ) == 0 );
2687  }
2688  }
2689  FCT_TEST_END();
2690 
2691 
2692  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_8)
2693  {
2694  unsigned char key_str[100];
2695  unsigned char iv_str[100];
2696  unsigned char src_str[100];
2697  unsigned char dst_str[100];
2698  unsigned char output[100];
2699  aes_context ctx;
2700  int key_len, data_len;
2701 
2702  memset(key_str, 0x00, 100);
2703  memset(iv_str, 0x00, 100);
2704  memset(src_str, 0x00, 100);
2705  memset(dst_str, 0x00, 100);
2706  memset(output, 0x00, 100);
2707 
2708  key_len = unhexify( key_str, "00000000000000000000000000000000" );
2709  unhexify( iv_str, "00000000000000000000000000000000" );
2710  data_len = unhexify( src_str, "cb9fceec81286ca3e989bd979b0cb284" );
2711 
2712  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2713  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2714  if( 0 == 0 )
2715  {
2716  hexify( dst_str, output, data_len );
2717 
2718  fct_chk( strcmp( (char *) dst_str, "92beedab1895a94faa69b632e5cc47ce" ) == 0 );
2719  }
2720  }
2721  FCT_TEST_END();
2722 
2723 
2724  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_9)
2725  {
2726  unsigned char key_str[100];
2727  unsigned char iv_str[100];
2728  unsigned char src_str[100];
2729  unsigned char dst_str[100];
2730  unsigned char output[100];
2731  aes_context ctx;
2732  int key_len, data_len;
2733 
2734  memset(key_str, 0x00, 100);
2735  memset(iv_str, 0x00, 100);
2736  memset(src_str, 0x00, 100);
2737  memset(dst_str, 0x00, 100);
2738  memset(output, 0x00, 100);
2739 
2740  key_len = unhexify( key_str, "00000000000000000000000000000000" );
2741  unhexify( iv_str, "00000000000000000000000000000000" );
2742  data_len = unhexify( src_str, "b26aeb1874e47ca8358ff22378f09144" );
2743 
2744  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2745  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2746  if( 0 == 0 )
2747  {
2748  hexify( dst_str, output, data_len );
2749 
2750  fct_chk( strcmp( (char *) dst_str, "459264f4798f6a78bacb89c15ed3d601" ) == 0 );
2751  }
2752  }
2753  FCT_TEST_END();
2754 
2755 
2756  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_10)
2757  {
2758  unsigned char key_str[100];
2759  unsigned char iv_str[100];
2760  unsigned char src_str[100];
2761  unsigned char dst_str[100];
2762  unsigned char output[100];
2763  aes_context ctx;
2764  int key_len, data_len;
2765 
2766  memset(key_str, 0x00, 100);
2767  memset(iv_str, 0x00, 100);
2768  memset(src_str, 0x00, 100);
2769  memset(dst_str, 0x00, 100);
2770  memset(output, 0x00, 100);
2771 
2772  key_len = unhexify( key_str, "00000000000000000000000000000000" );
2773  unhexify( iv_str, "00000000000000000000000000000000" );
2774  data_len = unhexify( src_str, "ffffffffffffffffffffffc000000000" );
2775 
2776  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2777  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2778  if( 0 == 0 )
2779  {
2780  hexify( dst_str, output, data_len );
2781 
2782  fct_chk( strcmp( (char *) dst_str, "90684a2ac55fe1ec2b8ebd5622520b73" ) == 0 );
2783  }
2784  }
2785  FCT_TEST_END();
2786 
2787 
2788  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_11)
2789  {
2790  unsigned char key_str[100];
2791  unsigned char iv_str[100];
2792  unsigned char src_str[100];
2793  unsigned char dst_str[100];
2794  unsigned char output[100];
2795  aes_context ctx;
2796  int key_len, data_len;
2797 
2798  memset(key_str, 0x00, 100);
2799  memset(iv_str, 0x00, 100);
2800  memset(src_str, 0x00, 100);
2801  memset(dst_str, 0x00, 100);
2802  memset(output, 0x00, 100);
2803 
2804  key_len = unhexify( key_str, "00000000000000000000000000000000" );
2805  unhexify( iv_str, "00000000000000000000000000000000" );
2806  data_len = unhexify( src_str, "ffffffffffffffffffffffe000000000" );
2807 
2808  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2809  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2810  if( 0 == 0 )
2811  {
2812  hexify( dst_str, output, data_len );
2813 
2814  fct_chk( strcmp( (char *) dst_str, "7472f9a7988607ca79707795991035e6" ) == 0 );
2815  }
2816  }
2817  FCT_TEST_END();
2818 
2819 
2820  FCT_TEST_BGN(aes_128_cbc_encrypt_nist_kat_12)
2821  {
2822  unsigned char key_str[100];
2823  unsigned char iv_str[100];
2824  unsigned char src_str[100];
2825  unsigned char dst_str[100];
2826  unsigned char output[100];
2827  aes_context ctx;
2828  int key_len, data_len;
2829 
2830  memset(key_str, 0x00, 100);
2831  memset(iv_str, 0x00, 100);
2832  memset(src_str, 0x00, 100);
2833  memset(dst_str, 0x00, 100);
2834  memset(output, 0x00, 100);
2835 
2836  key_len = unhexify( key_str, "00000000000000000000000000000000" );
2837  unhexify( iv_str, "00000000000000000000000000000000" );
2838  data_len = unhexify( src_str, "fffffffffffffffffffffff000000000" );
2839 
2840  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2841  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
2842  if( 0 == 0 )
2843  {
2844  hexify( dst_str, output, data_len );
2845 
2846  fct_chk( strcmp( (char *) dst_str, "56aff089878bf3352f8df172a3ae47d8" ) == 0 );
2847  }
2848  }
2849  FCT_TEST_END();
2850 
2851 
2852  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_1)
2853  {
2854  unsigned char key_str[100];
2855  unsigned char iv_str[100];
2856  unsigned char src_str[100];
2857  unsigned char dst_str[100];
2858  unsigned char output[100];
2859  aes_context ctx;
2860  int key_len, data_len;
2861 
2862  memset(key_str, 0x00, 100);
2863  memset(iv_str, 0x00, 100);
2864  memset(src_str, 0x00, 100);
2865  memset(dst_str, 0x00, 100);
2866  memset(output, 0x00, 100);
2867 
2868  key_len = unhexify( key_str, "ffffffffe00000000000000000000000" );
2869  unhexify( iv_str, "00000000000000000000000000000000" );
2870  data_len = unhexify( src_str, "23f710842b9bb9c32f26648c786807ca" );
2871 
2872  aes_setkey_dec( &ctx, key_str, key_len * 8 );
2873  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
2874  if( 0 == 0)
2875  {
2876  hexify( dst_str, output, data_len );
2877 
2878  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2879  }
2880  }
2881  FCT_TEST_END();
2882 
2883 
2884  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_2)
2885  {
2886  unsigned char key_str[100];
2887  unsigned char iv_str[100];
2888  unsigned char src_str[100];
2889  unsigned char dst_str[100];
2890  unsigned char output[100];
2891  aes_context ctx;
2892  int key_len, data_len;
2893 
2894  memset(key_str, 0x00, 100);
2895  memset(iv_str, 0x00, 100);
2896  memset(src_str, 0x00, 100);
2897  memset(dst_str, 0x00, 100);
2898  memset(output, 0x00, 100);
2899 
2900  key_len = unhexify( key_str, "fffffffff00000000000000000000000" );
2901  unhexify( iv_str, "00000000000000000000000000000000" );
2902  data_len = unhexify( src_str, "44a98bf11e163f632c47ec6a49683a89" );
2903 
2904  aes_setkey_dec( &ctx, key_str, key_len * 8 );
2905  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
2906  if( 0 == 0)
2907  {
2908  hexify( dst_str, output, data_len );
2909 
2910  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2911  }
2912  }
2913  FCT_TEST_END();
2914 
2915 
2916  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_3)
2917  {
2918  unsigned char key_str[100];
2919  unsigned char iv_str[100];
2920  unsigned char src_str[100];
2921  unsigned char dst_str[100];
2922  unsigned char output[100];
2923  aes_context ctx;
2924  int key_len, data_len;
2925 
2926  memset(key_str, 0x00, 100);
2927  memset(iv_str, 0x00, 100);
2928  memset(src_str, 0x00, 100);
2929  memset(dst_str, 0x00, 100);
2930  memset(output, 0x00, 100);
2931 
2932  key_len = unhexify( key_str, "fffffffff80000000000000000000000" );
2933  unhexify( iv_str, "00000000000000000000000000000000" );
2934  data_len = unhexify( src_str, "0f18aff94274696d9b61848bd50ac5e5" );
2935 
2936  aes_setkey_dec( &ctx, key_str, key_len * 8 );
2937  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
2938  if( 0 == 0)
2939  {
2940  hexify( dst_str, output, data_len );
2941 
2942  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2943  }
2944  }
2945  FCT_TEST_END();
2946 
2947 
2948  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_4)
2949  {
2950  unsigned char key_str[100];
2951  unsigned char iv_str[100];
2952  unsigned char src_str[100];
2953  unsigned char dst_str[100];
2954  unsigned char output[100];
2955  aes_context ctx;
2956  int key_len, data_len;
2957 
2958  memset(key_str, 0x00, 100);
2959  memset(iv_str, 0x00, 100);
2960  memset(src_str, 0x00, 100);
2961  memset(dst_str, 0x00, 100);
2962  memset(output, 0x00, 100);
2963 
2964  key_len = unhexify( key_str, "e234cdca2606b81f29408d5f6da21206" );
2965  unhexify( iv_str, "00000000000000000000000000000000" );
2966  data_len = unhexify( src_str, "fff60a4740086b3b9c56195b98d91a7b" );
2967 
2968  aes_setkey_dec( &ctx, key_str, key_len * 8 );
2969  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
2970  if( 0 == 0)
2971  {
2972  hexify( dst_str, output, data_len );
2973 
2974  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2975  }
2976  }
2977  FCT_TEST_END();
2978 
2979 
2980  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_5)
2981  {
2982  unsigned char key_str[100];
2983  unsigned char iv_str[100];
2984  unsigned char src_str[100];
2985  unsigned char dst_str[100];
2986  unsigned char output[100];
2987  aes_context ctx;
2988  int key_len, data_len;
2989 
2990  memset(key_str, 0x00, 100);
2991  memset(iv_str, 0x00, 100);
2992  memset(src_str, 0x00, 100);
2993  memset(dst_str, 0x00, 100);
2994  memset(output, 0x00, 100);
2995 
2996  key_len = unhexify( key_str, "13237c49074a3da078dc1d828bb78c6f" );
2997  unhexify( iv_str, "00000000000000000000000000000000" );
2998  data_len = unhexify( src_str, "8146a08e2357f0caa30ca8c94d1a0544" );
2999 
3000  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3001  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3002  if( 0 == 0)
3003  {
3004  hexify( dst_str, output, data_len );
3005 
3006  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3007  }
3008  }
3009  FCT_TEST_END();
3010 
3011 
3012  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_6)
3013  {
3014  unsigned char key_str[100];
3015  unsigned char iv_str[100];
3016  unsigned char src_str[100];
3017  unsigned char dst_str[100];
3018  unsigned char output[100];
3019  aes_context ctx;
3020  int key_len, data_len;
3021 
3022  memset(key_str, 0x00, 100);
3023  memset(iv_str, 0x00, 100);
3024  memset(src_str, 0x00, 100);
3025  memset(dst_str, 0x00, 100);
3026  memset(output, 0x00, 100);
3027 
3028  key_len = unhexify( key_str, "3071a2a48fe6cbd04f1a129098e308f8" );
3029  unhexify( iv_str, "00000000000000000000000000000000" );
3030  data_len = unhexify( src_str, "4b98e06d356deb07ebb824e5713f7be3" );
3031 
3032  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3033  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3034  if( 0 == 0)
3035  {
3036  hexify( dst_str, output, data_len );
3037 
3038  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3039  }
3040  }
3041  FCT_TEST_END();
3042 
3043 
3044  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_7)
3045  {
3046  unsigned char key_str[100];
3047  unsigned char iv_str[100];
3048  unsigned char src_str[100];
3049  unsigned char dst_str[100];
3050  unsigned char output[100];
3051  aes_context ctx;
3052  int key_len, data_len;
3053 
3054  memset(key_str, 0x00, 100);
3055  memset(iv_str, 0x00, 100);
3056  memset(src_str, 0x00, 100);
3057  memset(dst_str, 0x00, 100);
3058  memset(output, 0x00, 100);
3059 
3060  key_len = unhexify( key_str, "00000000000000000000000000000000" );
3061  unhexify( iv_str, "00000000000000000000000000000000" );
3062  data_len = unhexify( src_str, "0336763e966d92595a567cc9ce537f5e" );
3063 
3064  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3065  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3066  if( 0 == 0)
3067  {
3068  hexify( dst_str, output, data_len );
3069 
3070  fct_chk( strcmp( (char *) dst_str, "f34481ec3cc627bacd5dc3fb08f273e6" ) == 0 );
3071  }
3072  }
3073  FCT_TEST_END();
3074 
3075 
3076  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_8)
3077  {
3078  unsigned char key_str[100];
3079  unsigned char iv_str[100];
3080  unsigned char src_str[100];
3081  unsigned char dst_str[100];
3082  unsigned char output[100];
3083  aes_context ctx;
3084  int key_len, data_len;
3085 
3086  memset(key_str, 0x00, 100);
3087  memset(iv_str, 0x00, 100);
3088  memset(src_str, 0x00, 100);
3089  memset(dst_str, 0x00, 100);
3090  memset(output, 0x00, 100);
3091 
3092  key_len = unhexify( key_str, "00000000000000000000000000000000" );
3093  unhexify( iv_str, "00000000000000000000000000000000" );
3094  data_len = unhexify( src_str, "a9a1631bf4996954ebc093957b234589" );
3095 
3096  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3097  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3098  if( 0 == 0)
3099  {
3100  hexify( dst_str, output, data_len );
3101 
3102  fct_chk( strcmp( (char *) dst_str, "9798c4640bad75c7c3227db910174e72" ) == 0 );
3103  }
3104  }
3105  FCT_TEST_END();
3106 
3107 
3108  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_9)
3109  {
3110  unsigned char key_str[100];
3111  unsigned char iv_str[100];
3112  unsigned char src_str[100];
3113  unsigned char dst_str[100];
3114  unsigned char output[100];
3115  aes_context ctx;
3116  int key_len, data_len;
3117 
3118  memset(key_str, 0x00, 100);
3119  memset(iv_str, 0x00, 100);
3120  memset(src_str, 0x00, 100);
3121  memset(dst_str, 0x00, 100);
3122  memset(output, 0x00, 100);
3123 
3124  key_len = unhexify( key_str, "00000000000000000000000000000000" );
3125  unhexify( iv_str, "00000000000000000000000000000000" );
3126  data_len = unhexify( src_str, "ff4f8391a6a40ca5b25d23bedd44a597" );
3127 
3128  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3129  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3130  if( 0 == 0)
3131  {
3132  hexify( dst_str, output, data_len );
3133 
3134  fct_chk( strcmp( (char *) dst_str, "96ab5c2ff612d9dfaae8c31f30c42168" ) == 0 );
3135  }
3136  }
3137  FCT_TEST_END();
3138 
3139 
3140  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_10)
3141  {
3142  unsigned char key_str[100];
3143  unsigned char iv_str[100];
3144  unsigned char src_str[100];
3145  unsigned char dst_str[100];
3146  unsigned char output[100];
3147  aes_context ctx;
3148  int key_len, data_len;
3149 
3150  memset(key_str, 0x00, 100);
3151  memset(iv_str, 0x00, 100);
3152  memset(src_str, 0x00, 100);
3153  memset(dst_str, 0x00, 100);
3154  memset(output, 0x00, 100);
3155 
3156  key_len = unhexify( key_str, "00000000000000000000000000000000" );
3157  unhexify( iv_str, "00000000000000000000000000000000" );
3158  data_len = unhexify( src_str, "f9b0fda0c4a898f5b9e6f661c4ce4d07" );
3159 
3160  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3161  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3162  if( 0 == 0)
3163  {
3164  hexify( dst_str, output, data_len );
3165 
3166  fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffffffffffffff0" ) == 0 );
3167  }
3168  }
3169  FCT_TEST_END();
3170 
3171 
3172  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_11)
3173  {
3174  unsigned char key_str[100];
3175  unsigned char iv_str[100];
3176  unsigned char src_str[100];
3177  unsigned char dst_str[100];
3178  unsigned char output[100];
3179  aes_context ctx;
3180  int key_len, data_len;
3181 
3182  memset(key_str, 0x00, 100);
3183  memset(iv_str, 0x00, 100);
3184  memset(src_str, 0x00, 100);
3185  memset(dst_str, 0x00, 100);
3186  memset(output, 0x00, 100);
3187 
3188  key_len = unhexify( key_str, "00000000000000000000000000000000" );
3189  unhexify( iv_str, "00000000000000000000000000000000" );
3190  data_len = unhexify( src_str, "8ade895913685c67c5269f8aae42983e" );
3191 
3192  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3193  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3194  if( 0 == 0)
3195  {
3196  hexify( dst_str, output, data_len );
3197 
3198  fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffffffffffffff8" ) == 0 );
3199  }
3200  }
3201  FCT_TEST_END();
3202 
3203 
3204  FCT_TEST_BGN(aes_128_cbc_decrypt_nist_kat_12)
3205  {
3206  unsigned char key_str[100];
3207  unsigned char iv_str[100];
3208  unsigned char src_str[100];
3209  unsigned char dst_str[100];
3210  unsigned char output[100];
3211  aes_context ctx;
3212  int key_len, data_len;
3213 
3214  memset(key_str, 0x00, 100);
3215  memset(iv_str, 0x00, 100);
3216  memset(src_str, 0x00, 100);
3217  memset(dst_str, 0x00, 100);
3218  memset(output, 0x00, 100);
3219 
3220  key_len = unhexify( key_str, "00000000000000000000000000000000" );
3221  unhexify( iv_str, "00000000000000000000000000000000" );
3222  data_len = unhexify( src_str, "39bde67d5c8ed8a8b1c37eb8fa9f5ac0" );
3223 
3224  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3225  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3226  if( 0 == 0)
3227  {
3228  hexify( dst_str, output, data_len );
3229 
3230  fct_chk( strcmp( (char *) dst_str, "fffffffffffffffffffffffffffffffc" ) == 0 );
3231  }
3232  }
3233  FCT_TEST_END();
3234 
3235 
3236  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_1)
3237  {
3238  unsigned char key_str[100];
3239  unsigned char iv_str[100];
3240  unsigned char src_str[100];
3241  unsigned char dst_str[100];
3242  unsigned char output[100];
3243  aes_context ctx;
3244  int key_len, data_len;
3245 
3246  memset(key_str, 0x00, 100);
3247  memset(iv_str, 0x00, 100);
3248  memset(src_str, 0x00, 100);
3249  memset(dst_str, 0x00, 100);
3250  memset(output, 0x00, 100);
3251 
3252  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffe00" );
3253  unhexify( iv_str, "00000000000000000000000000000000" );
3254  data_len = unhexify( src_str, "00000000000000000000000000000000" );
3255 
3256  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3257  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3258  if( 0 == 0 )
3259  {
3260  hexify( dst_str, output, data_len );
3261 
3262  fct_chk( strcmp( (char *) dst_str, "ddb505e6cc1384cbaec1df90b80beb20" ) == 0 );
3263  }
3264  }
3265  FCT_TEST_END();
3266 
3267 
3268  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_2)
3269  {
3270  unsigned char key_str[100];
3271  unsigned char iv_str[100];
3272  unsigned char src_str[100];
3273  unsigned char dst_str[100];
3274  unsigned char output[100];
3275  aes_context ctx;
3276  int key_len, data_len;
3277 
3278  memset(key_str, 0x00, 100);
3279  memset(iv_str, 0x00, 100);
3280  memset(src_str, 0x00, 100);
3281  memset(dst_str, 0x00, 100);
3282  memset(output, 0x00, 100);
3283 
3284  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffffff00" );
3285  unhexify( iv_str, "00000000000000000000000000000000" );
3286  data_len = unhexify( src_str, "00000000000000000000000000000000" );
3287 
3288  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3289  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3290  if( 0 == 0 )
3291  {
3292  hexify( dst_str, output, data_len );
3293 
3294  fct_chk( strcmp( (char *) dst_str, "5674a3bed27bf4bd3622f9f5fe208306" ) == 0 );
3295  }
3296  }
3297  FCT_TEST_END();
3298 
3299 
3300  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_3)
3301  {
3302  unsigned char key_str[100];
3303  unsigned char iv_str[100];
3304  unsigned char src_str[100];
3305  unsigned char dst_str[100];
3306  unsigned char output[100];
3307  aes_context ctx;
3308  int key_len, data_len;
3309 
3310  memset(key_str, 0x00, 100);
3311  memset(iv_str, 0x00, 100);
3312  memset(src_str, 0x00, 100);
3313  memset(dst_str, 0x00, 100);
3314  memset(output, 0x00, 100);
3315 
3316  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffffff80" );
3317  unhexify( iv_str, "00000000000000000000000000000000" );
3318  data_len = unhexify( src_str, "00000000000000000000000000000000" );
3319 
3320  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3321  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3322  if( 0 == 0 )
3323  {
3324  hexify( dst_str, output, data_len );
3325 
3326  fct_chk( strcmp( (char *) dst_str, "b687f26a89cfbfbb8e5eeac54055315e" ) == 0 );
3327  }
3328  }
3329  FCT_TEST_END();
3330 
3331 
3332  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_4)
3333  {
3334  unsigned char key_str[100];
3335  unsigned char iv_str[100];
3336  unsigned char src_str[100];
3337  unsigned char dst_str[100];
3338  unsigned char output[100];
3339  aes_context ctx;
3340  int key_len, data_len;
3341 
3342  memset(key_str, 0x00, 100);
3343  memset(iv_str, 0x00, 100);
3344  memset(src_str, 0x00, 100);
3345  memset(dst_str, 0x00, 100);
3346  memset(output, 0x00, 100);
3347 
3348  key_len = unhexify( key_str, "25a39dbfd8034f71a81f9ceb55026e4037f8f6aa30ab44ce" );
3349  unhexify( iv_str, "00000000000000000000000000000000" );
3350  data_len = unhexify( src_str, "00000000000000000000000000000000" );
3351 
3352  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3353  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3354  if( 0 == 0 )
3355  {
3356  hexify( dst_str, output, data_len );
3357 
3358  fct_chk( strcmp( (char *) dst_str, "3608c344868e94555d23a120f8a5502d" ) == 0 );
3359  }
3360  }
3361  FCT_TEST_END();
3362 
3363 
3364  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_5)
3365  {
3366  unsigned char key_str[100];
3367  unsigned char iv_str[100];
3368  unsigned char src_str[100];
3369  unsigned char dst_str[100];
3370  unsigned char output[100];
3371  aes_context ctx;
3372  int key_len, data_len;
3373 
3374  memset(key_str, 0x00, 100);
3375  memset(iv_str, 0x00, 100);
3376  memset(src_str, 0x00, 100);
3377  memset(dst_str, 0x00, 100);
3378  memset(output, 0x00, 100);
3379 
3380  key_len = unhexify( key_str, "e08c15411774ec4a908b64eadc6ac4199c7cd453f3aaef53" );
3381  unhexify( iv_str, "00000000000000000000000000000000" );
3382  data_len = unhexify( src_str, "00000000000000000000000000000000" );
3383 
3384  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3385  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3386  if( 0 == 0 )
3387  {
3388  hexify( dst_str, output, data_len );
3389 
3390  fct_chk( strcmp( (char *) dst_str, "77da2021935b840b7f5dcc39132da9e5" ) == 0 );
3391  }
3392  }
3393  FCT_TEST_END();
3394 
3395 
3396  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_6)
3397  {
3398  unsigned char key_str[100];
3399  unsigned char iv_str[100];
3400  unsigned char src_str[100];
3401  unsigned char dst_str[100];
3402  unsigned char output[100];
3403  aes_context ctx;
3404  int key_len, data_len;
3405 
3406  memset(key_str, 0x00, 100);
3407  memset(iv_str, 0x00, 100);
3408  memset(src_str, 0x00, 100);
3409  memset(dst_str, 0x00, 100);
3410  memset(output, 0x00, 100);
3411 
3412  key_len = unhexify( key_str, "3b375a1ff7e8d44409696e6326ec9dec86138e2ae010b980" );
3413  unhexify( iv_str, "00000000000000000000000000000000" );
3414  data_len = unhexify( src_str, "00000000000000000000000000000000" );
3415 
3416  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3417  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3418  if( 0 == 0 )
3419  {
3420  hexify( dst_str, output, data_len );
3421 
3422  fct_chk( strcmp( (char *) dst_str, "3b7c24f825e3bf9873c9f14d39a0e6f4" ) == 0 );
3423  }
3424  }
3425  FCT_TEST_END();
3426 
3427 
3428  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_7)
3429  {
3430  unsigned char key_str[100];
3431  unsigned char iv_str[100];
3432  unsigned char src_str[100];
3433  unsigned char dst_str[100];
3434  unsigned char output[100];
3435  aes_context ctx;
3436  int key_len, data_len;
3437 
3438  memset(key_str, 0x00, 100);
3439  memset(iv_str, 0x00, 100);
3440  memset(src_str, 0x00, 100);
3441  memset(dst_str, 0x00, 100);
3442  memset(output, 0x00, 100);
3443 
3444  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3445  unhexify( iv_str, "00000000000000000000000000000000" );
3446  data_len = unhexify( src_str, "51719783d3185a535bd75adc65071ce1" );
3447 
3448  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3449  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3450  if( 0 == 0 )
3451  {
3452  hexify( dst_str, output, data_len );
3453 
3454  fct_chk( strcmp( (char *) dst_str, "4f354592ff7c8847d2d0870ca9481b7c" ) == 0 );
3455  }
3456  }
3457  FCT_TEST_END();
3458 
3459 
3460  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_8)
3461  {
3462  unsigned char key_str[100];
3463  unsigned char iv_str[100];
3464  unsigned char src_str[100];
3465  unsigned char dst_str[100];
3466  unsigned char output[100];
3467  aes_context ctx;
3468  int key_len, data_len;
3469 
3470  memset(key_str, 0x00, 100);
3471  memset(iv_str, 0x00, 100);
3472  memset(src_str, 0x00, 100);
3473  memset(dst_str, 0x00, 100);
3474  memset(output, 0x00, 100);
3475 
3476  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3477  unhexify( iv_str, "00000000000000000000000000000000" );
3478  data_len = unhexify( src_str, "26aa49dcfe7629a8901a69a9914e6dfd" );
3479 
3480  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3481  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3482  if( 0 == 0 )
3483  {
3484  hexify( dst_str, output, data_len );
3485 
3486  fct_chk( strcmp( (char *) dst_str, "d5e08bf9a182e857cf40b3a36ee248cc" ) == 0 );
3487  }
3488  }
3489  FCT_TEST_END();
3490 
3491 
3492  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_9)
3493  {
3494  unsigned char key_str[100];
3495  unsigned char iv_str[100];
3496  unsigned char src_str[100];
3497  unsigned char dst_str[100];
3498  unsigned char output[100];
3499  aes_context ctx;
3500  int key_len, data_len;
3501 
3502  memset(key_str, 0x00, 100);
3503  memset(iv_str, 0x00, 100);
3504  memset(src_str, 0x00, 100);
3505  memset(dst_str, 0x00, 100);
3506  memset(output, 0x00, 100);
3507 
3508  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3509  unhexify( iv_str, "00000000000000000000000000000000" );
3510  data_len = unhexify( src_str, "941a4773058224e1ef66d10e0a6ee782" );
3511 
3512  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3513  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3514  if( 0 == 0 )
3515  {
3516  hexify( dst_str, output, data_len );
3517 
3518  fct_chk( strcmp( (char *) dst_str, "067cd9d3749207791841562507fa9626" ) == 0 );
3519  }
3520  }
3521  FCT_TEST_END();
3522 
3523 
3524  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_10)
3525  {
3526  unsigned char key_str[100];
3527  unsigned char iv_str[100];
3528  unsigned char src_str[100];
3529  unsigned char dst_str[100];
3530  unsigned char output[100];
3531  aes_context ctx;
3532  int key_len, data_len;
3533 
3534  memset(key_str, 0x00, 100);
3535  memset(iv_str, 0x00, 100);
3536  memset(src_str, 0x00, 100);
3537  memset(dst_str, 0x00, 100);
3538  memset(output, 0x00, 100);
3539 
3540  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3541  unhexify( iv_str, "00000000000000000000000000000000" );
3542  data_len = unhexify( src_str, "ffc00000000000000000000000000000" );
3543 
3544  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3545  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3546  if( 0 == 0 )
3547  {
3548  hexify( dst_str, output, data_len );
3549 
3550  fct_chk( strcmp( (char *) dst_str, "030d7e5b64f380a7e4ea5387b5cd7f49" ) == 0 );
3551  }
3552  }
3553  FCT_TEST_END();
3554 
3555 
3556  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_11)
3557  {
3558  unsigned char key_str[100];
3559  unsigned char iv_str[100];
3560  unsigned char src_str[100];
3561  unsigned char dst_str[100];
3562  unsigned char output[100];
3563  aes_context ctx;
3564  int key_len, data_len;
3565 
3566  memset(key_str, 0x00, 100);
3567  memset(iv_str, 0x00, 100);
3568  memset(src_str, 0x00, 100);
3569  memset(dst_str, 0x00, 100);
3570  memset(output, 0x00, 100);
3571 
3572  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3573  unhexify( iv_str, "00000000000000000000000000000000" );
3574  data_len = unhexify( src_str, "ffe00000000000000000000000000000" );
3575 
3576  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3577  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3578  if( 0 == 0 )
3579  {
3580  hexify( dst_str, output, data_len );
3581 
3582  fct_chk( strcmp( (char *) dst_str, "0dc9a2610037009b698f11bb7e86c83e" ) == 0 );
3583  }
3584  }
3585  FCT_TEST_END();
3586 
3587 
3588  FCT_TEST_BGN(aes_192_cbc_encrypt_nist_kat_12)
3589  {
3590  unsigned char key_str[100];
3591  unsigned char iv_str[100];
3592  unsigned char src_str[100];
3593  unsigned char dst_str[100];
3594  unsigned char output[100];
3595  aes_context ctx;
3596  int key_len, data_len;
3597 
3598  memset(key_str, 0x00, 100);
3599  memset(iv_str, 0x00, 100);
3600  memset(src_str, 0x00, 100);
3601  memset(dst_str, 0x00, 100);
3602  memset(output, 0x00, 100);
3603 
3604  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3605  unhexify( iv_str, "00000000000000000000000000000000" );
3606  data_len = unhexify( src_str, "fff00000000000000000000000000000" );
3607 
3608  aes_setkey_enc( &ctx, key_str, key_len * 8 );
3609  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
3610  if( 0 == 0 )
3611  {
3612  hexify( dst_str, output, data_len );
3613 
3614  fct_chk( strcmp( (char *) dst_str, "0046612c766d1840c226364f1fa7ed72" ) == 0 );
3615  }
3616  }
3617  FCT_TEST_END();
3618 
3619 
3620  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_1)
3621  {
3622  unsigned char key_str[100];
3623  unsigned char iv_str[100];
3624  unsigned char src_str[100];
3625  unsigned char dst_str[100];
3626  unsigned char output[100];
3627  aes_context ctx;
3628  int key_len, data_len;
3629 
3630  memset(key_str, 0x00, 100);
3631  memset(iv_str, 0x00, 100);
3632  memset(src_str, 0x00, 100);
3633  memset(dst_str, 0x00, 100);
3634  memset(output, 0x00, 100);
3635 
3636  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3637  unhexify( iv_str, "00000000000000000000000000000000" );
3638  data_len = unhexify( src_str, "902d88d13eae52089abd6143cfe394e9" );
3639 
3640  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3641  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3642  if( 0 == 0)
3643  {
3644  hexify( dst_str, output, data_len );
3645 
3646  fct_chk( strcmp( (char *) dst_str, "ffffffffe00000000000000000000000" ) == 0 );
3647  }
3648  }
3649  FCT_TEST_END();
3650 
3651 
3652  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_2)
3653  {
3654  unsigned char key_str[100];
3655  unsigned char iv_str[100];
3656  unsigned char src_str[100];
3657  unsigned char dst_str[100];
3658  unsigned char output[100];
3659  aes_context ctx;
3660  int key_len, data_len;
3661 
3662  memset(key_str, 0x00, 100);
3663  memset(iv_str, 0x00, 100);
3664  memset(src_str, 0x00, 100);
3665  memset(dst_str, 0x00, 100);
3666  memset(output, 0x00, 100);
3667 
3668  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3669  unhexify( iv_str, "00000000000000000000000000000000" );
3670  data_len = unhexify( src_str, "d49bceb3b823fedd602c305345734bd2" );
3671 
3672  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3673  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3674  if( 0 == 0)
3675  {
3676  hexify( dst_str, output, data_len );
3677 
3678  fct_chk( strcmp( (char *) dst_str, "fffffffff00000000000000000000000" ) == 0 );
3679  }
3680  }
3681  FCT_TEST_END();
3682 
3683 
3684  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_3)
3685  {
3686  unsigned char key_str[100];
3687  unsigned char iv_str[100];
3688  unsigned char src_str[100];
3689  unsigned char dst_str[100];
3690  unsigned char output[100];
3691  aes_context ctx;
3692  int key_len, data_len;
3693 
3694  memset(key_str, 0x00, 100);
3695  memset(iv_str, 0x00, 100);
3696  memset(src_str, 0x00, 100);
3697  memset(dst_str, 0x00, 100);
3698  memset(output, 0x00, 100);
3699 
3700  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3701  unhexify( iv_str, "00000000000000000000000000000000" );
3702  data_len = unhexify( src_str, "707b1dbb0ffa40ef7d95def421233fae" );
3703 
3704  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3705  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3706  if( 0 == 0)
3707  {
3708  hexify( dst_str, output, data_len );
3709 
3710  fct_chk( strcmp( (char *) dst_str, "fffffffff80000000000000000000000" ) == 0 );
3711  }
3712  }
3713  FCT_TEST_END();
3714 
3715 
3716  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_4)
3717  {
3718  unsigned char key_str[100];
3719  unsigned char iv_str[100];
3720  unsigned char src_str[100];
3721  unsigned char dst_str[100];
3722  unsigned char output[100];
3723  aes_context ctx;
3724  int key_len, data_len;
3725 
3726  memset(key_str, 0x00, 100);
3727  memset(iv_str, 0x00, 100);
3728  memset(src_str, 0x00, 100);
3729  memset(dst_str, 0x00, 100);
3730  memset(output, 0x00, 100);
3731 
3732  key_len = unhexify( key_str, "fffffffffffffffffffc0000000000000000000000000000" );
3733  unhexify( iv_str, "00000000000000000000000000000000" );
3734  data_len = unhexify( src_str, "8dfd999be5d0cfa35732c0ddc88ff5a5" );
3735 
3736  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3737  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3738  if( 0 == 0)
3739  {
3740  hexify( dst_str, output, data_len );
3741 
3742  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3743  }
3744  }
3745  FCT_TEST_END();
3746 
3747 
3748  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_5)
3749  {
3750  unsigned char key_str[100];
3751  unsigned char iv_str[100];
3752  unsigned char src_str[100];
3753  unsigned char dst_str[100];
3754  unsigned char output[100];
3755  aes_context ctx;
3756  int key_len, data_len;
3757 
3758  memset(key_str, 0x00, 100);
3759  memset(iv_str, 0x00, 100);
3760  memset(src_str, 0x00, 100);
3761  memset(dst_str, 0x00, 100);
3762  memset(output, 0x00, 100);
3763 
3764  key_len = unhexify( key_str, "fffffffffffffffffffe0000000000000000000000000000" );
3765  unhexify( iv_str, "00000000000000000000000000000000" );
3766  data_len = unhexify( src_str, "02647c76a300c3173b841487eb2bae9f" );
3767 
3768  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3769  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3770  if( 0 == 0)
3771  {
3772  hexify( dst_str, output, data_len );
3773 
3774  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3775  }
3776  }
3777  FCT_TEST_END();
3778 
3779 
3780  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_6)
3781  {
3782  unsigned char key_str[100];
3783  unsigned char iv_str[100];
3784  unsigned char src_str[100];
3785  unsigned char dst_str[100];
3786  unsigned char output[100];
3787  aes_context ctx;
3788  int key_len, data_len;
3789 
3790  memset(key_str, 0x00, 100);
3791  memset(iv_str, 0x00, 100);
3792  memset(src_str, 0x00, 100);
3793  memset(dst_str, 0x00, 100);
3794  memset(output, 0x00, 100);
3795 
3796  key_len = unhexify( key_str, "ffffffffffffffffffff0000000000000000000000000000" );
3797  unhexify( iv_str, "00000000000000000000000000000000" );
3798  data_len = unhexify( src_str, "172df8b02f04b53adab028b4e01acd87" );
3799 
3800  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3801  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3802  if( 0 == 0)
3803  {
3804  hexify( dst_str, output, data_len );
3805 
3806  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3807  }
3808  }
3809  FCT_TEST_END();
3810 
3811 
3812  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_7)
3813  {
3814  unsigned char key_str[100];
3815  unsigned char iv_str[100];
3816  unsigned char src_str[100];
3817  unsigned char dst_str[100];
3818  unsigned char output[100];
3819  aes_context ctx;
3820  int key_len, data_len;
3821 
3822  memset(key_str, 0x00, 100);
3823  memset(iv_str, 0x00, 100);
3824  memset(src_str, 0x00, 100);
3825  memset(dst_str, 0x00, 100);
3826  memset(output, 0x00, 100);
3827 
3828  key_len = unhexify( key_str, "b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35" );
3829  unhexify( iv_str, "00000000000000000000000000000000" );
3830  data_len = unhexify( src_str, "3cf5e1d21a17956d1dffad6a7c41c659" );
3831 
3832  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3833  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3834  if( 0 == 0)
3835  {
3836  hexify( dst_str, output, data_len );
3837 
3838  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3839  }
3840  }
3841  FCT_TEST_END();
3842 
3843 
3844  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_8)
3845  {
3846  unsigned char key_str[100];
3847  unsigned char iv_str[100];
3848  unsigned char src_str[100];
3849  unsigned char dst_str[100];
3850  unsigned char output[100];
3851  aes_context ctx;
3852  int key_len, data_len;
3853 
3854  memset(key_str, 0x00, 100);
3855  memset(iv_str, 0x00, 100);
3856  memset(src_str, 0x00, 100);
3857  memset(dst_str, 0x00, 100);
3858  memset(output, 0x00, 100);
3859 
3860  key_len = unhexify( key_str, "45899367c3132849763073c435a9288a766c8b9ec2308516" );
3861  unhexify( iv_str, "00000000000000000000000000000000" );
3862  data_len = unhexify( src_str, "69fd12e8505f8ded2fdcb197a121b362" );
3863 
3864  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3865  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3866  if( 0 == 0)
3867  {
3868  hexify( dst_str, output, data_len );
3869 
3870  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3871  }
3872  }
3873  FCT_TEST_END();
3874 
3875 
3876  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_9)
3877  {
3878  unsigned char key_str[100];
3879  unsigned char iv_str[100];
3880  unsigned char src_str[100];
3881  unsigned char dst_str[100];
3882  unsigned char output[100];
3883  aes_context ctx;
3884  int key_len, data_len;
3885 
3886  memset(key_str, 0x00, 100);
3887  memset(iv_str, 0x00, 100);
3888  memset(src_str, 0x00, 100);
3889  memset(dst_str, 0x00, 100);
3890  memset(output, 0x00, 100);
3891 
3892  key_len = unhexify( key_str, "ec250e04c3903f602647b85a401a1ae7ca2f02f67fa4253e" );
3893  unhexify( iv_str, "00000000000000000000000000000000" );
3894  data_len = unhexify( src_str, "8aa584e2cc4d17417a97cb9a28ba29c8" );
3895 
3896  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3897  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3898  if( 0 == 0)
3899  {
3900  hexify( dst_str, output, data_len );
3901 
3902  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
3903  }
3904  }
3905  FCT_TEST_END();
3906 
3907 
3908  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_10)
3909  {
3910  unsigned char key_str[100];
3911  unsigned char iv_str[100];
3912  unsigned char src_str[100];
3913  unsigned char dst_str[100];
3914  unsigned char output[100];
3915  aes_context ctx;
3916  int key_len, data_len;
3917 
3918  memset(key_str, 0x00, 100);
3919  memset(iv_str, 0x00, 100);
3920  memset(src_str, 0x00, 100);
3921  memset(dst_str, 0x00, 100);
3922  memset(output, 0x00, 100);
3923 
3924  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3925  unhexify( iv_str, "00000000000000000000000000000000" );
3926  data_len = unhexify( src_str, "c9b8135ff1b5adc413dfd053b21bd96d" );
3927 
3928  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3929  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3930  if( 0 == 0)
3931  {
3932  hexify( dst_str, output, data_len );
3933 
3934  fct_chk( strcmp( (char *) dst_str, "9c2d8842e5f48f57648205d39a239af1" ) == 0 );
3935  }
3936  }
3937  FCT_TEST_END();
3938 
3939 
3940  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_11)
3941  {
3942  unsigned char key_str[100];
3943  unsigned char iv_str[100];
3944  unsigned char src_str[100];
3945  unsigned char dst_str[100];
3946  unsigned char output[100];
3947  aes_context ctx;
3948  int key_len, data_len;
3949 
3950  memset(key_str, 0x00, 100);
3951  memset(iv_str, 0x00, 100);
3952  memset(src_str, 0x00, 100);
3953  memset(dst_str, 0x00, 100);
3954  memset(output, 0x00, 100);
3955 
3956  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3957  unhexify( iv_str, "00000000000000000000000000000000" );
3958  data_len = unhexify( src_str, "4a3650c3371ce2eb35e389a171427440" );
3959 
3960  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3961  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3962  if( 0 == 0)
3963  {
3964  hexify( dst_str, output, data_len );
3965 
3966  fct_chk( strcmp( (char *) dst_str, "bff52510095f518ecca60af4205444bb" ) == 0 );
3967  }
3968  }
3969  FCT_TEST_END();
3970 
3971 
3972  FCT_TEST_BGN(aes_192_cbc_decrypt_nist_kat_12)
3973  {
3974  unsigned char key_str[100];
3975  unsigned char iv_str[100];
3976  unsigned char src_str[100];
3977  unsigned char dst_str[100];
3978  unsigned char output[100];
3979  aes_context ctx;
3980  int key_len, data_len;
3981 
3982  memset(key_str, 0x00, 100);
3983  memset(iv_str, 0x00, 100);
3984  memset(src_str, 0x00, 100);
3985  memset(dst_str, 0x00, 100);
3986  memset(output, 0x00, 100);
3987 
3988  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
3989  unhexify( iv_str, "00000000000000000000000000000000" );
3990  data_len = unhexify( src_str, "4f354592ff7c8847d2d0870ca9481b7c" );
3991 
3992  aes_setkey_dec( &ctx, key_str, key_len * 8 );
3993  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
3994  if( 0 == 0)
3995  {
3996  hexify( dst_str, output, data_len );
3997 
3998  fct_chk( strcmp( (char *) dst_str, "51719783d3185a535bd75adc65071ce1" ) == 0 );
3999  }
4000  }
4001  FCT_TEST_END();
4002 
4003 
4004  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_1)
4005  {
4006  unsigned char key_str[100];
4007  unsigned char iv_str[100];
4008  unsigned char src_str[100];
4009  unsigned char dst_str[100];
4010  unsigned char output[100];
4011  aes_context ctx;
4012  int key_len, data_len;
4013 
4014  memset(key_str, 0x00, 100);
4015  memset(iv_str, 0x00, 100);
4016  memset(src_str, 0x00, 100);
4017  memset(dst_str, 0x00, 100);
4018  memset(output, 0x00, 100);
4019 
4020  key_len = unhexify( key_str, "8000000000000000000000000000000000000000000000000000000000000000" );
4021  unhexify( iv_str, "00000000000000000000000000000000" );
4022  data_len = unhexify( src_str, "00000000000000000000000000000000" );
4023 
4024  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4025  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4026  if( 0 == 0 )
4027  {
4028  hexify( dst_str, output, data_len );
4029 
4030  fct_chk( strcmp( (char *) dst_str, "e35a6dcb19b201a01ebcfa8aa22b5759" ) == 0 );
4031  }
4032  }
4033  FCT_TEST_END();
4034 
4035 
4036  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_2)
4037  {
4038  unsigned char key_str[100];
4039  unsigned char iv_str[100];
4040  unsigned char src_str[100];
4041  unsigned char dst_str[100];
4042  unsigned char output[100];
4043  aes_context ctx;
4044  int key_len, data_len;
4045 
4046  memset(key_str, 0x00, 100);
4047  memset(iv_str, 0x00, 100);
4048  memset(src_str, 0x00, 100);
4049  memset(dst_str, 0x00, 100);
4050  memset(output, 0x00, 100);
4051 
4052  key_len = unhexify( key_str, "c000000000000000000000000000000000000000000000000000000000000000" );
4053  unhexify( iv_str, "00000000000000000000000000000000" );
4054  data_len = unhexify( src_str, "00000000000000000000000000000000" );
4055 
4056  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4057  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4058  if( 0 == 0 )
4059  {
4060  hexify( dst_str, output, data_len );
4061 
4062  fct_chk( strcmp( (char *) dst_str, "b29169cdcf2d83e838125a12ee6aa400" ) == 0 );
4063  }
4064  }
4065  FCT_TEST_END();
4066 
4067 
4068  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_3)
4069  {
4070  unsigned char key_str[100];
4071  unsigned char iv_str[100];
4072  unsigned char src_str[100];
4073  unsigned char dst_str[100];
4074  unsigned char output[100];
4075  aes_context ctx;
4076  int key_len, data_len;
4077 
4078  memset(key_str, 0x00, 100);
4079  memset(iv_str, 0x00, 100);
4080  memset(src_str, 0x00, 100);
4081  memset(dst_str, 0x00, 100);
4082  memset(output, 0x00, 100);
4083 
4084  key_len = unhexify( key_str, "e000000000000000000000000000000000000000000000000000000000000000" );
4085  unhexify( iv_str, "00000000000000000000000000000000" );
4086  data_len = unhexify( src_str, "00000000000000000000000000000000" );
4087 
4088  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4089  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4090  if( 0 == 0 )
4091  {
4092  hexify( dst_str, output, data_len );
4093 
4094  fct_chk( strcmp( (char *) dst_str, "d8f3a72fc3cdf74dfaf6c3e6b97b2fa6" ) == 0 );
4095  }
4096  }
4097  FCT_TEST_END();
4098 
4099 
4100  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_4)
4101  {
4102  unsigned char key_str[100];
4103  unsigned char iv_str[100];
4104  unsigned char src_str[100];
4105  unsigned char dst_str[100];
4106  unsigned char output[100];
4107  aes_context ctx;
4108  int key_len, data_len;
4109 
4110  memset(key_str, 0x00, 100);
4111  memset(iv_str, 0x00, 100);
4112  memset(src_str, 0x00, 100);
4113  memset(dst_str, 0x00, 100);
4114  memset(output, 0x00, 100);
4115 
4116  key_len = unhexify( key_str, "dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf" );
4117  unhexify( iv_str, "00000000000000000000000000000000" );
4118  data_len = unhexify( src_str, "00000000000000000000000000000000" );
4119 
4120  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4121  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4122  if( 0 == 0 )
4123  {
4124  hexify( dst_str, output, data_len );
4125 
4126  fct_chk( strcmp( (char *) dst_str, "fc6aec906323480005c58e7e1ab004ad" ) == 0 );
4127  }
4128  }
4129  FCT_TEST_END();
4130 
4131 
4132  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_5)
4133  {
4134  unsigned char key_str[100];
4135  unsigned char iv_str[100];
4136  unsigned char src_str[100];
4137  unsigned char dst_str[100];
4138  unsigned char output[100];
4139  aes_context ctx;
4140  int key_len, data_len;
4141 
4142  memset(key_str, 0x00, 100);
4143  memset(iv_str, 0x00, 100);
4144  memset(src_str, 0x00, 100);
4145  memset(dst_str, 0x00, 100);
4146  memset(output, 0x00, 100);
4147 
4148  key_len = unhexify( key_str, "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" );
4149  unhexify( iv_str, "00000000000000000000000000000000" );
4150  data_len = unhexify( src_str, "00000000000000000000000000000000" );
4151 
4152  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4153  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4154  if( 0 == 0 )
4155  {
4156  hexify( dst_str, output, data_len );
4157 
4158  fct_chk( strcmp( (char *) dst_str, "a3944b95ca0b52043584ef02151926a8" ) == 0 );
4159  }
4160  }
4161  FCT_TEST_END();
4162 
4163 
4164  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_6)
4165  {
4166  unsigned char key_str[100];
4167  unsigned char iv_str[100];
4168  unsigned char src_str[100];
4169  unsigned char dst_str[100];
4170  unsigned char output[100];
4171  aes_context ctx;
4172  int key_len, data_len;
4173 
4174  memset(key_str, 0x00, 100);
4175  memset(iv_str, 0x00, 100);
4176  memset(src_str, 0x00, 100);
4177  memset(dst_str, 0x00, 100);
4178  memset(output, 0x00, 100);
4179 
4180  key_len = unhexify( key_str, "797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e" );
4181  unhexify( iv_str, "00000000000000000000000000000000" );
4182  data_len = unhexify( src_str, "00000000000000000000000000000000" );
4183 
4184  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4185  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4186  if( 0 == 0 )
4187  {
4188  hexify( dst_str, output, data_len );
4189 
4190  fct_chk( strcmp( (char *) dst_str, "a74289fe73a4c123ca189ea1e1b49ad5" ) == 0 );
4191  }
4192  }
4193  FCT_TEST_END();
4194 
4195 
4196  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_7)
4197  {
4198  unsigned char key_str[100];
4199  unsigned char iv_str[100];
4200  unsigned char src_str[100];
4201  unsigned char dst_str[100];
4202  unsigned char output[100];
4203  aes_context ctx;
4204  int key_len, data_len;
4205 
4206  memset(key_str, 0x00, 100);
4207  memset(iv_str, 0x00, 100);
4208  memset(src_str, 0x00, 100);
4209  memset(dst_str, 0x00, 100);
4210  memset(output, 0x00, 100);
4211 
4212  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4213  unhexify( iv_str, "00000000000000000000000000000000" );
4214  data_len = unhexify( src_str, "761c1fe41a18acf20d241650611d90f1" );
4215 
4216  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4217  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4218  if( 0 == 0 )
4219  {
4220  hexify( dst_str, output, data_len );
4221 
4222  fct_chk( strcmp( (char *) dst_str, "623a52fcea5d443e48d9181ab32c7421" ) == 0 );
4223  }
4224  }
4225  FCT_TEST_END();
4226 
4227 
4228  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_8)
4229  {
4230  unsigned char key_str[100];
4231  unsigned char iv_str[100];
4232  unsigned char src_str[100];
4233  unsigned char dst_str[100];
4234  unsigned char output[100];
4235  aes_context ctx;
4236  int key_len, data_len;
4237 
4238  memset(key_str, 0x00, 100);
4239  memset(iv_str, 0x00, 100);
4240  memset(src_str, 0x00, 100);
4241  memset(dst_str, 0x00, 100);
4242  memset(output, 0x00, 100);
4243 
4244  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4245  unhexify( iv_str, "00000000000000000000000000000000" );
4246  data_len = unhexify( src_str, "8a560769d605868ad80d819bdba03771" );
4247 
4248  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4249  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4250  if( 0 == 0 )
4251  {
4252  hexify( dst_str, output, data_len );
4253 
4254  fct_chk( strcmp( (char *) dst_str, "38f2c7ae10612415d27ca190d27da8b4" ) == 0 );
4255  }
4256  }
4257  FCT_TEST_END();
4258 
4259 
4260  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_9)
4261  {
4262  unsigned char key_str[100];
4263  unsigned char iv_str[100];
4264  unsigned char src_str[100];
4265  unsigned char dst_str[100];
4266  unsigned char output[100];
4267  aes_context ctx;
4268  int key_len, data_len;
4269 
4270  memset(key_str, 0x00, 100);
4271  memset(iv_str, 0x00, 100);
4272  memset(src_str, 0x00, 100);
4273  memset(dst_str, 0x00, 100);
4274  memset(output, 0x00, 100);
4275 
4276  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4277  unhexify( iv_str, "00000000000000000000000000000000" );
4278  data_len = unhexify( src_str, "91fbef2d15a97816060bee1feaa49afe" );
4279 
4280  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4281  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4282  if( 0 == 0 )
4283  {
4284  hexify( dst_str, output, data_len );
4285 
4286  fct_chk( strcmp( (char *) dst_str, "1bc704f1bce135ceb810341b216d7abe" ) == 0 );
4287  }
4288  }
4289  FCT_TEST_END();
4290 
4291 
4292  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_10)
4293  {
4294  unsigned char key_str[100];
4295  unsigned char iv_str[100];
4296  unsigned char src_str[100];
4297  unsigned char dst_str[100];
4298  unsigned char output[100];
4299  aes_context ctx;
4300  int key_len, data_len;
4301 
4302  memset(key_str, 0x00, 100);
4303  memset(iv_str, 0x00, 100);
4304  memset(src_str, 0x00, 100);
4305  memset(dst_str, 0x00, 100);
4306  memset(output, 0x00, 100);
4307 
4308  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4309  unhexify( iv_str, "00000000000000000000000000000000" );
4310  data_len = unhexify( src_str, "ffffffffffffff800000000000000000" );
4311 
4312  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4313  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4314  if( 0 == 0 )
4315  {
4316  hexify( dst_str, output, data_len );
4317 
4318  fct_chk( strcmp( (char *) dst_str, "0d9ac756eb297695eed4d382eb126d26" ) == 0 );
4319  }
4320  }
4321  FCT_TEST_END();
4322 
4323 
4324  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_11)
4325  {
4326  unsigned char key_str[100];
4327  unsigned char iv_str[100];
4328  unsigned char src_str[100];
4329  unsigned char dst_str[100];
4330  unsigned char output[100];
4331  aes_context ctx;
4332  int key_len, data_len;
4333 
4334  memset(key_str, 0x00, 100);
4335  memset(iv_str, 0x00, 100);
4336  memset(src_str, 0x00, 100);
4337  memset(dst_str, 0x00, 100);
4338  memset(output, 0x00, 100);
4339 
4340  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4341  unhexify( iv_str, "00000000000000000000000000000000" );
4342  data_len = unhexify( src_str, "ffffffffffffffc00000000000000000" );
4343 
4344  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4345  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4346  if( 0 == 0 )
4347  {
4348  hexify( dst_str, output, data_len );
4349 
4350  fct_chk( strcmp( (char *) dst_str, "56ede9dda3f6f141bff1757fa689c3e1" ) == 0 );
4351  }
4352  }
4353  FCT_TEST_END();
4354 
4355 
4356  FCT_TEST_BGN(aes_256_cbc_encrypt_nist_kat_12)
4357  {
4358  unsigned char key_str[100];
4359  unsigned char iv_str[100];
4360  unsigned char src_str[100];
4361  unsigned char dst_str[100];
4362  unsigned char output[100];
4363  aes_context ctx;
4364  int key_len, data_len;
4365 
4366  memset(key_str, 0x00, 100);
4367  memset(iv_str, 0x00, 100);
4368  memset(src_str, 0x00, 100);
4369  memset(dst_str, 0x00, 100);
4370  memset(output, 0x00, 100);
4371 
4372  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4373  unhexify( iv_str, "00000000000000000000000000000000" );
4374  data_len = unhexify( src_str, "ffffffffffffffe00000000000000000" );
4375 
4376  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4377  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == 0 );
4378  if( 0 == 0 )
4379  {
4380  hexify( dst_str, output, data_len );
4381 
4382  fct_chk( strcmp( (char *) dst_str, "768f520efe0f23e61d3ec8ad9ce91774" ) == 0 );
4383  }
4384  }
4385  FCT_TEST_END();
4386 
4387 
4388  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_1)
4389  {
4390  unsigned char key_str[100];
4391  unsigned char iv_str[100];
4392  unsigned char src_str[100];
4393  unsigned char dst_str[100];
4394  unsigned char output[100];
4395  aes_context ctx;
4396  int key_len, data_len;
4397 
4398  memset(key_str, 0x00, 100);
4399  memset(iv_str, 0x00, 100);
4400  memset(src_str, 0x00, 100);
4401  memset(dst_str, 0x00, 100);
4402  memset(output, 0x00, 100);
4403 
4404  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4405  unhexify( iv_str, "00000000000000000000000000000000" );
4406  data_len = unhexify( src_str, "49af6b372135acef10132e548f217b17" );
4407 
4408  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4409  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4410  if( 0 == 0)
4411  {
4412  hexify( dst_str, output, data_len );
4413 
4414  fct_chk( strcmp( (char *) dst_str, "ff000000000000000000000000000000" ) == 0 );
4415  }
4416  }
4417  FCT_TEST_END();
4418 
4419 
4420  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_2)
4421  {
4422  unsigned char key_str[100];
4423  unsigned char iv_str[100];
4424  unsigned char src_str[100];
4425  unsigned char dst_str[100];
4426  unsigned char output[100];
4427  aes_context ctx;
4428  int key_len, data_len;
4429 
4430  memset(key_str, 0x00, 100);
4431  memset(iv_str, 0x00, 100);
4432  memset(src_str, 0x00, 100);
4433  memset(dst_str, 0x00, 100);
4434  memset(output, 0x00, 100);
4435 
4436  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4437  unhexify( iv_str, "00000000000000000000000000000000" );
4438  data_len = unhexify( src_str, "8bcd40f94ebb63b9f7909676e667f1e7" );
4439 
4440  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4441  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4442  if( 0 == 0)
4443  {
4444  hexify( dst_str, output, data_len );
4445 
4446  fct_chk( strcmp( (char *) dst_str, "ff800000000000000000000000000000" ) == 0 );
4447  }
4448  }
4449  FCT_TEST_END();
4450 
4451 
4452  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_3)
4453  {
4454  unsigned char key_str[100];
4455  unsigned char iv_str[100];
4456  unsigned char src_str[100];
4457  unsigned char dst_str[100];
4458  unsigned char output[100];
4459  aes_context ctx;
4460  int key_len, data_len;
4461 
4462  memset(key_str, 0x00, 100);
4463  memset(iv_str, 0x00, 100);
4464  memset(src_str, 0x00, 100);
4465  memset(dst_str, 0x00, 100);
4466  memset(output, 0x00, 100);
4467 
4468  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4469  unhexify( iv_str, "00000000000000000000000000000000" );
4470  data_len = unhexify( src_str, "fe1cffb83f45dcfb38b29be438dbd3ab" );
4471 
4472  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4473  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4474  if( 0 == 0)
4475  {
4476  hexify( dst_str, output, data_len );
4477 
4478  fct_chk( strcmp( (char *) dst_str, "ffc00000000000000000000000000000" ) == 0 );
4479  }
4480  }
4481  FCT_TEST_END();
4482 
4483 
4484  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_4)
4485  {
4486  unsigned char key_str[100];
4487  unsigned char iv_str[100];
4488  unsigned char src_str[100];
4489  unsigned char dst_str[100];
4490  unsigned char output[100];
4491  aes_context ctx;
4492  int key_len, data_len;
4493 
4494  memset(key_str, 0x00, 100);
4495  memset(iv_str, 0x00, 100);
4496  memset(src_str, 0x00, 100);
4497  memset(dst_str, 0x00, 100);
4498  memset(output, 0x00, 100);
4499 
4500  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00" );
4501  unhexify( iv_str, "00000000000000000000000000000000" );
4502  data_len = unhexify( src_str, "cca7c3086f5f9511b31233da7cab9160" );
4503 
4504  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4505  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4506  if( 0 == 0)
4507  {
4508  hexify( dst_str, output, data_len );
4509 
4510  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
4511  }
4512  }
4513  FCT_TEST_END();
4514 
4515 
4516  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_5)
4517  {
4518  unsigned char key_str[100];
4519  unsigned char iv_str[100];
4520  unsigned char src_str[100];
4521  unsigned char dst_str[100];
4522  unsigned char output[100];
4523  aes_context ctx;
4524  int key_len, data_len;
4525 
4526  memset(key_str, 0x00, 100);
4527  memset(iv_str, 0x00, 100);
4528  memset(src_str, 0x00, 100);
4529  memset(dst_str, 0x00, 100);
4530  memset(output, 0x00, 100);
4531 
4532  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00" );
4533  unhexify( iv_str, "00000000000000000000000000000000" );
4534  data_len = unhexify( src_str, "5b40ff4ec9be536ba23035fa4f06064c" );
4535 
4536  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4537  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4538  if( 0 == 0)
4539  {
4540  hexify( dst_str, output, data_len );
4541 
4542  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
4543  }
4544  }
4545  FCT_TEST_END();
4546 
4547 
4548  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_6)
4549  {
4550  unsigned char key_str[100];
4551  unsigned char iv_str[100];
4552  unsigned char src_str[100];
4553  unsigned char dst_str[100];
4554  unsigned char output[100];
4555  aes_context ctx;
4556  int key_len, data_len;
4557 
4558  memset(key_str, 0x00, 100);
4559  memset(iv_str, 0x00, 100);
4560  memset(src_str, 0x00, 100);
4561  memset(dst_str, 0x00, 100);
4562  memset(output, 0x00, 100);
4563 
4564  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00" );
4565  unhexify( iv_str, "00000000000000000000000000000000" );
4566  data_len = unhexify( src_str, "60eb5af8416b257149372194e8b88749" );
4567 
4568  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4569  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4570  if( 0 == 0)
4571  {
4572  hexify( dst_str, output, data_len );
4573 
4574  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
4575  }
4576  }
4577  FCT_TEST_END();
4578 
4579 
4580  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_7)
4581  {
4582  unsigned char key_str[100];
4583  unsigned char iv_str[100];
4584  unsigned char src_str[100];
4585  unsigned char dst_str[100];
4586  unsigned char output[100];
4587  aes_context ctx;
4588  int key_len, data_len;
4589 
4590  memset(key_str, 0x00, 100);
4591  memset(iv_str, 0x00, 100);
4592  memset(src_str, 0x00, 100);
4593  memset(dst_str, 0x00, 100);
4594  memset(output, 0x00, 100);
4595 
4596  key_len = unhexify( key_str, "90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1" );
4597  unhexify( iv_str, "00000000000000000000000000000000" );
4598  data_len = unhexify( src_str, "798c7c005dee432b2c8ea5dfa381ecc3" );
4599 
4600  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4601  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4602  if( 0 == 0)
4603  {
4604  hexify( dst_str, output, data_len );
4605 
4606  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
4607  }
4608  }
4609  FCT_TEST_END();
4610 
4611 
4612  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_8)
4613  {
4614  unsigned char key_str[100];
4615  unsigned char iv_str[100];
4616  unsigned char src_str[100];
4617  unsigned char dst_str[100];
4618  unsigned char output[100];
4619  aes_context ctx;
4620  int key_len, data_len;
4621 
4622  memset(key_str, 0x00, 100);
4623  memset(iv_str, 0x00, 100);
4624  memset(src_str, 0x00, 100);
4625  memset(dst_str, 0x00, 100);
4626  memset(output, 0x00, 100);
4627 
4628  key_len = unhexify( key_str, "b7a5794d52737475d53d5a377200849be0260a67a2b22ced8bbef12882270d07" );
4629  unhexify( iv_str, "00000000000000000000000000000000" );
4630  data_len = unhexify( src_str, "637c31dc2591a07636f646b72daabbe7" );
4631 
4632  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4633  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4634  if( 0 == 0)
4635  {
4636  hexify( dst_str, output, data_len );
4637 
4638  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
4639  }
4640  }
4641  FCT_TEST_END();
4642 
4643 
4644  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_9)
4645  {
4646  unsigned char key_str[100];
4647  unsigned char iv_str[100];
4648  unsigned char src_str[100];
4649  unsigned char dst_str[100];
4650  unsigned char output[100];
4651  aes_context ctx;
4652  int key_len, data_len;
4653 
4654  memset(key_str, 0x00, 100);
4655  memset(iv_str, 0x00, 100);
4656  memset(src_str, 0x00, 100);
4657  memset(dst_str, 0x00, 100);
4658  memset(output, 0x00, 100);
4659 
4660  key_len = unhexify( key_str, "fca02f3d5011cfc5c1e23165d413a049d4526a991827424d896fe3435e0bf68e" );
4661  unhexify( iv_str, "00000000000000000000000000000000" );
4662  data_len = unhexify( src_str, "179a49c712154bbffbe6e7a84a18e220" );
4663 
4664  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4665  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4666  if( 0 == 0)
4667  {
4668  hexify( dst_str, output, data_len );
4669 
4670  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
4671  }
4672  }
4673  FCT_TEST_END();
4674 
4675 
4676  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_10)
4677  {
4678  unsigned char key_str[100];
4679  unsigned char iv_str[100];
4680  unsigned char src_str[100];
4681  unsigned char dst_str[100];
4682  unsigned char output[100];
4683  aes_context ctx;
4684  int key_len, data_len;
4685 
4686  memset(key_str, 0x00, 100);
4687  memset(iv_str, 0x00, 100);
4688  memset(src_str, 0x00, 100);
4689  memset(dst_str, 0x00, 100);
4690  memset(output, 0x00, 100);
4691 
4692  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4693  unhexify( iv_str, "00000000000000000000000000000000" );
4694  data_len = unhexify( src_str, "5c9d844ed46f9885085e5d6a4f94c7d7" );
4695 
4696  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4697  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4698  if( 0 == 0)
4699  {
4700  hexify( dst_str, output, data_len );
4701 
4702  fct_chk( strcmp( (char *) dst_str, "014730f80ac625fe84f026c60bfd547d" ) == 0 );
4703  }
4704  }
4705  FCT_TEST_END();
4706 
4707 
4708  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_11)
4709  {
4710  unsigned char key_str[100];
4711  unsigned char iv_str[100];
4712  unsigned char src_str[100];
4713  unsigned char dst_str[100];
4714  unsigned char output[100];
4715  aes_context ctx;
4716  int key_len, data_len;
4717 
4718  memset(key_str, 0x00, 100);
4719  memset(iv_str, 0x00, 100);
4720  memset(src_str, 0x00, 100);
4721  memset(dst_str, 0x00, 100);
4722  memset(output, 0x00, 100);
4723 
4724  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4725  unhexify( iv_str, "00000000000000000000000000000000" );
4726  data_len = unhexify( src_str, "a9ff75bd7cf6613d3731c77c3b6d0c04" );
4727 
4728  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4729  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4730  if( 0 == 0)
4731  {
4732  hexify( dst_str, output, data_len );
4733 
4734  fct_chk( strcmp( (char *) dst_str, "0b24af36193ce4665f2825d7b4749c98" ) == 0 );
4735  }
4736  }
4737  FCT_TEST_END();
4738 
4739 
4740  FCT_TEST_BGN(aes_256_cbc_decrypt_nist_kat_12)
4741  {
4742  unsigned char key_str[100];
4743  unsigned char iv_str[100];
4744  unsigned char src_str[100];
4745  unsigned char dst_str[100];
4746  unsigned char output[100];
4747  aes_context ctx;
4748  int key_len, data_len;
4749 
4750  memset(key_str, 0x00, 100);
4751  memset(iv_str, 0x00, 100);
4752  memset(src_str, 0x00, 100);
4753  memset(dst_str, 0x00, 100);
4754  memset(output, 0x00, 100);
4755 
4756  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
4757  unhexify( iv_str, "00000000000000000000000000000000" );
4758  data_len = unhexify( src_str, "623a52fcea5d443e48d9181ab32c7421" );
4759 
4760  aes_setkey_dec( &ctx, key_str, key_len * 8 );
4761  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == 0 );
4762  if( 0 == 0)
4763  {
4764  hexify( dst_str, output, data_len );
4765 
4766  fct_chk( strcmp( (char *) dst_str, "761c1fe41a18acf20d241650611d90f1" ) == 0 );
4767  }
4768  }
4769  FCT_TEST_END();
4770 
4771 #ifdef POLARSSL_CIPHER_MODE_CFB
4772 
4773  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_1)
4774  {
4775  unsigned char key_str[100];
4776  unsigned char iv_str[100];
4777  unsigned char src_str[100];
4778  unsigned char dst_str[100];
4779  unsigned char output[100];
4780  aes_context ctx;
4781  size_t iv_offset = 0;
4782  int key_len;
4783 
4784  memset(key_str, 0x00, 100);
4785  memset(iv_str, 0x00, 100);
4786  memset(src_str, 0x00, 100);
4787  memset(dst_str, 0x00, 100);
4788  memset(output, 0x00, 100);
4789 
4790  key_len = unhexify( key_str, "f0000000000000000000000000000000" );
4791  unhexify( iv_str, "00000000000000000000000000000000" );
4792  unhexify( src_str, "00000000000000000000000000000000" );
4793 
4794  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4795  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
4796  hexify( dst_str, output, 16 );
4797 
4798  fct_chk( strcmp( (char *) dst_str, "970014d634e2b7650777e8e84d03ccd8" ) == 0 );
4799  }
4800  FCT_TEST_END();
4801 #endif /* POLARSSL_CIPHER_MODE_CFB */
4802 
4803 #ifdef POLARSSL_CIPHER_MODE_CFB
4804 
4805  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_2)
4806  {
4807  unsigned char key_str[100];
4808  unsigned char iv_str[100];
4809  unsigned char src_str[100];
4810  unsigned char dst_str[100];
4811  unsigned char output[100];
4812  aes_context ctx;
4813  size_t iv_offset = 0;
4814  int key_len;
4815 
4816  memset(key_str, 0x00, 100);
4817  memset(iv_str, 0x00, 100);
4818  memset(src_str, 0x00, 100);
4819  memset(dst_str, 0x00, 100);
4820  memset(output, 0x00, 100);
4821 
4822  key_len = unhexify( key_str, "f8000000000000000000000000000000" );
4823  unhexify( iv_str, "00000000000000000000000000000000" );
4824  unhexify( src_str, "00000000000000000000000000000000" );
4825 
4826  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4827  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
4828  hexify( dst_str, output, 16 );
4829 
4830  fct_chk( strcmp( (char *) dst_str, "f17e79aed0db7e279e955b5f493875a7" ) == 0 );
4831  }
4832  FCT_TEST_END();
4833 #endif /* POLARSSL_CIPHER_MODE_CFB */
4834 
4835 #ifdef POLARSSL_CIPHER_MODE_CFB
4836 
4837  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_3)
4838  {
4839  unsigned char key_str[100];
4840  unsigned char iv_str[100];
4841  unsigned char src_str[100];
4842  unsigned char dst_str[100];
4843  unsigned char output[100];
4844  aes_context ctx;
4845  size_t iv_offset = 0;
4846  int key_len;
4847 
4848  memset(key_str, 0x00, 100);
4849  memset(iv_str, 0x00, 100);
4850  memset(src_str, 0x00, 100);
4851  memset(dst_str, 0x00, 100);
4852  memset(output, 0x00, 100);
4853 
4854  key_len = unhexify( key_str, "fc000000000000000000000000000000" );
4855  unhexify( iv_str, "00000000000000000000000000000000" );
4856  unhexify( src_str, "00000000000000000000000000000000" );
4857 
4858  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4859  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
4860  hexify( dst_str, output, 16 );
4861 
4862  fct_chk( strcmp( (char *) dst_str, "9ed5a75136a940d0963da379db4af26a" ) == 0 );
4863  }
4864  FCT_TEST_END();
4865 #endif /* POLARSSL_CIPHER_MODE_CFB */
4866 
4867 #ifdef POLARSSL_CIPHER_MODE_CFB
4868 
4869  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_4)
4870  {
4871  unsigned char key_str[100];
4872  unsigned char iv_str[100];
4873  unsigned char src_str[100];
4874  unsigned char dst_str[100];
4875  unsigned char output[100];
4876  aes_context ctx;
4877  size_t iv_offset = 0;
4878  int key_len;
4879 
4880  memset(key_str, 0x00, 100);
4881  memset(iv_str, 0x00, 100);
4882  memset(src_str, 0x00, 100);
4883  memset(dst_str, 0x00, 100);
4884  memset(output, 0x00, 100);
4885 
4886  key_len = unhexify( key_str, "64cf9c7abc50b888af65f49d521944b2" );
4887  unhexify( iv_str, "00000000000000000000000000000000" );
4888  unhexify( src_str, "00000000000000000000000000000000" );
4889 
4890  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4891  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
4892  hexify( dst_str, output, 16 );
4893 
4894  fct_chk( strcmp( (char *) dst_str, "f7efc89d5dba578104016ce5ad659c05" ) == 0 );
4895  }
4896  FCT_TEST_END();
4897 #endif /* POLARSSL_CIPHER_MODE_CFB */
4898 
4899 #ifdef POLARSSL_CIPHER_MODE_CFB
4900 
4901  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_5)
4902  {
4903  unsigned char key_str[100];
4904  unsigned char iv_str[100];
4905  unsigned char src_str[100];
4906  unsigned char dst_str[100];
4907  unsigned char output[100];
4908  aes_context ctx;
4909  size_t iv_offset = 0;
4910  int key_len;
4911 
4912  memset(key_str, 0x00, 100);
4913  memset(iv_str, 0x00, 100);
4914  memset(src_str, 0x00, 100);
4915  memset(dst_str, 0x00, 100);
4916  memset(output, 0x00, 100);
4917 
4918  key_len = unhexify( key_str, "47d6742eefcc0465dc96355e851b64d9" );
4919  unhexify( iv_str, "00000000000000000000000000000000" );
4920  unhexify( src_str, "00000000000000000000000000000000" );
4921 
4922  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4923  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
4924  hexify( dst_str, output, 16 );
4925 
4926  fct_chk( strcmp( (char *) dst_str, "0306194f666d183624aa230a8b264ae7" ) == 0 );
4927  }
4928  FCT_TEST_END();
4929 #endif /* POLARSSL_CIPHER_MODE_CFB */
4930 
4931 #ifdef POLARSSL_CIPHER_MODE_CFB
4932 
4933  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_6)
4934  {
4935  unsigned char key_str[100];
4936  unsigned char iv_str[100];
4937  unsigned char src_str[100];
4938  unsigned char dst_str[100];
4939  unsigned char output[100];
4940  aes_context ctx;
4941  size_t iv_offset = 0;
4942  int key_len;
4943 
4944  memset(key_str, 0x00, 100);
4945  memset(iv_str, 0x00, 100);
4946  memset(src_str, 0x00, 100);
4947  memset(dst_str, 0x00, 100);
4948  memset(output, 0x00, 100);
4949 
4950  key_len = unhexify( key_str, "3eb39790678c56bee34bbcdeccf6cdb5" );
4951  unhexify( iv_str, "00000000000000000000000000000000" );
4952  unhexify( src_str, "00000000000000000000000000000000" );
4953 
4954  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4955  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
4956  hexify( dst_str, output, 16 );
4957 
4958  fct_chk( strcmp( (char *) dst_str, "858075d536d79ccee571f7d7204b1f67" ) == 0 );
4959  }
4960  FCT_TEST_END();
4961 #endif /* POLARSSL_CIPHER_MODE_CFB */
4962 
4963 #ifdef POLARSSL_CIPHER_MODE_CFB
4964 
4965  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_7)
4966  {
4967  unsigned char key_str[100];
4968  unsigned char iv_str[100];
4969  unsigned char src_str[100];
4970  unsigned char dst_str[100];
4971  unsigned char output[100];
4972  aes_context ctx;
4973  size_t iv_offset = 0;
4974  int key_len;
4975 
4976  memset(key_str, 0x00, 100);
4977  memset(iv_str, 0x00, 100);
4978  memset(src_str, 0x00, 100);
4979  memset(dst_str, 0x00, 100);
4980  memset(output, 0x00, 100);
4981 
4982  key_len = unhexify( key_str, "00000000000000000000000000000000" );
4983  unhexify( iv_str, "6a118a874519e64e9963798a503f1d35" );
4984  unhexify( src_str, "00000000000000000000000000000000" );
4985 
4986  aes_setkey_enc( &ctx, key_str, key_len * 8 );
4987  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
4988  hexify( dst_str, output, 16 );
4989 
4990  fct_chk( strcmp( (char *) dst_str, "dc43be40be0e53712f7e2bf5ca707209" ) == 0 );
4991  }
4992  FCT_TEST_END();
4993 #endif /* POLARSSL_CIPHER_MODE_CFB */
4994 
4995 #ifdef POLARSSL_CIPHER_MODE_CFB
4996 
4997  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_8)
4998  {
4999  unsigned char key_str[100];
5000  unsigned char iv_str[100];
5001  unsigned char src_str[100];
5002  unsigned char dst_str[100];
5003  unsigned char output[100];
5004  aes_context ctx;
5005  size_t iv_offset = 0;
5006  int key_len;
5007 
5008  memset(key_str, 0x00, 100);
5009  memset(iv_str, 0x00, 100);
5010  memset(src_str, 0x00, 100);
5011  memset(dst_str, 0x00, 100);
5012  memset(output, 0x00, 100);
5013 
5014  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5015  unhexify( iv_str, "cb9fceec81286ca3e989bd979b0cb284" );
5016  unhexify( src_str, "00000000000000000000000000000000" );
5017 
5018  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5019  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5020  hexify( dst_str, output, 16 );
5021 
5022  fct_chk( strcmp( (char *) dst_str, "92beedab1895a94faa69b632e5cc47ce" ) == 0 );
5023  }
5024  FCT_TEST_END();
5025 #endif /* POLARSSL_CIPHER_MODE_CFB */
5026 
5027 #ifdef POLARSSL_CIPHER_MODE_CFB
5028 
5029  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_9)
5030  {
5031  unsigned char key_str[100];
5032  unsigned char iv_str[100];
5033  unsigned char src_str[100];
5034  unsigned char dst_str[100];
5035  unsigned char output[100];
5036  aes_context ctx;
5037  size_t iv_offset = 0;
5038  int key_len;
5039 
5040  memset(key_str, 0x00, 100);
5041  memset(iv_str, 0x00, 100);
5042  memset(src_str, 0x00, 100);
5043  memset(dst_str, 0x00, 100);
5044  memset(output, 0x00, 100);
5045 
5046  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5047  unhexify( iv_str, "b26aeb1874e47ca8358ff22378f09144" );
5048  unhexify( src_str, "00000000000000000000000000000000" );
5049 
5050  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5051  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5052  hexify( dst_str, output, 16 );
5053 
5054  fct_chk( strcmp( (char *) dst_str, "459264f4798f6a78bacb89c15ed3d601" ) == 0 );
5055  }
5056  FCT_TEST_END();
5057 #endif /* POLARSSL_CIPHER_MODE_CFB */
5058 
5059 #ifdef POLARSSL_CIPHER_MODE_CFB
5060 
5061  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_10)
5062  {
5063  unsigned char key_str[100];
5064  unsigned char iv_str[100];
5065  unsigned char src_str[100];
5066  unsigned char dst_str[100];
5067  unsigned char output[100];
5068  aes_context ctx;
5069  size_t iv_offset = 0;
5070  int key_len;
5071 
5072  memset(key_str, 0x00, 100);
5073  memset(iv_str, 0x00, 100);
5074  memset(src_str, 0x00, 100);
5075  memset(dst_str, 0x00, 100);
5076  memset(output, 0x00, 100);
5077 
5078  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5079  unhexify( iv_str, "fffffffffffffffffffffffffffffff0" );
5080  unhexify( src_str, "00000000000000000000000000000000" );
5081 
5082  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5083  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5084  hexify( dst_str, output, 16 );
5085 
5086  fct_chk( strcmp( (char *) dst_str, "f9b0fda0c4a898f5b9e6f661c4ce4d07" ) == 0 );
5087  }
5088  FCT_TEST_END();
5089 #endif /* POLARSSL_CIPHER_MODE_CFB */
5090 
5091 #ifdef POLARSSL_CIPHER_MODE_CFB
5092 
5093  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_11)
5094  {
5095  unsigned char key_str[100];
5096  unsigned char iv_str[100];
5097  unsigned char src_str[100];
5098  unsigned char dst_str[100];
5099  unsigned char output[100];
5100  aes_context ctx;
5101  size_t iv_offset = 0;
5102  int key_len;
5103 
5104  memset(key_str, 0x00, 100);
5105  memset(iv_str, 0x00, 100);
5106  memset(src_str, 0x00, 100);
5107  memset(dst_str, 0x00, 100);
5108  memset(output, 0x00, 100);
5109 
5110  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5111  unhexify( iv_str, "fffffffffffffffffffffffffffffff8" );
5112  unhexify( src_str, "00000000000000000000000000000000" );
5113 
5114  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5115  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5116  hexify( dst_str, output, 16 );
5117 
5118  fct_chk( strcmp( (char *) dst_str, "8ade895913685c67c5269f8aae42983e" ) == 0 );
5119  }
5120  FCT_TEST_END();
5121 #endif /* POLARSSL_CIPHER_MODE_CFB */
5122 
5123 #ifdef POLARSSL_CIPHER_MODE_CFB
5124 
5125  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_12)
5126  {
5127  unsigned char key_str[100];
5128  unsigned char iv_str[100];
5129  unsigned char src_str[100];
5130  unsigned char dst_str[100];
5131  unsigned char output[100];
5132  aes_context ctx;
5133  size_t iv_offset = 0;
5134  int key_len;
5135 
5136  memset(key_str, 0x00, 100);
5137  memset(iv_str, 0x00, 100);
5138  memset(src_str, 0x00, 100);
5139  memset(dst_str, 0x00, 100);
5140  memset(output, 0x00, 100);
5141 
5142  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5143  unhexify( iv_str, "fffffffffffffffffffffffffffffffc" );
5144  unhexify( src_str, "00000000000000000000000000000000" );
5145 
5146  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5147  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5148  hexify( dst_str, output, 16 );
5149 
5150  fct_chk( strcmp( (char *) dst_str, "39bde67d5c8ed8a8b1c37eb8fa9f5ac0" ) == 0 );
5151  }
5152  FCT_TEST_END();
5153 #endif /* POLARSSL_CIPHER_MODE_CFB */
5154 
5155 #ifdef POLARSSL_CIPHER_MODE_CFB
5156 
5157  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_1)
5158  {
5159  unsigned char key_str[100];
5160  unsigned char iv_str[100];
5161  unsigned char src_str[100];
5162  unsigned char dst_str[100];
5163  unsigned char output[100];
5164  aes_context ctx;
5165  size_t iv_offset = 0;
5166  int key_len;
5167 
5168  memset(key_str, 0x00, 100);
5169  memset(iv_str, 0x00, 100);
5170  memset(src_str, 0x00, 100);
5171  memset(dst_str, 0x00, 100);
5172  memset(output, 0x00, 100);
5173 
5174  key_len = unhexify( key_str, "fffffffe000000000000000000000000" );
5175  unhexify( iv_str, "00000000000000000000000000000000" );
5176  unhexify( src_str, "1114bc2028009b923f0b01915ce5e7c4" );
5177 
5178  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5179  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5180  hexify( dst_str, output, 16 );
5181 
5182  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5183  }
5184  FCT_TEST_END();
5185 #endif /* POLARSSL_CIPHER_MODE_CFB */
5186 
5187 #ifdef POLARSSL_CIPHER_MODE_CFB
5188 
5189  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_2)
5190  {
5191  unsigned char key_str[100];
5192  unsigned char iv_str[100];
5193  unsigned char src_str[100];
5194  unsigned char dst_str[100];
5195  unsigned char output[100];
5196  aes_context ctx;
5197  size_t iv_offset = 0;
5198  int key_len;
5199 
5200  memset(key_str, 0x00, 100);
5201  memset(iv_str, 0x00, 100);
5202  memset(src_str, 0x00, 100);
5203  memset(dst_str, 0x00, 100);
5204  memset(output, 0x00, 100);
5205 
5206  key_len = unhexify( key_str, "ffffffff000000000000000000000000" );
5207  unhexify( iv_str, "00000000000000000000000000000000" );
5208  unhexify( src_str, "9c28524a16a1e1c1452971caa8d13476" );
5209 
5210  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5211  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5212  hexify( dst_str, output, 16 );
5213 
5214  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5215  }
5216  FCT_TEST_END();
5217 #endif /* POLARSSL_CIPHER_MODE_CFB */
5218 
5219 #ifdef POLARSSL_CIPHER_MODE_CFB
5220 
5221  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_3)
5222  {
5223  unsigned char key_str[100];
5224  unsigned char iv_str[100];
5225  unsigned char src_str[100];
5226  unsigned char dst_str[100];
5227  unsigned char output[100];
5228  aes_context ctx;
5229  size_t iv_offset = 0;
5230  int key_len;
5231 
5232  memset(key_str, 0x00, 100);
5233  memset(iv_str, 0x00, 100);
5234  memset(src_str, 0x00, 100);
5235  memset(dst_str, 0x00, 100);
5236  memset(output, 0x00, 100);
5237 
5238  key_len = unhexify( key_str, "ffffffff800000000000000000000000" );
5239  unhexify( iv_str, "00000000000000000000000000000000" );
5240  unhexify( src_str, "ed62e16363638360fdd6ad62112794f0" );
5241 
5242  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5243  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5244  hexify( dst_str, output, 16 );
5245 
5246  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5247  }
5248  FCT_TEST_END();
5249 #endif /* POLARSSL_CIPHER_MODE_CFB */
5250 
5251 #ifdef POLARSSL_CIPHER_MODE_CFB
5252 
5253  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_4)
5254  {
5255  unsigned char key_str[100];
5256  unsigned char iv_str[100];
5257  unsigned char src_str[100];
5258  unsigned char dst_str[100];
5259  unsigned char output[100];
5260  aes_context ctx;
5261  size_t iv_offset = 0;
5262  int key_len;
5263 
5264  memset(key_str, 0x00, 100);
5265  memset(iv_str, 0x00, 100);
5266  memset(src_str, 0x00, 100);
5267  memset(dst_str, 0x00, 100);
5268  memset(output, 0x00, 100);
5269 
5270  key_len = unhexify( key_str, "3071a2a48fe6cbd04f1a129098e308f8" );
5271  unhexify( iv_str, "00000000000000000000000000000000" );
5272  unhexify( src_str, "4b98e06d356deb07ebb824e5713f7be3" );
5273 
5274  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5275  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5276  hexify( dst_str, output, 16 );
5277 
5278  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5279  }
5280  FCT_TEST_END();
5281 #endif /* POLARSSL_CIPHER_MODE_CFB */
5282 
5283 #ifdef POLARSSL_CIPHER_MODE_CFB
5284 
5285  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_5)
5286  {
5287  unsigned char key_str[100];
5288  unsigned char iv_str[100];
5289  unsigned char src_str[100];
5290  unsigned char dst_str[100];
5291  unsigned char output[100];
5292  aes_context ctx;
5293  size_t iv_offset = 0;
5294  int key_len;
5295 
5296  memset(key_str, 0x00, 100);
5297  memset(iv_str, 0x00, 100);
5298  memset(src_str, 0x00, 100);
5299  memset(dst_str, 0x00, 100);
5300  memset(output, 0x00, 100);
5301 
5302  key_len = unhexify( key_str, "90f42ec0f68385f2ffc5dfc03a654dce" );
5303  unhexify( iv_str, "00000000000000000000000000000000" );
5304  unhexify( src_str, "7a20a53d460fc9ce0423a7a0764c6cf2" );
5305 
5306  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5307  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5308  hexify( dst_str, output, 16 );
5309 
5310  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5311  }
5312  FCT_TEST_END();
5313 #endif /* POLARSSL_CIPHER_MODE_CFB */
5314 
5315 #ifdef POLARSSL_CIPHER_MODE_CFB
5316 
5317  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_6)
5318  {
5319  unsigned char key_str[100];
5320  unsigned char iv_str[100];
5321  unsigned char src_str[100];
5322  unsigned char dst_str[100];
5323  unsigned char output[100];
5324  aes_context ctx;
5325  size_t iv_offset = 0;
5326  int key_len;
5327 
5328  memset(key_str, 0x00, 100);
5329  memset(iv_str, 0x00, 100);
5330  memset(src_str, 0x00, 100);
5331  memset(dst_str, 0x00, 100);
5332  memset(output, 0x00, 100);
5333 
5334  key_len = unhexify( key_str, "febd9a24d8b65c1c787d50a4ed3619a9" );
5335  unhexify( iv_str, "00000000000000000000000000000000" );
5336  unhexify( src_str, "f4a70d8af877f9b02b4c40df57d45b17" );
5337 
5338  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5339  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5340  hexify( dst_str, output, 16 );
5341 
5342  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5343  }
5344  FCT_TEST_END();
5345 #endif /* POLARSSL_CIPHER_MODE_CFB */
5346 
5347 #ifdef POLARSSL_CIPHER_MODE_CFB
5348 
5349  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_7)
5350  {
5351  unsigned char key_str[100];
5352  unsigned char iv_str[100];
5353  unsigned char src_str[100];
5354  unsigned char dst_str[100];
5355  unsigned char output[100];
5356  aes_context ctx;
5357  size_t iv_offset = 0;
5358  int key_len;
5359 
5360  memset(key_str, 0x00, 100);
5361  memset(iv_str, 0x00, 100);
5362  memset(src_str, 0x00, 100);
5363  memset(dst_str, 0x00, 100);
5364  memset(output, 0x00, 100);
5365 
5366  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5367  unhexify( iv_str, "f34481ec3cc627bacd5dc3fb08f273e6" );
5368  unhexify( src_str, "0336763e966d92595a567cc9ce537f5e" );
5369 
5370  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5371  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5372  hexify( dst_str, output, 16 );
5373 
5374  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5375  }
5376  FCT_TEST_END();
5377 #endif /* POLARSSL_CIPHER_MODE_CFB */
5378 
5379 #ifdef POLARSSL_CIPHER_MODE_CFB
5380 
5381  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_8)
5382  {
5383  unsigned char key_str[100];
5384  unsigned char iv_str[100];
5385  unsigned char src_str[100];
5386  unsigned char dst_str[100];
5387  unsigned char output[100];
5388  aes_context ctx;
5389  size_t iv_offset = 0;
5390  int key_len;
5391 
5392  memset(key_str, 0x00, 100);
5393  memset(iv_str, 0x00, 100);
5394  memset(src_str, 0x00, 100);
5395  memset(dst_str, 0x00, 100);
5396  memset(output, 0x00, 100);
5397 
5398  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5399  unhexify( iv_str, "9798c4640bad75c7c3227db910174e72" );
5400  unhexify( src_str, "a9a1631bf4996954ebc093957b234589" );
5401 
5402  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5403  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5404  hexify( dst_str, output, 16 );
5405 
5406  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5407  }
5408  FCT_TEST_END();
5409 #endif /* POLARSSL_CIPHER_MODE_CFB */
5410 
5411 #ifdef POLARSSL_CIPHER_MODE_CFB
5412 
5413  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_9)
5414  {
5415  unsigned char key_str[100];
5416  unsigned char iv_str[100];
5417  unsigned char src_str[100];
5418  unsigned char dst_str[100];
5419  unsigned char output[100];
5420  aes_context ctx;
5421  size_t iv_offset = 0;
5422  int key_len;
5423 
5424  memset(key_str, 0x00, 100);
5425  memset(iv_str, 0x00, 100);
5426  memset(src_str, 0x00, 100);
5427  memset(dst_str, 0x00, 100);
5428  memset(output, 0x00, 100);
5429 
5430  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5431  unhexify( iv_str, "96ab5c2ff612d9dfaae8c31f30c42168" );
5432  unhexify( src_str, "ff4f8391a6a40ca5b25d23bedd44a597" );
5433 
5434  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5435  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5436  hexify( dst_str, output, 16 );
5437 
5438  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5439  }
5440  FCT_TEST_END();
5441 #endif /* POLARSSL_CIPHER_MODE_CFB */
5442 
5443 #ifdef POLARSSL_CIPHER_MODE_CFB
5444 
5445  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_10)
5446  {
5447  unsigned char key_str[100];
5448  unsigned char iv_str[100];
5449  unsigned char src_str[100];
5450  unsigned char dst_str[100];
5451  unsigned char output[100];
5452  aes_context ctx;
5453  size_t iv_offset = 0;
5454  int key_len;
5455 
5456  memset(key_str, 0x00, 100);
5457  memset(iv_str, 0x00, 100);
5458  memset(src_str, 0x00, 100);
5459  memset(dst_str, 0x00, 100);
5460  memset(output, 0x00, 100);
5461 
5462  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5463  unhexify( iv_str, "ffffffffffffffff0000000000000000" );
5464  unhexify( src_str, "f807c3e7985fe0f5a50e2cdb25c5109e" );
5465 
5466  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5467  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5468  hexify( dst_str, output, 16 );
5469 
5470  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5471  }
5472  FCT_TEST_END();
5473 #endif /* POLARSSL_CIPHER_MODE_CFB */
5474 
5475 #ifdef POLARSSL_CIPHER_MODE_CFB
5476 
5477  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_11)
5478  {
5479  unsigned char key_str[100];
5480  unsigned char iv_str[100];
5481  unsigned char src_str[100];
5482  unsigned char dst_str[100];
5483  unsigned char output[100];
5484  aes_context ctx;
5485  size_t iv_offset = 0;
5486  int key_len;
5487 
5488  memset(key_str, 0x00, 100);
5489  memset(iv_str, 0x00, 100);
5490  memset(src_str, 0x00, 100);
5491  memset(dst_str, 0x00, 100);
5492  memset(output, 0x00, 100);
5493 
5494  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5495  unhexify( iv_str, "ffffffffffffffff8000000000000000" );
5496  unhexify( src_str, "41f992a856fb278b389a62f5d274d7e9" );
5497 
5498  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5499  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5500  hexify( dst_str, output, 16 );
5501 
5502  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5503  }
5504  FCT_TEST_END();
5505 #endif /* POLARSSL_CIPHER_MODE_CFB */
5506 
5507 #ifdef POLARSSL_CIPHER_MODE_CFB
5508 
5509  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_12)
5510  {
5511  unsigned char key_str[100];
5512  unsigned char iv_str[100];
5513  unsigned char src_str[100];
5514  unsigned char dst_str[100];
5515  unsigned char output[100];
5516  aes_context ctx;
5517  size_t iv_offset = 0;
5518  int key_len;
5519 
5520  memset(key_str, 0x00, 100);
5521  memset(iv_str, 0x00, 100);
5522  memset(src_str, 0x00, 100);
5523  memset(dst_str, 0x00, 100);
5524  memset(output, 0x00, 100);
5525 
5526  key_len = unhexify( key_str, "00000000000000000000000000000000" );
5527  unhexify( iv_str, "ffffffffffffffffc000000000000000" );
5528  unhexify( src_str, "10d3ed7a6fe15ab4d91acbc7d0767ab1" );
5529 
5530  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5531  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5532  hexify( dst_str, output, 16 );
5533 
5534  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5535  }
5536  FCT_TEST_END();
5537 #endif /* POLARSSL_CIPHER_MODE_CFB */
5538 
5539 #ifdef POLARSSL_CIPHER_MODE_CFB
5540 
5541  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_1)
5542  {
5543  unsigned char key_str[100];
5544  unsigned char iv_str[100];
5545  unsigned char src_str[100];
5546  unsigned char dst_str[100];
5547  unsigned char output[100];
5548  aes_context ctx;
5549  size_t iv_offset = 0;
5550  int key_len;
5551 
5552  memset(key_str, 0x00, 100);
5553  memset(iv_str, 0x00, 100);
5554  memset(src_str, 0x00, 100);
5555  memset(dst_str, 0x00, 100);
5556  memset(output, 0x00, 100);
5557 
5558  key_len = unhexify( key_str, "fffffffffffffffffffc0000000000000000000000000000" );
5559  unhexify( iv_str, "00000000000000000000000000000000" );
5560  unhexify( src_str, "00000000000000000000000000000000" );
5561 
5562  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5563  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5564  hexify( dst_str, output, 16 );
5565 
5566  fct_chk( strcmp( (char *) dst_str, "8dfd999be5d0cfa35732c0ddc88ff5a5" ) == 0 );
5567  }
5568  FCT_TEST_END();
5569 #endif /* POLARSSL_CIPHER_MODE_CFB */
5570 
5571 #ifdef POLARSSL_CIPHER_MODE_CFB
5572 
5573  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_2)
5574  {
5575  unsigned char key_str[100];
5576  unsigned char iv_str[100];
5577  unsigned char src_str[100];
5578  unsigned char dst_str[100];
5579  unsigned char output[100];
5580  aes_context ctx;
5581  size_t iv_offset = 0;
5582  int key_len;
5583 
5584  memset(key_str, 0x00, 100);
5585  memset(iv_str, 0x00, 100);
5586  memset(src_str, 0x00, 100);
5587  memset(dst_str, 0x00, 100);
5588  memset(output, 0x00, 100);
5589 
5590  key_len = unhexify( key_str, "fffffffffffffffffffe0000000000000000000000000000" );
5591  unhexify( iv_str, "00000000000000000000000000000000" );
5592  unhexify( src_str, "00000000000000000000000000000000" );
5593 
5594  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5595  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5596  hexify( dst_str, output, 16 );
5597 
5598  fct_chk( strcmp( (char *) dst_str, "02647c76a300c3173b841487eb2bae9f" ) == 0 );
5599  }
5600  FCT_TEST_END();
5601 #endif /* POLARSSL_CIPHER_MODE_CFB */
5602 
5603 #ifdef POLARSSL_CIPHER_MODE_CFB
5604 
5605  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_3)
5606  {
5607  unsigned char key_str[100];
5608  unsigned char iv_str[100];
5609  unsigned char src_str[100];
5610  unsigned char dst_str[100];
5611  unsigned char output[100];
5612  aes_context ctx;
5613  size_t iv_offset = 0;
5614  int key_len;
5615 
5616  memset(key_str, 0x00, 100);
5617  memset(iv_str, 0x00, 100);
5618  memset(src_str, 0x00, 100);
5619  memset(dst_str, 0x00, 100);
5620  memset(output, 0x00, 100);
5621 
5622  key_len = unhexify( key_str, "ffffffffffffffffffff0000000000000000000000000000" );
5623  unhexify( iv_str, "00000000000000000000000000000000" );
5624  unhexify( src_str, "00000000000000000000000000000000" );
5625 
5626  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5627  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5628  hexify( dst_str, output, 16 );
5629 
5630  fct_chk( strcmp( (char *) dst_str, "172df8b02f04b53adab028b4e01acd87" ) == 0 );
5631  }
5632  FCT_TEST_END();
5633 #endif /* POLARSSL_CIPHER_MODE_CFB */
5634 
5635 #ifdef POLARSSL_CIPHER_MODE_CFB
5636 
5637  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_4)
5638  {
5639  unsigned char key_str[100];
5640  unsigned char iv_str[100];
5641  unsigned char src_str[100];
5642  unsigned char dst_str[100];
5643  unsigned char output[100];
5644  aes_context ctx;
5645  size_t iv_offset = 0;
5646  int key_len;
5647 
5648  memset(key_str, 0x00, 100);
5649  memset(iv_str, 0x00, 100);
5650  memset(src_str, 0x00, 100);
5651  memset(dst_str, 0x00, 100);
5652  memset(output, 0x00, 100);
5653 
5654  key_len = unhexify( key_str, "d184c36cf0dddfec39e654195006022237871a47c33d3198" );
5655  unhexify( iv_str, "00000000000000000000000000000000" );
5656  unhexify( src_str, "00000000000000000000000000000000" );
5657 
5658  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5659  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5660  hexify( dst_str, output, 16 );
5661 
5662  fct_chk( strcmp( (char *) dst_str, "2e19fb60a3e1de0166f483c97824a978" ) == 0 );
5663  }
5664  FCT_TEST_END();
5665 #endif /* POLARSSL_CIPHER_MODE_CFB */
5666 
5667 #ifdef POLARSSL_CIPHER_MODE_CFB
5668 
5669  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_5)
5670  {
5671  unsigned char key_str[100];
5672  unsigned char iv_str[100];
5673  unsigned char src_str[100];
5674  unsigned char dst_str[100];
5675  unsigned char output[100];
5676  aes_context ctx;
5677  size_t iv_offset = 0;
5678  int key_len;
5679 
5680  memset(key_str, 0x00, 100);
5681  memset(iv_str, 0x00, 100);
5682  memset(src_str, 0x00, 100);
5683  memset(dst_str, 0x00, 100);
5684  memset(output, 0x00, 100);
5685 
5686  key_len = unhexify( key_str, "4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080" );
5687  unhexify( iv_str, "00000000000000000000000000000000" );
5688  unhexify( src_str, "00000000000000000000000000000000" );
5689 
5690  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5691  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5692  hexify( dst_str, output, 16 );
5693 
5694  fct_chk( strcmp( (char *) dst_str, "7656709538dd5fec41e0ce6a0f8e207d" ) == 0 );
5695  }
5696  FCT_TEST_END();
5697 #endif /* POLARSSL_CIPHER_MODE_CFB */
5698 
5699 #ifdef POLARSSL_CIPHER_MODE_CFB
5700 
5701  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_6)
5702  {
5703  unsigned char key_str[100];
5704  unsigned char iv_str[100];
5705  unsigned char src_str[100];
5706  unsigned char dst_str[100];
5707  unsigned char output[100];
5708  aes_context ctx;
5709  size_t iv_offset = 0;
5710  int key_len;
5711 
5712  memset(key_str, 0x00, 100);
5713  memset(iv_str, 0x00, 100);
5714  memset(src_str, 0x00, 100);
5715  memset(dst_str, 0x00, 100);
5716  memset(output, 0x00, 100);
5717 
5718  key_len = unhexify( key_str, "c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72" );
5719  unhexify( iv_str, "00000000000000000000000000000000" );
5720  unhexify( src_str, "00000000000000000000000000000000" );
5721 
5722  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5723  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5724  hexify( dst_str, output, 16 );
5725 
5726  fct_chk( strcmp( (char *) dst_str, "a67cf333b314d411d3c0ae6e1cfcd8f5" ) == 0 );
5727  }
5728  FCT_TEST_END();
5729 #endif /* POLARSSL_CIPHER_MODE_CFB */
5730 
5731 #ifdef POLARSSL_CIPHER_MODE_CFB
5732 
5733  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_7)
5734  {
5735  unsigned char key_str[100];
5736  unsigned char iv_str[100];
5737  unsigned char src_str[100];
5738  unsigned char dst_str[100];
5739  unsigned char output[100];
5740  aes_context ctx;
5741  size_t iv_offset = 0;
5742  int key_len;
5743 
5744  memset(key_str, 0x00, 100);
5745  memset(iv_str, 0x00, 100);
5746  memset(src_str, 0x00, 100);
5747  memset(dst_str, 0x00, 100);
5748  memset(output, 0x00, 100);
5749 
5750  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
5751  unhexify( iv_str, "9c2d8842e5f48f57648205d39a239af1" );
5752  unhexify( src_str, "00000000000000000000000000000000" );
5753 
5754  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5755  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5756  hexify( dst_str, output, 16 );
5757 
5758  fct_chk( strcmp( (char *) dst_str, "c9b8135ff1b5adc413dfd053b21bd96d" ) == 0 );
5759  }
5760  FCT_TEST_END();
5761 #endif /* POLARSSL_CIPHER_MODE_CFB */
5762 
5763 #ifdef POLARSSL_CIPHER_MODE_CFB
5764 
5765  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_8)
5766  {
5767  unsigned char key_str[100];
5768  unsigned char iv_str[100];
5769  unsigned char src_str[100];
5770  unsigned char dst_str[100];
5771  unsigned char output[100];
5772  aes_context ctx;
5773  size_t iv_offset = 0;
5774  int key_len;
5775 
5776  memset(key_str, 0x00, 100);
5777  memset(iv_str, 0x00, 100);
5778  memset(src_str, 0x00, 100);
5779  memset(dst_str, 0x00, 100);
5780  memset(output, 0x00, 100);
5781 
5782  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
5783  unhexify( iv_str, "bff52510095f518ecca60af4205444bb" );
5784  unhexify( src_str, "00000000000000000000000000000000" );
5785 
5786  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5787  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5788  hexify( dst_str, output, 16 );
5789 
5790  fct_chk( strcmp( (char *) dst_str, "4a3650c3371ce2eb35e389a171427440" ) == 0 );
5791  }
5792  FCT_TEST_END();
5793 #endif /* POLARSSL_CIPHER_MODE_CFB */
5794 
5795 #ifdef POLARSSL_CIPHER_MODE_CFB
5796 
5797  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_9)
5798  {
5799  unsigned char key_str[100];
5800  unsigned char iv_str[100];
5801  unsigned char src_str[100];
5802  unsigned char dst_str[100];
5803  unsigned char output[100];
5804  aes_context ctx;
5805  size_t iv_offset = 0;
5806  int key_len;
5807 
5808  memset(key_str, 0x00, 100);
5809  memset(iv_str, 0x00, 100);
5810  memset(src_str, 0x00, 100);
5811  memset(dst_str, 0x00, 100);
5812  memset(output, 0x00, 100);
5813 
5814  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
5815  unhexify( iv_str, "51719783d3185a535bd75adc65071ce1" );
5816  unhexify( src_str, "00000000000000000000000000000000" );
5817 
5818  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5819  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5820  hexify( dst_str, output, 16 );
5821 
5822  fct_chk( strcmp( (char *) dst_str, "4f354592ff7c8847d2d0870ca9481b7c" ) == 0 );
5823  }
5824  FCT_TEST_END();
5825 #endif /* POLARSSL_CIPHER_MODE_CFB */
5826 
5827 #ifdef POLARSSL_CIPHER_MODE_CFB
5828 
5829  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_10)
5830  {
5831  unsigned char key_str[100];
5832  unsigned char iv_str[100];
5833  unsigned char src_str[100];
5834  unsigned char dst_str[100];
5835  unsigned char output[100];
5836  aes_context ctx;
5837  size_t iv_offset = 0;
5838  int key_len;
5839 
5840  memset(key_str, 0x00, 100);
5841  memset(iv_str, 0x00, 100);
5842  memset(src_str, 0x00, 100);
5843  memset(dst_str, 0x00, 100);
5844  memset(output, 0x00, 100);
5845 
5846  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
5847  unhexify( iv_str, "ffffffffffffffe00000000000000000" );
5848  unhexify( src_str, "00000000000000000000000000000000" );
5849 
5850  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5851  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5852  hexify( dst_str, output, 16 );
5853 
5854  fct_chk( strcmp( (char *) dst_str, "f34e4a6324ea4a5c39a661c8fe5ada8f" ) == 0 );
5855  }
5856  FCT_TEST_END();
5857 #endif /* POLARSSL_CIPHER_MODE_CFB */
5858 
5859 #ifdef POLARSSL_CIPHER_MODE_CFB
5860 
5861  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_11)
5862  {
5863  unsigned char key_str[100];
5864  unsigned char iv_str[100];
5865  unsigned char src_str[100];
5866  unsigned char dst_str[100];
5867  unsigned char output[100];
5868  aes_context ctx;
5869  size_t iv_offset = 0;
5870  int key_len;
5871 
5872  memset(key_str, 0x00, 100);
5873  memset(iv_str, 0x00, 100);
5874  memset(src_str, 0x00, 100);
5875  memset(dst_str, 0x00, 100);
5876  memset(output, 0x00, 100);
5877 
5878  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
5879  unhexify( iv_str, "fffffffffffffff00000000000000000" );
5880  unhexify( src_str, "00000000000000000000000000000000" );
5881 
5882  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5883  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5884  hexify( dst_str, output, 16 );
5885 
5886  fct_chk( strcmp( (char *) dst_str, "0882a16f44088d42447a29ac090ec17e" ) == 0 );
5887  }
5888  FCT_TEST_END();
5889 #endif /* POLARSSL_CIPHER_MODE_CFB */
5890 
5891 #ifdef POLARSSL_CIPHER_MODE_CFB
5892 
5893  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_12)
5894  {
5895  unsigned char key_str[100];
5896  unsigned char iv_str[100];
5897  unsigned char src_str[100];
5898  unsigned char dst_str[100];
5899  unsigned char output[100];
5900  aes_context ctx;
5901  size_t iv_offset = 0;
5902  int key_len;
5903 
5904  memset(key_str, 0x00, 100);
5905  memset(iv_str, 0x00, 100);
5906  memset(src_str, 0x00, 100);
5907  memset(dst_str, 0x00, 100);
5908  memset(output, 0x00, 100);
5909 
5910  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
5911  unhexify( iv_str, "fffffffffffffff80000000000000000" );
5912  unhexify( src_str, "00000000000000000000000000000000" );
5913 
5914  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5915  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5916  hexify( dst_str, output, 16 );
5917 
5918  fct_chk( strcmp( (char *) dst_str, "3a3c15bfc11a9537c130687004e136ee" ) == 0 );
5919  }
5920  FCT_TEST_END();
5921 #endif /* POLARSSL_CIPHER_MODE_CFB */
5922 
5923 #ifdef POLARSSL_CIPHER_MODE_CFB
5924 
5925  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_1)
5926  {
5927  unsigned char key_str[100];
5928  unsigned char iv_str[100];
5929  unsigned char src_str[100];
5930  unsigned char dst_str[100];
5931  unsigned char output[100];
5932  aes_context ctx;
5933  size_t iv_offset = 0;
5934  int key_len;
5935 
5936  memset(key_str, 0x00, 100);
5937  memset(iv_str, 0x00, 100);
5938  memset(src_str, 0x00, 100);
5939  memset(dst_str, 0x00, 100);
5940  memset(output, 0x00, 100);
5941 
5942  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffe00000" );
5943  unhexify( iv_str, "00000000000000000000000000000000" );
5944  unhexify( src_str, "60136703374f64e860b48ce31f930716" );
5945 
5946  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5947  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5948  hexify( dst_str, output, 16 );
5949 
5950  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5951  }
5952  FCT_TEST_END();
5953 #endif /* POLARSSL_CIPHER_MODE_CFB */
5954 
5955 #ifdef POLARSSL_CIPHER_MODE_CFB
5956 
5957  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_2)
5958  {
5959  unsigned char key_str[100];
5960  unsigned char iv_str[100];
5961  unsigned char src_str[100];
5962  unsigned char dst_str[100];
5963  unsigned char output[100];
5964  aes_context ctx;
5965  size_t iv_offset = 0;
5966  int key_len;
5967 
5968  memset(key_str, 0x00, 100);
5969  memset(iv_str, 0x00, 100);
5970  memset(src_str, 0x00, 100);
5971  memset(dst_str, 0x00, 100);
5972  memset(output, 0x00, 100);
5973 
5974  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffff00000" );
5975  unhexify( iv_str, "00000000000000000000000000000000" );
5976  unhexify( src_str, "8d63a269b14d506ccc401ab8a9f1b591" );
5977 
5978  aes_setkey_enc( &ctx, key_str, key_len * 8 );
5979  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
5980  hexify( dst_str, output, 16 );
5981 
5982  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
5983  }
5984  FCT_TEST_END();
5985 #endif /* POLARSSL_CIPHER_MODE_CFB */
5986 
5987 #ifdef POLARSSL_CIPHER_MODE_CFB
5988 
5989  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_3)
5990  {
5991  unsigned char key_str[100];
5992  unsigned char iv_str[100];
5993  unsigned char src_str[100];
5994  unsigned char dst_str[100];
5995  unsigned char output[100];
5996  aes_context ctx;
5997  size_t iv_offset = 0;
5998  int key_len;
5999 
6000  memset(key_str, 0x00, 100);
6001  memset(iv_str, 0x00, 100);
6002  memset(src_str, 0x00, 100);
6003  memset(dst_str, 0x00, 100);
6004  memset(output, 0x00, 100);
6005 
6006  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffff80000" );
6007  unhexify( iv_str, "00000000000000000000000000000000" );
6008  unhexify( src_str, "d317f81dc6aa454aee4bd4a5a5cff4bd" );
6009 
6010  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6011  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6012  hexify( dst_str, output, 16 );
6013 
6014  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6015  }
6016  FCT_TEST_END();
6017 #endif /* POLARSSL_CIPHER_MODE_CFB */
6018 
6019 #ifdef POLARSSL_CIPHER_MODE_CFB
6020 
6021  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_4)
6022  {
6023  unsigned char key_str[100];
6024  unsigned char iv_str[100];
6025  unsigned char src_str[100];
6026  unsigned char dst_str[100];
6027  unsigned char output[100];
6028  aes_context ctx;
6029  size_t iv_offset = 0;
6030  int key_len;
6031 
6032  memset(key_str, 0x00, 100);
6033  memset(iv_str, 0x00, 100);
6034  memset(src_str, 0x00, 100);
6035  memset(dst_str, 0x00, 100);
6036  memset(output, 0x00, 100);
6037 
6038  key_len = unhexify( key_str, "98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9" );
6039  unhexify( iv_str, "00000000000000000000000000000000" );
6040  unhexify( src_str, "19c80ec4a6deb7e5ed1033dda933498f" );
6041 
6042  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6043  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6044  hexify( dst_str, output, 16 );
6045 
6046  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6047  }
6048  FCT_TEST_END();
6049 #endif /* POLARSSL_CIPHER_MODE_CFB */
6050 
6051 #ifdef POLARSSL_CIPHER_MODE_CFB
6052 
6053  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_5)
6054  {
6055  unsigned char key_str[100];
6056  unsigned char iv_str[100];
6057  unsigned char src_str[100];
6058  unsigned char dst_str[100];
6059  unsigned char output[100];
6060  aes_context ctx;
6061  size_t iv_offset = 0;
6062  int key_len;
6063 
6064  memset(key_str, 0x00, 100);
6065  memset(iv_str, 0x00, 100);
6066  memset(src_str, 0x00, 100);
6067  memset(dst_str, 0x00, 100);
6068  memset(output, 0x00, 100);
6069 
6070  key_len = unhexify( key_str, "b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35" );
6071  unhexify( iv_str, "00000000000000000000000000000000" );
6072  unhexify( src_str, "3cf5e1d21a17956d1dffad6a7c41c659" );
6073 
6074  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6075  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6076  hexify( dst_str, output, 16 );
6077 
6078  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6079  }
6080  FCT_TEST_END();
6081 #endif /* POLARSSL_CIPHER_MODE_CFB */
6082 
6083 #ifdef POLARSSL_CIPHER_MODE_CFB
6084 
6085  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_6)
6086  {
6087  unsigned char key_str[100];
6088  unsigned char iv_str[100];
6089  unsigned char src_str[100];
6090  unsigned char dst_str[100];
6091  unsigned char output[100];
6092  aes_context ctx;
6093  size_t iv_offset = 0;
6094  int key_len;
6095 
6096  memset(key_str, 0x00, 100);
6097  memset(iv_str, 0x00, 100);
6098  memset(src_str, 0x00, 100);
6099  memset(dst_str, 0x00, 100);
6100  memset(output, 0x00, 100);
6101 
6102  key_len = unhexify( key_str, "45899367c3132849763073c435a9288a766c8b9ec2308516" );
6103  unhexify( iv_str, "00000000000000000000000000000000" );
6104  unhexify( src_str, "69fd12e8505f8ded2fdcb197a121b362" );
6105 
6106  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6107  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6108  hexify( dst_str, output, 16 );
6109 
6110  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6111  }
6112  FCT_TEST_END();
6113 #endif /* POLARSSL_CIPHER_MODE_CFB */
6114 
6115 #ifdef POLARSSL_CIPHER_MODE_CFB
6116 
6117  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_7)
6118  {
6119  unsigned char key_str[100];
6120  unsigned char iv_str[100];
6121  unsigned char src_str[100];
6122  unsigned char dst_str[100];
6123  unsigned char output[100];
6124  aes_context ctx;
6125  size_t iv_offset = 0;
6126  int key_len;
6127 
6128  memset(key_str, 0x00, 100);
6129  memset(iv_str, 0x00, 100);
6130  memset(src_str, 0x00, 100);
6131  memset(dst_str, 0x00, 100);
6132  memset(output, 0x00, 100);
6133 
6134  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
6135  unhexify( iv_str, "1b077a6af4b7f98229de786d7516b639" );
6136  unhexify( src_str, "275cfc0413d8ccb70513c3859b1d0f72" );
6137 
6138  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6139  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6140  hexify( dst_str, output, 16 );
6141 
6142  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6143  }
6144  FCT_TEST_END();
6145 #endif /* POLARSSL_CIPHER_MODE_CFB */
6146 
6147 #ifdef POLARSSL_CIPHER_MODE_CFB
6148 
6149  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_8)
6150  {
6151  unsigned char key_str[100];
6152  unsigned char iv_str[100];
6153  unsigned char src_str[100];
6154  unsigned char dst_str[100];
6155  unsigned char output[100];
6156  aes_context ctx;
6157  size_t iv_offset = 0;
6158  int key_len;
6159 
6160  memset(key_str, 0x00, 100);
6161  memset(iv_str, 0x00, 100);
6162  memset(src_str, 0x00, 100);
6163  memset(dst_str, 0x00, 100);
6164  memset(output, 0x00, 100);
6165 
6166  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
6167  unhexify( iv_str, "9c2d8842e5f48f57648205d39a239af1" );
6168  unhexify( src_str, "c9b8135ff1b5adc413dfd053b21bd96d" );
6169 
6170  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6171  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6172  hexify( dst_str, output, 16 );
6173 
6174  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6175  }
6176  FCT_TEST_END();
6177 #endif /* POLARSSL_CIPHER_MODE_CFB */
6178 
6179 #ifdef POLARSSL_CIPHER_MODE_CFB
6180 
6181  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_9)
6182  {
6183  unsigned char key_str[100];
6184  unsigned char iv_str[100];
6185  unsigned char src_str[100];
6186  unsigned char dst_str[100];
6187  unsigned char output[100];
6188  aes_context ctx;
6189  size_t iv_offset = 0;
6190  int key_len;
6191 
6192  memset(key_str, 0x00, 100);
6193  memset(iv_str, 0x00, 100);
6194  memset(src_str, 0x00, 100);
6195  memset(dst_str, 0x00, 100);
6196  memset(output, 0x00, 100);
6197 
6198  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
6199  unhexify( iv_str, "bff52510095f518ecca60af4205444bb" );
6200  unhexify( src_str, "4a3650c3371ce2eb35e389a171427440" );
6201 
6202  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6203  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6204  hexify( dst_str, output, 16 );
6205 
6206  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6207  }
6208  FCT_TEST_END();
6209 #endif /* POLARSSL_CIPHER_MODE_CFB */
6210 
6211 #ifdef POLARSSL_CIPHER_MODE_CFB
6212 
6213  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_10)
6214  {
6215  unsigned char key_str[100];
6216  unsigned char iv_str[100];
6217  unsigned char src_str[100];
6218  unsigned char dst_str[100];
6219  unsigned char output[100];
6220  aes_context ctx;
6221  size_t iv_offset = 0;
6222  int key_len;
6223 
6224  memset(key_str, 0x00, 100);
6225  memset(iv_str, 0x00, 100);
6226  memset(src_str, 0x00, 100);
6227  memset(dst_str, 0x00, 100);
6228  memset(output, 0x00, 100);
6229 
6230  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
6231  unhexify( iv_str, "ffffffffffffffffffff000000000000" );
6232  unhexify( src_str, "54d632d03aba0bd0f91877ebdd4d09cb" );
6233 
6234  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6235  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6236  hexify( dst_str, output, 16 );
6237 
6238  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6239  }
6240  FCT_TEST_END();
6241 #endif /* POLARSSL_CIPHER_MODE_CFB */
6242 
6243 #ifdef POLARSSL_CIPHER_MODE_CFB
6244 
6245  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_11)
6246  {
6247  unsigned char key_str[100];
6248  unsigned char iv_str[100];
6249  unsigned char src_str[100];
6250  unsigned char dst_str[100];
6251  unsigned char output[100];
6252  aes_context ctx;
6253  size_t iv_offset = 0;
6254  int key_len;
6255 
6256  memset(key_str, 0x00, 100);
6257  memset(iv_str, 0x00, 100);
6258  memset(src_str, 0x00, 100);
6259  memset(dst_str, 0x00, 100);
6260  memset(output, 0x00, 100);
6261 
6262  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
6263  unhexify( iv_str, "ffffffffffffffffffff800000000000" );
6264  unhexify( src_str, "d3427be7e4d27cd54f5fe37b03cf0897" );
6265 
6266  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6267  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6268  hexify( dst_str, output, 16 );
6269 
6270  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6271  }
6272  FCT_TEST_END();
6273 #endif /* POLARSSL_CIPHER_MODE_CFB */
6274 
6275 #ifdef POLARSSL_CIPHER_MODE_CFB
6276 
6277  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_12)
6278  {
6279  unsigned char key_str[100];
6280  unsigned char iv_str[100];
6281  unsigned char src_str[100];
6282  unsigned char dst_str[100];
6283  unsigned char output[100];
6284  aes_context ctx;
6285  size_t iv_offset = 0;
6286  int key_len;
6287 
6288  memset(key_str, 0x00, 100);
6289  memset(iv_str, 0x00, 100);
6290  memset(src_str, 0x00, 100);
6291  memset(dst_str, 0x00, 100);
6292  memset(output, 0x00, 100);
6293 
6294  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
6295  unhexify( iv_str, "ffffffffffffffffffffc00000000000" );
6296  unhexify( src_str, "b2099795e88cc158fd75ea133d7e7fbe" );
6297 
6298  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6299  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6300  hexify( dst_str, output, 16 );
6301 
6302  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6303  }
6304  FCT_TEST_END();
6305 #endif /* POLARSSL_CIPHER_MODE_CFB */
6306 
6307 #ifdef POLARSSL_CIPHER_MODE_CFB
6308 
6309  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_1)
6310  {
6311  unsigned char key_str[100];
6312  unsigned char iv_str[100];
6313  unsigned char src_str[100];
6314  unsigned char dst_str[100];
6315  unsigned char output[100];
6316  aes_context ctx;
6317  size_t iv_offset = 0;
6318  int key_len;
6319 
6320  memset(key_str, 0x00, 100);
6321  memset(iv_str, 0x00, 100);
6322  memset(src_str, 0x00, 100);
6323  memset(dst_str, 0x00, 100);
6324  memset(output, 0x00, 100);
6325 
6326  key_len = unhexify( key_str, "ffffffe000000000000000000000000000000000000000000000000000000000" );
6327  unhexify( iv_str, "00000000000000000000000000000000" );
6328  unhexify( src_str, "00000000000000000000000000000000" );
6329 
6330  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6331  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6332  hexify( dst_str, output, 16 );
6333 
6334  fct_chk( strcmp( (char *) dst_str, "bbd1097a62433f79449fa97d4ee80dbf" ) == 0 );
6335  }
6336  FCT_TEST_END();
6337 #endif /* POLARSSL_CIPHER_MODE_CFB */
6338 
6339 #ifdef POLARSSL_CIPHER_MODE_CFB
6340 
6341  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_2)
6342  {
6343  unsigned char key_str[100];
6344  unsigned char iv_str[100];
6345  unsigned char src_str[100];
6346  unsigned char dst_str[100];
6347  unsigned char output[100];
6348  aes_context ctx;
6349  size_t iv_offset = 0;
6350  int key_len;
6351 
6352  memset(key_str, 0x00, 100);
6353  memset(iv_str, 0x00, 100);
6354  memset(src_str, 0x00, 100);
6355  memset(dst_str, 0x00, 100);
6356  memset(output, 0x00, 100);
6357 
6358  key_len = unhexify( key_str, "fffffff000000000000000000000000000000000000000000000000000000000" );
6359  unhexify( iv_str, "00000000000000000000000000000000" );
6360  unhexify( src_str, "00000000000000000000000000000000" );
6361 
6362  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6363  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6364  hexify( dst_str, output, 16 );
6365 
6366  fct_chk( strcmp( (char *) dst_str, "07058e408f5b99b0e0f061a1761b5b3b" ) == 0 );
6367  }
6368  FCT_TEST_END();
6369 #endif /* POLARSSL_CIPHER_MODE_CFB */
6370 
6371 #ifdef POLARSSL_CIPHER_MODE_CFB
6372 
6373  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_3)
6374  {
6375  unsigned char key_str[100];
6376  unsigned char iv_str[100];
6377  unsigned char src_str[100];
6378  unsigned char dst_str[100];
6379  unsigned char output[100];
6380  aes_context ctx;
6381  size_t iv_offset = 0;
6382  int key_len;
6383 
6384  memset(key_str, 0x00, 100);
6385  memset(iv_str, 0x00, 100);
6386  memset(src_str, 0x00, 100);
6387  memset(dst_str, 0x00, 100);
6388  memset(output, 0x00, 100);
6389 
6390  key_len = unhexify( key_str, "fffffff800000000000000000000000000000000000000000000000000000000" );
6391  unhexify( iv_str, "00000000000000000000000000000000" );
6392  unhexify( src_str, "00000000000000000000000000000000" );
6393 
6394  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6395  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6396  hexify( dst_str, output, 16 );
6397 
6398  fct_chk( strcmp( (char *) dst_str, "5fd1f13fa0f31e37fabde328f894eac2" ) == 0 );
6399  }
6400  FCT_TEST_END();
6401 #endif /* POLARSSL_CIPHER_MODE_CFB */
6402 
6403 #ifdef POLARSSL_CIPHER_MODE_CFB
6404 
6405  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_4)
6406  {
6407  unsigned char key_str[100];
6408  unsigned char iv_str[100];
6409  unsigned char src_str[100];
6410  unsigned char dst_str[100];
6411  unsigned char output[100];
6412  aes_context ctx;
6413  size_t iv_offset = 0;
6414  int key_len;
6415 
6416  memset(key_str, 0x00, 100);
6417  memset(iv_str, 0x00, 100);
6418  memset(src_str, 0x00, 100);
6419  memset(dst_str, 0x00, 100);
6420  memset(output, 0x00, 100);
6421 
6422  key_len = unhexify( key_str, "13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887" );
6423  unhexify( iv_str, "00000000000000000000000000000000" );
6424  unhexify( src_str, "00000000000000000000000000000000" );
6425 
6426  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6427  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6428  hexify( dst_str, output, 16 );
6429 
6430  fct_chk( strcmp( (char *) dst_str, "649a71545378c783e368c9ade7114f6c" ) == 0 );
6431  }
6432  FCT_TEST_END();
6433 #endif /* POLARSSL_CIPHER_MODE_CFB */
6434 
6435 #ifdef POLARSSL_CIPHER_MODE_CFB
6436 
6437  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_5)
6438  {
6439  unsigned char key_str[100];
6440  unsigned char iv_str[100];
6441  unsigned char src_str[100];
6442  unsigned char dst_str[100];
6443  unsigned char output[100];
6444  aes_context ctx;
6445  size_t iv_offset = 0;
6446  int key_len;
6447 
6448  memset(key_str, 0x00, 100);
6449  memset(iv_str, 0x00, 100);
6450  memset(src_str, 0x00, 100);
6451  memset(dst_str, 0x00, 100);
6452  memset(output, 0x00, 100);
6453 
6454  key_len = unhexify( key_str, "07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee" );
6455  unhexify( iv_str, "00000000000000000000000000000000" );
6456  unhexify( src_str, "00000000000000000000000000000000" );
6457 
6458  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6459  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6460  hexify( dst_str, output, 16 );
6461 
6462  fct_chk( strcmp( (char *) dst_str, "47cb030da2ab051dfc6c4bf6910d12bb" ) == 0 );
6463  }
6464  FCT_TEST_END();
6465 #endif /* POLARSSL_CIPHER_MODE_CFB */
6466 
6467 #ifdef POLARSSL_CIPHER_MODE_CFB
6468 
6469  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_6)
6470  {
6471  unsigned char key_str[100];
6472  unsigned char iv_str[100];
6473  unsigned char src_str[100];
6474  unsigned char dst_str[100];
6475  unsigned char output[100];
6476  aes_context ctx;
6477  size_t iv_offset = 0;
6478  int key_len;
6479 
6480  memset(key_str, 0x00, 100);
6481  memset(iv_str, 0x00, 100);
6482  memset(src_str, 0x00, 100);
6483  memset(dst_str, 0x00, 100);
6484  memset(output, 0x00, 100);
6485 
6486  key_len = unhexify( key_str, "90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1" );
6487  unhexify( iv_str, "00000000000000000000000000000000" );
6488  unhexify( src_str, "00000000000000000000000000000000" );
6489 
6490  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6491  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6492  hexify( dst_str, output, 16 );
6493 
6494  fct_chk( strcmp( (char *) dst_str, "798c7c005dee432b2c8ea5dfa381ecc3" ) == 0 );
6495  }
6496  FCT_TEST_END();
6497 #endif /* POLARSSL_CIPHER_MODE_CFB */
6498 
6499 #ifdef POLARSSL_CIPHER_MODE_CFB
6500 
6501  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_7)
6502  {
6503  unsigned char key_str[100];
6504  unsigned char iv_str[100];
6505  unsigned char src_str[100];
6506  unsigned char dst_str[100];
6507  unsigned char output[100];
6508  aes_context ctx;
6509  size_t iv_offset = 0;
6510  int key_len;
6511 
6512  memset(key_str, 0x00, 100);
6513  memset(iv_str, 0x00, 100);
6514  memset(src_str, 0x00, 100);
6515  memset(dst_str, 0x00, 100);
6516  memset(output, 0x00, 100);
6517 
6518  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6519  unhexify( iv_str, "0b24af36193ce4665f2825d7b4749c98" );
6520  unhexify( src_str, "00000000000000000000000000000000" );
6521 
6522  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6523  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6524  hexify( dst_str, output, 16 );
6525 
6526  fct_chk( strcmp( (char *) dst_str, "a9ff75bd7cf6613d3731c77c3b6d0c04" ) == 0 );
6527  }
6528  FCT_TEST_END();
6529 #endif /* POLARSSL_CIPHER_MODE_CFB */
6530 
6531 #ifdef POLARSSL_CIPHER_MODE_CFB
6532 
6533  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_8)
6534  {
6535  unsigned char key_str[100];
6536  unsigned char iv_str[100];
6537  unsigned char src_str[100];
6538  unsigned char dst_str[100];
6539  unsigned char output[100];
6540  aes_context ctx;
6541  size_t iv_offset = 0;
6542  int key_len;
6543 
6544  memset(key_str, 0x00, 100);
6545  memset(iv_str, 0x00, 100);
6546  memset(src_str, 0x00, 100);
6547  memset(dst_str, 0x00, 100);
6548  memset(output, 0x00, 100);
6549 
6550  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6551  unhexify( iv_str, "761c1fe41a18acf20d241650611d90f1" );
6552  unhexify( src_str, "00000000000000000000000000000000" );
6553 
6554  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6555  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6556  hexify( dst_str, output, 16 );
6557 
6558  fct_chk( strcmp( (char *) dst_str, "623a52fcea5d443e48d9181ab32c7421" ) == 0 );
6559  }
6560  FCT_TEST_END();
6561 #endif /* POLARSSL_CIPHER_MODE_CFB */
6562 
6563 #ifdef POLARSSL_CIPHER_MODE_CFB
6564 
6565  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_9)
6566  {
6567  unsigned char key_str[100];
6568  unsigned char iv_str[100];
6569  unsigned char src_str[100];
6570  unsigned char dst_str[100];
6571  unsigned char output[100];
6572  aes_context ctx;
6573  size_t iv_offset = 0;
6574  int key_len;
6575 
6576  memset(key_str, 0x00, 100);
6577  memset(iv_str, 0x00, 100);
6578  memset(src_str, 0x00, 100);
6579  memset(dst_str, 0x00, 100);
6580  memset(output, 0x00, 100);
6581 
6582  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6583  unhexify( iv_str, "8a560769d605868ad80d819bdba03771" );
6584  unhexify( src_str, "00000000000000000000000000000000" );
6585 
6586  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6587  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6588  hexify( dst_str, output, 16 );
6589 
6590  fct_chk( strcmp( (char *) dst_str, "38f2c7ae10612415d27ca190d27da8b4" ) == 0 );
6591  }
6592  FCT_TEST_END();
6593 #endif /* POLARSSL_CIPHER_MODE_CFB */
6594 
6595 #ifdef POLARSSL_CIPHER_MODE_CFB
6596 
6597  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_10)
6598  {
6599  unsigned char key_str[100];
6600  unsigned char iv_str[100];
6601  unsigned char src_str[100];
6602  unsigned char dst_str[100];
6603  unsigned char output[100];
6604  aes_context ctx;
6605  size_t iv_offset = 0;
6606  int key_len;
6607 
6608  memset(key_str, 0x00, 100);
6609  memset(iv_str, 0x00, 100);
6610  memset(src_str, 0x00, 100);
6611  memset(dst_str, 0x00, 100);
6612  memset(output, 0x00, 100);
6613 
6614  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6615  unhexify( iv_str, "ffffffffffffffffffffffffe0000000" );
6616  unhexify( src_str, "00000000000000000000000000000000" );
6617 
6618  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6619  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6620  hexify( dst_str, output, 16 );
6621 
6622  fct_chk( strcmp( (char *) dst_str, "2be1fae5048a25582a679ca10905eb80" ) == 0 );
6623  }
6624  FCT_TEST_END();
6625 #endif /* POLARSSL_CIPHER_MODE_CFB */
6626 
6627 #ifdef POLARSSL_CIPHER_MODE_CFB
6628 
6629  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_11)
6630  {
6631  unsigned char key_str[100];
6632  unsigned char iv_str[100];
6633  unsigned char src_str[100];
6634  unsigned char dst_str[100];
6635  unsigned char output[100];
6636  aes_context ctx;
6637  size_t iv_offset = 0;
6638  int key_len;
6639 
6640  memset(key_str, 0x00, 100);
6641  memset(iv_str, 0x00, 100);
6642  memset(src_str, 0x00, 100);
6643  memset(dst_str, 0x00, 100);
6644  memset(output, 0x00, 100);
6645 
6646  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6647  unhexify( iv_str, "fffffffffffffffffffffffff0000000" );
6648  unhexify( src_str, "00000000000000000000000000000000" );
6649 
6650  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6651  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6652  hexify( dst_str, output, 16 );
6653 
6654  fct_chk( strcmp( (char *) dst_str, "da86f292c6f41ea34fb2068df75ecc29" ) == 0 );
6655  }
6656  FCT_TEST_END();
6657 #endif /* POLARSSL_CIPHER_MODE_CFB */
6658 
6659 #ifdef POLARSSL_CIPHER_MODE_CFB
6660 
6661  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_12)
6662  {
6663  unsigned char key_str[100];
6664  unsigned char iv_str[100];
6665  unsigned char src_str[100];
6666  unsigned char dst_str[100];
6667  unsigned char output[100];
6668  aes_context ctx;
6669  size_t iv_offset = 0;
6670  int key_len;
6671 
6672  memset(key_str, 0x00, 100);
6673  memset(iv_str, 0x00, 100);
6674  memset(src_str, 0x00, 100);
6675  memset(dst_str, 0x00, 100);
6676  memset(output, 0x00, 100);
6677 
6678  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6679  unhexify( iv_str, "fffffffffffffffffffffffff8000000" );
6680  unhexify( src_str, "00000000000000000000000000000000" );
6681 
6682  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6683  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6684  hexify( dst_str, output, 16 );
6685 
6686  fct_chk( strcmp( (char *) dst_str, "220df19f85d69b1b562fa69a3c5beca5" ) == 0 );
6687  }
6688  FCT_TEST_END();
6689 #endif /* POLARSSL_CIPHER_MODE_CFB */
6690 
6691 #ifdef POLARSSL_CIPHER_MODE_CFB
6692 
6693  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_1)
6694  {
6695  unsigned char key_str[100];
6696  unsigned char iv_str[100];
6697  unsigned char src_str[100];
6698  unsigned char dst_str[100];
6699  unsigned char output[100];
6700  aes_context ctx;
6701  size_t iv_offset = 0;
6702  int key_len;
6703 
6704  memset(key_str, 0x00, 100);
6705  memset(iv_str, 0x00, 100);
6706  memset(src_str, 0x00, 100);
6707  memset(dst_str, 0x00, 100);
6708  memset(output, 0x00, 100);
6709 
6710  key_len = unhexify( key_str, "ffffffffff800000000000000000000000000000000000000000000000000000" );
6711  unhexify( iv_str, "00000000000000000000000000000000" );
6712  unhexify( src_str, "be66cfea2fecd6bf0ec7b4352c99bcaa" );
6713 
6714  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6715  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6716  hexify( dst_str, output, 16 );
6717 
6718  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6719  }
6720  FCT_TEST_END();
6721 #endif /* POLARSSL_CIPHER_MODE_CFB */
6722 
6723 #ifdef POLARSSL_CIPHER_MODE_CFB
6724 
6725  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_2)
6726  {
6727  unsigned char key_str[100];
6728  unsigned char iv_str[100];
6729  unsigned char src_str[100];
6730  unsigned char dst_str[100];
6731  unsigned char output[100];
6732  aes_context ctx;
6733  size_t iv_offset = 0;
6734  int key_len;
6735 
6736  memset(key_str, 0x00, 100);
6737  memset(iv_str, 0x00, 100);
6738  memset(src_str, 0x00, 100);
6739  memset(dst_str, 0x00, 100);
6740  memset(output, 0x00, 100);
6741 
6742  key_len = unhexify( key_str, "ffffffffffc00000000000000000000000000000000000000000000000000000" );
6743  unhexify( iv_str, "00000000000000000000000000000000" );
6744  unhexify( src_str, "df31144f87a2ef523facdcf21a427804" );
6745 
6746  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6747  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6748  hexify( dst_str, output, 16 );
6749 
6750  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6751  }
6752  FCT_TEST_END();
6753 #endif /* POLARSSL_CIPHER_MODE_CFB */
6754 
6755 #ifdef POLARSSL_CIPHER_MODE_CFB
6756 
6757  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_3)
6758  {
6759  unsigned char key_str[100];
6760  unsigned char iv_str[100];
6761  unsigned char src_str[100];
6762  unsigned char dst_str[100];
6763  unsigned char output[100];
6764  aes_context ctx;
6765  size_t iv_offset = 0;
6766  int key_len;
6767 
6768  memset(key_str, 0x00, 100);
6769  memset(iv_str, 0x00, 100);
6770  memset(src_str, 0x00, 100);
6771  memset(dst_str, 0x00, 100);
6772  memset(output, 0x00, 100);
6773 
6774  key_len = unhexify( key_str, "ffffffffffe00000000000000000000000000000000000000000000000000000" );
6775  unhexify( iv_str, "00000000000000000000000000000000" );
6776  unhexify( src_str, "b5bb0f5629fb6aae5e1839a3c3625d63" );
6777 
6778  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6779  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6780  hexify( dst_str, output, 16 );
6781 
6782  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6783  }
6784  FCT_TEST_END();
6785 #endif /* POLARSSL_CIPHER_MODE_CFB */
6786 
6787 #ifdef POLARSSL_CIPHER_MODE_CFB
6788 
6789  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_4)
6790  {
6791  unsigned char key_str[100];
6792  unsigned char iv_str[100];
6793  unsigned char src_str[100];
6794  unsigned char dst_str[100];
6795  unsigned char output[100];
6796  aes_context ctx;
6797  size_t iv_offset = 0;
6798  int key_len;
6799 
6800  memset(key_str, 0x00, 100);
6801  memset(iv_str, 0x00, 100);
6802  memset(src_str, 0x00, 100);
6803  memset(dst_str, 0x00, 100);
6804  memset(output, 0x00, 100);
6805 
6806  key_len = unhexify( key_str, "1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9" );
6807  unhexify( iv_str, "00000000000000000000000000000000" );
6808  unhexify( src_str, "531c2c38344578b84d50b3c917bbb6e1" );
6809 
6810  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6811  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6812  hexify( dst_str, output, 16 );
6813 
6814  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6815  }
6816  FCT_TEST_END();
6817 #endif /* POLARSSL_CIPHER_MODE_CFB */
6818 
6819 #ifdef POLARSSL_CIPHER_MODE_CFB
6820 
6821  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_5)
6822  {
6823  unsigned char key_str[100];
6824  unsigned char iv_str[100];
6825  unsigned char src_str[100];
6826  unsigned char dst_str[100];
6827  unsigned char output[100];
6828  aes_context ctx;
6829  size_t iv_offset = 0;
6830  int key_len;
6831 
6832  memset(key_str, 0x00, 100);
6833  memset(iv_str, 0x00, 100);
6834  memset(src_str, 0x00, 100);
6835  memset(dst_str, 0x00, 100);
6836  memset(output, 0x00, 100);
6837 
6838  key_len = unhexify( key_str, "dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf" );
6839  unhexify( iv_str, "00000000000000000000000000000000" );
6840  unhexify( src_str, "fc6aec906323480005c58e7e1ab004ad" );
6841 
6842  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6843  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6844  hexify( dst_str, output, 16 );
6845 
6846  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6847  }
6848  FCT_TEST_END();
6849 #endif /* POLARSSL_CIPHER_MODE_CFB */
6850 
6851 #ifdef POLARSSL_CIPHER_MODE_CFB
6852 
6853  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_6)
6854  {
6855  unsigned char key_str[100];
6856  unsigned char iv_str[100];
6857  unsigned char src_str[100];
6858  unsigned char dst_str[100];
6859  unsigned char output[100];
6860  aes_context ctx;
6861  size_t iv_offset = 0;
6862  int key_len;
6863 
6864  memset(key_str, 0x00, 100);
6865  memset(iv_str, 0x00, 100);
6866  memset(src_str, 0x00, 100);
6867  memset(dst_str, 0x00, 100);
6868  memset(output, 0x00, 100);
6869 
6870  key_len = unhexify( key_str, "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" );
6871  unhexify( iv_str, "00000000000000000000000000000000" );
6872  unhexify( src_str, "a3944b95ca0b52043584ef02151926a8" );
6873 
6874  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6875  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6876  hexify( dst_str, output, 16 );
6877 
6878  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6879  }
6880  FCT_TEST_END();
6881 #endif /* POLARSSL_CIPHER_MODE_CFB */
6882 
6883 #ifdef POLARSSL_CIPHER_MODE_CFB
6884 
6885  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_7)
6886  {
6887  unsigned char key_str[100];
6888  unsigned char iv_str[100];
6889  unsigned char src_str[100];
6890  unsigned char dst_str[100];
6891  unsigned char output[100];
6892  aes_context ctx;
6893  size_t iv_offset = 0;
6894  int key_len;
6895 
6896  memset(key_str, 0x00, 100);
6897  memset(iv_str, 0x00, 100);
6898  memset(src_str, 0x00, 100);
6899  memset(dst_str, 0x00, 100);
6900  memset(output, 0x00, 100);
6901 
6902  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6903  unhexify( iv_str, "761c1fe41a18acf20d241650611d90f1" );
6904  unhexify( src_str, "623a52fcea5d443e48d9181ab32c7421" );
6905 
6906  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6907  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6908  hexify( dst_str, output, 16 );
6909 
6910  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6911  }
6912  FCT_TEST_END();
6913 #endif /* POLARSSL_CIPHER_MODE_CFB */
6914 
6915 #ifdef POLARSSL_CIPHER_MODE_CFB
6916 
6917  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_8)
6918  {
6919  unsigned char key_str[100];
6920  unsigned char iv_str[100];
6921  unsigned char src_str[100];
6922  unsigned char dst_str[100];
6923  unsigned char output[100];
6924  aes_context ctx;
6925  size_t iv_offset = 0;
6926  int key_len;
6927 
6928  memset(key_str, 0x00, 100);
6929  memset(iv_str, 0x00, 100);
6930  memset(src_str, 0x00, 100);
6931  memset(dst_str, 0x00, 100);
6932  memset(output, 0x00, 100);
6933 
6934  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6935  unhexify( iv_str, "8a560769d605868ad80d819bdba03771" );
6936  unhexify( src_str, "38f2c7ae10612415d27ca190d27da8b4" );
6937 
6938  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6939  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6940  hexify( dst_str, output, 16 );
6941 
6942  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6943  }
6944  FCT_TEST_END();
6945 #endif /* POLARSSL_CIPHER_MODE_CFB */
6946 
6947 #ifdef POLARSSL_CIPHER_MODE_CFB
6948 
6949  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_9)
6950  {
6951  unsigned char key_str[100];
6952  unsigned char iv_str[100];
6953  unsigned char src_str[100];
6954  unsigned char dst_str[100];
6955  unsigned char output[100];
6956  aes_context ctx;
6957  size_t iv_offset = 0;
6958  int key_len;
6959 
6960  memset(key_str, 0x00, 100);
6961  memset(iv_str, 0x00, 100);
6962  memset(src_str, 0x00, 100);
6963  memset(dst_str, 0x00, 100);
6964  memset(output, 0x00, 100);
6965 
6966  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6967  unhexify( iv_str, "91fbef2d15a97816060bee1feaa49afe" );
6968  unhexify( src_str, "1bc704f1bce135ceb810341b216d7abe" );
6969 
6970  aes_setkey_enc( &ctx, key_str, key_len * 8 );
6971  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
6972  hexify( dst_str, output, 16 );
6973 
6974  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
6975  }
6976  FCT_TEST_END();
6977 #endif /* POLARSSL_CIPHER_MODE_CFB */
6978 
6979 #ifdef POLARSSL_CIPHER_MODE_CFB
6980 
6981  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_10)
6982  {
6983  unsigned char key_str[100];
6984  unsigned char iv_str[100];
6985  unsigned char src_str[100];
6986  unsigned char dst_str[100];
6987  unsigned char output[100];
6988  aes_context ctx;
6989  size_t iv_offset = 0;
6990  int key_len;
6991 
6992  memset(key_str, 0x00, 100);
6993  memset(iv_str, 0x00, 100);
6994  memset(src_str, 0x00, 100);
6995  memset(dst_str, 0x00, 100);
6996  memset(output, 0x00, 100);
6997 
6998  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
6999  unhexify( iv_str, "e0000000000000000000000000000000" );
7000  unhexify( src_str, "9b80eefb7ebe2d2b16247aa0efc72f5d" );
7001 
7002  aes_setkey_enc( &ctx, key_str, key_len * 8 );
7003  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
7004  hexify( dst_str, output, 16 );
7005 
7006  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
7007  }
7008  FCT_TEST_END();
7009 #endif /* POLARSSL_CIPHER_MODE_CFB */
7010 
7011 #ifdef POLARSSL_CIPHER_MODE_CFB
7012 
7013  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_11)
7014  {
7015  unsigned char key_str[100];
7016  unsigned char iv_str[100];
7017  unsigned char src_str[100];
7018  unsigned char dst_str[100];
7019  unsigned char output[100];
7020  aes_context ctx;
7021  size_t iv_offset = 0;
7022  int key_len;
7023 
7024  memset(key_str, 0x00, 100);
7025  memset(iv_str, 0x00, 100);
7026  memset(src_str, 0x00, 100);
7027  memset(dst_str, 0x00, 100);
7028  memset(output, 0x00, 100);
7029 
7030  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
7031  unhexify( iv_str, "f0000000000000000000000000000000" );
7032  unhexify( src_str, "7f2c5ece07a98d8bee13c51177395ff7" );
7033 
7034  aes_setkey_enc( &ctx, key_str, key_len * 8 );
7035  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
7036  hexify( dst_str, output, 16 );
7037 
7038  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
7039  }
7040  FCT_TEST_END();
7041 #endif /* POLARSSL_CIPHER_MODE_CFB */
7042 
7043 #ifdef POLARSSL_CIPHER_MODE_CFB
7044 
7045  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_12)
7046  {
7047  unsigned char key_str[100];
7048  unsigned char iv_str[100];
7049  unsigned char src_str[100];
7050  unsigned char dst_str[100];
7051  unsigned char output[100];
7052  aes_context ctx;
7053  size_t iv_offset = 0;
7054  int key_len;
7055 
7056  memset(key_str, 0x00, 100);
7057  memset(iv_str, 0x00, 100);
7058  memset(src_str, 0x00, 100);
7059  memset(dst_str, 0x00, 100);
7060  memset(output, 0x00, 100);
7061 
7062  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
7063  unhexify( iv_str, "f8000000000000000000000000000000" );
7064  unhexify( src_str, "7818d800dcf6f4be1e0e94f403d1e4c2" );
7065 
7066  aes_setkey_enc( &ctx, key_str, key_len * 8 );
7067  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
7068  hexify( dst_str, output, 16 );
7069 
7070  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
7071  }
7072  FCT_TEST_END();
7073 #endif /* POLARSSL_CIPHER_MODE_CFB */
7074 
7075 
7076  FCT_TEST_BGN(aes_ecb_encrypt_invalid_keylength)
7077  {
7078  unsigned char key_str[100];
7079  unsigned char src_str[100];
7080  unsigned char dst_str[100];
7081  unsigned char output[100];
7082  aes_context ctx;
7083  int key_len;
7084 
7085  memset(key_str, 0x00, 100);
7086  memset(src_str, 0x00, 100);
7087  memset(dst_str, 0x00, 100);
7088  memset(output, 0x00, 100);
7089 
7090  key_len = unhexify( key_str, "000000000000000000000000000000" );
7091  unhexify( src_str, "f34481ec3cc627bacd5dc3fb08f273e6" );
7092 
7093  fct_chk( aes_setkey_enc( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_AES_INVALID_KEY_LENGTH );
7095  {
7096  fct_chk( aes_crypt_ecb( &ctx, AES_ENCRYPT, src_str, output ) == 0 );
7097  hexify( dst_str, output, 16 );
7098 
7099  fct_chk( strcmp( (char *) dst_str, "0336763e966d92595a567cc9ce537f5e" ) == 0 );
7100  }
7101  }
7102  FCT_TEST_END();
7103 
7104 
7105  FCT_TEST_BGN(aes_ecb_decrypt_invalid_keylength)
7106  {
7107  unsigned char key_str[100];
7108  unsigned char src_str[100];
7109  unsigned char dst_str[100];
7110  unsigned char output[100];
7111  aes_context ctx;
7112  int key_len;
7113 
7114  memset(key_str, 0x00, 100);
7115  memset(src_str, 0x00, 100);
7116  memset(dst_str, 0x00, 100);
7117  memset(output, 0x00, 100);
7118 
7119  key_len = unhexify( key_str, "000000000000000000000000000000" );
7120  unhexify( src_str, "f34481ec3cc627bacd5dc3fb08f273e6" );
7121 
7122  fct_chk( aes_setkey_dec( &ctx, key_str, key_len * 8 ) == POLARSSL_ERR_AES_INVALID_KEY_LENGTH );
7124  {
7125  fct_chk( aes_crypt_ecb( &ctx, AES_DECRYPT, src_str, output ) == 0 );
7126  hexify( dst_str, output, 16 );
7127 
7128  fct_chk( strcmp( (char *) dst_str, "0336763e966d92595a567cc9ce537f5e" ) == 0 );
7129  }
7130  }
7131  FCT_TEST_END();
7132 
7133 
7134  FCT_TEST_BGN(aes_256_cbc_encrypt_invalid_input_length)
7135  {
7136  unsigned char key_str[100];
7137  unsigned char iv_str[100];
7138  unsigned char src_str[100];
7139  unsigned char dst_str[100];
7140  unsigned char output[100];
7141  aes_context ctx;
7142  int key_len, data_len;
7143 
7144  memset(key_str, 0x00, 100);
7145  memset(iv_str, 0x00, 100);
7146  memset(src_str, 0x00, 100);
7147  memset(dst_str, 0x00, 100);
7148  memset(output, 0x00, 100);
7149 
7150  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
7151  unhexify( iv_str, "00000000000000000000000000000000" );
7152  data_len = unhexify( src_str, "ffffffffffffffe000000000000000" );
7153 
7154  aes_setkey_enc( &ctx, key_str, key_len * 8 );
7155  fct_chk( aes_crypt_cbc( &ctx, AES_ENCRYPT, data_len, iv_str, src_str, output ) == POLARSSL_ERR_AES_INVALID_INPUT_LENGTH );
7157  {
7158  hexify( dst_str, output, data_len );
7159 
7160  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
7161  }
7162  }
7163  FCT_TEST_END();
7164 
7165 
7166  FCT_TEST_BGN(aes_256_cbc_decrypt_invalid_input_length)
7167  {
7168  unsigned char key_str[100];
7169  unsigned char iv_str[100];
7170  unsigned char src_str[100];
7171  unsigned char dst_str[100];
7172  unsigned char output[100];
7173  aes_context ctx;
7174  int key_len, data_len;
7175 
7176  memset(key_str, 0x00, 100);
7177  memset(iv_str, 0x00, 100);
7178  memset(src_str, 0x00, 100);
7179  memset(dst_str, 0x00, 100);
7180  memset(output, 0x00, 100);
7181 
7182  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
7183  unhexify( iv_str, "00000000000000000000000000000000" );
7184  data_len = unhexify( src_str, "623a52fcea5d443e48d9181ab32c74" );
7185 
7186  aes_setkey_dec( &ctx, key_str, key_len * 8 );
7187  fct_chk( aes_crypt_cbc( &ctx, AES_DECRYPT, data_len, iv_str, src_str, output ) == POLARSSL_ERR_AES_INVALID_INPUT_LENGTH );
7189  {
7190  hexify( dst_str, output, data_len );
7191 
7192  fct_chk( strcmp( (char *) dst_str, "" ) == 0 );
7193  }
7194  }
7195  FCT_TEST_END();
7196 
7197 #ifdef POLARSSL_SELF_TEST
7198 
7199  FCT_TEST_BGN(aes_selftest)
7200  {
7201  fct_chk( aes_self_test( 0 ) == 0 );
7202  }
7203  FCT_TEST_END();
7204 #endif /* POLARSSL_SELF_TEST */
7205 
7206  }
7207  FCT_SUITE_END();
7208 
7209 #endif /* POLARSSL_AES_C */
7210 
7211 }
7212 FCT_END();
7213