PolarSSL v1.2.8
test_suite_aes.cfb.c
Go to the documentation of this file.
1 #include "fct.h"
2 #include <polarssl/config.h>
3 
4 #include <polarssl/aes.h>
5 
6 #ifdef _MSC_VER
7 #include <basetsd.h>
8 typedef UINT32 uint32_t;
9 #else
10 #include <inttypes.h>
11 #endif
12 
13 /*
14  * 32-bit integer manipulation macros (big endian)
15  */
16 #ifndef GET_UINT32_BE
17 #define GET_UINT32_BE(n,b,i) \
18 { \
19  (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
20  | ( (uint32_t) (b)[(i) + 1] << 16 ) \
21  | ( (uint32_t) (b)[(i) + 2] << 8 ) \
22  | ( (uint32_t) (b)[(i) + 3] ); \
23 }
24 #endif
25 
26 #ifndef PUT_UINT32_BE
27 #define PUT_UINT32_BE(n,b,i) \
28 { \
29  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
30  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
31  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
32  (b)[(i) + 3] = (unsigned char) ( (n) ); \
33 }
34 #endif
35 
36 int unhexify(unsigned char *obuf, const char *ibuf)
37 {
38  unsigned char c, c2;
39  int len = strlen(ibuf) / 2;
40  assert(!(strlen(ibuf) %1)); // must be even number of bytes
41 
42  while (*ibuf != 0)
43  {
44  c = *ibuf++;
45  if( c >= '0' && c <= '9' )
46  c -= '0';
47  else if( c >= 'a' && c <= 'f' )
48  c -= 'a' - 10;
49  else if( c >= 'A' && c <= 'F' )
50  c -= 'A' - 10;
51  else
52  assert( 0 );
53 
54  c2 = *ibuf++;
55  if( c2 >= '0' && c2 <= '9' )
56  c2 -= '0';
57  else if( c2 >= 'a' && c2 <= 'f' )
58  c2 -= 'a' - 10;
59  else if( c2 >= 'A' && c2 <= 'F' )
60  c2 -= 'A' - 10;
61  else
62  assert( 0 );
63 
64  *obuf++ = ( c << 4 ) | c2;
65  }
66 
67  return len;
68 }
69 
70 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
71 {
72  unsigned char l, h;
73 
74  while (len != 0)
75  {
76  h = (*ibuf) / 16;
77  l = (*ibuf) % 16;
78 
79  if( h < 10 )
80  *obuf++ = '0' + h;
81  else
82  *obuf++ = 'a' + h - 10;
83 
84  if( l < 10 )
85  *obuf++ = '0' + l;
86  else
87  *obuf++ = 'a' + l - 10;
88 
89  ++ibuf;
90  len--;
91  }
92 }
93 
103 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
104 {
105  size_t i;
106 
107  if( rng_state != NULL )
108  rng_state = NULL;
109 
110  for( i = 0; i < len; ++i )
111  output[i] = rand();
112 
113  return( 0 );
114 }
115 
121 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
122 {
123  if( rng_state != NULL )
124  rng_state = NULL;
125 
126  memset( output, 0, len );
127 
128  return( 0 );
129 }
130 
131 typedef struct
132 {
133  unsigned char *buf;
134  size_t length;
135 } rnd_buf_info;
136 
148 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
149 {
150  rnd_buf_info *info = (rnd_buf_info *) rng_state;
151  size_t use_len;
152 
153  if( rng_state == NULL )
154  return( rnd_std_rand( NULL, output, len ) );
155 
156  use_len = len;
157  if( len > info->length )
158  use_len = info->length;
159 
160  if( use_len )
161  {
162  memcpy( output, info->buf, use_len );
163  info->buf += use_len;
164  info->length -= use_len;
165  }
166 
167  if( len - use_len > 0 )
168  return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
169 
170  return( 0 );
171 }
172 
180 typedef struct
181 {
182  uint32_t key[16];
183  uint32_t v0, v1;
185 
194 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
195 {
196  rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
197  uint32_t i, *k, sum, delta=0x9E3779B9;
198  unsigned char result[4];
199 
200  if( rng_state == NULL )
201  return( rnd_std_rand( NULL, output, len ) );
202 
203  k = info->key;
204 
205  while( len > 0 )
206  {
207  size_t use_len = ( len > 4 ) ? 4 : len;
208  sum = 0;
209 
210  for( i = 0; i < 32; i++ )
211  {
212  info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
213  sum += delta;
214  info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
215  }
216 
217  PUT_UINT32_BE( info->v0, result, 0 );
218  memcpy( output, result, use_len );
219  len -= use_len;
220  }
221 
222  return( 0 );
223 }
224 
225 
227 {
228 #ifdef POLARSSL_AES_C
229 
230 
231  FCT_SUITE_BGN(test_suite_aes)
232  {
233 #ifdef POLARSSL_CIPHER_MODE_CFB
234 
235  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_1)
236  {
237  unsigned char key_str[100];
238  unsigned char iv_str[100];
239  unsigned char src_str[100];
240  unsigned char dst_str[100];
241  unsigned char output[100];
242  aes_context ctx;
243  size_t iv_offset = 0;
244  int key_len;
245 
246  memset(key_str, 0x00, 100);
247  memset(iv_str, 0x00, 100);
248  memset(src_str, 0x00, 100);
249  memset(dst_str, 0x00, 100);
250  memset(output, 0x00, 100);
251 
252  key_len = unhexify( key_str, "f0000000000000000000000000000000" );
253  unhexify( iv_str, "00000000000000000000000000000000" );
254  unhexify( src_str, "00000000000000000000000000000000" );
255 
256  aes_setkey_enc( &ctx, key_str, key_len * 8 );
257  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
258  hexify( dst_str, output, 16 );
259 
260  fct_chk( strcmp( (char *) dst_str, "970014d634e2b7650777e8e84d03ccd8" ) == 0 );
261  }
262  FCT_TEST_END();
263 #endif /* POLARSSL_CIPHER_MODE_CFB */
264 
265 #ifdef POLARSSL_CIPHER_MODE_CFB
266 
267  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_2)
268  {
269  unsigned char key_str[100];
270  unsigned char iv_str[100];
271  unsigned char src_str[100];
272  unsigned char dst_str[100];
273  unsigned char output[100];
274  aes_context ctx;
275  size_t iv_offset = 0;
276  int key_len;
277 
278  memset(key_str, 0x00, 100);
279  memset(iv_str, 0x00, 100);
280  memset(src_str, 0x00, 100);
281  memset(dst_str, 0x00, 100);
282  memset(output, 0x00, 100);
283 
284  key_len = unhexify( key_str, "f8000000000000000000000000000000" );
285  unhexify( iv_str, "00000000000000000000000000000000" );
286  unhexify( src_str, "00000000000000000000000000000000" );
287 
288  aes_setkey_enc( &ctx, key_str, key_len * 8 );
289  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
290  hexify( dst_str, output, 16 );
291 
292  fct_chk( strcmp( (char *) dst_str, "f17e79aed0db7e279e955b5f493875a7" ) == 0 );
293  }
294  FCT_TEST_END();
295 #endif /* POLARSSL_CIPHER_MODE_CFB */
296 
297 #ifdef POLARSSL_CIPHER_MODE_CFB
298 
299  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_3)
300  {
301  unsigned char key_str[100];
302  unsigned char iv_str[100];
303  unsigned char src_str[100];
304  unsigned char dst_str[100];
305  unsigned char output[100];
306  aes_context ctx;
307  size_t iv_offset = 0;
308  int key_len;
309 
310  memset(key_str, 0x00, 100);
311  memset(iv_str, 0x00, 100);
312  memset(src_str, 0x00, 100);
313  memset(dst_str, 0x00, 100);
314  memset(output, 0x00, 100);
315 
316  key_len = unhexify( key_str, "fc000000000000000000000000000000" );
317  unhexify( iv_str, "00000000000000000000000000000000" );
318  unhexify( src_str, "00000000000000000000000000000000" );
319 
320  aes_setkey_enc( &ctx, key_str, key_len * 8 );
321  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
322  hexify( dst_str, output, 16 );
323 
324  fct_chk( strcmp( (char *) dst_str, "9ed5a75136a940d0963da379db4af26a" ) == 0 );
325  }
326  FCT_TEST_END();
327 #endif /* POLARSSL_CIPHER_MODE_CFB */
328 
329 #ifdef POLARSSL_CIPHER_MODE_CFB
330 
331  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_4)
332  {
333  unsigned char key_str[100];
334  unsigned char iv_str[100];
335  unsigned char src_str[100];
336  unsigned char dst_str[100];
337  unsigned char output[100];
338  aes_context ctx;
339  size_t iv_offset = 0;
340  int key_len;
341 
342  memset(key_str, 0x00, 100);
343  memset(iv_str, 0x00, 100);
344  memset(src_str, 0x00, 100);
345  memset(dst_str, 0x00, 100);
346  memset(output, 0x00, 100);
347 
348  key_len = unhexify( key_str, "64cf9c7abc50b888af65f49d521944b2" );
349  unhexify( iv_str, "00000000000000000000000000000000" );
350  unhexify( src_str, "00000000000000000000000000000000" );
351 
352  aes_setkey_enc( &ctx, key_str, key_len * 8 );
353  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
354  hexify( dst_str, output, 16 );
355 
356  fct_chk( strcmp( (char *) dst_str, "f7efc89d5dba578104016ce5ad659c05" ) == 0 );
357  }
358  FCT_TEST_END();
359 #endif /* POLARSSL_CIPHER_MODE_CFB */
360 
361 #ifdef POLARSSL_CIPHER_MODE_CFB
362 
363  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_5)
364  {
365  unsigned char key_str[100];
366  unsigned char iv_str[100];
367  unsigned char src_str[100];
368  unsigned char dst_str[100];
369  unsigned char output[100];
370  aes_context ctx;
371  size_t iv_offset = 0;
372  int key_len;
373 
374  memset(key_str, 0x00, 100);
375  memset(iv_str, 0x00, 100);
376  memset(src_str, 0x00, 100);
377  memset(dst_str, 0x00, 100);
378  memset(output, 0x00, 100);
379 
380  key_len = unhexify( key_str, "47d6742eefcc0465dc96355e851b64d9" );
381  unhexify( iv_str, "00000000000000000000000000000000" );
382  unhexify( src_str, "00000000000000000000000000000000" );
383 
384  aes_setkey_enc( &ctx, key_str, key_len * 8 );
385  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
386  hexify( dst_str, output, 16 );
387 
388  fct_chk( strcmp( (char *) dst_str, "0306194f666d183624aa230a8b264ae7" ) == 0 );
389  }
390  FCT_TEST_END();
391 #endif /* POLARSSL_CIPHER_MODE_CFB */
392 
393 #ifdef POLARSSL_CIPHER_MODE_CFB
394 
395  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_6)
396  {
397  unsigned char key_str[100];
398  unsigned char iv_str[100];
399  unsigned char src_str[100];
400  unsigned char dst_str[100];
401  unsigned char output[100];
402  aes_context ctx;
403  size_t iv_offset = 0;
404  int key_len;
405 
406  memset(key_str, 0x00, 100);
407  memset(iv_str, 0x00, 100);
408  memset(src_str, 0x00, 100);
409  memset(dst_str, 0x00, 100);
410  memset(output, 0x00, 100);
411 
412  key_len = unhexify( key_str, "3eb39790678c56bee34bbcdeccf6cdb5" );
413  unhexify( iv_str, "00000000000000000000000000000000" );
414  unhexify( src_str, "00000000000000000000000000000000" );
415 
416  aes_setkey_enc( &ctx, key_str, key_len * 8 );
417  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
418  hexify( dst_str, output, 16 );
419 
420  fct_chk( strcmp( (char *) dst_str, "858075d536d79ccee571f7d7204b1f67" ) == 0 );
421  }
422  FCT_TEST_END();
423 #endif /* POLARSSL_CIPHER_MODE_CFB */
424 
425 #ifdef POLARSSL_CIPHER_MODE_CFB
426 
427  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_7)
428  {
429  unsigned char key_str[100];
430  unsigned char iv_str[100];
431  unsigned char src_str[100];
432  unsigned char dst_str[100];
433  unsigned char output[100];
434  aes_context ctx;
435  size_t iv_offset = 0;
436  int key_len;
437 
438  memset(key_str, 0x00, 100);
439  memset(iv_str, 0x00, 100);
440  memset(src_str, 0x00, 100);
441  memset(dst_str, 0x00, 100);
442  memset(output, 0x00, 100);
443 
444  key_len = unhexify( key_str, "00000000000000000000000000000000" );
445  unhexify( iv_str, "6a118a874519e64e9963798a503f1d35" );
446  unhexify( src_str, "00000000000000000000000000000000" );
447 
448  aes_setkey_enc( &ctx, key_str, key_len * 8 );
449  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
450  hexify( dst_str, output, 16 );
451 
452  fct_chk( strcmp( (char *) dst_str, "dc43be40be0e53712f7e2bf5ca707209" ) == 0 );
453  }
454  FCT_TEST_END();
455 #endif /* POLARSSL_CIPHER_MODE_CFB */
456 
457 #ifdef POLARSSL_CIPHER_MODE_CFB
458 
459  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_8)
460  {
461  unsigned char key_str[100];
462  unsigned char iv_str[100];
463  unsigned char src_str[100];
464  unsigned char dst_str[100];
465  unsigned char output[100];
466  aes_context ctx;
467  size_t iv_offset = 0;
468  int key_len;
469 
470  memset(key_str, 0x00, 100);
471  memset(iv_str, 0x00, 100);
472  memset(src_str, 0x00, 100);
473  memset(dst_str, 0x00, 100);
474  memset(output, 0x00, 100);
475 
476  key_len = unhexify( key_str, "00000000000000000000000000000000" );
477  unhexify( iv_str, "cb9fceec81286ca3e989bd979b0cb284" );
478  unhexify( src_str, "00000000000000000000000000000000" );
479 
480  aes_setkey_enc( &ctx, key_str, key_len * 8 );
481  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
482  hexify( dst_str, output, 16 );
483 
484  fct_chk( strcmp( (char *) dst_str, "92beedab1895a94faa69b632e5cc47ce" ) == 0 );
485  }
486  FCT_TEST_END();
487 #endif /* POLARSSL_CIPHER_MODE_CFB */
488 
489 #ifdef POLARSSL_CIPHER_MODE_CFB
490 
491  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_9)
492  {
493  unsigned char key_str[100];
494  unsigned char iv_str[100];
495  unsigned char src_str[100];
496  unsigned char dst_str[100];
497  unsigned char output[100];
498  aes_context ctx;
499  size_t iv_offset = 0;
500  int key_len;
501 
502  memset(key_str, 0x00, 100);
503  memset(iv_str, 0x00, 100);
504  memset(src_str, 0x00, 100);
505  memset(dst_str, 0x00, 100);
506  memset(output, 0x00, 100);
507 
508  key_len = unhexify( key_str, "00000000000000000000000000000000" );
509  unhexify( iv_str, "b26aeb1874e47ca8358ff22378f09144" );
510  unhexify( src_str, "00000000000000000000000000000000" );
511 
512  aes_setkey_enc( &ctx, key_str, key_len * 8 );
513  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
514  hexify( dst_str, output, 16 );
515 
516  fct_chk( strcmp( (char *) dst_str, "459264f4798f6a78bacb89c15ed3d601" ) == 0 );
517  }
518  FCT_TEST_END();
519 #endif /* POLARSSL_CIPHER_MODE_CFB */
520 
521 #ifdef POLARSSL_CIPHER_MODE_CFB
522 
523  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_10)
524  {
525  unsigned char key_str[100];
526  unsigned char iv_str[100];
527  unsigned char src_str[100];
528  unsigned char dst_str[100];
529  unsigned char output[100];
530  aes_context ctx;
531  size_t iv_offset = 0;
532  int key_len;
533 
534  memset(key_str, 0x00, 100);
535  memset(iv_str, 0x00, 100);
536  memset(src_str, 0x00, 100);
537  memset(dst_str, 0x00, 100);
538  memset(output, 0x00, 100);
539 
540  key_len = unhexify( key_str, "00000000000000000000000000000000" );
541  unhexify( iv_str, "fffffffffffffffffffffffffffffff0" );
542  unhexify( src_str, "00000000000000000000000000000000" );
543 
544  aes_setkey_enc( &ctx, key_str, key_len * 8 );
545  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
546  hexify( dst_str, output, 16 );
547 
548  fct_chk( strcmp( (char *) dst_str, "f9b0fda0c4a898f5b9e6f661c4ce4d07" ) == 0 );
549  }
550  FCT_TEST_END();
551 #endif /* POLARSSL_CIPHER_MODE_CFB */
552 
553 #ifdef POLARSSL_CIPHER_MODE_CFB
554 
555  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_11)
556  {
557  unsigned char key_str[100];
558  unsigned char iv_str[100];
559  unsigned char src_str[100];
560  unsigned char dst_str[100];
561  unsigned char output[100];
562  aes_context ctx;
563  size_t iv_offset = 0;
564  int key_len;
565 
566  memset(key_str, 0x00, 100);
567  memset(iv_str, 0x00, 100);
568  memset(src_str, 0x00, 100);
569  memset(dst_str, 0x00, 100);
570  memset(output, 0x00, 100);
571 
572  key_len = unhexify( key_str, "00000000000000000000000000000000" );
573  unhexify( iv_str, "fffffffffffffffffffffffffffffff8" );
574  unhexify( src_str, "00000000000000000000000000000000" );
575 
576  aes_setkey_enc( &ctx, key_str, key_len * 8 );
577  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
578  hexify( dst_str, output, 16 );
579 
580  fct_chk( strcmp( (char *) dst_str, "8ade895913685c67c5269f8aae42983e" ) == 0 );
581  }
582  FCT_TEST_END();
583 #endif /* POLARSSL_CIPHER_MODE_CFB */
584 
585 #ifdef POLARSSL_CIPHER_MODE_CFB
586 
587  FCT_TEST_BGN(aes_128_cfb128_encrypt_nist_kat_12)
588  {
589  unsigned char key_str[100];
590  unsigned char iv_str[100];
591  unsigned char src_str[100];
592  unsigned char dst_str[100];
593  unsigned char output[100];
594  aes_context ctx;
595  size_t iv_offset = 0;
596  int key_len;
597 
598  memset(key_str, 0x00, 100);
599  memset(iv_str, 0x00, 100);
600  memset(src_str, 0x00, 100);
601  memset(dst_str, 0x00, 100);
602  memset(output, 0x00, 100);
603 
604  key_len = unhexify( key_str, "00000000000000000000000000000000" );
605  unhexify( iv_str, "fffffffffffffffffffffffffffffffc" );
606  unhexify( src_str, "00000000000000000000000000000000" );
607 
608  aes_setkey_enc( &ctx, key_str, key_len * 8 );
609  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
610  hexify( dst_str, output, 16 );
611 
612  fct_chk( strcmp( (char *) dst_str, "39bde67d5c8ed8a8b1c37eb8fa9f5ac0" ) == 0 );
613  }
614  FCT_TEST_END();
615 #endif /* POLARSSL_CIPHER_MODE_CFB */
616 
617 #ifdef POLARSSL_CIPHER_MODE_CFB
618 
619  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_1)
620  {
621  unsigned char key_str[100];
622  unsigned char iv_str[100];
623  unsigned char src_str[100];
624  unsigned char dst_str[100];
625  unsigned char output[100];
626  aes_context ctx;
627  size_t iv_offset = 0;
628  int key_len;
629 
630  memset(key_str, 0x00, 100);
631  memset(iv_str, 0x00, 100);
632  memset(src_str, 0x00, 100);
633  memset(dst_str, 0x00, 100);
634  memset(output, 0x00, 100);
635 
636  key_len = unhexify( key_str, "fffffffe000000000000000000000000" );
637  unhexify( iv_str, "00000000000000000000000000000000" );
638  unhexify( src_str, "1114bc2028009b923f0b01915ce5e7c4" );
639 
640  aes_setkey_enc( &ctx, key_str, key_len * 8 );
641  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
642  hexify( dst_str, output, 16 );
643 
644  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
645  }
646  FCT_TEST_END();
647 #endif /* POLARSSL_CIPHER_MODE_CFB */
648 
649 #ifdef POLARSSL_CIPHER_MODE_CFB
650 
651  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_2)
652  {
653  unsigned char key_str[100];
654  unsigned char iv_str[100];
655  unsigned char src_str[100];
656  unsigned char dst_str[100];
657  unsigned char output[100];
658  aes_context ctx;
659  size_t iv_offset = 0;
660  int key_len;
661 
662  memset(key_str, 0x00, 100);
663  memset(iv_str, 0x00, 100);
664  memset(src_str, 0x00, 100);
665  memset(dst_str, 0x00, 100);
666  memset(output, 0x00, 100);
667 
668  key_len = unhexify( key_str, "ffffffff000000000000000000000000" );
669  unhexify( iv_str, "00000000000000000000000000000000" );
670  unhexify( src_str, "9c28524a16a1e1c1452971caa8d13476" );
671 
672  aes_setkey_enc( &ctx, key_str, key_len * 8 );
673  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
674  hexify( dst_str, output, 16 );
675 
676  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
677  }
678  FCT_TEST_END();
679 #endif /* POLARSSL_CIPHER_MODE_CFB */
680 
681 #ifdef POLARSSL_CIPHER_MODE_CFB
682 
683  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_3)
684  {
685  unsigned char key_str[100];
686  unsigned char iv_str[100];
687  unsigned char src_str[100];
688  unsigned char dst_str[100];
689  unsigned char output[100];
690  aes_context ctx;
691  size_t iv_offset = 0;
692  int key_len;
693 
694  memset(key_str, 0x00, 100);
695  memset(iv_str, 0x00, 100);
696  memset(src_str, 0x00, 100);
697  memset(dst_str, 0x00, 100);
698  memset(output, 0x00, 100);
699 
700  key_len = unhexify( key_str, "ffffffff800000000000000000000000" );
701  unhexify( iv_str, "00000000000000000000000000000000" );
702  unhexify( src_str, "ed62e16363638360fdd6ad62112794f0" );
703 
704  aes_setkey_enc( &ctx, key_str, key_len * 8 );
705  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
706  hexify( dst_str, output, 16 );
707 
708  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
709  }
710  FCT_TEST_END();
711 #endif /* POLARSSL_CIPHER_MODE_CFB */
712 
713 #ifdef POLARSSL_CIPHER_MODE_CFB
714 
715  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_4)
716  {
717  unsigned char key_str[100];
718  unsigned char iv_str[100];
719  unsigned char src_str[100];
720  unsigned char dst_str[100];
721  unsigned char output[100];
722  aes_context ctx;
723  size_t iv_offset = 0;
724  int key_len;
725 
726  memset(key_str, 0x00, 100);
727  memset(iv_str, 0x00, 100);
728  memset(src_str, 0x00, 100);
729  memset(dst_str, 0x00, 100);
730  memset(output, 0x00, 100);
731 
732  key_len = unhexify( key_str, "3071a2a48fe6cbd04f1a129098e308f8" );
733  unhexify( iv_str, "00000000000000000000000000000000" );
734  unhexify( src_str, "4b98e06d356deb07ebb824e5713f7be3" );
735 
736  aes_setkey_enc( &ctx, key_str, key_len * 8 );
737  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
738  hexify( dst_str, output, 16 );
739 
740  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
741  }
742  FCT_TEST_END();
743 #endif /* POLARSSL_CIPHER_MODE_CFB */
744 
745 #ifdef POLARSSL_CIPHER_MODE_CFB
746 
747  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_5)
748  {
749  unsigned char key_str[100];
750  unsigned char iv_str[100];
751  unsigned char src_str[100];
752  unsigned char dst_str[100];
753  unsigned char output[100];
754  aes_context ctx;
755  size_t iv_offset = 0;
756  int key_len;
757 
758  memset(key_str, 0x00, 100);
759  memset(iv_str, 0x00, 100);
760  memset(src_str, 0x00, 100);
761  memset(dst_str, 0x00, 100);
762  memset(output, 0x00, 100);
763 
764  key_len = unhexify( key_str, "90f42ec0f68385f2ffc5dfc03a654dce" );
765  unhexify( iv_str, "00000000000000000000000000000000" );
766  unhexify( src_str, "7a20a53d460fc9ce0423a7a0764c6cf2" );
767 
768  aes_setkey_enc( &ctx, key_str, key_len * 8 );
769  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
770  hexify( dst_str, output, 16 );
771 
772  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
773  }
774  FCT_TEST_END();
775 #endif /* POLARSSL_CIPHER_MODE_CFB */
776 
777 #ifdef POLARSSL_CIPHER_MODE_CFB
778 
779  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_6)
780  {
781  unsigned char key_str[100];
782  unsigned char iv_str[100];
783  unsigned char src_str[100];
784  unsigned char dst_str[100];
785  unsigned char output[100];
786  aes_context ctx;
787  size_t iv_offset = 0;
788  int key_len;
789 
790  memset(key_str, 0x00, 100);
791  memset(iv_str, 0x00, 100);
792  memset(src_str, 0x00, 100);
793  memset(dst_str, 0x00, 100);
794  memset(output, 0x00, 100);
795 
796  key_len = unhexify( key_str, "febd9a24d8b65c1c787d50a4ed3619a9" );
797  unhexify( iv_str, "00000000000000000000000000000000" );
798  unhexify( src_str, "f4a70d8af877f9b02b4c40df57d45b17" );
799 
800  aes_setkey_enc( &ctx, key_str, key_len * 8 );
801  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
802  hexify( dst_str, output, 16 );
803 
804  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
805  }
806  FCT_TEST_END();
807 #endif /* POLARSSL_CIPHER_MODE_CFB */
808 
809 #ifdef POLARSSL_CIPHER_MODE_CFB
810 
811  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_7)
812  {
813  unsigned char key_str[100];
814  unsigned char iv_str[100];
815  unsigned char src_str[100];
816  unsigned char dst_str[100];
817  unsigned char output[100];
818  aes_context ctx;
819  size_t iv_offset = 0;
820  int key_len;
821 
822  memset(key_str, 0x00, 100);
823  memset(iv_str, 0x00, 100);
824  memset(src_str, 0x00, 100);
825  memset(dst_str, 0x00, 100);
826  memset(output, 0x00, 100);
827 
828  key_len = unhexify( key_str, "00000000000000000000000000000000" );
829  unhexify( iv_str, "f34481ec3cc627bacd5dc3fb08f273e6" );
830  unhexify( src_str, "0336763e966d92595a567cc9ce537f5e" );
831 
832  aes_setkey_enc( &ctx, key_str, key_len * 8 );
833  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
834  hexify( dst_str, output, 16 );
835 
836  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
837  }
838  FCT_TEST_END();
839 #endif /* POLARSSL_CIPHER_MODE_CFB */
840 
841 #ifdef POLARSSL_CIPHER_MODE_CFB
842 
843  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_8)
844  {
845  unsigned char key_str[100];
846  unsigned char iv_str[100];
847  unsigned char src_str[100];
848  unsigned char dst_str[100];
849  unsigned char output[100];
850  aes_context ctx;
851  size_t iv_offset = 0;
852  int key_len;
853 
854  memset(key_str, 0x00, 100);
855  memset(iv_str, 0x00, 100);
856  memset(src_str, 0x00, 100);
857  memset(dst_str, 0x00, 100);
858  memset(output, 0x00, 100);
859 
860  key_len = unhexify( key_str, "00000000000000000000000000000000" );
861  unhexify( iv_str, "9798c4640bad75c7c3227db910174e72" );
862  unhexify( src_str, "a9a1631bf4996954ebc093957b234589" );
863 
864  aes_setkey_enc( &ctx, key_str, key_len * 8 );
865  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
866  hexify( dst_str, output, 16 );
867 
868  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
869  }
870  FCT_TEST_END();
871 #endif /* POLARSSL_CIPHER_MODE_CFB */
872 
873 #ifdef POLARSSL_CIPHER_MODE_CFB
874 
875  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_9)
876  {
877  unsigned char key_str[100];
878  unsigned char iv_str[100];
879  unsigned char src_str[100];
880  unsigned char dst_str[100];
881  unsigned char output[100];
882  aes_context ctx;
883  size_t iv_offset = 0;
884  int key_len;
885 
886  memset(key_str, 0x00, 100);
887  memset(iv_str, 0x00, 100);
888  memset(src_str, 0x00, 100);
889  memset(dst_str, 0x00, 100);
890  memset(output, 0x00, 100);
891 
892  key_len = unhexify( key_str, "00000000000000000000000000000000" );
893  unhexify( iv_str, "96ab5c2ff612d9dfaae8c31f30c42168" );
894  unhexify( src_str, "ff4f8391a6a40ca5b25d23bedd44a597" );
895 
896  aes_setkey_enc( &ctx, key_str, key_len * 8 );
897  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
898  hexify( dst_str, output, 16 );
899 
900  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
901  }
902  FCT_TEST_END();
903 #endif /* POLARSSL_CIPHER_MODE_CFB */
904 
905 #ifdef POLARSSL_CIPHER_MODE_CFB
906 
907  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_10)
908  {
909  unsigned char key_str[100];
910  unsigned char iv_str[100];
911  unsigned char src_str[100];
912  unsigned char dst_str[100];
913  unsigned char output[100];
914  aes_context ctx;
915  size_t iv_offset = 0;
916  int key_len;
917 
918  memset(key_str, 0x00, 100);
919  memset(iv_str, 0x00, 100);
920  memset(src_str, 0x00, 100);
921  memset(dst_str, 0x00, 100);
922  memset(output, 0x00, 100);
923 
924  key_len = unhexify( key_str, "00000000000000000000000000000000" );
925  unhexify( iv_str, "ffffffffffffffff0000000000000000" );
926  unhexify( src_str, "f807c3e7985fe0f5a50e2cdb25c5109e" );
927 
928  aes_setkey_enc( &ctx, key_str, key_len * 8 );
929  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
930  hexify( dst_str, output, 16 );
931 
932  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
933  }
934  FCT_TEST_END();
935 #endif /* POLARSSL_CIPHER_MODE_CFB */
936 
937 #ifdef POLARSSL_CIPHER_MODE_CFB
938 
939  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_11)
940  {
941  unsigned char key_str[100];
942  unsigned char iv_str[100];
943  unsigned char src_str[100];
944  unsigned char dst_str[100];
945  unsigned char output[100];
946  aes_context ctx;
947  size_t iv_offset = 0;
948  int key_len;
949 
950  memset(key_str, 0x00, 100);
951  memset(iv_str, 0x00, 100);
952  memset(src_str, 0x00, 100);
953  memset(dst_str, 0x00, 100);
954  memset(output, 0x00, 100);
955 
956  key_len = unhexify( key_str, "00000000000000000000000000000000" );
957  unhexify( iv_str, "ffffffffffffffff8000000000000000" );
958  unhexify( src_str, "41f992a856fb278b389a62f5d274d7e9" );
959 
960  aes_setkey_enc( &ctx, key_str, key_len * 8 );
961  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
962  hexify( dst_str, output, 16 );
963 
964  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
965  }
966  FCT_TEST_END();
967 #endif /* POLARSSL_CIPHER_MODE_CFB */
968 
969 #ifdef POLARSSL_CIPHER_MODE_CFB
970 
971  FCT_TEST_BGN(aes_128_cfb128_decrypt_nist_kat_12)
972  {
973  unsigned char key_str[100];
974  unsigned char iv_str[100];
975  unsigned char src_str[100];
976  unsigned char dst_str[100];
977  unsigned char output[100];
978  aes_context ctx;
979  size_t iv_offset = 0;
980  int key_len;
981 
982  memset(key_str, 0x00, 100);
983  memset(iv_str, 0x00, 100);
984  memset(src_str, 0x00, 100);
985  memset(dst_str, 0x00, 100);
986  memset(output, 0x00, 100);
987 
988  key_len = unhexify( key_str, "00000000000000000000000000000000" );
989  unhexify( iv_str, "ffffffffffffffffc000000000000000" );
990  unhexify( src_str, "10d3ed7a6fe15ab4d91acbc7d0767ab1" );
991 
992  aes_setkey_enc( &ctx, key_str, key_len * 8 );
993  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
994  hexify( dst_str, output, 16 );
995 
996  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
997  }
998  FCT_TEST_END();
999 #endif /* POLARSSL_CIPHER_MODE_CFB */
1000 
1001 #ifdef POLARSSL_CIPHER_MODE_CFB
1002 
1003  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_1)
1004  {
1005  unsigned char key_str[100];
1006  unsigned char iv_str[100];
1007  unsigned char src_str[100];
1008  unsigned char dst_str[100];
1009  unsigned char output[100];
1010  aes_context ctx;
1011  size_t iv_offset = 0;
1012  int key_len;
1013 
1014  memset(key_str, 0x00, 100);
1015  memset(iv_str, 0x00, 100);
1016  memset(src_str, 0x00, 100);
1017  memset(dst_str, 0x00, 100);
1018  memset(output, 0x00, 100);
1019 
1020  key_len = unhexify( key_str, "fffffffffffffffffffc0000000000000000000000000000" );
1021  unhexify( iv_str, "00000000000000000000000000000000" );
1022  unhexify( src_str, "00000000000000000000000000000000" );
1023 
1024  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1025  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1026  hexify( dst_str, output, 16 );
1027 
1028  fct_chk( strcmp( (char *) dst_str, "8dfd999be5d0cfa35732c0ddc88ff5a5" ) == 0 );
1029  }
1030  FCT_TEST_END();
1031 #endif /* POLARSSL_CIPHER_MODE_CFB */
1032 
1033 #ifdef POLARSSL_CIPHER_MODE_CFB
1034 
1035  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_2)
1036  {
1037  unsigned char key_str[100];
1038  unsigned char iv_str[100];
1039  unsigned char src_str[100];
1040  unsigned char dst_str[100];
1041  unsigned char output[100];
1042  aes_context ctx;
1043  size_t iv_offset = 0;
1044  int key_len;
1045 
1046  memset(key_str, 0x00, 100);
1047  memset(iv_str, 0x00, 100);
1048  memset(src_str, 0x00, 100);
1049  memset(dst_str, 0x00, 100);
1050  memset(output, 0x00, 100);
1051 
1052  key_len = unhexify( key_str, "fffffffffffffffffffe0000000000000000000000000000" );
1053  unhexify( iv_str, "00000000000000000000000000000000" );
1054  unhexify( src_str, "00000000000000000000000000000000" );
1055 
1056  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1057  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1058  hexify( dst_str, output, 16 );
1059 
1060  fct_chk( strcmp( (char *) dst_str, "02647c76a300c3173b841487eb2bae9f" ) == 0 );
1061  }
1062  FCT_TEST_END();
1063 #endif /* POLARSSL_CIPHER_MODE_CFB */
1064 
1065 #ifdef POLARSSL_CIPHER_MODE_CFB
1066 
1067  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_3)
1068  {
1069  unsigned char key_str[100];
1070  unsigned char iv_str[100];
1071  unsigned char src_str[100];
1072  unsigned char dst_str[100];
1073  unsigned char output[100];
1074  aes_context ctx;
1075  size_t iv_offset = 0;
1076  int key_len;
1077 
1078  memset(key_str, 0x00, 100);
1079  memset(iv_str, 0x00, 100);
1080  memset(src_str, 0x00, 100);
1081  memset(dst_str, 0x00, 100);
1082  memset(output, 0x00, 100);
1083 
1084  key_len = unhexify( key_str, "ffffffffffffffffffff0000000000000000000000000000" );
1085  unhexify( iv_str, "00000000000000000000000000000000" );
1086  unhexify( src_str, "00000000000000000000000000000000" );
1087 
1088  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1089  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1090  hexify( dst_str, output, 16 );
1091 
1092  fct_chk( strcmp( (char *) dst_str, "172df8b02f04b53adab028b4e01acd87" ) == 0 );
1093  }
1094  FCT_TEST_END();
1095 #endif /* POLARSSL_CIPHER_MODE_CFB */
1096 
1097 #ifdef POLARSSL_CIPHER_MODE_CFB
1098 
1099  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_4)
1100  {
1101  unsigned char key_str[100];
1102  unsigned char iv_str[100];
1103  unsigned char src_str[100];
1104  unsigned char dst_str[100];
1105  unsigned char output[100];
1106  aes_context ctx;
1107  size_t iv_offset = 0;
1108  int key_len;
1109 
1110  memset(key_str, 0x00, 100);
1111  memset(iv_str, 0x00, 100);
1112  memset(src_str, 0x00, 100);
1113  memset(dst_str, 0x00, 100);
1114  memset(output, 0x00, 100);
1115 
1116  key_len = unhexify( key_str, "d184c36cf0dddfec39e654195006022237871a47c33d3198" );
1117  unhexify( iv_str, "00000000000000000000000000000000" );
1118  unhexify( src_str, "00000000000000000000000000000000" );
1119 
1120  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1121  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1122  hexify( dst_str, output, 16 );
1123 
1124  fct_chk( strcmp( (char *) dst_str, "2e19fb60a3e1de0166f483c97824a978" ) == 0 );
1125  }
1126  FCT_TEST_END();
1127 #endif /* POLARSSL_CIPHER_MODE_CFB */
1128 
1129 #ifdef POLARSSL_CIPHER_MODE_CFB
1130 
1131  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_5)
1132  {
1133  unsigned char key_str[100];
1134  unsigned char iv_str[100];
1135  unsigned char src_str[100];
1136  unsigned char dst_str[100];
1137  unsigned char output[100];
1138  aes_context ctx;
1139  size_t iv_offset = 0;
1140  int key_len;
1141 
1142  memset(key_str, 0x00, 100);
1143  memset(iv_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, "4c6994ffa9dcdc805b60c2c0095334c42d95a8fc0ca5b080" );
1149  unhexify( iv_str, "00000000000000000000000000000000" );
1150  unhexify( src_str, "00000000000000000000000000000000" );
1151 
1152  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1153  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1154  hexify( dst_str, output, 16 );
1155 
1156  fct_chk( strcmp( (char *) dst_str, "7656709538dd5fec41e0ce6a0f8e207d" ) == 0 );
1157  }
1158  FCT_TEST_END();
1159 #endif /* POLARSSL_CIPHER_MODE_CFB */
1160 
1161 #ifdef POLARSSL_CIPHER_MODE_CFB
1162 
1163  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_6)
1164  {
1165  unsigned char key_str[100];
1166  unsigned char iv_str[100];
1167  unsigned char src_str[100];
1168  unsigned char dst_str[100];
1169  unsigned char output[100];
1170  aes_context ctx;
1171  size_t iv_offset = 0;
1172  int key_len;
1173 
1174  memset(key_str, 0x00, 100);
1175  memset(iv_str, 0x00, 100);
1176  memset(src_str, 0x00, 100);
1177  memset(dst_str, 0x00, 100);
1178  memset(output, 0x00, 100);
1179 
1180  key_len = unhexify( key_str, "c88f5b00a4ef9a6840e2acaf33f00a3bdc4e25895303fa72" );
1181  unhexify( iv_str, "00000000000000000000000000000000" );
1182  unhexify( src_str, "00000000000000000000000000000000" );
1183 
1184  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1185  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1186  hexify( dst_str, output, 16 );
1187 
1188  fct_chk( strcmp( (char *) dst_str, "a67cf333b314d411d3c0ae6e1cfcd8f5" ) == 0 );
1189  }
1190  FCT_TEST_END();
1191 #endif /* POLARSSL_CIPHER_MODE_CFB */
1192 
1193 #ifdef POLARSSL_CIPHER_MODE_CFB
1194 
1195  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_7)
1196  {
1197  unsigned char key_str[100];
1198  unsigned char iv_str[100];
1199  unsigned char src_str[100];
1200  unsigned char dst_str[100];
1201  unsigned char output[100];
1202  aes_context ctx;
1203  size_t iv_offset = 0;
1204  int key_len;
1205 
1206  memset(key_str, 0x00, 100);
1207  memset(iv_str, 0x00, 100);
1208  memset(src_str, 0x00, 100);
1209  memset(dst_str, 0x00, 100);
1210  memset(output, 0x00, 100);
1211 
1212  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1213  unhexify( iv_str, "9c2d8842e5f48f57648205d39a239af1" );
1214  unhexify( src_str, "00000000000000000000000000000000" );
1215 
1216  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1217  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1218  hexify( dst_str, output, 16 );
1219 
1220  fct_chk( strcmp( (char *) dst_str, "c9b8135ff1b5adc413dfd053b21bd96d" ) == 0 );
1221  }
1222  FCT_TEST_END();
1223 #endif /* POLARSSL_CIPHER_MODE_CFB */
1224 
1225 #ifdef POLARSSL_CIPHER_MODE_CFB
1226 
1227  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_8)
1228  {
1229  unsigned char key_str[100];
1230  unsigned char iv_str[100];
1231  unsigned char src_str[100];
1232  unsigned char dst_str[100];
1233  unsigned char output[100];
1234  aes_context ctx;
1235  size_t iv_offset = 0;
1236  int key_len;
1237 
1238  memset(key_str, 0x00, 100);
1239  memset(iv_str, 0x00, 100);
1240  memset(src_str, 0x00, 100);
1241  memset(dst_str, 0x00, 100);
1242  memset(output, 0x00, 100);
1243 
1244  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1245  unhexify( iv_str, "bff52510095f518ecca60af4205444bb" );
1246  unhexify( src_str, "00000000000000000000000000000000" );
1247 
1248  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1249  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1250  hexify( dst_str, output, 16 );
1251 
1252  fct_chk( strcmp( (char *) dst_str, "4a3650c3371ce2eb35e389a171427440" ) == 0 );
1253  }
1254  FCT_TEST_END();
1255 #endif /* POLARSSL_CIPHER_MODE_CFB */
1256 
1257 #ifdef POLARSSL_CIPHER_MODE_CFB
1258 
1259  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_9)
1260  {
1261  unsigned char key_str[100];
1262  unsigned char iv_str[100];
1263  unsigned char src_str[100];
1264  unsigned char dst_str[100];
1265  unsigned char output[100];
1266  aes_context ctx;
1267  size_t iv_offset = 0;
1268  int key_len;
1269 
1270  memset(key_str, 0x00, 100);
1271  memset(iv_str, 0x00, 100);
1272  memset(src_str, 0x00, 100);
1273  memset(dst_str, 0x00, 100);
1274  memset(output, 0x00, 100);
1275 
1276  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1277  unhexify( iv_str, "51719783d3185a535bd75adc65071ce1" );
1278  unhexify( src_str, "00000000000000000000000000000000" );
1279 
1280  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1281  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1282  hexify( dst_str, output, 16 );
1283 
1284  fct_chk( strcmp( (char *) dst_str, "4f354592ff7c8847d2d0870ca9481b7c" ) == 0 );
1285  }
1286  FCT_TEST_END();
1287 #endif /* POLARSSL_CIPHER_MODE_CFB */
1288 
1289 #ifdef POLARSSL_CIPHER_MODE_CFB
1290 
1291  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_10)
1292  {
1293  unsigned char key_str[100];
1294  unsigned char iv_str[100];
1295  unsigned char src_str[100];
1296  unsigned char dst_str[100];
1297  unsigned char output[100];
1298  aes_context ctx;
1299  size_t iv_offset = 0;
1300  int key_len;
1301 
1302  memset(key_str, 0x00, 100);
1303  memset(iv_str, 0x00, 100);
1304  memset(src_str, 0x00, 100);
1305  memset(dst_str, 0x00, 100);
1306  memset(output, 0x00, 100);
1307 
1308  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1309  unhexify( iv_str, "ffffffffffffffe00000000000000000" );
1310  unhexify( src_str, "00000000000000000000000000000000" );
1311 
1312  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1313  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1314  hexify( dst_str, output, 16 );
1315 
1316  fct_chk( strcmp( (char *) dst_str, "f34e4a6324ea4a5c39a661c8fe5ada8f" ) == 0 );
1317  }
1318  FCT_TEST_END();
1319 #endif /* POLARSSL_CIPHER_MODE_CFB */
1320 
1321 #ifdef POLARSSL_CIPHER_MODE_CFB
1322 
1323  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_11)
1324  {
1325  unsigned char key_str[100];
1326  unsigned char iv_str[100];
1327  unsigned char src_str[100];
1328  unsigned char dst_str[100];
1329  unsigned char output[100];
1330  aes_context ctx;
1331  size_t iv_offset = 0;
1332  int key_len;
1333 
1334  memset(key_str, 0x00, 100);
1335  memset(iv_str, 0x00, 100);
1336  memset(src_str, 0x00, 100);
1337  memset(dst_str, 0x00, 100);
1338  memset(output, 0x00, 100);
1339 
1340  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1341  unhexify( iv_str, "fffffffffffffff00000000000000000" );
1342  unhexify( src_str, "00000000000000000000000000000000" );
1343 
1344  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1345  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1346  hexify( dst_str, output, 16 );
1347 
1348  fct_chk( strcmp( (char *) dst_str, "0882a16f44088d42447a29ac090ec17e" ) == 0 );
1349  }
1350  FCT_TEST_END();
1351 #endif /* POLARSSL_CIPHER_MODE_CFB */
1352 
1353 #ifdef POLARSSL_CIPHER_MODE_CFB
1354 
1355  FCT_TEST_BGN(aes_192_cfb128_encrypt_nist_kat_12)
1356  {
1357  unsigned char key_str[100];
1358  unsigned char iv_str[100];
1359  unsigned char src_str[100];
1360  unsigned char dst_str[100];
1361  unsigned char output[100];
1362  aes_context ctx;
1363  size_t iv_offset = 0;
1364  int key_len;
1365 
1366  memset(key_str, 0x00, 100);
1367  memset(iv_str, 0x00, 100);
1368  memset(src_str, 0x00, 100);
1369  memset(dst_str, 0x00, 100);
1370  memset(output, 0x00, 100);
1371 
1372  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1373  unhexify( iv_str, "fffffffffffffff80000000000000000" );
1374  unhexify( src_str, "00000000000000000000000000000000" );
1375 
1376  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1377  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1378  hexify( dst_str, output, 16 );
1379 
1380  fct_chk( strcmp( (char *) dst_str, "3a3c15bfc11a9537c130687004e136ee" ) == 0 );
1381  }
1382  FCT_TEST_END();
1383 #endif /* POLARSSL_CIPHER_MODE_CFB */
1384 
1385 #ifdef POLARSSL_CIPHER_MODE_CFB
1386 
1387  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_1)
1388  {
1389  unsigned char key_str[100];
1390  unsigned char iv_str[100];
1391  unsigned char src_str[100];
1392  unsigned char dst_str[100];
1393  unsigned char output[100];
1394  aes_context ctx;
1395  size_t iv_offset = 0;
1396  int key_len;
1397 
1398  memset(key_str, 0x00, 100);
1399  memset(iv_str, 0x00, 100);
1400  memset(src_str, 0x00, 100);
1401  memset(dst_str, 0x00, 100);
1402  memset(output, 0x00, 100);
1403 
1404  key_len = unhexify( key_str, "ffffffffffffffffffffffffffffffffffffffffffe00000" );
1405  unhexify( iv_str, "00000000000000000000000000000000" );
1406  unhexify( src_str, "60136703374f64e860b48ce31f930716" );
1407 
1408  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1409  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1410  hexify( dst_str, output, 16 );
1411 
1412  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1413  }
1414  FCT_TEST_END();
1415 #endif /* POLARSSL_CIPHER_MODE_CFB */
1416 
1417 #ifdef POLARSSL_CIPHER_MODE_CFB
1418 
1419  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_2)
1420  {
1421  unsigned char key_str[100];
1422  unsigned char iv_str[100];
1423  unsigned char src_str[100];
1424  unsigned char dst_str[100];
1425  unsigned char output[100];
1426  aes_context ctx;
1427  size_t iv_offset = 0;
1428  int key_len;
1429 
1430  memset(key_str, 0x00, 100);
1431  memset(iv_str, 0x00, 100);
1432  memset(src_str, 0x00, 100);
1433  memset(dst_str, 0x00, 100);
1434  memset(output, 0x00, 100);
1435 
1436  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffff00000" );
1437  unhexify( iv_str, "00000000000000000000000000000000" );
1438  unhexify( src_str, "8d63a269b14d506ccc401ab8a9f1b591" );
1439 
1440  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1441  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1442  hexify( dst_str, output, 16 );
1443 
1444  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1445  }
1446  FCT_TEST_END();
1447 #endif /* POLARSSL_CIPHER_MODE_CFB */
1448 
1449 #ifdef POLARSSL_CIPHER_MODE_CFB
1450 
1451  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_3)
1452  {
1453  unsigned char key_str[100];
1454  unsigned char iv_str[100];
1455  unsigned char src_str[100];
1456  unsigned char dst_str[100];
1457  unsigned char output[100];
1458  aes_context ctx;
1459  size_t iv_offset = 0;
1460  int key_len;
1461 
1462  memset(key_str, 0x00, 100);
1463  memset(iv_str, 0x00, 100);
1464  memset(src_str, 0x00, 100);
1465  memset(dst_str, 0x00, 100);
1466  memset(output, 0x00, 100);
1467 
1468  key_len = unhexify( key_str, "fffffffffffffffffffffffffffffffffffffffffff80000" );
1469  unhexify( iv_str, "00000000000000000000000000000000" );
1470  unhexify( src_str, "d317f81dc6aa454aee4bd4a5a5cff4bd" );
1471 
1472  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1473  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1474  hexify( dst_str, output, 16 );
1475 
1476  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1477  }
1478  FCT_TEST_END();
1479 #endif /* POLARSSL_CIPHER_MODE_CFB */
1480 
1481 #ifdef POLARSSL_CIPHER_MODE_CFB
1482 
1483  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_4)
1484  {
1485  unsigned char key_str[100];
1486  unsigned char iv_str[100];
1487  unsigned char src_str[100];
1488  unsigned char dst_str[100];
1489  unsigned char output[100];
1490  aes_context ctx;
1491  size_t iv_offset = 0;
1492  int key_len;
1493 
1494  memset(key_str, 0x00, 100);
1495  memset(iv_str, 0x00, 100);
1496  memset(src_str, 0x00, 100);
1497  memset(dst_str, 0x00, 100);
1498  memset(output, 0x00, 100);
1499 
1500  key_len = unhexify( key_str, "98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9" );
1501  unhexify( iv_str, "00000000000000000000000000000000" );
1502  unhexify( src_str, "19c80ec4a6deb7e5ed1033dda933498f" );
1503 
1504  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1505  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1506  hexify( dst_str, output, 16 );
1507 
1508  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1509  }
1510  FCT_TEST_END();
1511 #endif /* POLARSSL_CIPHER_MODE_CFB */
1512 
1513 #ifdef POLARSSL_CIPHER_MODE_CFB
1514 
1515  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_5)
1516  {
1517  unsigned char key_str[100];
1518  unsigned char iv_str[100];
1519  unsigned char src_str[100];
1520  unsigned char dst_str[100];
1521  unsigned char output[100];
1522  aes_context ctx;
1523  size_t iv_offset = 0;
1524  int key_len;
1525 
1526  memset(key_str, 0x00, 100);
1527  memset(iv_str, 0x00, 100);
1528  memset(src_str, 0x00, 100);
1529  memset(dst_str, 0x00, 100);
1530  memset(output, 0x00, 100);
1531 
1532  key_len = unhexify( key_str, "b3ad5cea1dddc214ca969ac35f37dae1a9a9d1528f89bb35" );
1533  unhexify( iv_str, "00000000000000000000000000000000" );
1534  unhexify( src_str, "3cf5e1d21a17956d1dffad6a7c41c659" );
1535 
1536  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1537  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1538  hexify( dst_str, output, 16 );
1539 
1540  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1541  }
1542  FCT_TEST_END();
1543 #endif /* POLARSSL_CIPHER_MODE_CFB */
1544 
1545 #ifdef POLARSSL_CIPHER_MODE_CFB
1546 
1547  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_6)
1548  {
1549  unsigned char key_str[100];
1550  unsigned char iv_str[100];
1551  unsigned char src_str[100];
1552  unsigned char dst_str[100];
1553  unsigned char output[100];
1554  aes_context ctx;
1555  size_t iv_offset = 0;
1556  int key_len;
1557 
1558  memset(key_str, 0x00, 100);
1559  memset(iv_str, 0x00, 100);
1560  memset(src_str, 0x00, 100);
1561  memset(dst_str, 0x00, 100);
1562  memset(output, 0x00, 100);
1563 
1564  key_len = unhexify( key_str, "45899367c3132849763073c435a9288a766c8b9ec2308516" );
1565  unhexify( iv_str, "00000000000000000000000000000000" );
1566  unhexify( src_str, "69fd12e8505f8ded2fdcb197a121b362" );
1567 
1568  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1569  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1570  hexify( dst_str, output, 16 );
1571 
1572  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1573  }
1574  FCT_TEST_END();
1575 #endif /* POLARSSL_CIPHER_MODE_CFB */
1576 
1577 #ifdef POLARSSL_CIPHER_MODE_CFB
1578 
1579  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_7)
1580  {
1581  unsigned char key_str[100];
1582  unsigned char iv_str[100];
1583  unsigned char src_str[100];
1584  unsigned char dst_str[100];
1585  unsigned char output[100];
1586  aes_context ctx;
1587  size_t iv_offset = 0;
1588  int key_len;
1589 
1590  memset(key_str, 0x00, 100);
1591  memset(iv_str, 0x00, 100);
1592  memset(src_str, 0x00, 100);
1593  memset(dst_str, 0x00, 100);
1594  memset(output, 0x00, 100);
1595 
1596  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1597  unhexify( iv_str, "1b077a6af4b7f98229de786d7516b639" );
1598  unhexify( src_str, "275cfc0413d8ccb70513c3859b1d0f72" );
1599 
1600  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1601  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1602  hexify( dst_str, output, 16 );
1603 
1604  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1605  }
1606  FCT_TEST_END();
1607 #endif /* POLARSSL_CIPHER_MODE_CFB */
1608 
1609 #ifdef POLARSSL_CIPHER_MODE_CFB
1610 
1611  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_8)
1612  {
1613  unsigned char key_str[100];
1614  unsigned char iv_str[100];
1615  unsigned char src_str[100];
1616  unsigned char dst_str[100];
1617  unsigned char output[100];
1618  aes_context ctx;
1619  size_t iv_offset = 0;
1620  int key_len;
1621 
1622  memset(key_str, 0x00, 100);
1623  memset(iv_str, 0x00, 100);
1624  memset(src_str, 0x00, 100);
1625  memset(dst_str, 0x00, 100);
1626  memset(output, 0x00, 100);
1627 
1628  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1629  unhexify( iv_str, "9c2d8842e5f48f57648205d39a239af1" );
1630  unhexify( src_str, "c9b8135ff1b5adc413dfd053b21bd96d" );
1631 
1632  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1633  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1634  hexify( dst_str, output, 16 );
1635 
1636  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1637  }
1638  FCT_TEST_END();
1639 #endif /* POLARSSL_CIPHER_MODE_CFB */
1640 
1641 #ifdef POLARSSL_CIPHER_MODE_CFB
1642 
1643  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_9)
1644  {
1645  unsigned char key_str[100];
1646  unsigned char iv_str[100];
1647  unsigned char src_str[100];
1648  unsigned char dst_str[100];
1649  unsigned char output[100];
1650  aes_context ctx;
1651  size_t iv_offset = 0;
1652  int key_len;
1653 
1654  memset(key_str, 0x00, 100);
1655  memset(iv_str, 0x00, 100);
1656  memset(src_str, 0x00, 100);
1657  memset(dst_str, 0x00, 100);
1658  memset(output, 0x00, 100);
1659 
1660  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1661  unhexify( iv_str, "bff52510095f518ecca60af4205444bb" );
1662  unhexify( src_str, "4a3650c3371ce2eb35e389a171427440" );
1663 
1664  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1665  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1666  hexify( dst_str, output, 16 );
1667 
1668  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1669  }
1670  FCT_TEST_END();
1671 #endif /* POLARSSL_CIPHER_MODE_CFB */
1672 
1673 #ifdef POLARSSL_CIPHER_MODE_CFB
1674 
1675  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_10)
1676  {
1677  unsigned char key_str[100];
1678  unsigned char iv_str[100];
1679  unsigned char src_str[100];
1680  unsigned char dst_str[100];
1681  unsigned char output[100];
1682  aes_context ctx;
1683  size_t iv_offset = 0;
1684  int key_len;
1685 
1686  memset(key_str, 0x00, 100);
1687  memset(iv_str, 0x00, 100);
1688  memset(src_str, 0x00, 100);
1689  memset(dst_str, 0x00, 100);
1690  memset(output, 0x00, 100);
1691 
1692  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1693  unhexify( iv_str, "ffffffffffffffffffff000000000000" );
1694  unhexify( src_str, "54d632d03aba0bd0f91877ebdd4d09cb" );
1695 
1696  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1697  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1698  hexify( dst_str, output, 16 );
1699 
1700  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1701  }
1702  FCT_TEST_END();
1703 #endif /* POLARSSL_CIPHER_MODE_CFB */
1704 
1705 #ifdef POLARSSL_CIPHER_MODE_CFB
1706 
1707  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_11)
1708  {
1709  unsigned char key_str[100];
1710  unsigned char iv_str[100];
1711  unsigned char src_str[100];
1712  unsigned char dst_str[100];
1713  unsigned char output[100];
1714  aes_context ctx;
1715  size_t iv_offset = 0;
1716  int key_len;
1717 
1718  memset(key_str, 0x00, 100);
1719  memset(iv_str, 0x00, 100);
1720  memset(src_str, 0x00, 100);
1721  memset(dst_str, 0x00, 100);
1722  memset(output, 0x00, 100);
1723 
1724  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1725  unhexify( iv_str, "ffffffffffffffffffff800000000000" );
1726  unhexify( src_str, "d3427be7e4d27cd54f5fe37b03cf0897" );
1727 
1728  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1729  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1730  hexify( dst_str, output, 16 );
1731 
1732  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1733  }
1734  FCT_TEST_END();
1735 #endif /* POLARSSL_CIPHER_MODE_CFB */
1736 
1737 #ifdef POLARSSL_CIPHER_MODE_CFB
1738 
1739  FCT_TEST_BGN(aes_192_cfb128_decrypt_nist_kat_12)
1740  {
1741  unsigned char key_str[100];
1742  unsigned char iv_str[100];
1743  unsigned char src_str[100];
1744  unsigned char dst_str[100];
1745  unsigned char output[100];
1746  aes_context ctx;
1747  size_t iv_offset = 0;
1748  int key_len;
1749 
1750  memset(key_str, 0x00, 100);
1751  memset(iv_str, 0x00, 100);
1752  memset(src_str, 0x00, 100);
1753  memset(dst_str, 0x00, 100);
1754  memset(output, 0x00, 100);
1755 
1756  key_len = unhexify( key_str, "000000000000000000000000000000000000000000000000" );
1757  unhexify( iv_str, "ffffffffffffffffffffc00000000000" );
1758  unhexify( src_str, "b2099795e88cc158fd75ea133d7e7fbe" );
1759 
1760  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1761  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1762  hexify( dst_str, output, 16 );
1763 
1764  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
1765  }
1766  FCT_TEST_END();
1767 #endif /* POLARSSL_CIPHER_MODE_CFB */
1768 
1769 #ifdef POLARSSL_CIPHER_MODE_CFB
1770 
1771  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_1)
1772  {
1773  unsigned char key_str[100];
1774  unsigned char iv_str[100];
1775  unsigned char src_str[100];
1776  unsigned char dst_str[100];
1777  unsigned char output[100];
1778  aes_context ctx;
1779  size_t iv_offset = 0;
1780  int key_len;
1781 
1782  memset(key_str, 0x00, 100);
1783  memset(iv_str, 0x00, 100);
1784  memset(src_str, 0x00, 100);
1785  memset(dst_str, 0x00, 100);
1786  memset(output, 0x00, 100);
1787 
1788  key_len = unhexify( key_str, "ffffffe000000000000000000000000000000000000000000000000000000000" );
1789  unhexify( iv_str, "00000000000000000000000000000000" );
1790  unhexify( src_str, "00000000000000000000000000000000" );
1791 
1792  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1793  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1794  hexify( dst_str, output, 16 );
1795 
1796  fct_chk( strcmp( (char *) dst_str, "bbd1097a62433f79449fa97d4ee80dbf" ) == 0 );
1797  }
1798  FCT_TEST_END();
1799 #endif /* POLARSSL_CIPHER_MODE_CFB */
1800 
1801 #ifdef POLARSSL_CIPHER_MODE_CFB
1802 
1803  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_2)
1804  {
1805  unsigned char key_str[100];
1806  unsigned char iv_str[100];
1807  unsigned char src_str[100];
1808  unsigned char dst_str[100];
1809  unsigned char output[100];
1810  aes_context ctx;
1811  size_t iv_offset = 0;
1812  int key_len;
1813 
1814  memset(key_str, 0x00, 100);
1815  memset(iv_str, 0x00, 100);
1816  memset(src_str, 0x00, 100);
1817  memset(dst_str, 0x00, 100);
1818  memset(output, 0x00, 100);
1819 
1820  key_len = unhexify( key_str, "fffffff000000000000000000000000000000000000000000000000000000000" );
1821  unhexify( iv_str, "00000000000000000000000000000000" );
1822  unhexify( src_str, "00000000000000000000000000000000" );
1823 
1824  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1825  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1826  hexify( dst_str, output, 16 );
1827 
1828  fct_chk( strcmp( (char *) dst_str, "07058e408f5b99b0e0f061a1761b5b3b" ) == 0 );
1829  }
1830  FCT_TEST_END();
1831 #endif /* POLARSSL_CIPHER_MODE_CFB */
1832 
1833 #ifdef POLARSSL_CIPHER_MODE_CFB
1834 
1835  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_3)
1836  {
1837  unsigned char key_str[100];
1838  unsigned char iv_str[100];
1839  unsigned char src_str[100];
1840  unsigned char dst_str[100];
1841  unsigned char output[100];
1842  aes_context ctx;
1843  size_t iv_offset = 0;
1844  int key_len;
1845 
1846  memset(key_str, 0x00, 100);
1847  memset(iv_str, 0x00, 100);
1848  memset(src_str, 0x00, 100);
1849  memset(dst_str, 0x00, 100);
1850  memset(output, 0x00, 100);
1851 
1852  key_len = unhexify( key_str, "fffffff800000000000000000000000000000000000000000000000000000000" );
1853  unhexify( iv_str, "00000000000000000000000000000000" );
1854  unhexify( src_str, "00000000000000000000000000000000" );
1855 
1856  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1857  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1858  hexify( dst_str, output, 16 );
1859 
1860  fct_chk( strcmp( (char *) dst_str, "5fd1f13fa0f31e37fabde328f894eac2" ) == 0 );
1861  }
1862  FCT_TEST_END();
1863 #endif /* POLARSSL_CIPHER_MODE_CFB */
1864 
1865 #ifdef POLARSSL_CIPHER_MODE_CFB
1866 
1867  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_4)
1868  {
1869  unsigned char key_str[100];
1870  unsigned char iv_str[100];
1871  unsigned char src_str[100];
1872  unsigned char dst_str[100];
1873  unsigned char output[100];
1874  aes_context ctx;
1875  size_t iv_offset = 0;
1876  int key_len;
1877 
1878  memset(key_str, 0x00, 100);
1879  memset(iv_str, 0x00, 100);
1880  memset(src_str, 0x00, 100);
1881  memset(dst_str, 0x00, 100);
1882  memset(output, 0x00, 100);
1883 
1884  key_len = unhexify( key_str, "13428b5e4c005e0636dd338405d173ab135dec2a25c22c5df0722d69dcc43887" );
1885  unhexify( iv_str, "00000000000000000000000000000000" );
1886  unhexify( src_str, "00000000000000000000000000000000" );
1887 
1888  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1889  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1890  hexify( dst_str, output, 16 );
1891 
1892  fct_chk( strcmp( (char *) dst_str, "649a71545378c783e368c9ade7114f6c" ) == 0 );
1893  }
1894  FCT_TEST_END();
1895 #endif /* POLARSSL_CIPHER_MODE_CFB */
1896 
1897 #ifdef POLARSSL_CIPHER_MODE_CFB
1898 
1899  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_5)
1900  {
1901  unsigned char key_str[100];
1902  unsigned char iv_str[100];
1903  unsigned char src_str[100];
1904  unsigned char dst_str[100];
1905  unsigned char output[100];
1906  aes_context ctx;
1907  size_t iv_offset = 0;
1908  int key_len;
1909 
1910  memset(key_str, 0x00, 100);
1911  memset(iv_str, 0x00, 100);
1912  memset(src_str, 0x00, 100);
1913  memset(dst_str, 0x00, 100);
1914  memset(output, 0x00, 100);
1915 
1916  key_len = unhexify( key_str, "07eb03a08d291d1b07408bf3512ab40c91097ac77461aad4bb859647f74f00ee" );
1917  unhexify( iv_str, "00000000000000000000000000000000" );
1918  unhexify( src_str, "00000000000000000000000000000000" );
1919 
1920  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1921  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1922  hexify( dst_str, output, 16 );
1923 
1924  fct_chk( strcmp( (char *) dst_str, "47cb030da2ab051dfc6c4bf6910d12bb" ) == 0 );
1925  }
1926  FCT_TEST_END();
1927 #endif /* POLARSSL_CIPHER_MODE_CFB */
1928 
1929 #ifdef POLARSSL_CIPHER_MODE_CFB
1930 
1931  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_6)
1932  {
1933  unsigned char key_str[100];
1934  unsigned char iv_str[100];
1935  unsigned char src_str[100];
1936  unsigned char dst_str[100];
1937  unsigned char output[100];
1938  aes_context ctx;
1939  size_t iv_offset = 0;
1940  int key_len;
1941 
1942  memset(key_str, 0x00, 100);
1943  memset(iv_str, 0x00, 100);
1944  memset(src_str, 0x00, 100);
1945  memset(dst_str, 0x00, 100);
1946  memset(output, 0x00, 100);
1947 
1948  key_len = unhexify( key_str, "90143ae20cd78c5d8ebdd6cb9dc1762427a96c78c639bccc41a61424564eafe1" );
1949  unhexify( iv_str, "00000000000000000000000000000000" );
1950  unhexify( src_str, "00000000000000000000000000000000" );
1951 
1952  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1953  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1954  hexify( dst_str, output, 16 );
1955 
1956  fct_chk( strcmp( (char *) dst_str, "798c7c005dee432b2c8ea5dfa381ecc3" ) == 0 );
1957  }
1958  FCT_TEST_END();
1959 #endif /* POLARSSL_CIPHER_MODE_CFB */
1960 
1961 #ifdef POLARSSL_CIPHER_MODE_CFB
1962 
1963  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_7)
1964  {
1965  unsigned char key_str[100];
1966  unsigned char iv_str[100];
1967  unsigned char src_str[100];
1968  unsigned char dst_str[100];
1969  unsigned char output[100];
1970  aes_context ctx;
1971  size_t iv_offset = 0;
1972  int key_len;
1973 
1974  memset(key_str, 0x00, 100);
1975  memset(iv_str, 0x00, 100);
1976  memset(src_str, 0x00, 100);
1977  memset(dst_str, 0x00, 100);
1978  memset(output, 0x00, 100);
1979 
1980  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
1981  unhexify( iv_str, "0b24af36193ce4665f2825d7b4749c98" );
1982  unhexify( src_str, "00000000000000000000000000000000" );
1983 
1984  aes_setkey_enc( &ctx, key_str, key_len * 8 );
1985  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
1986  hexify( dst_str, output, 16 );
1987 
1988  fct_chk( strcmp( (char *) dst_str, "a9ff75bd7cf6613d3731c77c3b6d0c04" ) == 0 );
1989  }
1990  FCT_TEST_END();
1991 #endif /* POLARSSL_CIPHER_MODE_CFB */
1992 
1993 #ifdef POLARSSL_CIPHER_MODE_CFB
1994 
1995  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_8)
1996  {
1997  unsigned char key_str[100];
1998  unsigned char iv_str[100];
1999  unsigned char src_str[100];
2000  unsigned char dst_str[100];
2001  unsigned char output[100];
2002  aes_context ctx;
2003  size_t iv_offset = 0;
2004  int key_len;
2005 
2006  memset(key_str, 0x00, 100);
2007  memset(iv_str, 0x00, 100);
2008  memset(src_str, 0x00, 100);
2009  memset(dst_str, 0x00, 100);
2010  memset(output, 0x00, 100);
2011 
2012  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2013  unhexify( iv_str, "761c1fe41a18acf20d241650611d90f1" );
2014  unhexify( src_str, "00000000000000000000000000000000" );
2015 
2016  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2017  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2018  hexify( dst_str, output, 16 );
2019 
2020  fct_chk( strcmp( (char *) dst_str, "623a52fcea5d443e48d9181ab32c7421" ) == 0 );
2021  }
2022  FCT_TEST_END();
2023 #endif /* POLARSSL_CIPHER_MODE_CFB */
2024 
2025 #ifdef POLARSSL_CIPHER_MODE_CFB
2026 
2027  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_9)
2028  {
2029  unsigned char key_str[100];
2030  unsigned char iv_str[100];
2031  unsigned char src_str[100];
2032  unsigned char dst_str[100];
2033  unsigned char output[100];
2034  aes_context ctx;
2035  size_t iv_offset = 0;
2036  int key_len;
2037 
2038  memset(key_str, 0x00, 100);
2039  memset(iv_str, 0x00, 100);
2040  memset(src_str, 0x00, 100);
2041  memset(dst_str, 0x00, 100);
2042  memset(output, 0x00, 100);
2043 
2044  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2045  unhexify( iv_str, "8a560769d605868ad80d819bdba03771" );
2046  unhexify( src_str, "00000000000000000000000000000000" );
2047 
2048  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2049  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2050  hexify( dst_str, output, 16 );
2051 
2052  fct_chk( strcmp( (char *) dst_str, "38f2c7ae10612415d27ca190d27da8b4" ) == 0 );
2053  }
2054  FCT_TEST_END();
2055 #endif /* POLARSSL_CIPHER_MODE_CFB */
2056 
2057 #ifdef POLARSSL_CIPHER_MODE_CFB
2058 
2059  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_10)
2060  {
2061  unsigned char key_str[100];
2062  unsigned char iv_str[100];
2063  unsigned char src_str[100];
2064  unsigned char dst_str[100];
2065  unsigned char output[100];
2066  aes_context ctx;
2067  size_t iv_offset = 0;
2068  int key_len;
2069 
2070  memset(key_str, 0x00, 100);
2071  memset(iv_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, "0000000000000000000000000000000000000000000000000000000000000000" );
2077  unhexify( iv_str, "ffffffffffffffffffffffffe0000000" );
2078  unhexify( src_str, "00000000000000000000000000000000" );
2079 
2080  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2081  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2082  hexify( dst_str, output, 16 );
2083 
2084  fct_chk( strcmp( (char *) dst_str, "2be1fae5048a25582a679ca10905eb80" ) == 0 );
2085  }
2086  FCT_TEST_END();
2087 #endif /* POLARSSL_CIPHER_MODE_CFB */
2088 
2089 #ifdef POLARSSL_CIPHER_MODE_CFB
2090 
2091  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_11)
2092  {
2093  unsigned char key_str[100];
2094  unsigned char iv_str[100];
2095  unsigned char src_str[100];
2096  unsigned char dst_str[100];
2097  unsigned char output[100];
2098  aes_context ctx;
2099  size_t iv_offset = 0;
2100  int key_len;
2101 
2102  memset(key_str, 0x00, 100);
2103  memset(iv_str, 0x00, 100);
2104  memset(src_str, 0x00, 100);
2105  memset(dst_str, 0x00, 100);
2106  memset(output, 0x00, 100);
2107 
2108  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2109  unhexify( iv_str, "fffffffffffffffffffffffff0000000" );
2110  unhexify( src_str, "00000000000000000000000000000000" );
2111 
2112  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2113  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2114  hexify( dst_str, output, 16 );
2115 
2116  fct_chk( strcmp( (char *) dst_str, "da86f292c6f41ea34fb2068df75ecc29" ) == 0 );
2117  }
2118  FCT_TEST_END();
2119 #endif /* POLARSSL_CIPHER_MODE_CFB */
2120 
2121 #ifdef POLARSSL_CIPHER_MODE_CFB
2122 
2123  FCT_TEST_BGN(aes_256_cfb128_encrypt_nist_kat_12)
2124  {
2125  unsigned char key_str[100];
2126  unsigned char iv_str[100];
2127  unsigned char src_str[100];
2128  unsigned char dst_str[100];
2129  unsigned char output[100];
2130  aes_context ctx;
2131  size_t iv_offset = 0;
2132  int key_len;
2133 
2134  memset(key_str, 0x00, 100);
2135  memset(iv_str, 0x00, 100);
2136  memset(src_str, 0x00, 100);
2137  memset(dst_str, 0x00, 100);
2138  memset(output, 0x00, 100);
2139 
2140  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2141  unhexify( iv_str, "fffffffffffffffffffffffff8000000" );
2142  unhexify( src_str, "00000000000000000000000000000000" );
2143 
2144  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2145  fct_chk( aes_crypt_cfb128( &ctx, AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2146  hexify( dst_str, output, 16 );
2147 
2148  fct_chk( strcmp( (char *) dst_str, "220df19f85d69b1b562fa69a3c5beca5" ) == 0 );
2149  }
2150  FCT_TEST_END();
2151 #endif /* POLARSSL_CIPHER_MODE_CFB */
2152 
2153 #ifdef POLARSSL_CIPHER_MODE_CFB
2154 
2155  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_1)
2156  {
2157  unsigned char key_str[100];
2158  unsigned char iv_str[100];
2159  unsigned char src_str[100];
2160  unsigned char dst_str[100];
2161  unsigned char output[100];
2162  aes_context ctx;
2163  size_t iv_offset = 0;
2164  int key_len;
2165 
2166  memset(key_str, 0x00, 100);
2167  memset(iv_str, 0x00, 100);
2168  memset(src_str, 0x00, 100);
2169  memset(dst_str, 0x00, 100);
2170  memset(output, 0x00, 100);
2171 
2172  key_len = unhexify( key_str, "ffffffffff800000000000000000000000000000000000000000000000000000" );
2173  unhexify( iv_str, "00000000000000000000000000000000" );
2174  unhexify( src_str, "be66cfea2fecd6bf0ec7b4352c99bcaa" );
2175 
2176  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2177  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2178  hexify( dst_str, output, 16 );
2179 
2180  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2181  }
2182  FCT_TEST_END();
2183 #endif /* POLARSSL_CIPHER_MODE_CFB */
2184 
2185 #ifdef POLARSSL_CIPHER_MODE_CFB
2186 
2187  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_2)
2188  {
2189  unsigned char key_str[100];
2190  unsigned char iv_str[100];
2191  unsigned char src_str[100];
2192  unsigned char dst_str[100];
2193  unsigned char output[100];
2194  aes_context ctx;
2195  size_t iv_offset = 0;
2196  int key_len;
2197 
2198  memset(key_str, 0x00, 100);
2199  memset(iv_str, 0x00, 100);
2200  memset(src_str, 0x00, 100);
2201  memset(dst_str, 0x00, 100);
2202  memset(output, 0x00, 100);
2203 
2204  key_len = unhexify( key_str, "ffffffffffc00000000000000000000000000000000000000000000000000000" );
2205  unhexify( iv_str, "00000000000000000000000000000000" );
2206  unhexify( src_str, "df31144f87a2ef523facdcf21a427804" );
2207 
2208  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2209  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2210  hexify( dst_str, output, 16 );
2211 
2212  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2213  }
2214  FCT_TEST_END();
2215 #endif /* POLARSSL_CIPHER_MODE_CFB */
2216 
2217 #ifdef POLARSSL_CIPHER_MODE_CFB
2218 
2219  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_3)
2220  {
2221  unsigned char key_str[100];
2222  unsigned char iv_str[100];
2223  unsigned char src_str[100];
2224  unsigned char dst_str[100];
2225  unsigned char output[100];
2226  aes_context ctx;
2227  size_t iv_offset = 0;
2228  int key_len;
2229 
2230  memset(key_str, 0x00, 100);
2231  memset(iv_str, 0x00, 100);
2232  memset(src_str, 0x00, 100);
2233  memset(dst_str, 0x00, 100);
2234  memset(output, 0x00, 100);
2235 
2236  key_len = unhexify( key_str, "ffffffffffe00000000000000000000000000000000000000000000000000000" );
2237  unhexify( iv_str, "00000000000000000000000000000000" );
2238  unhexify( src_str, "b5bb0f5629fb6aae5e1839a3c3625d63" );
2239 
2240  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2241  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2242  hexify( dst_str, output, 16 );
2243 
2244  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2245  }
2246  FCT_TEST_END();
2247 #endif /* POLARSSL_CIPHER_MODE_CFB */
2248 
2249 #ifdef POLARSSL_CIPHER_MODE_CFB
2250 
2251  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_4)
2252  {
2253  unsigned char key_str[100];
2254  unsigned char iv_str[100];
2255  unsigned char src_str[100];
2256  unsigned char dst_str[100];
2257  unsigned char output[100];
2258  aes_context ctx;
2259  size_t iv_offset = 0;
2260  int key_len;
2261 
2262  memset(key_str, 0x00, 100);
2263  memset(iv_str, 0x00, 100);
2264  memset(src_str, 0x00, 100);
2265  memset(dst_str, 0x00, 100);
2266  memset(output, 0x00, 100);
2267 
2268  key_len = unhexify( key_str, "1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9" );
2269  unhexify( iv_str, "00000000000000000000000000000000" );
2270  unhexify( src_str, "531c2c38344578b84d50b3c917bbb6e1" );
2271 
2272  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2273  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2274  hexify( dst_str, output, 16 );
2275 
2276  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2277  }
2278  FCT_TEST_END();
2279 #endif /* POLARSSL_CIPHER_MODE_CFB */
2280 
2281 #ifdef POLARSSL_CIPHER_MODE_CFB
2282 
2283  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_5)
2284  {
2285  unsigned char key_str[100];
2286  unsigned char iv_str[100];
2287  unsigned char src_str[100];
2288  unsigned char dst_str[100];
2289  unsigned char output[100];
2290  aes_context ctx;
2291  size_t iv_offset = 0;
2292  int key_len;
2293 
2294  memset(key_str, 0x00, 100);
2295  memset(iv_str, 0x00, 100);
2296  memset(src_str, 0x00, 100);
2297  memset(dst_str, 0x00, 100);
2298  memset(output, 0x00, 100);
2299 
2300  key_len = unhexify( key_str, "dc0eba1f2232a7879ded34ed8428eeb8769b056bbaf8ad77cb65c3541430b4cf" );
2301  unhexify( iv_str, "00000000000000000000000000000000" );
2302  unhexify( src_str, "fc6aec906323480005c58e7e1ab004ad" );
2303 
2304  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2305  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2306  hexify( dst_str, output, 16 );
2307 
2308  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2309  }
2310  FCT_TEST_END();
2311 #endif /* POLARSSL_CIPHER_MODE_CFB */
2312 
2313 #ifdef POLARSSL_CIPHER_MODE_CFB
2314 
2315  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_6)
2316  {
2317  unsigned char key_str[100];
2318  unsigned char iv_str[100];
2319  unsigned char src_str[100];
2320  unsigned char dst_str[100];
2321  unsigned char output[100];
2322  aes_context ctx;
2323  size_t iv_offset = 0;
2324  int key_len;
2325 
2326  memset(key_str, 0x00, 100);
2327  memset(iv_str, 0x00, 100);
2328  memset(src_str, 0x00, 100);
2329  memset(dst_str, 0x00, 100);
2330  memset(output, 0x00, 100);
2331 
2332  key_len = unhexify( key_str, "f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" );
2333  unhexify( iv_str, "00000000000000000000000000000000" );
2334  unhexify( src_str, "a3944b95ca0b52043584ef02151926a8" );
2335 
2336  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2337  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2338  hexify( dst_str, output, 16 );
2339 
2340  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2341  }
2342  FCT_TEST_END();
2343 #endif /* POLARSSL_CIPHER_MODE_CFB */
2344 
2345 #ifdef POLARSSL_CIPHER_MODE_CFB
2346 
2347  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_7)
2348  {
2349  unsigned char key_str[100];
2350  unsigned char iv_str[100];
2351  unsigned char src_str[100];
2352  unsigned char dst_str[100];
2353  unsigned char output[100];
2354  aes_context ctx;
2355  size_t iv_offset = 0;
2356  int key_len;
2357 
2358  memset(key_str, 0x00, 100);
2359  memset(iv_str, 0x00, 100);
2360  memset(src_str, 0x00, 100);
2361  memset(dst_str, 0x00, 100);
2362  memset(output, 0x00, 100);
2363 
2364  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2365  unhexify( iv_str, "761c1fe41a18acf20d241650611d90f1" );
2366  unhexify( src_str, "623a52fcea5d443e48d9181ab32c7421" );
2367 
2368  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2369  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2370  hexify( dst_str, output, 16 );
2371 
2372  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2373  }
2374  FCT_TEST_END();
2375 #endif /* POLARSSL_CIPHER_MODE_CFB */
2376 
2377 #ifdef POLARSSL_CIPHER_MODE_CFB
2378 
2379  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_8)
2380  {
2381  unsigned char key_str[100];
2382  unsigned char iv_str[100];
2383  unsigned char src_str[100];
2384  unsigned char dst_str[100];
2385  unsigned char output[100];
2386  aes_context ctx;
2387  size_t iv_offset = 0;
2388  int key_len;
2389 
2390  memset(key_str, 0x00, 100);
2391  memset(iv_str, 0x00, 100);
2392  memset(src_str, 0x00, 100);
2393  memset(dst_str, 0x00, 100);
2394  memset(output, 0x00, 100);
2395 
2396  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2397  unhexify( iv_str, "8a560769d605868ad80d819bdba03771" );
2398  unhexify( src_str, "38f2c7ae10612415d27ca190d27da8b4" );
2399 
2400  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2401  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2402  hexify( dst_str, output, 16 );
2403 
2404  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2405  }
2406  FCT_TEST_END();
2407 #endif /* POLARSSL_CIPHER_MODE_CFB */
2408 
2409 #ifdef POLARSSL_CIPHER_MODE_CFB
2410 
2411  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_9)
2412  {
2413  unsigned char key_str[100];
2414  unsigned char iv_str[100];
2415  unsigned char src_str[100];
2416  unsigned char dst_str[100];
2417  unsigned char output[100];
2418  aes_context ctx;
2419  size_t iv_offset = 0;
2420  int key_len;
2421 
2422  memset(key_str, 0x00, 100);
2423  memset(iv_str, 0x00, 100);
2424  memset(src_str, 0x00, 100);
2425  memset(dst_str, 0x00, 100);
2426  memset(output, 0x00, 100);
2427 
2428  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2429  unhexify( iv_str, "91fbef2d15a97816060bee1feaa49afe" );
2430  unhexify( src_str, "1bc704f1bce135ceb810341b216d7abe" );
2431 
2432  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2433  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2434  hexify( dst_str, output, 16 );
2435 
2436  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2437  }
2438  FCT_TEST_END();
2439 #endif /* POLARSSL_CIPHER_MODE_CFB */
2440 
2441 #ifdef POLARSSL_CIPHER_MODE_CFB
2442 
2443  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_10)
2444  {
2445  unsigned char key_str[100];
2446  unsigned char iv_str[100];
2447  unsigned char src_str[100];
2448  unsigned char dst_str[100];
2449  unsigned char output[100];
2450  aes_context ctx;
2451  size_t iv_offset = 0;
2452  int key_len;
2453 
2454  memset(key_str, 0x00, 100);
2455  memset(iv_str, 0x00, 100);
2456  memset(src_str, 0x00, 100);
2457  memset(dst_str, 0x00, 100);
2458  memset(output, 0x00, 100);
2459 
2460  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2461  unhexify( iv_str, "e0000000000000000000000000000000" );
2462  unhexify( src_str, "9b80eefb7ebe2d2b16247aa0efc72f5d" );
2463 
2464  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2465  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2466  hexify( dst_str, output, 16 );
2467 
2468  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2469  }
2470  FCT_TEST_END();
2471 #endif /* POLARSSL_CIPHER_MODE_CFB */
2472 
2473 #ifdef POLARSSL_CIPHER_MODE_CFB
2474 
2475  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_11)
2476  {
2477  unsigned char key_str[100];
2478  unsigned char iv_str[100];
2479  unsigned char src_str[100];
2480  unsigned char dst_str[100];
2481  unsigned char output[100];
2482  aes_context ctx;
2483  size_t iv_offset = 0;
2484  int key_len;
2485 
2486  memset(key_str, 0x00, 100);
2487  memset(iv_str, 0x00, 100);
2488  memset(src_str, 0x00, 100);
2489  memset(dst_str, 0x00, 100);
2490  memset(output, 0x00, 100);
2491 
2492  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2493  unhexify( iv_str, "f0000000000000000000000000000000" );
2494  unhexify( src_str, "7f2c5ece07a98d8bee13c51177395ff7" );
2495 
2496  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2497  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2498  hexify( dst_str, output, 16 );
2499 
2500  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2501  }
2502  FCT_TEST_END();
2503 #endif /* POLARSSL_CIPHER_MODE_CFB */
2504 
2505 #ifdef POLARSSL_CIPHER_MODE_CFB
2506 
2507  FCT_TEST_BGN(aes_256_cfb128_decrypt_nist_kat_12)
2508  {
2509  unsigned char key_str[100];
2510  unsigned char iv_str[100];
2511  unsigned char src_str[100];
2512  unsigned char dst_str[100];
2513  unsigned char output[100];
2514  aes_context ctx;
2515  size_t iv_offset = 0;
2516  int key_len;
2517 
2518  memset(key_str, 0x00, 100);
2519  memset(iv_str, 0x00, 100);
2520  memset(src_str, 0x00, 100);
2521  memset(dst_str, 0x00, 100);
2522  memset(output, 0x00, 100);
2523 
2524  key_len = unhexify( key_str, "0000000000000000000000000000000000000000000000000000000000000000" );
2525  unhexify( iv_str, "f8000000000000000000000000000000" );
2526  unhexify( src_str, "7818d800dcf6f4be1e0e94f403d1e4c2" );
2527 
2528  aes_setkey_enc( &ctx, key_str, key_len * 8 );
2529  fct_chk( aes_crypt_cfb128( &ctx, AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 );
2530  hexify( dst_str, output, 16 );
2531 
2532  fct_chk( strcmp( (char *) dst_str, "00000000000000000000000000000000" ) == 0 );
2533  }
2534  FCT_TEST_END();
2535 #endif /* POLARSSL_CIPHER_MODE_CFB */
2536 
2537  }
2538  FCT_SUITE_END();
2539 
2540 #endif /* POLARSSL_AES_C */
2541 
2542 }
2543 FCT_END();
2544