PolarSSL v1.1.4
test_suite_md.c
Go to the documentation of this file.
1 #include "fct.h"
2 
3 #include <polarssl/md.h>
4 #include <polarssl/md2.h>
5 #include <polarssl/md4.h>
6 #include <polarssl/md5.h>
7 #include <polarssl/sha1.h>
8 #include <polarssl/sha2.h>
9 #include <polarssl/sha4.h>
10 
11 #include <polarssl/config.h>
12 
13 #ifdef _MSC_VER
14 #include <basetsd.h>
15 typedef UINT32 uint32_t;
16 #else
17 #include <inttypes.h>
18 #endif
19 
20 /*
21  * 32-bit integer manipulation macros (big endian)
22  */
23 #ifndef GET_ULONG_BE
24 #define GET_ULONG_BE(n,b,i) \
25 { \
26  (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
27  | ( (unsigned long) (b)[(i) + 1] << 16 ) \
28  | ( (unsigned long) (b)[(i) + 2] << 8 ) \
29  | ( (unsigned long) (b)[(i) + 3] ); \
30 }
31 #endif
32 
33 #ifndef PUT_ULONG_BE
34 #define PUT_ULONG_BE(n,b,i) \
35 { \
36  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
37  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
38  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
39  (b)[(i) + 3] = (unsigned char) ( (n) ); \
40 }
41 #endif
42 
43 int unhexify(unsigned char *obuf, const char *ibuf)
44 {
45  unsigned char c, c2;
46  int len = strlen(ibuf) / 2;
47  assert(!(strlen(ibuf) %1)); // must be even number of bytes
48 
49  while (*ibuf != 0)
50  {
51  c = *ibuf++;
52  if( c >= '0' && c <= '9' )
53  c -= '0';
54  else if( c >= 'a' && c <= 'f' )
55  c -= 'a' - 10;
56  else if( c >= 'A' && c <= 'F' )
57  c -= 'A' - 10;
58  else
59  assert( 0 );
60 
61  c2 = *ibuf++;
62  if( c2 >= '0' && c2 <= '9' )
63  c2 -= '0';
64  else if( c2 >= 'a' && c2 <= 'f' )
65  c2 -= 'a' - 10;
66  else if( c2 >= 'A' && c2 <= 'F' )
67  c2 -= 'A' - 10;
68  else
69  assert( 0 );
70 
71  *obuf++ = ( c << 4 ) | c2;
72  }
73 
74  return len;
75 }
76 
77 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
78 {
79  unsigned char l, h;
80 
81  while (len != 0)
82  {
83  h = (*ibuf) / 16;
84  l = (*ibuf) % 16;
85 
86  if( h < 10 )
87  *obuf++ = '0' + h;
88  else
89  *obuf++ = 'a' + h - 10;
90 
91  if( l < 10 )
92  *obuf++ = '0' + l;
93  else
94  *obuf++ = 'a' + l - 10;
95 
96  ++ibuf;
97  len--;
98  }
99 }
100 
110 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
111 {
112  size_t i;
113 
114  if( rng_state != NULL )
115  rng_state = NULL;
116 
117  for( i = 0; i < len; ++i )
118  output[i] = rand();
119 
120  return( 0 );
121 }
122 
128 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
129 {
130  if( rng_state != NULL )
131  rng_state = NULL;
132 
133  memset( output, 0, len );
134 
135  return( 0 );
136 }
137 
138 typedef struct
139 {
140  unsigned char *buf;
141  size_t length;
142 } rnd_buf_info;
143 
155 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
156 {
157  rnd_buf_info *info = (rnd_buf_info *) rng_state;
158  size_t use_len;
159 
160  if( rng_state == NULL )
161  return( rnd_std_rand( NULL, output, len ) );
162 
163  use_len = len;
164  if( len > info->length )
165  use_len = info->length;
166 
167  if( use_len )
168  {
169  memcpy( output, info->buf, use_len );
170  info->buf += use_len;
171  info->length -= use_len;
172  }
173 
174  if( len - use_len > 0 )
175  return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
176 
177  return( 0 );
178 }
179 
187 typedef struct
188 {
189  uint32_t key[16];
190  uint32_t v0, v1;
192 
201 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
202 {
203  rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
204  uint32_t i, *k, sum, delta=0x9E3779B9;
205  unsigned char result[4];
206 
207  if( rng_state == NULL )
208  return( rnd_std_rand( NULL, output, len ) );
209 
210  k = info->key;
211 
212  while( len > 0 )
213  {
214  size_t use_len = ( len > 4 ) ? 4 : len;
215  sum = 0;
216 
217  for( i = 0; i < 32; i++ )
218  {
219  info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
220  sum += delta;
221  info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
222  }
223 
224  PUT_ULONG_BE( info->v0, result, 0 );
225  memcpy( output, result, use_len );
226  len -= use_len;
227  }
228 
229  return( 0 );
230 }
231 
232 
234 {
235 #ifdef POLARSSL_MD_C
236 
237 
238  FCT_SUITE_BGN(test_suite_md)
239  {
240 #ifdef POLARSSL_MD2_C
241 
242  FCT_TEST_BGN(generic_md2_test_vector_rfc1319_1)
243  {
244  char md_name[100];
245  unsigned char src_str[1000];
246  unsigned char hash_str[1000];
247  unsigned char output[100];
248  const md_info_t *md_info = NULL;
249 
250  memset(md_name, 0x00, 100);
251  memset(src_str, 0x00, 1000);
252  memset(hash_str, 0x00, 1000);
253  memset(output, 0x00, 100);
254 
255  strcpy( (char *) src_str, "" );
256 
257  strncpy( (char *) md_name, "md2", 100 );
258  md_info = md_info_from_string(md_name);
259  fct_chk( md_info != NULL );
260 
261  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
262  hexify( hash_str, output, md_get_size(md_info) );
263 
264  fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
265  }
266  FCT_TEST_END();
267 #endif /* POLARSSL_MD2_C */
268 
269 #ifdef POLARSSL_MD2_C
270 
271  FCT_TEST_BGN(generic_md2_test_vector_rfc1319_2)
272  {
273  char md_name[100];
274  unsigned char src_str[1000];
275  unsigned char hash_str[1000];
276  unsigned char output[100];
277  const md_info_t *md_info = NULL;
278 
279  memset(md_name, 0x00, 100);
280  memset(src_str, 0x00, 1000);
281  memset(hash_str, 0x00, 1000);
282  memset(output, 0x00, 100);
283 
284  strcpy( (char *) src_str, "a" );
285 
286  strncpy( (char *) md_name, "md2", 100 );
287  md_info = md_info_from_string(md_name);
288  fct_chk( md_info != NULL );
289 
290  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
291  hexify( hash_str, output, md_get_size(md_info) );
292 
293  fct_chk( strcmp( (char *) hash_str, "32ec01ec4a6dac72c0ab96fb34c0b5d1" ) == 0 );
294  }
295  FCT_TEST_END();
296 #endif /* POLARSSL_MD2_C */
297 
298 #ifdef POLARSSL_MD2_C
299 
300  FCT_TEST_BGN(generic_md2_test_vector_rfc1319_3)
301  {
302  char md_name[100];
303  unsigned char src_str[1000];
304  unsigned char hash_str[1000];
305  unsigned char output[100];
306  const md_info_t *md_info = NULL;
307 
308  memset(md_name, 0x00, 100);
309  memset(src_str, 0x00, 1000);
310  memset(hash_str, 0x00, 1000);
311  memset(output, 0x00, 100);
312 
313  strcpy( (char *) src_str, "abc" );
314 
315  strncpy( (char *) md_name, "md2", 100 );
316  md_info = md_info_from_string(md_name);
317  fct_chk( md_info != NULL );
318 
319  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
320  hexify( hash_str, output, md_get_size(md_info) );
321 
322  fct_chk( strcmp( (char *) hash_str, "da853b0d3f88d99b30283a69e6ded6bb" ) == 0 );
323  }
324  FCT_TEST_END();
325 #endif /* POLARSSL_MD2_C */
326 
327 #ifdef POLARSSL_MD2_C
328 
329  FCT_TEST_BGN(generic_md2_test_vector_rfc1319_4)
330  {
331  char md_name[100];
332  unsigned char src_str[1000];
333  unsigned char hash_str[1000];
334  unsigned char output[100];
335  const md_info_t *md_info = NULL;
336 
337  memset(md_name, 0x00, 100);
338  memset(src_str, 0x00, 1000);
339  memset(hash_str, 0x00, 1000);
340  memset(output, 0x00, 100);
341 
342  strcpy( (char *) src_str, "message digest" );
343 
344  strncpy( (char *) md_name, "md2", 100 );
345  md_info = md_info_from_string(md_name);
346  fct_chk( md_info != NULL );
347 
348  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
349  hexify( hash_str, output, md_get_size(md_info) );
350 
351  fct_chk( strcmp( (char *) hash_str, "ab4f496bfb2a530b219ff33031fe06b0" ) == 0 );
352  }
353  FCT_TEST_END();
354 #endif /* POLARSSL_MD2_C */
355 
356 #ifdef POLARSSL_MD2_C
357 
358  FCT_TEST_BGN(generic_md2_test_vector_rfc1319_5)
359  {
360  char md_name[100];
361  unsigned char src_str[1000];
362  unsigned char hash_str[1000];
363  unsigned char output[100];
364  const md_info_t *md_info = NULL;
365 
366  memset(md_name, 0x00, 100);
367  memset(src_str, 0x00, 1000);
368  memset(hash_str, 0x00, 1000);
369  memset(output, 0x00, 100);
370 
371  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
372 
373  strncpy( (char *) md_name, "md2", 100 );
374  md_info = md_info_from_string(md_name);
375  fct_chk( md_info != NULL );
376 
377  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
378  hexify( hash_str, output, md_get_size(md_info) );
379 
380  fct_chk( strcmp( (char *) hash_str, "4e8ddff3650292ab5a4108c3aa47940b" ) == 0 );
381  }
382  FCT_TEST_END();
383 #endif /* POLARSSL_MD2_C */
384 
385 #ifdef POLARSSL_MD2_C
386 
387  FCT_TEST_BGN(generic_md2_test_vector_rfc1319_6)
388  {
389  char md_name[100];
390  unsigned char src_str[1000];
391  unsigned char hash_str[1000];
392  unsigned char output[100];
393  const md_info_t *md_info = NULL;
394 
395  memset(md_name, 0x00, 100);
396  memset(src_str, 0x00, 1000);
397  memset(hash_str, 0x00, 1000);
398  memset(output, 0x00, 100);
399 
400  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
401 
402  strncpy( (char *) md_name, "md2", 100 );
403  md_info = md_info_from_string(md_name);
404  fct_chk( md_info != NULL );
405 
406  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
407  hexify( hash_str, output, md_get_size(md_info) );
408 
409  fct_chk( strcmp( (char *) hash_str, "da33def2a42df13975352846c30338cd" ) == 0 );
410  }
411  FCT_TEST_END();
412 #endif /* POLARSSL_MD2_C */
413 
414 #ifdef POLARSSL_MD2_C
415 
416  FCT_TEST_BGN(generic_md2_test_vector_rfc1319_7)
417  {
418  char md_name[100];
419  unsigned char src_str[1000];
420  unsigned char hash_str[1000];
421  unsigned char output[100];
422  const md_info_t *md_info = NULL;
423 
424  memset(md_name, 0x00, 100);
425  memset(src_str, 0x00, 1000);
426  memset(hash_str, 0x00, 1000);
427  memset(output, 0x00, 100);
428 
429  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
430 
431  strncpy( (char *) md_name, "md2", 100 );
432  md_info = md_info_from_string(md_name);
433  fct_chk( md_info != NULL );
434 
435  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
436  hexify( hash_str, output, md_get_size(md_info) );
437 
438  fct_chk( strcmp( (char *) hash_str, "d5976f79d83d3a0dc9806c3c66f3efd8" ) == 0 );
439  }
440  FCT_TEST_END();
441 #endif /* POLARSSL_MD2_C */
442 
443 #ifdef POLARSSL_MD4_C
444 
445  FCT_TEST_BGN(generic_md4_test_vector_rfc1320_1)
446  {
447  char md_name[100];
448  unsigned char src_str[1000];
449  unsigned char hash_str[1000];
450  unsigned char output[100];
451  const md_info_t *md_info = NULL;
452 
453  memset(md_name, 0x00, 100);
454  memset(src_str, 0x00, 1000);
455  memset(hash_str, 0x00, 1000);
456  memset(output, 0x00, 100);
457 
458  strcpy( (char *) src_str, "" );
459 
460  strncpy( (char *) md_name, "md4", 100 );
461  md_info = md_info_from_string(md_name);
462  fct_chk( md_info != NULL );
463 
464  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
465  hexify( hash_str, output, md_get_size(md_info) );
466 
467  fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
468  }
469  FCT_TEST_END();
470 #endif /* POLARSSL_MD4_C */
471 
472 #ifdef POLARSSL_MD4_C
473 
474  FCT_TEST_BGN(generic_md4_test_vector_rfc1320_2)
475  {
476  char md_name[100];
477  unsigned char src_str[1000];
478  unsigned char hash_str[1000];
479  unsigned char output[100];
480  const md_info_t *md_info = NULL;
481 
482  memset(md_name, 0x00, 100);
483  memset(src_str, 0x00, 1000);
484  memset(hash_str, 0x00, 1000);
485  memset(output, 0x00, 100);
486 
487  strcpy( (char *) src_str, "a" );
488 
489  strncpy( (char *) md_name, "md4", 100 );
490  md_info = md_info_from_string(md_name);
491  fct_chk( md_info != NULL );
492 
493  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
494  hexify( hash_str, output, md_get_size(md_info) );
495 
496  fct_chk( strcmp( (char *) hash_str, "bde52cb31de33e46245e05fbdbd6fb24" ) == 0 );
497  }
498  FCT_TEST_END();
499 #endif /* POLARSSL_MD4_C */
500 
501 #ifdef POLARSSL_MD4_C
502 
503  FCT_TEST_BGN(generic_md4_test_vector_rfc1320_3)
504  {
505  char md_name[100];
506  unsigned char src_str[1000];
507  unsigned char hash_str[1000];
508  unsigned char output[100];
509  const md_info_t *md_info = NULL;
510 
511  memset(md_name, 0x00, 100);
512  memset(src_str, 0x00, 1000);
513  memset(hash_str, 0x00, 1000);
514  memset(output, 0x00, 100);
515 
516  strcpy( (char *) src_str, "abc" );
517 
518  strncpy( (char *) md_name, "md4", 100 );
519  md_info = md_info_from_string(md_name);
520  fct_chk( md_info != NULL );
521 
522  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
523  hexify( hash_str, output, md_get_size(md_info) );
524 
525  fct_chk( strcmp( (char *) hash_str, "a448017aaf21d8525fc10ae87aa6729d" ) == 0 );
526  }
527  FCT_TEST_END();
528 #endif /* POLARSSL_MD4_C */
529 
530 #ifdef POLARSSL_MD4_C
531 
532  FCT_TEST_BGN(generic_md4_test_vector_rfc1320_4)
533  {
534  char md_name[100];
535  unsigned char src_str[1000];
536  unsigned char hash_str[1000];
537  unsigned char output[100];
538  const md_info_t *md_info = NULL;
539 
540  memset(md_name, 0x00, 100);
541  memset(src_str, 0x00, 1000);
542  memset(hash_str, 0x00, 1000);
543  memset(output, 0x00, 100);
544 
545  strcpy( (char *) src_str, "message digest" );
546 
547  strncpy( (char *) md_name, "md4", 100 );
548  md_info = md_info_from_string(md_name);
549  fct_chk( md_info != NULL );
550 
551  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
552  hexify( hash_str, output, md_get_size(md_info) );
553 
554  fct_chk( strcmp( (char *) hash_str, "d9130a8164549fe818874806e1c7014b" ) == 0 );
555  }
556  FCT_TEST_END();
557 #endif /* POLARSSL_MD4_C */
558 
559 #ifdef POLARSSL_MD4_C
560 
561  FCT_TEST_BGN(generic_md4_test_vector_rfc1320_5)
562  {
563  char md_name[100];
564  unsigned char src_str[1000];
565  unsigned char hash_str[1000];
566  unsigned char output[100];
567  const md_info_t *md_info = NULL;
568 
569  memset(md_name, 0x00, 100);
570  memset(src_str, 0x00, 1000);
571  memset(hash_str, 0x00, 1000);
572  memset(output, 0x00, 100);
573 
574  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
575 
576  strncpy( (char *) md_name, "md4", 100 );
577  md_info = md_info_from_string(md_name);
578  fct_chk( md_info != NULL );
579 
580  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
581  hexify( hash_str, output, md_get_size(md_info) );
582 
583  fct_chk( strcmp( (char *) hash_str, "d79e1c308aa5bbcdeea8ed63df412da9" ) == 0 );
584  }
585  FCT_TEST_END();
586 #endif /* POLARSSL_MD4_C */
587 
588 #ifdef POLARSSL_MD4_C
589 
590  FCT_TEST_BGN(generic_md4_test_vector_rfc1320_6)
591  {
592  char md_name[100];
593  unsigned char src_str[1000];
594  unsigned char hash_str[1000];
595  unsigned char output[100];
596  const md_info_t *md_info = NULL;
597 
598  memset(md_name, 0x00, 100);
599  memset(src_str, 0x00, 1000);
600  memset(hash_str, 0x00, 1000);
601  memset(output, 0x00, 100);
602 
603  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
604 
605  strncpy( (char *) md_name, "md4", 100 );
606  md_info = md_info_from_string(md_name);
607  fct_chk( md_info != NULL );
608 
609  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
610  hexify( hash_str, output, md_get_size(md_info) );
611 
612  fct_chk( strcmp( (char *) hash_str, "043f8582f241db351ce627e153e7f0e4" ) == 0 );
613  }
614  FCT_TEST_END();
615 #endif /* POLARSSL_MD4_C */
616 
617 #ifdef POLARSSL_MD4_C
618 
619  FCT_TEST_BGN(generic_md4_test_vector_rfc1320_7)
620  {
621  char md_name[100];
622  unsigned char src_str[1000];
623  unsigned char hash_str[1000];
624  unsigned char output[100];
625  const md_info_t *md_info = NULL;
626 
627  memset(md_name, 0x00, 100);
628  memset(src_str, 0x00, 1000);
629  memset(hash_str, 0x00, 1000);
630  memset(output, 0x00, 100);
631 
632  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
633 
634  strncpy( (char *) md_name, "md4", 100 );
635  md_info = md_info_from_string(md_name);
636  fct_chk( md_info != NULL );
637 
638  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
639  hexify( hash_str, output, md_get_size(md_info) );
640 
641  fct_chk( strcmp( (char *) hash_str, "e33b4ddc9c38f2199c3e7b164fcc0536" ) == 0 );
642  }
643  FCT_TEST_END();
644 #endif /* POLARSSL_MD4_C */
645 
646 #ifdef POLARSSL_MD5_C
647 
648  FCT_TEST_BGN(generic_md5_test_vector_rfc1321_1)
649  {
650  char md_name[100];
651  unsigned char src_str[1000];
652  unsigned char hash_str[1000];
653  unsigned char output[100];
654  const md_info_t *md_info = NULL;
655 
656  memset(md_name, 0x00, 100);
657  memset(src_str, 0x00, 1000);
658  memset(hash_str, 0x00, 1000);
659  memset(output, 0x00, 100);
660 
661  strcpy( (char *) src_str, "" );
662 
663  strncpy( (char *) md_name, "md5", 100 );
664  md_info = md_info_from_string(md_name);
665  fct_chk( md_info != NULL );
666 
667  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
668  hexify( hash_str, output, md_get_size(md_info) );
669 
670  fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
671  }
672  FCT_TEST_END();
673 #endif /* POLARSSL_MD5_C */
674 
675 #ifdef POLARSSL_MD5_C
676 
677  FCT_TEST_BGN(generic_md5_test_vector_rfc1321_2)
678  {
679  char md_name[100];
680  unsigned char src_str[1000];
681  unsigned char hash_str[1000];
682  unsigned char output[100];
683  const md_info_t *md_info = NULL;
684 
685  memset(md_name, 0x00, 100);
686  memset(src_str, 0x00, 1000);
687  memset(hash_str, 0x00, 1000);
688  memset(output, 0x00, 100);
689 
690  strcpy( (char *) src_str, "a" );
691 
692  strncpy( (char *) md_name, "md5", 100 );
693  md_info = md_info_from_string(md_name);
694  fct_chk( md_info != NULL );
695 
696  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
697  hexify( hash_str, output, md_get_size(md_info) );
698 
699  fct_chk( strcmp( (char *) hash_str, "0cc175b9c0f1b6a831c399e269772661" ) == 0 );
700  }
701  FCT_TEST_END();
702 #endif /* POLARSSL_MD5_C */
703 
704 #ifdef POLARSSL_MD5_C
705 
706  FCT_TEST_BGN(generic_md5_test_vector_rfc1321_3)
707  {
708  char md_name[100];
709  unsigned char src_str[1000];
710  unsigned char hash_str[1000];
711  unsigned char output[100];
712  const md_info_t *md_info = NULL;
713 
714  memset(md_name, 0x00, 100);
715  memset(src_str, 0x00, 1000);
716  memset(hash_str, 0x00, 1000);
717  memset(output, 0x00, 100);
718 
719  strcpy( (char *) src_str, "abc" );
720 
721  strncpy( (char *) md_name, "md5", 100 );
722  md_info = md_info_from_string(md_name);
723  fct_chk( md_info != NULL );
724 
725  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
726  hexify( hash_str, output, md_get_size(md_info) );
727 
728  fct_chk( strcmp( (char *) hash_str, "900150983cd24fb0d6963f7d28e17f72" ) == 0 );
729  }
730  FCT_TEST_END();
731 #endif /* POLARSSL_MD5_C */
732 
733 #ifdef POLARSSL_MD5_C
734 
735  FCT_TEST_BGN(generic_md5_test_vector_rfc1321_4)
736  {
737  char md_name[100];
738  unsigned char src_str[1000];
739  unsigned char hash_str[1000];
740  unsigned char output[100];
741  const md_info_t *md_info = NULL;
742 
743  memset(md_name, 0x00, 100);
744  memset(src_str, 0x00, 1000);
745  memset(hash_str, 0x00, 1000);
746  memset(output, 0x00, 100);
747 
748  strcpy( (char *) src_str, "message digest" );
749 
750  strncpy( (char *) md_name, "md5", 100 );
751  md_info = md_info_from_string(md_name);
752  fct_chk( md_info != NULL );
753 
754  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
755  hexify( hash_str, output, md_get_size(md_info) );
756 
757  fct_chk( strcmp( (char *) hash_str, "f96b697d7cb7938d525a2f31aaf161d0" ) == 0 );
758  }
759  FCT_TEST_END();
760 #endif /* POLARSSL_MD5_C */
761 
762 #ifdef POLARSSL_MD5_C
763 
764  FCT_TEST_BGN(generic_md5_test_vector_rfc1321_5)
765  {
766  char md_name[100];
767  unsigned char src_str[1000];
768  unsigned char hash_str[1000];
769  unsigned char output[100];
770  const md_info_t *md_info = NULL;
771 
772  memset(md_name, 0x00, 100);
773  memset(src_str, 0x00, 1000);
774  memset(hash_str, 0x00, 1000);
775  memset(output, 0x00, 100);
776 
777  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
778 
779  strncpy( (char *) md_name, "md5", 100 );
780  md_info = md_info_from_string(md_name);
781  fct_chk( md_info != NULL );
782 
783  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
784  hexify( hash_str, output, md_get_size(md_info) );
785 
786  fct_chk( strcmp( (char *) hash_str, "c3fcd3d76192e4007dfb496cca67e13b" ) == 0 );
787  }
788  FCT_TEST_END();
789 #endif /* POLARSSL_MD5_C */
790 
791 #ifdef POLARSSL_MD5_C
792 
793  FCT_TEST_BGN(generic_md5_test_vector_rfc1321_6)
794  {
795  char md_name[100];
796  unsigned char src_str[1000];
797  unsigned char hash_str[1000];
798  unsigned char output[100];
799  const md_info_t *md_info = NULL;
800 
801  memset(md_name, 0x00, 100);
802  memset(src_str, 0x00, 1000);
803  memset(hash_str, 0x00, 1000);
804  memset(output, 0x00, 100);
805 
806  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
807 
808  strncpy( (char *) md_name, "md5", 100 );
809  md_info = md_info_from_string(md_name);
810  fct_chk( md_info != NULL );
811 
812  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
813  hexify( hash_str, output, md_get_size(md_info) );
814 
815  fct_chk( strcmp( (char *) hash_str, "d174ab98d277d9f5a5611c2c9f419d9f" ) == 0 );
816  }
817  FCT_TEST_END();
818 #endif /* POLARSSL_MD5_C */
819 
820 #ifdef POLARSSL_MD5_C
821 
822  FCT_TEST_BGN(generic_md5_test_vector_rfc1321_7)
823  {
824  char md_name[100];
825  unsigned char src_str[1000];
826  unsigned char hash_str[1000];
827  unsigned char output[100];
828  const md_info_t *md_info = NULL;
829 
830  memset(md_name, 0x00, 100);
831  memset(src_str, 0x00, 1000);
832  memset(hash_str, 0x00, 1000);
833  memset(output, 0x00, 100);
834 
835  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
836 
837  strncpy( (char *) md_name, "md5", 100 );
838  md_info = md_info_from_string(md_name);
839  fct_chk( md_info != NULL );
840 
841  fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
842  hexify( hash_str, output, md_get_size(md_info) );
843 
844  fct_chk( strcmp( (char *) hash_str, "57edf4a22be3c955ac49da2e2107b67a" ) == 0 );
845  }
846  FCT_TEST_END();
847 #endif /* POLARSSL_MD5_C */
848 
849 #ifdef POLARSSL_MD2_C
850 
851  FCT_TEST_BGN(generic_hmac_md2_hash_file_openssl_test_1)
852  {
853  char md_name[100];
854  unsigned char src_str[10000];
855  unsigned char key_str[10000];
856  unsigned char hash_str[10000];
857  unsigned char output[100];
858  int key_len, src_len;
859  const md_info_t *md_info = NULL;
860 
861  memset(md_name, 0x00, 100);
862  memset(src_str, 0x00, 10000);
863  memset(key_str, 0x00, 10000);
864  memset(hash_str, 0x00, 10000);
865  memset(output, 0x00, 100);
866 
867  strncpy( (char *) md_name, "md2", 100 );
868  md_info = md_info_from_string( md_name );
869  fct_chk( md_info != NULL );
870 
871  key_len = unhexify( key_str, "61616161616161616161616161616161" );
872  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
873 
874  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
875  hexify( hash_str, output, md_get_size(md_info) );
876 
877  fct_chk( strncmp( (char *) hash_str, "d5732582f494f5ddf35efd166c85af9c", 16 * 2 ) == 0 );
878  }
879  FCT_TEST_END();
880 #endif /* POLARSSL_MD2_C */
881 
882 #ifdef POLARSSL_MD2_C
883 
884  FCT_TEST_BGN(generic_hmac_md2_hash_file_openssl_test_2)
885  {
886  char md_name[100];
887  unsigned char src_str[10000];
888  unsigned char key_str[10000];
889  unsigned char hash_str[10000];
890  unsigned char output[100];
891  int key_len, src_len;
892  const md_info_t *md_info = NULL;
893 
894  memset(md_name, 0x00, 100);
895  memset(src_str, 0x00, 10000);
896  memset(key_str, 0x00, 10000);
897  memset(hash_str, 0x00, 10000);
898  memset(output, 0x00, 100);
899 
900  strncpy( (char *) md_name, "md2", 100 );
901  md_info = md_info_from_string( md_name );
902  fct_chk( md_info != NULL );
903 
904  key_len = unhexify( key_str, "61616161616161616161616161616161" );
905  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
906 
907  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
908  hexify( hash_str, output, md_get_size(md_info) );
909 
910  fct_chk( strncmp( (char *) hash_str, "54ab68503f7d1b5c7741340dff2722a9", 16 * 2 ) == 0 );
911  }
912  FCT_TEST_END();
913 #endif /* POLARSSL_MD2_C */
914 
915 #ifdef POLARSSL_MD2_C
916 
917  FCT_TEST_BGN(generic_hmac_md2_hash_file_openssl_test_3)
918  {
919  char md_name[100];
920  unsigned char src_str[10000];
921  unsigned char key_str[10000];
922  unsigned char hash_str[10000];
923  unsigned char output[100];
924  int key_len, src_len;
925  const md_info_t *md_info = NULL;
926 
927  memset(md_name, 0x00, 100);
928  memset(src_str, 0x00, 10000);
929  memset(key_str, 0x00, 10000);
930  memset(hash_str, 0x00, 10000);
931  memset(output, 0x00, 100);
932 
933  strncpy( (char *) md_name, "md2", 100 );
934  md_info = md_info_from_string( md_name );
935  fct_chk( md_info != NULL );
936 
937  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
938  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
939 
940  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
941  hexify( hash_str, output, md_get_size(md_info) );
942 
943  fct_chk( strncmp( (char *) hash_str, "d850e5f554558cf0fe79a0612e1d0365", 16 * 2 ) == 0 );
944  }
945  FCT_TEST_END();
946 #endif /* POLARSSL_MD2_C */
947 
948 #ifdef POLARSSL_MD4_C
949 
950  FCT_TEST_BGN(generic_hmac_md4_hash_file_openssl_test_1)
951  {
952  char md_name[100];
953  unsigned char src_str[10000];
954  unsigned char key_str[10000];
955  unsigned char hash_str[10000];
956  unsigned char output[100];
957  int key_len, src_len;
958  const md_info_t *md_info = NULL;
959 
960  memset(md_name, 0x00, 100);
961  memset(src_str, 0x00, 10000);
962  memset(key_str, 0x00, 10000);
963  memset(hash_str, 0x00, 10000);
964  memset(output, 0x00, 100);
965 
966  strncpy( (char *) md_name, "md4", 100 );
967  md_info = md_info_from_string( md_name );
968  fct_chk( md_info != NULL );
969 
970  key_len = unhexify( key_str, "61616161616161616161616161616161" );
971  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
972 
973  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
974  hexify( hash_str, output, md_get_size(md_info) );
975 
976  fct_chk( strncmp( (char *) hash_str, "eabd0fbefb82fb0063a25a6d7b8bdc0f", 16 * 2 ) == 0 );
977  }
978  FCT_TEST_END();
979 #endif /* POLARSSL_MD4_C */
980 
981 #ifdef POLARSSL_MD4_C
982 
983  FCT_TEST_BGN(generic_hmac_md4_hash_file_openssl_test_2)
984  {
985  char md_name[100];
986  unsigned char src_str[10000];
987  unsigned char key_str[10000];
988  unsigned char hash_str[10000];
989  unsigned char output[100];
990  int key_len, src_len;
991  const md_info_t *md_info = NULL;
992 
993  memset(md_name, 0x00, 100);
994  memset(src_str, 0x00, 10000);
995  memset(key_str, 0x00, 10000);
996  memset(hash_str, 0x00, 10000);
997  memset(output, 0x00, 100);
998 
999  strncpy( (char *) md_name, "md4", 100 );
1000  md_info = md_info_from_string( md_name );
1001  fct_chk( md_info != NULL );
1002 
1003  key_len = unhexify( key_str, "61616161616161616161616161616161" );
1004  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
1005 
1006  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1007  hexify( hash_str, output, md_get_size(md_info) );
1008 
1009  fct_chk( strncmp( (char *) hash_str, "cec3c5e421a7b783aa89cacf78daf6dc", 16 * 2 ) == 0 );
1010  }
1011  FCT_TEST_END();
1012 #endif /* POLARSSL_MD4_C */
1013 
1014 #ifdef POLARSSL_MD4_C
1015 
1016  FCT_TEST_BGN(generic_hmac_md4_hash_file_openssl_test_3)
1017  {
1018  char md_name[100];
1019  unsigned char src_str[10000];
1020  unsigned char key_str[10000];
1021  unsigned char hash_str[10000];
1022  unsigned char output[100];
1023  int key_len, src_len;
1024  const md_info_t *md_info = NULL;
1025 
1026  memset(md_name, 0x00, 100);
1027  memset(src_str, 0x00, 10000);
1028  memset(key_str, 0x00, 10000);
1029  memset(hash_str, 0x00, 10000);
1030  memset(output, 0x00, 100);
1031 
1032  strncpy( (char *) md_name, "md4", 100 );
1033  md_info = md_info_from_string( md_name );
1034  fct_chk( md_info != NULL );
1035 
1036  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
1037  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
1038 
1039  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1040  hexify( hash_str, output, md_get_size(md_info) );
1041 
1042  fct_chk( strncmp( (char *) hash_str, "ad5f0a04116109b397b57f9cc9b6df4b", 16 * 2 ) == 0 );
1043  }
1044  FCT_TEST_END();
1045 #endif /* POLARSSL_MD4_C */
1046 
1047 #ifdef POLARSSL_MD5_C
1048 
1049  FCT_TEST_BGN(generic_hmac_md5_hash_file_openssl_test_1)
1050  {
1051  char md_name[100];
1052  unsigned char src_str[10000];
1053  unsigned char key_str[10000];
1054  unsigned char hash_str[10000];
1055  unsigned char output[100];
1056  int key_len, src_len;
1057  const md_info_t *md_info = NULL;
1058 
1059  memset(md_name, 0x00, 100);
1060  memset(src_str, 0x00, 10000);
1061  memset(key_str, 0x00, 10000);
1062  memset(hash_str, 0x00, 10000);
1063  memset(output, 0x00, 100);
1064 
1065  strncpy( (char *) md_name, "md5", 100 );
1066  md_info = md_info_from_string( md_name );
1067  fct_chk( md_info != NULL );
1068 
1069  key_len = unhexify( key_str, "61616161616161616161616161616161" );
1070  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
1071 
1072  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1073  hexify( hash_str, output, md_get_size(md_info) );
1074 
1075  fct_chk( strncmp( (char *) hash_str, "42552882f00bd4633ea81135a184b284", 16 * 2 ) == 0 );
1076  }
1077  FCT_TEST_END();
1078 #endif /* POLARSSL_MD5_C */
1079 
1080 #ifdef POLARSSL_MD5_C
1081 
1082  FCT_TEST_BGN(generic_hmac_md5_hash_file_openssl_test_2)
1083  {
1084  char md_name[100];
1085  unsigned char src_str[10000];
1086  unsigned char key_str[10000];
1087  unsigned char hash_str[10000];
1088  unsigned char output[100];
1089  int key_len, src_len;
1090  const md_info_t *md_info = NULL;
1091 
1092  memset(md_name, 0x00, 100);
1093  memset(src_str, 0x00, 10000);
1094  memset(key_str, 0x00, 10000);
1095  memset(hash_str, 0x00, 10000);
1096  memset(output, 0x00, 100);
1097 
1098  strncpy( (char *) md_name, "md5", 100 );
1099  md_info = md_info_from_string( md_name );
1100  fct_chk( md_info != NULL );
1101 
1102  key_len = unhexify( key_str, "61616161616161616161616161616161" );
1103  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
1104 
1105  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1106  hexify( hash_str, output, md_get_size(md_info) );
1107 
1108  fct_chk( strncmp( (char *) hash_str, "a16a842891786d01fe50ba7731db7464", 16 * 2 ) == 0 );
1109  }
1110  FCT_TEST_END();
1111 #endif /* POLARSSL_MD5_C */
1112 
1113 #ifdef POLARSSL_MD5_C
1114 
1115  FCT_TEST_BGN(generic_hmac_md5_hash_file_openssl_test_3)
1116  {
1117  char md_name[100];
1118  unsigned char src_str[10000];
1119  unsigned char key_str[10000];
1120  unsigned char hash_str[10000];
1121  unsigned char output[100];
1122  int key_len, src_len;
1123  const md_info_t *md_info = NULL;
1124 
1125  memset(md_name, 0x00, 100);
1126  memset(src_str, 0x00, 10000);
1127  memset(key_str, 0x00, 10000);
1128  memset(hash_str, 0x00, 10000);
1129  memset(output, 0x00, 100);
1130 
1131  strncpy( (char *) md_name, "md5", 100 );
1132  md_info = md_info_from_string( md_name );
1133  fct_chk( md_info != NULL );
1134 
1135  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
1136  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
1137 
1138  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1139  hexify( hash_str, output, md_get_size(md_info) );
1140 
1141  fct_chk( strncmp( (char *) hash_str, "e97f623936f98a7f741c4bd0612fecc2", 16 * 2 ) == 0 );
1142  }
1143  FCT_TEST_END();
1144 #endif /* POLARSSL_MD5_C */
1145 
1146 #ifdef POLARSSL_MD5_C
1147 
1148  FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_1)
1149  {
1150  char md_name[100];
1151  unsigned char src_str[10000];
1152  unsigned char key_str[10000];
1153  unsigned char hash_str[10000];
1154  unsigned char output[100];
1155  int key_len, src_len;
1156  const md_info_t *md_info = NULL;
1157 
1158  memset(md_name, 0x00, 100);
1159  memset(src_str, 0x00, 10000);
1160  memset(key_str, 0x00, 10000);
1161  memset(hash_str, 0x00, 10000);
1162  memset(output, 0x00, 100);
1163 
1164  strncpy( (char *) md_name, "md5", 100 );
1165  md_info = md_info_from_string( md_name );
1166  fct_chk( md_info != NULL );
1167 
1168  key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
1169  src_len = unhexify( src_str, "4869205468657265" );
1170 
1171  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1172  hexify( hash_str, output, md_get_size(md_info) );
1173 
1174  fct_chk( strncmp( (char *) hash_str, "9294727a3638bb1c13f48ef8158bfc9d", 16 * 2 ) == 0 );
1175  }
1176  FCT_TEST_END();
1177 #endif /* POLARSSL_MD5_C */
1178 
1179 #ifdef POLARSSL_MD5_C
1180 
1181  FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_2)
1182  {
1183  char md_name[100];
1184  unsigned char src_str[10000];
1185  unsigned char key_str[10000];
1186  unsigned char hash_str[10000];
1187  unsigned char output[100];
1188  int key_len, src_len;
1189  const md_info_t *md_info = NULL;
1190 
1191  memset(md_name, 0x00, 100);
1192  memset(src_str, 0x00, 10000);
1193  memset(key_str, 0x00, 10000);
1194  memset(hash_str, 0x00, 10000);
1195  memset(output, 0x00, 100);
1196 
1197  strncpy( (char *) md_name, "md5", 100 );
1198  md_info = md_info_from_string( md_name );
1199  fct_chk( md_info != NULL );
1200 
1201  key_len = unhexify( key_str, "4a656665" );
1202  src_len = unhexify( src_str, "7768617420646f2079612077616e7420666f72206e6f7468696e673f" );
1203 
1204  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1205  hexify( hash_str, output, md_get_size(md_info) );
1206 
1207  fct_chk( strncmp( (char *) hash_str, "750c783e6ab0b503eaa86e310a5db738", 16 * 2 ) == 0 );
1208  }
1209  FCT_TEST_END();
1210 #endif /* POLARSSL_MD5_C */
1211 
1212 #ifdef POLARSSL_MD5_C
1213 
1214  FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_3)
1215  {
1216  char md_name[100];
1217  unsigned char src_str[10000];
1218  unsigned char key_str[10000];
1219  unsigned char hash_str[10000];
1220  unsigned char output[100];
1221  int key_len, src_len;
1222  const md_info_t *md_info = NULL;
1223 
1224  memset(md_name, 0x00, 100);
1225  memset(src_str, 0x00, 10000);
1226  memset(key_str, 0x00, 10000);
1227  memset(hash_str, 0x00, 10000);
1228  memset(output, 0x00, 100);
1229 
1230  strncpy( (char *) md_name, "md5", 100 );
1231  md_info = md_info_from_string( md_name );
1232  fct_chk( md_info != NULL );
1233 
1234  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
1235  src_len = unhexify( src_str, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" );
1236 
1237  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1238  hexify( hash_str, output, md_get_size(md_info) );
1239 
1240  fct_chk( strncmp( (char *) hash_str, "56be34521d144c88dbb8c733f0e8b3f6", 16 * 2 ) == 0 );
1241  }
1242  FCT_TEST_END();
1243 #endif /* POLARSSL_MD5_C */
1244 
1245 #ifdef POLARSSL_MD5_C
1246 
1247  FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_4)
1248  {
1249  char md_name[100];
1250  unsigned char src_str[10000];
1251  unsigned char key_str[10000];
1252  unsigned char hash_str[10000];
1253  unsigned char output[100];
1254  int key_len, src_len;
1255  const md_info_t *md_info = NULL;
1256 
1257  memset(md_name, 0x00, 100);
1258  memset(src_str, 0x00, 10000);
1259  memset(key_str, 0x00, 10000);
1260  memset(hash_str, 0x00, 10000);
1261  memset(output, 0x00, 100);
1262 
1263  strncpy( (char *) md_name, "md5", 100 );
1264  md_info = md_info_from_string( md_name );
1265  fct_chk( md_info != NULL );
1266 
1267  key_len = unhexify( key_str, "0102030405060708090a0b0c0d0e0f10111213141516171819" );
1268  src_len = unhexify( src_str, "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
1269 
1270  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1271  hexify( hash_str, output, md_get_size(md_info) );
1272 
1273  fct_chk( strncmp( (char *) hash_str, "697eaf0aca3a3aea3a75164746ffaa79", 16 * 2 ) == 0 );
1274  }
1275  FCT_TEST_END();
1276 #endif /* POLARSSL_MD5_C */
1277 
1278 #ifdef POLARSSL_MD5_C
1279 
1280  FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_5)
1281  {
1282  char md_name[100];
1283  unsigned char src_str[10000];
1284  unsigned char key_str[10000];
1285  unsigned char hash_str[10000];
1286  unsigned char output[100];
1287  int key_len, src_len;
1288  const md_info_t *md_info = NULL;
1289 
1290  memset(md_name, 0x00, 100);
1291  memset(src_str, 0x00, 10000);
1292  memset(key_str, 0x00, 10000);
1293  memset(hash_str, 0x00, 10000);
1294  memset(output, 0x00, 100);
1295 
1296  strncpy( (char *) md_name, "md5", 100 );
1297  md_info = md_info_from_string( md_name );
1298  fct_chk( md_info != NULL );
1299 
1300  key_len = unhexify( key_str, "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" );
1301  src_len = unhexify( src_str, "546573742057697468205472756e636174696f6e" );
1302 
1303  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1304  hexify( hash_str, output, md_get_size(md_info) );
1305 
1306  fct_chk( strncmp( (char *) hash_str, "56461ef2342edc00f9bab995", 12 * 2 ) == 0 );
1307  }
1308  FCT_TEST_END();
1309 #endif /* POLARSSL_MD5_C */
1310 
1311 #ifdef POLARSSL_MD5_C
1312 
1313  FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_6)
1314  {
1315  char md_name[100];
1316  unsigned char src_str[10000];
1317  unsigned char key_str[10000];
1318  unsigned char hash_str[10000];
1319  unsigned char output[100];
1320  int key_len, src_len;
1321  const md_info_t *md_info = NULL;
1322 
1323  memset(md_name, 0x00, 100);
1324  memset(src_str, 0x00, 10000);
1325  memset(key_str, 0x00, 10000);
1326  memset(hash_str, 0x00, 10000);
1327  memset(output, 0x00, 100);
1328 
1329  strncpy( (char *) md_name, "md5", 100 );
1330  md_info = md_info_from_string( md_name );
1331  fct_chk( md_info != NULL );
1332 
1333  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
1334  src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374" );
1335 
1336  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1337  hexify( hash_str, output, md_get_size(md_info) );
1338 
1339  fct_chk( strncmp( (char *) hash_str, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", 16 * 2 ) == 0 );
1340  }
1341  FCT_TEST_END();
1342 #endif /* POLARSSL_MD5_C */
1343 
1344 #ifdef POLARSSL_MD5_C
1345 
1346  FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_7)
1347  {
1348  char md_name[100];
1349  unsigned char src_str[10000];
1350  unsigned char key_str[10000];
1351  unsigned char hash_str[10000];
1352  unsigned char output[100];
1353  int key_len, src_len;
1354  const md_info_t *md_info = NULL;
1355 
1356  memset(md_name, 0x00, 100);
1357  memset(src_str, 0x00, 10000);
1358  memset(key_str, 0x00, 10000);
1359  memset(hash_str, 0x00, 10000);
1360  memset(output, 0x00, 100);
1361 
1362  strncpy( (char *) md_name, "md5", 100 );
1363  md_info = md_info_from_string( md_name );
1364  fct_chk( md_info != NULL );
1365 
1366  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
1367  src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461" );
1368 
1369  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
1370  hexify( hash_str, output, md_get_size(md_info) );
1371 
1372  fct_chk( strncmp( (char *) hash_str, "6f630fad67cda0ee1fb1f562db3aa53e", 16 * 2 ) == 0 );
1373  }
1374  FCT_TEST_END();
1375 #endif /* POLARSSL_MD5_C */
1376 
1377 #ifdef POLARSSL_MD_C
1378 #ifdef POLARSSL_MD2_C
1379 
1380  FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_1)
1381  {
1382  char md_name[100];
1383  unsigned char src_str[1000];
1384  unsigned char hash_str[1000];
1385  unsigned char output[100];
1386 
1387  const md_info_t *md_info = NULL;
1389 
1390  memset(md_name, 0x00, 100);
1391  memset(src_str, 0x00, 1000);
1392  memset(hash_str, 0x00, 1000);
1393  memset(output, 0x00, 100);
1394 
1395  strcpy( (char *) src_str, "" );
1396 
1397  strncpy( (char *) md_name, "md2", 100 );
1398  md_info = md_info_from_string(md_name);
1399  fct_chk( md_info != NULL );
1400  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1401 
1402  fct_chk ( 0 == md_starts( &ctx ) );
1403  fct_chk ( ctx.md_ctx != NULL );
1404  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1405  fct_chk ( 0 == md_finish( &ctx, output ) );
1406  fct_chk ( 0 == md_free_ctx( &ctx ) );
1407 
1408  hexify( hash_str, output, md_get_size(md_info) );
1409 
1410  fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
1411  }
1412  FCT_TEST_END();
1413 #endif /* POLARSSL_MD_C */
1414 #endif /* POLARSSL_MD2_C */
1415 
1416 #ifdef POLARSSL_MD2_C
1417 
1418  FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_2)
1419  {
1420  char md_name[100];
1421  unsigned char src_str[1000];
1422  unsigned char hash_str[1000];
1423  unsigned char output[100];
1424 
1425  const md_info_t *md_info = NULL;
1427 
1428  memset(md_name, 0x00, 100);
1429  memset(src_str, 0x00, 1000);
1430  memset(hash_str, 0x00, 1000);
1431  memset(output, 0x00, 100);
1432 
1433  strcpy( (char *) src_str, "a" );
1434 
1435  strncpy( (char *) md_name, "md2", 100 );
1436  md_info = md_info_from_string(md_name);
1437  fct_chk( md_info != NULL );
1438  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1439 
1440  fct_chk ( 0 == md_starts( &ctx ) );
1441  fct_chk ( ctx.md_ctx != NULL );
1442  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1443  fct_chk ( 0 == md_finish( &ctx, output ) );
1444  fct_chk ( 0 == md_free_ctx( &ctx ) );
1445 
1446  hexify( hash_str, output, md_get_size(md_info) );
1447 
1448  fct_chk( strcmp( (char *) hash_str, "32ec01ec4a6dac72c0ab96fb34c0b5d1" ) == 0 );
1449  }
1450  FCT_TEST_END();
1451 #endif /* POLARSSL_MD2_C */
1452 
1453 #ifdef POLARSSL_MD2_C
1454 
1455  FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_3)
1456  {
1457  char md_name[100];
1458  unsigned char src_str[1000];
1459  unsigned char hash_str[1000];
1460  unsigned char output[100];
1461 
1462  const md_info_t *md_info = NULL;
1464 
1465  memset(md_name, 0x00, 100);
1466  memset(src_str, 0x00, 1000);
1467  memset(hash_str, 0x00, 1000);
1468  memset(output, 0x00, 100);
1469 
1470  strcpy( (char *) src_str, "abc" );
1471 
1472  strncpy( (char *) md_name, "md2", 100 );
1473  md_info = md_info_from_string(md_name);
1474  fct_chk( md_info != NULL );
1475  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1476 
1477  fct_chk ( 0 == md_starts( &ctx ) );
1478  fct_chk ( ctx.md_ctx != NULL );
1479  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1480  fct_chk ( 0 == md_finish( &ctx, output ) );
1481  fct_chk ( 0 == md_free_ctx( &ctx ) );
1482 
1483  hexify( hash_str, output, md_get_size(md_info) );
1484 
1485  fct_chk( strcmp( (char *) hash_str, "da853b0d3f88d99b30283a69e6ded6bb" ) == 0 );
1486  }
1487  FCT_TEST_END();
1488 #endif /* POLARSSL_MD2_C */
1489 
1490 #ifdef POLARSSL_MD2_C
1491 
1492  FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_4)
1493  {
1494  char md_name[100];
1495  unsigned char src_str[1000];
1496  unsigned char hash_str[1000];
1497  unsigned char output[100];
1498 
1499  const md_info_t *md_info = NULL;
1501 
1502  memset(md_name, 0x00, 100);
1503  memset(src_str, 0x00, 1000);
1504  memset(hash_str, 0x00, 1000);
1505  memset(output, 0x00, 100);
1506 
1507  strcpy( (char *) src_str, "message digest" );
1508 
1509  strncpy( (char *) md_name, "md2", 100 );
1510  md_info = md_info_from_string(md_name);
1511  fct_chk( md_info != NULL );
1512  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1513 
1514  fct_chk ( 0 == md_starts( &ctx ) );
1515  fct_chk ( ctx.md_ctx != NULL );
1516  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1517  fct_chk ( 0 == md_finish( &ctx, output ) );
1518  fct_chk ( 0 == md_free_ctx( &ctx ) );
1519 
1520  hexify( hash_str, output, md_get_size(md_info) );
1521 
1522  fct_chk( strcmp( (char *) hash_str, "ab4f496bfb2a530b219ff33031fe06b0" ) == 0 );
1523  }
1524  FCT_TEST_END();
1525 #endif /* POLARSSL_MD2_C */
1526 
1527 #ifdef POLARSSL_MD2_C
1528 
1529  FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_5)
1530  {
1531  char md_name[100];
1532  unsigned char src_str[1000];
1533  unsigned char hash_str[1000];
1534  unsigned char output[100];
1535 
1536  const md_info_t *md_info = NULL;
1538 
1539  memset(md_name, 0x00, 100);
1540  memset(src_str, 0x00, 1000);
1541  memset(hash_str, 0x00, 1000);
1542  memset(output, 0x00, 100);
1543 
1544  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
1545 
1546  strncpy( (char *) md_name, "md2", 100 );
1547  md_info = md_info_from_string(md_name);
1548  fct_chk( md_info != NULL );
1549  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1550 
1551  fct_chk ( 0 == md_starts( &ctx ) );
1552  fct_chk ( ctx.md_ctx != NULL );
1553  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1554  fct_chk ( 0 == md_finish( &ctx, output ) );
1555  fct_chk ( 0 == md_free_ctx( &ctx ) );
1556 
1557  hexify( hash_str, output, md_get_size(md_info) );
1558 
1559  fct_chk( strcmp( (char *) hash_str, "4e8ddff3650292ab5a4108c3aa47940b" ) == 0 );
1560  }
1561  FCT_TEST_END();
1562 #endif /* POLARSSL_MD2_C */
1563 
1564 #ifdef POLARSSL_MD2_C
1565 
1566  FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_6)
1567  {
1568  char md_name[100];
1569  unsigned char src_str[1000];
1570  unsigned char hash_str[1000];
1571  unsigned char output[100];
1572 
1573  const md_info_t *md_info = NULL;
1575 
1576  memset(md_name, 0x00, 100);
1577  memset(src_str, 0x00, 1000);
1578  memset(hash_str, 0x00, 1000);
1579  memset(output, 0x00, 100);
1580 
1581  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
1582 
1583  strncpy( (char *) md_name, "md2", 100 );
1584  md_info = md_info_from_string(md_name);
1585  fct_chk( md_info != NULL );
1586  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1587 
1588  fct_chk ( 0 == md_starts( &ctx ) );
1589  fct_chk ( ctx.md_ctx != NULL );
1590  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1591  fct_chk ( 0 == md_finish( &ctx, output ) );
1592  fct_chk ( 0 == md_free_ctx( &ctx ) );
1593 
1594  hexify( hash_str, output, md_get_size(md_info) );
1595 
1596  fct_chk( strcmp( (char *) hash_str, "da33def2a42df13975352846c30338cd" ) == 0 );
1597  }
1598  FCT_TEST_END();
1599 #endif /* POLARSSL_MD2_C */
1600 
1601 #ifdef POLARSSL_MD2_C
1602 
1603  FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_7)
1604  {
1605  char md_name[100];
1606  unsigned char src_str[1000];
1607  unsigned char hash_str[1000];
1608  unsigned char output[100];
1609 
1610  const md_info_t *md_info = NULL;
1612 
1613  memset(md_name, 0x00, 100);
1614  memset(src_str, 0x00, 1000);
1615  memset(hash_str, 0x00, 1000);
1616  memset(output, 0x00, 100);
1617 
1618  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
1619 
1620  strncpy( (char *) md_name, "md2", 100 );
1621  md_info = md_info_from_string(md_name);
1622  fct_chk( md_info != NULL );
1623  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1624 
1625  fct_chk ( 0 == md_starts( &ctx ) );
1626  fct_chk ( ctx.md_ctx != NULL );
1627  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1628  fct_chk ( 0 == md_finish( &ctx, output ) );
1629  fct_chk ( 0 == md_free_ctx( &ctx ) );
1630 
1631  hexify( hash_str, output, md_get_size(md_info) );
1632 
1633  fct_chk( strcmp( (char *) hash_str, "d5976f79d83d3a0dc9806c3c66f3efd8" ) == 0 );
1634  }
1635  FCT_TEST_END();
1636 #endif /* POLARSSL_MD2_C */
1637 
1638 #ifdef POLARSSL_MD4_C
1639 
1640  FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_1)
1641  {
1642  char md_name[100];
1643  unsigned char src_str[1000];
1644  unsigned char hash_str[1000];
1645  unsigned char output[100];
1646 
1647  const md_info_t *md_info = NULL;
1649 
1650  memset(md_name, 0x00, 100);
1651  memset(src_str, 0x00, 1000);
1652  memset(hash_str, 0x00, 1000);
1653  memset(output, 0x00, 100);
1654 
1655  strcpy( (char *) src_str, "" );
1656 
1657  strncpy( (char *) md_name, "md4", 100 );
1658  md_info = md_info_from_string(md_name);
1659  fct_chk( md_info != NULL );
1660  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1661 
1662  fct_chk ( 0 == md_starts( &ctx ) );
1663  fct_chk ( ctx.md_ctx != NULL );
1664  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1665  fct_chk ( 0 == md_finish( &ctx, output ) );
1666  fct_chk ( 0 == md_free_ctx( &ctx ) );
1667 
1668  hexify( hash_str, output, md_get_size(md_info) );
1669 
1670  fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
1671  }
1672  FCT_TEST_END();
1673 #endif /* POLARSSL_MD4_C */
1674 
1675 #ifdef POLARSSL_MD4_C
1676 
1677  FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_2)
1678  {
1679  char md_name[100];
1680  unsigned char src_str[1000];
1681  unsigned char hash_str[1000];
1682  unsigned char output[100];
1683 
1684  const md_info_t *md_info = NULL;
1686 
1687  memset(md_name, 0x00, 100);
1688  memset(src_str, 0x00, 1000);
1689  memset(hash_str, 0x00, 1000);
1690  memset(output, 0x00, 100);
1691 
1692  strcpy( (char *) src_str, "a" );
1693 
1694  strncpy( (char *) md_name, "md4", 100 );
1695  md_info = md_info_from_string(md_name);
1696  fct_chk( md_info != NULL );
1697  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1698 
1699  fct_chk ( 0 == md_starts( &ctx ) );
1700  fct_chk ( ctx.md_ctx != NULL );
1701  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1702  fct_chk ( 0 == md_finish( &ctx, output ) );
1703  fct_chk ( 0 == md_free_ctx( &ctx ) );
1704 
1705  hexify( hash_str, output, md_get_size(md_info) );
1706 
1707  fct_chk( strcmp( (char *) hash_str, "bde52cb31de33e46245e05fbdbd6fb24" ) == 0 );
1708  }
1709  FCT_TEST_END();
1710 #endif /* POLARSSL_MD4_C */
1711 
1712 #ifdef POLARSSL_MD4_C
1713 
1714  FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_3)
1715  {
1716  char md_name[100];
1717  unsigned char src_str[1000];
1718  unsigned char hash_str[1000];
1719  unsigned char output[100];
1720 
1721  const md_info_t *md_info = NULL;
1723 
1724  memset(md_name, 0x00, 100);
1725  memset(src_str, 0x00, 1000);
1726  memset(hash_str, 0x00, 1000);
1727  memset(output, 0x00, 100);
1728 
1729  strcpy( (char *) src_str, "abc" );
1730 
1731  strncpy( (char *) md_name, "md4", 100 );
1732  md_info = md_info_from_string(md_name);
1733  fct_chk( md_info != NULL );
1734  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1735 
1736  fct_chk ( 0 == md_starts( &ctx ) );
1737  fct_chk ( ctx.md_ctx != NULL );
1738  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1739  fct_chk ( 0 == md_finish( &ctx, output ) );
1740  fct_chk ( 0 == md_free_ctx( &ctx ) );
1741 
1742  hexify( hash_str, output, md_get_size(md_info) );
1743 
1744  fct_chk( strcmp( (char *) hash_str, "a448017aaf21d8525fc10ae87aa6729d" ) == 0 );
1745  }
1746  FCT_TEST_END();
1747 #endif /* POLARSSL_MD4_C */
1748 
1749 #ifdef POLARSSL_MD4_C
1750 
1751  FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_4)
1752  {
1753  char md_name[100];
1754  unsigned char src_str[1000];
1755  unsigned char hash_str[1000];
1756  unsigned char output[100];
1757 
1758  const md_info_t *md_info = NULL;
1760 
1761  memset(md_name, 0x00, 100);
1762  memset(src_str, 0x00, 1000);
1763  memset(hash_str, 0x00, 1000);
1764  memset(output, 0x00, 100);
1765 
1766  strcpy( (char *) src_str, "message digest" );
1767 
1768  strncpy( (char *) md_name, "md4", 100 );
1769  md_info = md_info_from_string(md_name);
1770  fct_chk( md_info != NULL );
1771  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1772 
1773  fct_chk ( 0 == md_starts( &ctx ) );
1774  fct_chk ( ctx.md_ctx != NULL );
1775  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1776  fct_chk ( 0 == md_finish( &ctx, output ) );
1777  fct_chk ( 0 == md_free_ctx( &ctx ) );
1778 
1779  hexify( hash_str, output, md_get_size(md_info) );
1780 
1781  fct_chk( strcmp( (char *) hash_str, "d9130a8164549fe818874806e1c7014b" ) == 0 );
1782  }
1783  FCT_TEST_END();
1784 #endif /* POLARSSL_MD4_C */
1785 
1786 #ifdef POLARSSL_MD4_C
1787 
1788  FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_5)
1789  {
1790  char md_name[100];
1791  unsigned char src_str[1000];
1792  unsigned char hash_str[1000];
1793  unsigned char output[100];
1794 
1795  const md_info_t *md_info = NULL;
1797 
1798  memset(md_name, 0x00, 100);
1799  memset(src_str, 0x00, 1000);
1800  memset(hash_str, 0x00, 1000);
1801  memset(output, 0x00, 100);
1802 
1803  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
1804 
1805  strncpy( (char *) md_name, "md4", 100 );
1806  md_info = md_info_from_string(md_name);
1807  fct_chk( md_info != NULL );
1808  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1809 
1810  fct_chk ( 0 == md_starts( &ctx ) );
1811  fct_chk ( ctx.md_ctx != NULL );
1812  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1813  fct_chk ( 0 == md_finish( &ctx, output ) );
1814  fct_chk ( 0 == md_free_ctx( &ctx ) );
1815 
1816  hexify( hash_str, output, md_get_size(md_info) );
1817 
1818  fct_chk( strcmp( (char *) hash_str, "d79e1c308aa5bbcdeea8ed63df412da9" ) == 0 );
1819  }
1820  FCT_TEST_END();
1821 #endif /* POLARSSL_MD4_C */
1822 
1823 #ifdef POLARSSL_MD4_C
1824 
1825  FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_6)
1826  {
1827  char md_name[100];
1828  unsigned char src_str[1000];
1829  unsigned char hash_str[1000];
1830  unsigned char output[100];
1831 
1832  const md_info_t *md_info = NULL;
1834 
1835  memset(md_name, 0x00, 100);
1836  memset(src_str, 0x00, 1000);
1837  memset(hash_str, 0x00, 1000);
1838  memset(output, 0x00, 100);
1839 
1840  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
1841 
1842  strncpy( (char *) md_name, "md4", 100 );
1843  md_info = md_info_from_string(md_name);
1844  fct_chk( md_info != NULL );
1845  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1846 
1847  fct_chk ( 0 == md_starts( &ctx ) );
1848  fct_chk ( ctx.md_ctx != NULL );
1849  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1850  fct_chk ( 0 == md_finish( &ctx, output ) );
1851  fct_chk ( 0 == md_free_ctx( &ctx ) );
1852 
1853  hexify( hash_str, output, md_get_size(md_info) );
1854 
1855  fct_chk( strcmp( (char *) hash_str, "043f8582f241db351ce627e153e7f0e4" ) == 0 );
1856  }
1857  FCT_TEST_END();
1858 #endif /* POLARSSL_MD4_C */
1859 
1860 #ifdef POLARSSL_MD4_C
1861 
1862  FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_7)
1863  {
1864  char md_name[100];
1865  unsigned char src_str[1000];
1866  unsigned char hash_str[1000];
1867  unsigned char output[100];
1868 
1869  const md_info_t *md_info = NULL;
1871 
1872  memset(md_name, 0x00, 100);
1873  memset(src_str, 0x00, 1000);
1874  memset(hash_str, 0x00, 1000);
1875  memset(output, 0x00, 100);
1876 
1877  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
1878 
1879  strncpy( (char *) md_name, "md4", 100 );
1880  md_info = md_info_from_string(md_name);
1881  fct_chk( md_info != NULL );
1882  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1883 
1884  fct_chk ( 0 == md_starts( &ctx ) );
1885  fct_chk ( ctx.md_ctx != NULL );
1886  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1887  fct_chk ( 0 == md_finish( &ctx, output ) );
1888  fct_chk ( 0 == md_free_ctx( &ctx ) );
1889 
1890  hexify( hash_str, output, md_get_size(md_info) );
1891 
1892  fct_chk( strcmp( (char *) hash_str, "e33b4ddc9c38f2199c3e7b164fcc0536" ) == 0 );
1893  }
1894  FCT_TEST_END();
1895 #endif /* POLARSSL_MD4_C */
1896 
1897 #ifdef POLARSSL_MD5_C
1898 
1899  FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_1)
1900  {
1901  char md_name[100];
1902  unsigned char src_str[1000];
1903  unsigned char hash_str[1000];
1904  unsigned char output[100];
1905 
1906  const md_info_t *md_info = NULL;
1908 
1909  memset(md_name, 0x00, 100);
1910  memset(src_str, 0x00, 1000);
1911  memset(hash_str, 0x00, 1000);
1912  memset(output, 0x00, 100);
1913 
1914  strcpy( (char *) src_str, "" );
1915 
1916  strncpy( (char *) md_name, "md5", 100 );
1917  md_info = md_info_from_string(md_name);
1918  fct_chk( md_info != NULL );
1919  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1920 
1921  fct_chk ( 0 == md_starts( &ctx ) );
1922  fct_chk ( ctx.md_ctx != NULL );
1923  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1924  fct_chk ( 0 == md_finish( &ctx, output ) );
1925  fct_chk ( 0 == md_free_ctx( &ctx ) );
1926 
1927  hexify( hash_str, output, md_get_size(md_info) );
1928 
1929  fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
1930  }
1931  FCT_TEST_END();
1932 #endif /* POLARSSL_MD5_C */
1933 
1934 #ifdef POLARSSL_MD5_C
1935 
1936  FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_2)
1937  {
1938  char md_name[100];
1939  unsigned char src_str[1000];
1940  unsigned char hash_str[1000];
1941  unsigned char output[100];
1942 
1943  const md_info_t *md_info = NULL;
1945 
1946  memset(md_name, 0x00, 100);
1947  memset(src_str, 0x00, 1000);
1948  memset(hash_str, 0x00, 1000);
1949  memset(output, 0x00, 100);
1950 
1951  strcpy( (char *) src_str, "a" );
1952 
1953  strncpy( (char *) md_name, "md5", 100 );
1954  md_info = md_info_from_string(md_name);
1955  fct_chk( md_info != NULL );
1956  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1957 
1958  fct_chk ( 0 == md_starts( &ctx ) );
1959  fct_chk ( ctx.md_ctx != NULL );
1960  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1961  fct_chk ( 0 == md_finish( &ctx, output ) );
1962  fct_chk ( 0 == md_free_ctx( &ctx ) );
1963 
1964  hexify( hash_str, output, md_get_size(md_info) );
1965 
1966  fct_chk( strcmp( (char *) hash_str, "0cc175b9c0f1b6a831c399e269772661" ) == 0 );
1967  }
1968  FCT_TEST_END();
1969 #endif /* POLARSSL_MD5_C */
1970 
1971 #ifdef POLARSSL_MD5_C
1972 
1973  FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_3)
1974  {
1975  char md_name[100];
1976  unsigned char src_str[1000];
1977  unsigned char hash_str[1000];
1978  unsigned char output[100];
1979 
1980  const md_info_t *md_info = NULL;
1982 
1983  memset(md_name, 0x00, 100);
1984  memset(src_str, 0x00, 1000);
1985  memset(hash_str, 0x00, 1000);
1986  memset(output, 0x00, 100);
1987 
1988  strcpy( (char *) src_str, "abc" );
1989 
1990  strncpy( (char *) md_name, "md5", 100 );
1991  md_info = md_info_from_string(md_name);
1992  fct_chk( md_info != NULL );
1993  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
1994 
1995  fct_chk ( 0 == md_starts( &ctx ) );
1996  fct_chk ( ctx.md_ctx != NULL );
1997  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
1998  fct_chk ( 0 == md_finish( &ctx, output ) );
1999  fct_chk ( 0 == md_free_ctx( &ctx ) );
2000 
2001  hexify( hash_str, output, md_get_size(md_info) );
2002 
2003  fct_chk( strcmp( (char *) hash_str, "900150983cd24fb0d6963f7d28e17f72" ) == 0 );
2004  }
2005  FCT_TEST_END();
2006 #endif /* POLARSSL_MD5_C */
2007 
2008 #ifdef POLARSSL_MD5_C
2009 
2010  FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_4)
2011  {
2012  char md_name[100];
2013  unsigned char src_str[1000];
2014  unsigned char hash_str[1000];
2015  unsigned char output[100];
2016 
2017  const md_info_t *md_info = NULL;
2019 
2020  memset(md_name, 0x00, 100);
2021  memset(src_str, 0x00, 1000);
2022  memset(hash_str, 0x00, 1000);
2023  memset(output, 0x00, 100);
2024 
2025  strcpy( (char *) src_str, "message digest" );
2026 
2027  strncpy( (char *) md_name, "md5", 100 );
2028  md_info = md_info_from_string(md_name);
2029  fct_chk( md_info != NULL );
2030  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2031 
2032  fct_chk ( 0 == md_starts( &ctx ) );
2033  fct_chk ( ctx.md_ctx != NULL );
2034  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
2035  fct_chk ( 0 == md_finish( &ctx, output ) );
2036  fct_chk ( 0 == md_free_ctx( &ctx ) );
2037 
2038  hexify( hash_str, output, md_get_size(md_info) );
2039 
2040  fct_chk( strcmp( (char *) hash_str, "f96b697d7cb7938d525a2f31aaf161d0" ) == 0 );
2041  }
2042  FCT_TEST_END();
2043 #endif /* POLARSSL_MD5_C */
2044 
2045 #ifdef POLARSSL_MD5_C
2046 
2047  FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_5)
2048  {
2049  char md_name[100];
2050  unsigned char src_str[1000];
2051  unsigned char hash_str[1000];
2052  unsigned char output[100];
2053 
2054  const md_info_t *md_info = NULL;
2056 
2057  memset(md_name, 0x00, 100);
2058  memset(src_str, 0x00, 1000);
2059  memset(hash_str, 0x00, 1000);
2060  memset(output, 0x00, 100);
2061 
2062  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
2063 
2064  strncpy( (char *) md_name, "md5", 100 );
2065  md_info = md_info_from_string(md_name);
2066  fct_chk( md_info != NULL );
2067  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2068 
2069  fct_chk ( 0 == md_starts( &ctx ) );
2070  fct_chk ( ctx.md_ctx != NULL );
2071  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
2072  fct_chk ( 0 == md_finish( &ctx, output ) );
2073  fct_chk ( 0 == md_free_ctx( &ctx ) );
2074 
2075  hexify( hash_str, output, md_get_size(md_info) );
2076 
2077  fct_chk( strcmp( (char *) hash_str, "c3fcd3d76192e4007dfb496cca67e13b" ) == 0 );
2078  }
2079  FCT_TEST_END();
2080 #endif /* POLARSSL_MD5_C */
2081 
2082 #ifdef POLARSSL_MD5_C
2083 
2084  FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_6)
2085  {
2086  char md_name[100];
2087  unsigned char src_str[1000];
2088  unsigned char hash_str[1000];
2089  unsigned char output[100];
2090 
2091  const md_info_t *md_info = NULL;
2093 
2094  memset(md_name, 0x00, 100);
2095  memset(src_str, 0x00, 1000);
2096  memset(hash_str, 0x00, 1000);
2097  memset(output, 0x00, 100);
2098 
2099  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
2100 
2101  strncpy( (char *) md_name, "md5", 100 );
2102  md_info = md_info_from_string(md_name);
2103  fct_chk( md_info != NULL );
2104  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2105 
2106  fct_chk ( 0 == md_starts( &ctx ) );
2107  fct_chk ( ctx.md_ctx != NULL );
2108  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
2109  fct_chk ( 0 == md_finish( &ctx, output ) );
2110  fct_chk ( 0 == md_free_ctx( &ctx ) );
2111 
2112  hexify( hash_str, output, md_get_size(md_info) );
2113 
2114  fct_chk( strcmp( (char *) hash_str, "d174ab98d277d9f5a5611c2c9f419d9f" ) == 0 );
2115  }
2116  FCT_TEST_END();
2117 #endif /* POLARSSL_MD5_C */
2118 
2119 #ifdef POLARSSL_MD5_C
2120 
2121  FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_7)
2122  {
2123  char md_name[100];
2124  unsigned char src_str[1000];
2125  unsigned char hash_str[1000];
2126  unsigned char output[100];
2127 
2128  const md_info_t *md_info = NULL;
2130 
2131  memset(md_name, 0x00, 100);
2132  memset(src_str, 0x00, 1000);
2133  memset(hash_str, 0x00, 1000);
2134  memset(output, 0x00, 100);
2135 
2136  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
2137 
2138  strncpy( (char *) md_name, "md5", 100 );
2139  md_info = md_info_from_string(md_name);
2140  fct_chk( md_info != NULL );
2141  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2142 
2143  fct_chk ( 0 == md_starts( &ctx ) );
2144  fct_chk ( ctx.md_ctx != NULL );
2145  fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
2146  fct_chk ( 0 == md_finish( &ctx, output ) );
2147  fct_chk ( 0 == md_free_ctx( &ctx ) );
2148 
2149  hexify( hash_str, output, md_get_size(md_info) );
2150 
2151  fct_chk( strcmp( (char *) hash_str, "57edf4a22be3c955ac49da2e2107b67a" ) == 0 );
2152  }
2153  FCT_TEST_END();
2154 #endif /* POLARSSL_MD5_C */
2155 
2156 #ifdef POLARSSL_MD2_C
2157 
2158  FCT_TEST_BGN(generic_multi_step_hmac_md2_hash_file_openssl_test_1)
2159  {
2160  char md_name[100];
2161  unsigned char src_str[10000];
2162  unsigned char key_str[10000];
2163  unsigned char hash_str[10000];
2164  unsigned char output[100];
2165  int key_len, src_len;
2166  const md_info_t *md_info = NULL;
2168 
2169  memset(md_name, 0x00, 100);
2170  memset(src_str, 0x00, 10000);
2171  memset(key_str, 0x00, 10000);
2172  memset(hash_str, 0x00, 10000);
2173  memset(output, 0x00, 100);
2174 
2175  strncpy( (char *) md_name, "md2", 100 );
2176  md_info = md_info_from_string( md_name );
2177  fct_chk( md_info != NULL );
2178  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2179 
2180  key_len = unhexify( key_str, "61616161616161616161616161616161" );
2181  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
2182 
2183  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2184  fct_chk ( ctx.md_ctx != NULL );
2185  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2186  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2187  fct_chk ( 0 == md_free_ctx( &ctx ) );
2188 
2189  hexify( hash_str, output, md_get_size(md_info) );
2190 
2191  fct_chk( strncmp( (char *) hash_str, "d5732582f494f5ddf35efd166c85af9c", 16 * 2 ) == 0 );
2192  }
2193  FCT_TEST_END();
2194 #endif /* POLARSSL_MD2_C */
2195 
2196 #ifdef POLARSSL_MD2_C
2197 
2198  FCT_TEST_BGN(generic_multi_step_hmac_md2_hash_file_openssl_test_2)
2199  {
2200  char md_name[100];
2201  unsigned char src_str[10000];
2202  unsigned char key_str[10000];
2203  unsigned char hash_str[10000];
2204  unsigned char output[100];
2205  int key_len, src_len;
2206  const md_info_t *md_info = NULL;
2208 
2209  memset(md_name, 0x00, 100);
2210  memset(src_str, 0x00, 10000);
2211  memset(key_str, 0x00, 10000);
2212  memset(hash_str, 0x00, 10000);
2213  memset(output, 0x00, 100);
2214 
2215  strncpy( (char *) md_name, "md2", 100 );
2216  md_info = md_info_from_string( md_name );
2217  fct_chk( md_info != NULL );
2218  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2219 
2220  key_len = unhexify( key_str, "61616161616161616161616161616161" );
2221  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
2222 
2223  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2224  fct_chk ( ctx.md_ctx != NULL );
2225  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2226  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2227  fct_chk ( 0 == md_free_ctx( &ctx ) );
2228 
2229  hexify( hash_str, output, md_get_size(md_info) );
2230 
2231  fct_chk( strncmp( (char *) hash_str, "54ab68503f7d1b5c7741340dff2722a9", 16 * 2 ) == 0 );
2232  }
2233  FCT_TEST_END();
2234 #endif /* POLARSSL_MD2_C */
2235 
2236 #ifdef POLARSSL_MD2_C
2237 
2238  FCT_TEST_BGN(generic_multi_step_hmac_md2_hash_file_openssl_test_3)
2239  {
2240  char md_name[100];
2241  unsigned char src_str[10000];
2242  unsigned char key_str[10000];
2243  unsigned char hash_str[10000];
2244  unsigned char output[100];
2245  int key_len, src_len;
2246  const md_info_t *md_info = NULL;
2248 
2249  memset(md_name, 0x00, 100);
2250  memset(src_str, 0x00, 10000);
2251  memset(key_str, 0x00, 10000);
2252  memset(hash_str, 0x00, 10000);
2253  memset(output, 0x00, 100);
2254 
2255  strncpy( (char *) md_name, "md2", 100 );
2256  md_info = md_info_from_string( md_name );
2257  fct_chk( md_info != NULL );
2258  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2259 
2260  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
2261  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
2262 
2263  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2264  fct_chk ( ctx.md_ctx != NULL );
2265  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2266  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2267  fct_chk ( 0 == md_free_ctx( &ctx ) );
2268 
2269  hexify( hash_str, output, md_get_size(md_info) );
2270 
2271  fct_chk( strncmp( (char *) hash_str, "d850e5f554558cf0fe79a0612e1d0365", 16 * 2 ) == 0 );
2272  }
2273  FCT_TEST_END();
2274 #endif /* POLARSSL_MD2_C */
2275 
2276 #ifdef POLARSSL_MD4_C
2277 
2278  FCT_TEST_BGN(generic_multi_step_hmac_md4_hash_file_openssl_test_1)
2279  {
2280  char md_name[100];
2281  unsigned char src_str[10000];
2282  unsigned char key_str[10000];
2283  unsigned char hash_str[10000];
2284  unsigned char output[100];
2285  int key_len, src_len;
2286  const md_info_t *md_info = NULL;
2288 
2289  memset(md_name, 0x00, 100);
2290  memset(src_str, 0x00, 10000);
2291  memset(key_str, 0x00, 10000);
2292  memset(hash_str, 0x00, 10000);
2293  memset(output, 0x00, 100);
2294 
2295  strncpy( (char *) md_name, "md4", 100 );
2296  md_info = md_info_from_string( md_name );
2297  fct_chk( md_info != NULL );
2298  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2299 
2300  key_len = unhexify( key_str, "61616161616161616161616161616161" );
2301  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
2302 
2303  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2304  fct_chk ( ctx.md_ctx != NULL );
2305  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2306  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2307  fct_chk ( 0 == md_free_ctx( &ctx ) );
2308 
2309  hexify( hash_str, output, md_get_size(md_info) );
2310 
2311  fct_chk( strncmp( (char *) hash_str, "eabd0fbefb82fb0063a25a6d7b8bdc0f", 16 * 2 ) == 0 );
2312  }
2313  FCT_TEST_END();
2314 #endif /* POLARSSL_MD4_C */
2315 
2316 #ifdef POLARSSL_MD4_C
2317 
2318  FCT_TEST_BGN(generic_multi_step_hmac_md4_hash_file_openssl_test_2)
2319  {
2320  char md_name[100];
2321  unsigned char src_str[10000];
2322  unsigned char key_str[10000];
2323  unsigned char hash_str[10000];
2324  unsigned char output[100];
2325  int key_len, src_len;
2326  const md_info_t *md_info = NULL;
2328 
2329  memset(md_name, 0x00, 100);
2330  memset(src_str, 0x00, 10000);
2331  memset(key_str, 0x00, 10000);
2332  memset(hash_str, 0x00, 10000);
2333  memset(output, 0x00, 100);
2334 
2335  strncpy( (char *) md_name, "md4", 100 );
2336  md_info = md_info_from_string( md_name );
2337  fct_chk( md_info != NULL );
2338  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2339 
2340  key_len = unhexify( key_str, "61616161616161616161616161616161" );
2341  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
2342 
2343  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2344  fct_chk ( ctx.md_ctx != NULL );
2345  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2346  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2347  fct_chk ( 0 == md_free_ctx( &ctx ) );
2348 
2349  hexify( hash_str, output, md_get_size(md_info) );
2350 
2351  fct_chk( strncmp( (char *) hash_str, "cec3c5e421a7b783aa89cacf78daf6dc", 16 * 2 ) == 0 );
2352  }
2353  FCT_TEST_END();
2354 #endif /* POLARSSL_MD4_C */
2355 
2356 #ifdef POLARSSL_MD4_C
2357 
2358  FCT_TEST_BGN(generic_multi_step_hmac_md4_hash_file_openssl_test_3)
2359  {
2360  char md_name[100];
2361  unsigned char src_str[10000];
2362  unsigned char key_str[10000];
2363  unsigned char hash_str[10000];
2364  unsigned char output[100];
2365  int key_len, src_len;
2366  const md_info_t *md_info = NULL;
2368 
2369  memset(md_name, 0x00, 100);
2370  memset(src_str, 0x00, 10000);
2371  memset(key_str, 0x00, 10000);
2372  memset(hash_str, 0x00, 10000);
2373  memset(output, 0x00, 100);
2374 
2375  strncpy( (char *) md_name, "md4", 100 );
2376  md_info = md_info_from_string( md_name );
2377  fct_chk( md_info != NULL );
2378  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2379 
2380  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
2381  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
2382 
2383  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2384  fct_chk ( ctx.md_ctx != NULL );
2385  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2386  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2387  fct_chk ( 0 == md_free_ctx( &ctx ) );
2388 
2389  hexify( hash_str, output, md_get_size(md_info) );
2390 
2391  fct_chk( strncmp( (char *) hash_str, "ad5f0a04116109b397b57f9cc9b6df4b", 16 * 2 ) == 0 );
2392  }
2393  FCT_TEST_END();
2394 #endif /* POLARSSL_MD4_C */
2395 
2396 #ifdef POLARSSL_MD5_C
2397 
2398  FCT_TEST_BGN(generic_multi_step_hmac_md5_hash_file_openssl_test_1)
2399  {
2400  char md_name[100];
2401  unsigned char src_str[10000];
2402  unsigned char key_str[10000];
2403  unsigned char hash_str[10000];
2404  unsigned char output[100];
2405  int key_len, src_len;
2406  const md_info_t *md_info = NULL;
2408 
2409  memset(md_name, 0x00, 100);
2410  memset(src_str, 0x00, 10000);
2411  memset(key_str, 0x00, 10000);
2412  memset(hash_str, 0x00, 10000);
2413  memset(output, 0x00, 100);
2414 
2415  strncpy( (char *) md_name, "md5", 100 );
2416  md_info = md_info_from_string( md_name );
2417  fct_chk( md_info != NULL );
2418  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2419 
2420  key_len = unhexify( key_str, "61616161616161616161616161616161" );
2421  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
2422 
2423  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2424  fct_chk ( ctx.md_ctx != NULL );
2425  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2426  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2427  fct_chk ( 0 == md_free_ctx( &ctx ) );
2428 
2429  hexify( hash_str, output, md_get_size(md_info) );
2430 
2431  fct_chk( strncmp( (char *) hash_str, "42552882f00bd4633ea81135a184b284", 16 * 2 ) == 0 );
2432  }
2433  FCT_TEST_END();
2434 #endif /* POLARSSL_MD5_C */
2435 
2436 #ifdef POLARSSL_MD5_C
2437 
2438  FCT_TEST_BGN(generic_multi_step_hmac_md5_hash_file_openssl_test_2)
2439  {
2440  char md_name[100];
2441  unsigned char src_str[10000];
2442  unsigned char key_str[10000];
2443  unsigned char hash_str[10000];
2444  unsigned char output[100];
2445  int key_len, src_len;
2446  const md_info_t *md_info = NULL;
2448 
2449  memset(md_name, 0x00, 100);
2450  memset(src_str, 0x00, 10000);
2451  memset(key_str, 0x00, 10000);
2452  memset(hash_str, 0x00, 10000);
2453  memset(output, 0x00, 100);
2454 
2455  strncpy( (char *) md_name, "md5", 100 );
2456  md_info = md_info_from_string( md_name );
2457  fct_chk( md_info != NULL );
2458  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2459 
2460  key_len = unhexify( key_str, "61616161616161616161616161616161" );
2461  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
2462 
2463  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2464  fct_chk ( ctx.md_ctx != NULL );
2465  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2466  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2467  fct_chk ( 0 == md_free_ctx( &ctx ) );
2468 
2469  hexify( hash_str, output, md_get_size(md_info) );
2470 
2471  fct_chk( strncmp( (char *) hash_str, "a16a842891786d01fe50ba7731db7464", 16 * 2 ) == 0 );
2472  }
2473  FCT_TEST_END();
2474 #endif /* POLARSSL_MD5_C */
2475 
2476 #ifdef POLARSSL_MD5_C
2477 
2478  FCT_TEST_BGN(generic_multi_step_hmac_md5_hash_file_openssl_test_3)
2479  {
2480  char md_name[100];
2481  unsigned char src_str[10000];
2482  unsigned char key_str[10000];
2483  unsigned char hash_str[10000];
2484  unsigned char output[100];
2485  int key_len, src_len;
2486  const md_info_t *md_info = NULL;
2488 
2489  memset(md_name, 0x00, 100);
2490  memset(src_str, 0x00, 10000);
2491  memset(key_str, 0x00, 10000);
2492  memset(hash_str, 0x00, 10000);
2493  memset(output, 0x00, 100);
2494 
2495  strncpy( (char *) md_name, "md5", 100 );
2496  md_info = md_info_from_string( md_name );
2497  fct_chk( md_info != NULL );
2498  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2499 
2500  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
2501  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
2502 
2503  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2504  fct_chk ( ctx.md_ctx != NULL );
2505  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2506  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2507  fct_chk ( 0 == md_free_ctx( &ctx ) );
2508 
2509  hexify( hash_str, output, md_get_size(md_info) );
2510 
2511  fct_chk( strncmp( (char *) hash_str, "e97f623936f98a7f741c4bd0612fecc2", 16 * 2 ) == 0 );
2512  }
2513  FCT_TEST_END();
2514 #endif /* POLARSSL_MD5_C */
2515 
2516 #ifdef POLARSSL_MD5_C
2517 
2518  FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_1)
2519  {
2520  char md_name[100];
2521  unsigned char src_str[10000];
2522  unsigned char key_str[10000];
2523  unsigned char hash_str[10000];
2524  unsigned char output[100];
2525  int key_len, src_len;
2526  const md_info_t *md_info = NULL;
2528 
2529  memset(md_name, 0x00, 100);
2530  memset(src_str, 0x00, 10000);
2531  memset(key_str, 0x00, 10000);
2532  memset(hash_str, 0x00, 10000);
2533  memset(output, 0x00, 100);
2534 
2535  strncpy( (char *) md_name, "md5", 100 );
2536  md_info = md_info_from_string( md_name );
2537  fct_chk( md_info != NULL );
2538  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2539 
2540  key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
2541  src_len = unhexify( src_str, "4869205468657265" );
2542 
2543  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2544  fct_chk ( ctx.md_ctx != NULL );
2545  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2546  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2547  fct_chk ( 0 == md_free_ctx( &ctx ) );
2548 
2549  hexify( hash_str, output, md_get_size(md_info) );
2550 
2551  fct_chk( strncmp( (char *) hash_str, "9294727a3638bb1c13f48ef8158bfc9d", 16 * 2 ) == 0 );
2552  }
2553  FCT_TEST_END();
2554 #endif /* POLARSSL_MD5_C */
2555 
2556 #ifdef POLARSSL_MD5_C
2557 
2558  FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_2)
2559  {
2560  char md_name[100];
2561  unsigned char src_str[10000];
2562  unsigned char key_str[10000];
2563  unsigned char hash_str[10000];
2564  unsigned char output[100];
2565  int key_len, src_len;
2566  const md_info_t *md_info = NULL;
2568 
2569  memset(md_name, 0x00, 100);
2570  memset(src_str, 0x00, 10000);
2571  memset(key_str, 0x00, 10000);
2572  memset(hash_str, 0x00, 10000);
2573  memset(output, 0x00, 100);
2574 
2575  strncpy( (char *) md_name, "md5", 100 );
2576  md_info = md_info_from_string( md_name );
2577  fct_chk( md_info != NULL );
2578  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2579 
2580  key_len = unhexify( key_str, "4a656665" );
2581  src_len = unhexify( src_str, "7768617420646f2079612077616e7420666f72206e6f7468696e673f" );
2582 
2583  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2584  fct_chk ( ctx.md_ctx != NULL );
2585  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2586  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2587  fct_chk ( 0 == md_free_ctx( &ctx ) );
2588 
2589  hexify( hash_str, output, md_get_size(md_info) );
2590 
2591  fct_chk( strncmp( (char *) hash_str, "750c783e6ab0b503eaa86e310a5db738", 16 * 2 ) == 0 );
2592  }
2593  FCT_TEST_END();
2594 #endif /* POLARSSL_MD5_C */
2595 
2596 #ifdef POLARSSL_MD5_C
2597 
2598  FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_3)
2599  {
2600  char md_name[100];
2601  unsigned char src_str[10000];
2602  unsigned char key_str[10000];
2603  unsigned char hash_str[10000];
2604  unsigned char output[100];
2605  int key_len, src_len;
2606  const md_info_t *md_info = NULL;
2608 
2609  memset(md_name, 0x00, 100);
2610  memset(src_str, 0x00, 10000);
2611  memset(key_str, 0x00, 10000);
2612  memset(hash_str, 0x00, 10000);
2613  memset(output, 0x00, 100);
2614 
2615  strncpy( (char *) md_name, "md5", 100 );
2616  md_info = md_info_from_string( md_name );
2617  fct_chk( md_info != NULL );
2618  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2619 
2620  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
2621  src_len = unhexify( src_str, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" );
2622 
2623  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2624  fct_chk ( ctx.md_ctx != NULL );
2625  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2626  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2627  fct_chk ( 0 == md_free_ctx( &ctx ) );
2628 
2629  hexify( hash_str, output, md_get_size(md_info) );
2630 
2631  fct_chk( strncmp( (char *) hash_str, "56be34521d144c88dbb8c733f0e8b3f6", 16 * 2 ) == 0 );
2632  }
2633  FCT_TEST_END();
2634 #endif /* POLARSSL_MD5_C */
2635 
2636 #ifdef POLARSSL_MD5_C
2637 
2638  FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_4)
2639  {
2640  char md_name[100];
2641  unsigned char src_str[10000];
2642  unsigned char key_str[10000];
2643  unsigned char hash_str[10000];
2644  unsigned char output[100];
2645  int key_len, src_len;
2646  const md_info_t *md_info = NULL;
2648 
2649  memset(md_name, 0x00, 100);
2650  memset(src_str, 0x00, 10000);
2651  memset(key_str, 0x00, 10000);
2652  memset(hash_str, 0x00, 10000);
2653  memset(output, 0x00, 100);
2654 
2655  strncpy( (char *) md_name, "md5", 100 );
2656  md_info = md_info_from_string( md_name );
2657  fct_chk( md_info != NULL );
2658  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2659 
2660  key_len = unhexify( key_str, "0102030405060708090a0b0c0d0e0f10111213141516171819" );
2661  src_len = unhexify( src_str, "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
2662 
2663  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2664  fct_chk ( ctx.md_ctx != NULL );
2665  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2666  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2667  fct_chk ( 0 == md_free_ctx( &ctx ) );
2668 
2669  hexify( hash_str, output, md_get_size(md_info) );
2670 
2671  fct_chk( strncmp( (char *) hash_str, "697eaf0aca3a3aea3a75164746ffaa79", 16 * 2 ) == 0 );
2672  }
2673  FCT_TEST_END();
2674 #endif /* POLARSSL_MD5_C */
2675 
2676 #ifdef POLARSSL_MD5_C
2677 
2678  FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_5)
2679  {
2680  char md_name[100];
2681  unsigned char src_str[10000];
2682  unsigned char key_str[10000];
2683  unsigned char hash_str[10000];
2684  unsigned char output[100];
2685  int key_len, src_len;
2686  const md_info_t *md_info = NULL;
2688 
2689  memset(md_name, 0x00, 100);
2690  memset(src_str, 0x00, 10000);
2691  memset(key_str, 0x00, 10000);
2692  memset(hash_str, 0x00, 10000);
2693  memset(output, 0x00, 100);
2694 
2695  strncpy( (char *) md_name, "md5", 100 );
2696  md_info = md_info_from_string( md_name );
2697  fct_chk( md_info != NULL );
2698  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2699 
2700  key_len = unhexify( key_str, "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" );
2701  src_len = unhexify( src_str, "546573742057697468205472756e636174696f6e" );
2702 
2703  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2704  fct_chk ( ctx.md_ctx != NULL );
2705  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2706  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2707  fct_chk ( 0 == md_free_ctx( &ctx ) );
2708 
2709  hexify( hash_str, output, md_get_size(md_info) );
2710 
2711  fct_chk( strncmp( (char *) hash_str, "56461ef2342edc00f9bab995", 12 * 2 ) == 0 );
2712  }
2713  FCT_TEST_END();
2714 #endif /* POLARSSL_MD5_C */
2715 
2716 #ifdef POLARSSL_MD5_C
2717 
2718  FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_6)
2719  {
2720  char md_name[100];
2721  unsigned char src_str[10000];
2722  unsigned char key_str[10000];
2723  unsigned char hash_str[10000];
2724  unsigned char output[100];
2725  int key_len, src_len;
2726  const md_info_t *md_info = NULL;
2728 
2729  memset(md_name, 0x00, 100);
2730  memset(src_str, 0x00, 10000);
2731  memset(key_str, 0x00, 10000);
2732  memset(hash_str, 0x00, 10000);
2733  memset(output, 0x00, 100);
2734 
2735  strncpy( (char *) md_name, "md5", 100 );
2736  md_info = md_info_from_string( md_name );
2737  fct_chk( md_info != NULL );
2738  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2739 
2740  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
2741  src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374" );
2742 
2743  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2744  fct_chk ( ctx.md_ctx != NULL );
2745  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2746  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2747  fct_chk ( 0 == md_free_ctx( &ctx ) );
2748 
2749  hexify( hash_str, output, md_get_size(md_info) );
2750 
2751  fct_chk( strncmp( (char *) hash_str, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", 16 * 2 ) == 0 );
2752  }
2753  FCT_TEST_END();
2754 #endif /* POLARSSL_MD5_C */
2755 
2756 #ifdef POLARSSL_MD5_C
2757 
2758  FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_7)
2759  {
2760  char md_name[100];
2761  unsigned char src_str[10000];
2762  unsigned char key_str[10000];
2763  unsigned char hash_str[10000];
2764  unsigned char output[100];
2765  int key_len, src_len;
2766  const md_info_t *md_info = NULL;
2768 
2769  memset(md_name, 0x00, 100);
2770  memset(src_str, 0x00, 10000);
2771  memset(key_str, 0x00, 10000);
2772  memset(hash_str, 0x00, 10000);
2773  memset(output, 0x00, 100);
2774 
2775  strncpy( (char *) md_name, "md5", 100 );
2776  md_info = md_info_from_string( md_name );
2777  fct_chk( md_info != NULL );
2778  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
2779 
2780  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
2781  src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461" );
2782 
2783  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
2784  fct_chk ( ctx.md_ctx != NULL );
2785  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
2786  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
2787  fct_chk ( 0 == md_free_ctx( &ctx ) );
2788 
2789  hexify( hash_str, output, md_get_size(md_info) );
2790 
2791  fct_chk( strncmp( (char *) hash_str, "6f630fad67cda0ee1fb1f562db3aa53e", 16 * 2 ) == 0 );
2792  }
2793  FCT_TEST_END();
2794 #endif /* POLARSSL_MD5_C */
2795 
2796 #ifdef POLARSSL_MD2_C
2797 #ifdef POLARSSL_FS_IO
2798 
2799  FCT_TEST_BGN(generic_md2_hash_file_1)
2800  {
2801  char md_name[100];
2802  unsigned char hash_str[1000];
2803  unsigned char output[100];
2804  const md_info_t *md_info = NULL;
2805 
2806  memset(md_name, 0x00, 100);
2807  memset(hash_str, 0x00, 1000);
2808  memset(output, 0x00, 100);
2809 
2810  strncpy( (char *) md_name, "md2", 100 );
2811  md_info = md_info_from_string( md_name );
2812  fct_chk( md_info != NULL );
2813 
2814  md_file( md_info, "data_files/hash_file_1", output);
2815  hexify( hash_str, output, md_get_size(md_info) );
2816 
2817  fct_chk( strcmp( (char *) hash_str, "b593c098712d2e21628c8986695451a8" ) == 0 );
2818  }
2819  FCT_TEST_END();
2820 #endif /* POLARSSL_MD2_C */
2821 #endif /* POLARSSL_FS_IO */
2822 
2823 #ifdef POLARSSL_MD2_C
2824 #ifdef POLARSSL_FS_IO
2825 
2826  FCT_TEST_BGN(generic_md2_hash_file_2)
2827  {
2828  char md_name[100];
2829  unsigned char hash_str[1000];
2830  unsigned char output[100];
2831  const md_info_t *md_info = NULL;
2832 
2833  memset(md_name, 0x00, 100);
2834  memset(hash_str, 0x00, 1000);
2835  memset(output, 0x00, 100);
2836 
2837  strncpy( (char *) md_name, "md2", 100 );
2838  md_info = md_info_from_string( md_name );
2839  fct_chk( md_info != NULL );
2840 
2841  md_file( md_info, "data_files/hash_file_2", output);
2842  hexify( hash_str, output, md_get_size(md_info) );
2843 
2844  fct_chk( strcmp( (char *) hash_str, "3c027b7409909a4c4b26bbab69ad9f4f" ) == 0 );
2845  }
2846  FCT_TEST_END();
2847 #endif /* POLARSSL_MD2_C */
2848 #endif /* POLARSSL_FS_IO */
2849 
2850 #ifdef POLARSSL_MD2_C
2851 #ifdef POLARSSL_FS_IO
2852 
2853  FCT_TEST_BGN(generic_md2_hash_file_3)
2854  {
2855  char md_name[100];
2856  unsigned char hash_str[1000];
2857  unsigned char output[100];
2858  const md_info_t *md_info = NULL;
2859 
2860  memset(md_name, 0x00, 100);
2861  memset(hash_str, 0x00, 1000);
2862  memset(output, 0x00, 100);
2863 
2864  strncpy( (char *) md_name, "md2", 100 );
2865  md_info = md_info_from_string( md_name );
2866  fct_chk( md_info != NULL );
2867 
2868  md_file( md_info, "data_files/hash_file_3", output);
2869  hexify( hash_str, output, md_get_size(md_info) );
2870 
2871  fct_chk( strcmp( (char *) hash_str, "6bb43eb285e81f414083a94cdbe2989d" ) == 0 );
2872  }
2873  FCT_TEST_END();
2874 #endif /* POLARSSL_MD2_C */
2875 #endif /* POLARSSL_FS_IO */
2876 
2877 #ifdef POLARSSL_MD2_C
2878 #ifdef POLARSSL_FS_IO
2879 
2880  FCT_TEST_BGN(generic_md2_hash_file_4)
2881  {
2882  char md_name[100];
2883  unsigned char hash_str[1000];
2884  unsigned char output[100];
2885  const md_info_t *md_info = NULL;
2886 
2887  memset(md_name, 0x00, 100);
2888  memset(hash_str, 0x00, 1000);
2889  memset(output, 0x00, 100);
2890 
2891  strncpy( (char *) md_name, "md2", 100 );
2892  md_info = md_info_from_string( md_name );
2893  fct_chk( md_info != NULL );
2894 
2895  md_file( md_info, "data_files/hash_file_4", output);
2896  hexify( hash_str, output, md_get_size(md_info) );
2897 
2898  fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
2899  }
2900  FCT_TEST_END();
2901 #endif /* POLARSSL_MD2_C */
2902 #endif /* POLARSSL_FS_IO */
2903 
2904 #ifdef POLARSSL_MD4_C
2905 #ifdef POLARSSL_FS_IO
2906 
2907  FCT_TEST_BGN(generic_md4_hash_file_1)
2908  {
2909  char md_name[100];
2910  unsigned char hash_str[1000];
2911  unsigned char output[100];
2912  const md_info_t *md_info = NULL;
2913 
2914  memset(md_name, 0x00, 100);
2915  memset(hash_str, 0x00, 1000);
2916  memset(output, 0x00, 100);
2917 
2918  strncpy( (char *) md_name, "md4", 100 );
2919  md_info = md_info_from_string( md_name );
2920  fct_chk( md_info != NULL );
2921 
2922  md_file( md_info, "data_files/hash_file_1", output);
2923  hexify( hash_str, output, md_get_size(md_info) );
2924 
2925  fct_chk( strcmp( (char *) hash_str, "8d19772c176bd27153b9486715e2c0b9" ) == 0 );
2926  }
2927  FCT_TEST_END();
2928 #endif /* POLARSSL_MD4_C */
2929 #endif /* POLARSSL_FS_IO */
2930 
2931 #ifdef POLARSSL_MD4_C
2932 #ifdef POLARSSL_FS_IO
2933 
2934  FCT_TEST_BGN(generic_md4_hash_file_2)
2935  {
2936  char md_name[100];
2937  unsigned char hash_str[1000];
2938  unsigned char output[100];
2939  const md_info_t *md_info = NULL;
2940 
2941  memset(md_name, 0x00, 100);
2942  memset(hash_str, 0x00, 1000);
2943  memset(output, 0x00, 100);
2944 
2945  strncpy( (char *) md_name, "md4", 100 );
2946  md_info = md_info_from_string( md_name );
2947  fct_chk( md_info != NULL );
2948 
2949  md_file( md_info, "data_files/hash_file_2", output);
2950  hexify( hash_str, output, md_get_size(md_info) );
2951 
2952  fct_chk( strcmp( (char *) hash_str, "f2ac53b8542882a5a0007c6f84b4d9fd" ) == 0 );
2953  }
2954  FCT_TEST_END();
2955 #endif /* POLARSSL_MD4_C */
2956 #endif /* POLARSSL_FS_IO */
2957 
2958 #ifdef POLARSSL_MD4_C
2959 #ifdef POLARSSL_FS_IO
2960 
2961  FCT_TEST_BGN(generic_md4_hash_file_3)
2962  {
2963  char md_name[100];
2964  unsigned char hash_str[1000];
2965  unsigned char output[100];
2966  const md_info_t *md_info = NULL;
2967 
2968  memset(md_name, 0x00, 100);
2969  memset(hash_str, 0x00, 1000);
2970  memset(output, 0x00, 100);
2971 
2972  strncpy( (char *) md_name, "md4", 100 );
2973  md_info = md_info_from_string( md_name );
2974  fct_chk( md_info != NULL );
2975 
2976  md_file( md_info, "data_files/hash_file_3", output);
2977  hexify( hash_str, output, md_get_size(md_info) );
2978 
2979  fct_chk( strcmp( (char *) hash_str, "195c15158e2d07881d9a654095ce4a42" ) == 0 );
2980  }
2981  FCT_TEST_END();
2982 #endif /* POLARSSL_MD4_C */
2983 #endif /* POLARSSL_FS_IO */
2984 
2985 #ifdef POLARSSL_MD4_C
2986 #ifdef POLARSSL_FS_IO
2987 
2988  FCT_TEST_BGN(generic_md4_hash_file_4)
2989  {
2990  char md_name[100];
2991  unsigned char hash_str[1000];
2992  unsigned char output[100];
2993  const md_info_t *md_info = NULL;
2994 
2995  memset(md_name, 0x00, 100);
2996  memset(hash_str, 0x00, 1000);
2997  memset(output, 0x00, 100);
2998 
2999  strncpy( (char *) md_name, "md4", 100 );
3000  md_info = md_info_from_string( md_name );
3001  fct_chk( md_info != NULL );
3002 
3003  md_file( md_info, "data_files/hash_file_4", output);
3004  hexify( hash_str, output, md_get_size(md_info) );
3005 
3006  fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
3007  }
3008  FCT_TEST_END();
3009 #endif /* POLARSSL_MD4_C */
3010 #endif /* POLARSSL_FS_IO */
3011 
3012 #ifdef POLARSSL_MD5_C
3013 #ifdef POLARSSL_FS_IO
3014 
3015  FCT_TEST_BGN(generic_md5_hash_file_1)
3016  {
3017  char md_name[100];
3018  unsigned char hash_str[1000];
3019  unsigned char output[100];
3020  const md_info_t *md_info = NULL;
3021 
3022  memset(md_name, 0x00, 100);
3023  memset(hash_str, 0x00, 1000);
3024  memset(output, 0x00, 100);
3025 
3026  strncpy( (char *) md_name, "md5", 100 );
3027  md_info = md_info_from_string( md_name );
3028  fct_chk( md_info != NULL );
3029 
3030  md_file( md_info, "data_files/hash_file_1", output);
3031  hexify( hash_str, output, md_get_size(md_info) );
3032 
3033  fct_chk( strcmp( (char *) hash_str, "52bcdc983c9ed64fc148a759b3c7a415" ) == 0 );
3034  }
3035  FCT_TEST_END();
3036 #endif /* POLARSSL_MD5_C */
3037 #endif /* POLARSSL_FS_IO */
3038 
3039 #ifdef POLARSSL_MD5_C
3040 #ifdef POLARSSL_FS_IO
3041 
3042  FCT_TEST_BGN(generic_md5_hash_file_2)
3043  {
3044  char md_name[100];
3045  unsigned char hash_str[1000];
3046  unsigned char output[100];
3047  const md_info_t *md_info = NULL;
3048 
3049  memset(md_name, 0x00, 100);
3050  memset(hash_str, 0x00, 1000);
3051  memset(output, 0x00, 100);
3052 
3053  strncpy( (char *) md_name, "md5", 100 );
3054  md_info = md_info_from_string( md_name );
3055  fct_chk( md_info != NULL );
3056 
3057  md_file( md_info, "data_files/hash_file_2", output);
3058  hexify( hash_str, output, md_get_size(md_info) );
3059 
3060  fct_chk( strcmp( (char *) hash_str, "d17d466f15891df10542207ae78277f0" ) == 0 );
3061  }
3062  FCT_TEST_END();
3063 #endif /* POLARSSL_MD5_C */
3064 #endif /* POLARSSL_FS_IO */
3065 
3066 #ifdef POLARSSL_MD5_C
3067 #ifdef POLARSSL_FS_IO
3068 
3069  FCT_TEST_BGN(generic_md5_hash_file_3)
3070  {
3071  char md_name[100];
3072  unsigned char hash_str[1000];
3073  unsigned char output[100];
3074  const md_info_t *md_info = NULL;
3075 
3076  memset(md_name, 0x00, 100);
3077  memset(hash_str, 0x00, 1000);
3078  memset(output, 0x00, 100);
3079 
3080  strncpy( (char *) md_name, "md5", 100 );
3081  md_info = md_info_from_string( md_name );
3082  fct_chk( md_info != NULL );
3083 
3084  md_file( md_info, "data_files/hash_file_3", output);
3085  hexify( hash_str, output, md_get_size(md_info) );
3086 
3087  fct_chk( strcmp( (char *) hash_str, "d945bcc6200ea95d061a2a818167d920" ) == 0 );
3088  }
3089  FCT_TEST_END();
3090 #endif /* POLARSSL_MD5_C */
3091 #endif /* POLARSSL_FS_IO */
3092 
3093 #ifdef POLARSSL_MD5_C
3094 #ifdef POLARSSL_FS_IO
3095 
3096  FCT_TEST_BGN(generic_md5_hash_file_4)
3097  {
3098  char md_name[100];
3099  unsigned char hash_str[1000];
3100  unsigned char output[100];
3101  const md_info_t *md_info = NULL;
3102 
3103  memset(md_name, 0x00, 100);
3104  memset(hash_str, 0x00, 1000);
3105  memset(output, 0x00, 100);
3106 
3107  strncpy( (char *) md_name, "md5", 100 );
3108  md_info = md_info_from_string( md_name );
3109  fct_chk( md_info != NULL );
3110 
3111  md_file( md_info, "data_files/hash_file_4", output);
3112  hexify( hash_str, output, md_get_size(md_info) );
3113 
3114  fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
3115  }
3116  FCT_TEST_END();
3117 #endif /* POLARSSL_MD5_C */
3118 #endif /* POLARSSL_FS_IO */
3119 
3120 #ifdef POLARSSL_SHA1_C
3121 
3122  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_1)
3123  {
3124  char md_name[100];
3125  unsigned char src_str[10000];
3126  unsigned char key_str[10000];
3127  unsigned char hash_str[10000];
3128  unsigned char output[100];
3129  int key_len, src_len;
3130  const md_info_t *md_info = NULL;
3131 
3132  memset(md_name, 0x00, 100);
3133  memset(src_str, 0x00, 10000);
3134  memset(key_str, 0x00, 10000);
3135  memset(hash_str, 0x00, 10000);
3136  memset(output, 0x00, 100);
3137 
3138  strncpy( (char *) md_name, "sha1", 100 );
3139  md_info = md_info_from_string( md_name );
3140  fct_chk( md_info != NULL );
3141 
3142  key_len = unhexify( key_str, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" );
3143  src_len = unhexify( src_str, "53616d706c65202331" );
3144 
3145  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3146  hexify( hash_str, output, md_get_size(md_info) );
3147 
3148  fct_chk( strncmp( (char *) hash_str, "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", 20 * 2 ) == 0 );
3149  }
3150  FCT_TEST_END();
3151 #endif /* POLARSSL_SHA1_C */
3152 
3153 #ifdef POLARSSL_SHA1_C
3154 
3155  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_2)
3156  {
3157  char md_name[100];
3158  unsigned char src_str[10000];
3159  unsigned char key_str[10000];
3160  unsigned char hash_str[10000];
3161  unsigned char output[100];
3162  int key_len, src_len;
3163  const md_info_t *md_info = NULL;
3164 
3165  memset(md_name, 0x00, 100);
3166  memset(src_str, 0x00, 10000);
3167  memset(key_str, 0x00, 10000);
3168  memset(hash_str, 0x00, 10000);
3169  memset(output, 0x00, 100);
3170 
3171  strncpy( (char *) md_name, "sha1", 100 );
3172  md_info = md_info_from_string( md_name );
3173  fct_chk( md_info != NULL );
3174 
3175  key_len = unhexify( key_str, "303132333435363738393a3b3c3d3e3f40414243" );
3176  src_len = unhexify( src_str, "53616d706c65202332" );
3177 
3178  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3179  hexify( hash_str, output, md_get_size(md_info) );
3180 
3181  fct_chk( strncmp( (char *) hash_str, "0922d3405faa3d194f82a45830737d5cc6c75d24", 20 * 2 ) == 0 );
3182  }
3183  FCT_TEST_END();
3184 #endif /* POLARSSL_SHA1_C */
3185 
3186 #ifdef POLARSSL_SHA1_C
3187 
3188  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_3)
3189  {
3190  char md_name[100];
3191  unsigned char src_str[10000];
3192  unsigned char key_str[10000];
3193  unsigned char hash_str[10000];
3194  unsigned char output[100];
3195  int key_len, src_len;
3196  const md_info_t *md_info = NULL;
3197 
3198  memset(md_name, 0x00, 100);
3199  memset(src_str, 0x00, 10000);
3200  memset(key_str, 0x00, 10000);
3201  memset(hash_str, 0x00, 10000);
3202  memset(output, 0x00, 100);
3203 
3204  strncpy( (char *) md_name, "sha1", 100 );
3205  md_info = md_info_from_string( md_name );
3206  fct_chk( md_info != NULL );
3207 
3208  key_len = unhexify( key_str, "505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" );
3209  src_len = unhexify( src_str, "53616d706c65202333" );
3210 
3211  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3212  hexify( hash_str, output, md_get_size(md_info) );
3213 
3214  fct_chk( strncmp( (char *) hash_str, "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", 20 * 2 ) == 0 );
3215  }
3216  FCT_TEST_END();
3217 #endif /* POLARSSL_SHA1_C */
3218 
3219 #ifdef POLARSSL_SHA1_C
3220 
3221  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_4)
3222  {
3223  char md_name[100];
3224  unsigned char src_str[10000];
3225  unsigned char key_str[10000];
3226  unsigned char hash_str[10000];
3227  unsigned char output[100];
3228  int key_len, src_len;
3229  const md_info_t *md_info = NULL;
3230 
3231  memset(md_name, 0x00, 100);
3232  memset(src_str, 0x00, 10000);
3233  memset(key_str, 0x00, 10000);
3234  memset(hash_str, 0x00, 10000);
3235  memset(output, 0x00, 100);
3236 
3237  strncpy( (char *) md_name, "sha1", 100 );
3238  md_info = md_info_from_string( md_name );
3239  fct_chk( md_info != NULL );
3240 
3241  key_len = unhexify( key_str, "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0" );
3242  src_len = unhexify( src_str, "53616d706c65202334" );
3243 
3244  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3245  hexify( hash_str, output, md_get_size(md_info) );
3246 
3247  fct_chk( strncmp( (char *) hash_str, "9ea886efe268dbecce420c75", 12 * 2 ) == 0 );
3248  }
3249  FCT_TEST_END();
3250 #endif /* POLARSSL_SHA1_C */
3251 
3252 #ifdef POLARSSL_SHA1_C
3253 
3254  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_1)
3255  {
3256  char md_name[100];
3257  unsigned char src_str[10000];
3258  unsigned char key_str[10000];
3259  unsigned char hash_str[10000];
3260  unsigned char output[100];
3261  int key_len, src_len;
3262  const md_info_t *md_info = NULL;
3263 
3264  memset(md_name, 0x00, 100);
3265  memset(src_str, 0x00, 10000);
3266  memset(key_str, 0x00, 10000);
3267  memset(hash_str, 0x00, 10000);
3268  memset(output, 0x00, 100);
3269 
3270  strncpy( (char *) md_name, "sha1", 100 );
3271  md_info = md_info_from_string( md_name );
3272  fct_chk( md_info != NULL );
3273 
3274  key_len = unhexify( key_str, "7b10f4124b15c82e" );
3275  src_len = unhexify( src_str, "27dcb5b1daf60cfd3e2f73d4d64ca9c684f8bf71fc682a46793b1790afa4feb100ca7aaff26f58f0e1d0ed42f1cdad1f474afa2e79d53a0c42892c4d7b327cbe46b295ed8da3b6ecab3d4851687a6f812b79df2f6b20f11f6706f5301790ca99625aad7391d84f78043d2a0a239b1477984c157bbc9276064e7a1a406b0612ca" );
3276 
3277  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3278  hexify( hash_str, output, md_get_size(md_info) );
3279 
3280  fct_chk( strncmp( (char *) hash_str, "4ead12c2fe3d6ea43acb", 10 * 2 ) == 0 );
3281  }
3282  FCT_TEST_END();
3283 #endif /* POLARSSL_SHA1_C */
3284 
3285 #ifdef POLARSSL_SHA1_C
3286 
3287  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_2)
3288  {
3289  char md_name[100];
3290  unsigned char src_str[10000];
3291  unsigned char key_str[10000];
3292  unsigned char hash_str[10000];
3293  unsigned char output[100];
3294  int key_len, src_len;
3295  const md_info_t *md_info = NULL;
3296 
3297  memset(md_name, 0x00, 100);
3298  memset(src_str, 0x00, 10000);
3299  memset(key_str, 0x00, 10000);
3300  memset(hash_str, 0x00, 10000);
3301  memset(output, 0x00, 100);
3302 
3303  strncpy( (char *) md_name, "sha1", 100 );
3304  md_info = md_info_from_string( md_name );
3305  fct_chk( md_info != NULL );
3306 
3307  key_len = unhexify( key_str, "4fe9fb902172a21b" );
3308  src_len = unhexify( src_str, "4ceb3a7c13659c22fe51134f03dce4c239d181b63c6b0b59d367157fd05cab98384f92dfa482d2d5e78e72eef1b1838af4696026c54233d484ecbbe87f904df5546419f8567eafd232e6c2fcd3ee2b7682c63000524b078dbb2096f585007deae752562df1fe3b01278089e16f3be46e2d0f7cabac2d8e6cc02a2d0ca953425f" );
3309 
3310  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3311  hexify( hash_str, output, md_get_size(md_info) );
3312 
3313  fct_chk( strncmp( (char *) hash_str, "564428a67be1924b5793", 10 * 2 ) == 0 );
3314  }
3315  FCT_TEST_END();
3316 #endif /* POLARSSL_SHA1_C */
3317 
3318 #ifdef POLARSSL_SHA1_C
3319 
3320  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_3)
3321  {
3322  char md_name[100];
3323  unsigned char src_str[10000];
3324  unsigned char key_str[10000];
3325  unsigned char hash_str[10000];
3326  unsigned char output[100];
3327  int key_len, src_len;
3328  const md_info_t *md_info = NULL;
3329 
3330  memset(md_name, 0x00, 100);
3331  memset(src_str, 0x00, 10000);
3332  memset(key_str, 0x00, 10000);
3333  memset(hash_str, 0x00, 10000);
3334  memset(output, 0x00, 100);
3335 
3336  strncpy( (char *) md_name, "sha1", 100 );
3337  md_info = md_info_from_string( md_name );
3338  fct_chk( md_info != NULL );
3339 
3340  key_len = unhexify( key_str, "d1f01455f78c4fb4" );
3341  src_len = unhexify( src_str, "00d40f67b57914bec456a3e3201ef1464be319a8d188c02e157af4b54f9b5a66d67f898a9bdbb19ff63a80aba6f246d013575721d52eb1b47a65def884011c49b257bcc2817fc853f106e8138ce386d7a5ac3103de0a3fa0ed6bb7af9ff66ebd1cc46fb86e4da0013d20a3c2dcd8fb828a4b70f7f104b41bf3f44682a66497ea" );
3342 
3343  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3344  hexify( hash_str, output, md_get_size(md_info) );
3345 
3346  fct_chk( strncmp( (char *) hash_str, "56a665a7cdfe610f9fc5", 10 * 2 ) == 0 );
3347  }
3348  FCT_TEST_END();
3349 #endif /* POLARSSL_SHA1_C */
3350 
3351 #ifdef POLARSSL_SHA1_C
3352 
3353  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_4)
3354  {
3355  char md_name[100];
3356  unsigned char src_str[10000];
3357  unsigned char key_str[10000];
3358  unsigned char hash_str[10000];
3359  unsigned char output[100];
3360  int key_len, src_len;
3361  const md_info_t *md_info = NULL;
3362 
3363  memset(md_name, 0x00, 100);
3364  memset(src_str, 0x00, 10000);
3365  memset(key_str, 0x00, 10000);
3366  memset(hash_str, 0x00, 10000);
3367  memset(output, 0x00, 100);
3368 
3369  strncpy( (char *) md_name, "sha1", 100 );
3370  md_info = md_info_from_string( md_name );
3371  fct_chk( md_info != NULL );
3372 
3373  key_len = unhexify( key_str, "4e5ef77fdf033a5b" );
3374  src_len = unhexify( src_str, "e59326464e3201d195e29f2a3446ec1b1c9ff31154e2a4d0e40ed466f1bc855d29f76835624fa0127d29c9b1915939a046f385af7e5d47a23ba91f28bd22f811ea258dbbf3332bcd3543b8285d5df41bd064ffd64a341c22c4edb44f9c8d9e6df0c59dbf4a052a6c83da7478e179a6f3839c6870ff8ca8b9497f9ac1d725fdda" );
3375 
3376  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3377  hexify( hash_str, output, md_get_size(md_info) );
3378 
3379  fct_chk( strncmp( (char *) hash_str, "981c0a7a8423b63a8fa6", 10 * 2 ) == 0 );
3380  }
3381  FCT_TEST_END();
3382 #endif /* POLARSSL_SHA1_C */
3383 
3384 #ifdef POLARSSL_SHA1_C
3385 
3386  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_5)
3387  {
3388  char md_name[100];
3389  unsigned char src_str[10000];
3390  unsigned char key_str[10000];
3391  unsigned char hash_str[10000];
3392  unsigned char output[100];
3393  int key_len, src_len;
3394  const md_info_t *md_info = NULL;
3395 
3396  memset(md_name, 0x00, 100);
3397  memset(src_str, 0x00, 10000);
3398  memset(key_str, 0x00, 10000);
3399  memset(hash_str, 0x00, 10000);
3400  memset(output, 0x00, 100);
3401 
3402  strncpy( (char *) md_name, "sha1", 100 );
3403  md_info = md_info_from_string( md_name );
3404  fct_chk( md_info != NULL );
3405 
3406  key_len = unhexify( key_str, "bcd9ff8aa60be2be" );
3407  src_len = unhexify( src_str, "51be4d0eb37bab714f92e19e9d70390655b363e8cd346a748245e731f437759cb8206412c8dab2ef1d4f36f880f41ff69d949da4594fdecb65e23cac1329b59e69e29bf875b38c31df6fa546c595f35cc2192aa750679a8a51a65e00e839d73a8d8c598a610d237fbe78955213589d80efcb73b95b8586f96d17b6f51a71c3b8" );
3408 
3409  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3410  hexify( hash_str, output, md_get_size(md_info) );
3411 
3412  fct_chk( strncmp( (char *) hash_str, "84633f9f5040c8971478", 10 * 2 ) == 0 );
3413  }
3414  FCT_TEST_END();
3415 #endif /* POLARSSL_SHA1_C */
3416 
3417 #ifdef POLARSSL_SHA1_C
3418 
3419  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_6)
3420  {
3421  char md_name[100];
3422  unsigned char src_str[10000];
3423  unsigned char key_str[10000];
3424  unsigned char hash_str[10000];
3425  unsigned char output[100];
3426  int key_len, src_len;
3427  const md_info_t *md_info = NULL;
3428 
3429  memset(md_name, 0x00, 100);
3430  memset(src_str, 0x00, 10000);
3431  memset(key_str, 0x00, 10000);
3432  memset(hash_str, 0x00, 10000);
3433  memset(output, 0x00, 100);
3434 
3435  strncpy( (char *) md_name, "sha1", 100 );
3436  md_info = md_info_from_string( md_name );
3437  fct_chk( md_info != NULL );
3438 
3439  key_len = unhexify( key_str, "4a661bce6ed86d21" );
3440  src_len = unhexify( src_str, "5ff6c744f1aab1bc29697d71f67541b8b3cec3c7079183b10a83fb98a9ee251d4bac3e1cb581ca972aaed8efd7c2875a6fb4c991132f67c9742d45e53bc7e8eaa94b35b37a907be61086b426cd11088ac118934e85d968c9667fd69fc6f6ea38c0fe34710b7ece91211b9b7ea00acd31f022aa6726368f9928a1352f122233f1" );
3441 
3442  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3443  hexify( hash_str, output, md_get_size(md_info) );
3444 
3445  fct_chk( strncmp( (char *) hash_str, "739df59353ac6694e55e", 10 * 2 ) == 0 );
3446  }
3447  FCT_TEST_END();
3448 #endif /* POLARSSL_SHA1_C */
3449 
3450 #ifdef POLARSSL_SHA1_C
3451 
3452  FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_7)
3453  {
3454  char md_name[100];
3455  unsigned char src_str[10000];
3456  unsigned char key_str[10000];
3457  unsigned char hash_str[10000];
3458  unsigned char output[100];
3459  int key_len, src_len;
3460  const md_info_t *md_info = NULL;
3461 
3462  memset(md_name, 0x00, 100);
3463  memset(src_str, 0x00, 10000);
3464  memset(key_str, 0x00, 10000);
3465  memset(hash_str, 0x00, 10000);
3466  memset(output, 0x00, 100);
3467 
3468  strncpy( (char *) md_name, "sha1", 100 );
3469  md_info = md_info_from_string( md_name );
3470  fct_chk( md_info != NULL );
3471 
3472  key_len = unhexify( key_str, "1287e1565a57b547" );
3473  src_len = unhexify( src_str, "390ffdccc6171c11568d85b8f913e019bf4cd982ca9cd21ea730d41bdf3fcc0bc88ff48ba13a8f23deb2d96ec1033e7b2a58ca72b0c1e17bf03330db25d1e360fa6918009c4294bd1215b5ccd159a8f58bc3dc3d490eb7c3b9f887e8c98dbbb274a75373dcb695a59abd0219529d88518a96f92abc0bbcbda985c388f1fbbcc9" );
3474 
3475  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3476  hexify( hash_str, output, md_get_size(md_info) );
3477 
3478  fct_chk( strncmp( (char *) hash_str, "d78ddf08077c7d9e2ba6", 10 * 2 ) == 0 );
3479  }
3480  FCT_TEST_END();
3481 #endif /* POLARSSL_SHA1_C */
3482 
3483 #ifdef POLARSSL_SHA2_C
3484 
3485  FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_1)
3486  {
3487  char md_name[100];
3488  unsigned char src_str[10000];
3489  unsigned char key_str[10000];
3490  unsigned char hash_str[10000];
3491  unsigned char output[100];
3492  int key_len, src_len;
3493  const md_info_t *md_info = NULL;
3494 
3495  memset(md_name, 0x00, 100);
3496  memset(src_str, 0x00, 10000);
3497  memset(key_str, 0x00, 10000);
3498  memset(hash_str, 0x00, 10000);
3499  memset(output, 0x00, 100);
3500 
3501  strncpy( (char *) md_name, "sha224", 100 );
3502  md_info = md_info_from_string( md_name );
3503  fct_chk( md_info != NULL );
3504 
3505  key_len = unhexify( key_str, "e055eb756697ee573fd3214811a9f7fa" );
3506  src_len = unhexify( src_str, "3875847012ee42fe54a0027bdf38cca7021b83a2ed0503af69ef6c37c637bc1114fba40096c5947d736e19b7af3c68d95a4e3b8b073adbbb80f47e9db8f2d4f0018ddd847fabfdf9dd9b52c93e40458977725f6b7ba15f0816bb895cdf50401268f5d702b7e6a5f9faef57b8768c8a3fc14f9a4b3182b41d940e337d219b29ff" );
3507 
3508  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3509  hexify( hash_str, output, md_get_size(md_info) );
3510 
3511  fct_chk( strncmp( (char *) hash_str, "40a453133361cc48da11baf616ee", 14 * 2 ) == 0 );
3512  }
3513  FCT_TEST_END();
3514 #endif /* POLARSSL_SHA2_C */
3515 
3516 #ifdef POLARSSL_SHA2_C
3517 
3518  FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_2)
3519  {
3520  char md_name[100];
3521  unsigned char src_str[10000];
3522  unsigned char key_str[10000];
3523  unsigned char hash_str[10000];
3524  unsigned char output[100];
3525  int key_len, src_len;
3526  const md_info_t *md_info = NULL;
3527 
3528  memset(md_name, 0x00, 100);
3529  memset(src_str, 0x00, 10000);
3530  memset(key_str, 0x00, 10000);
3531  memset(hash_str, 0x00, 10000);
3532  memset(output, 0x00, 100);
3533 
3534  strncpy( (char *) md_name, "sha224", 100 );
3535  md_info = md_info_from_string( md_name );
3536  fct_chk( md_info != NULL );
3537 
3538  key_len = unhexify( key_str, "88e5258b55b1623385eb9632fa7c57d6" );
3539  src_len = unhexify( src_str, "ada76bb604be14326551701cf30e48a65eee80b44f0b9d4a07b1844543b7844a621097fdc99de57387458ae9354899b620d0617eabcaefa9eef3d413a33628054335ce656c26fa2986e0f111a6351096b283101ec7868871d770b370973c7405983f9756b3005a3eab492cfd0e7eb42e5c2e15fa6be8718c0a50acc4e5717230" );
3540 
3541  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3542  hexify( hash_str, output, md_get_size(md_info) );
3543 
3544  fct_chk( strncmp( (char *) hash_str, "81c783af538015cef3c60095df53", 14 * 2 ) == 0 );
3545  }
3546  FCT_TEST_END();
3547 #endif /* POLARSSL_SHA2_C */
3548 
3549 #ifdef POLARSSL_SHA2_C
3550 
3551  FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_3)
3552  {
3553  char md_name[100];
3554  unsigned char src_str[10000];
3555  unsigned char key_str[10000];
3556  unsigned char hash_str[10000];
3557  unsigned char output[100];
3558  int key_len, src_len;
3559  const md_info_t *md_info = NULL;
3560 
3561  memset(md_name, 0x00, 100);
3562  memset(src_str, 0x00, 10000);
3563  memset(key_str, 0x00, 10000);
3564  memset(hash_str, 0x00, 10000);
3565  memset(output, 0x00, 100);
3566 
3567  strncpy( (char *) md_name, "sha224", 100 );
3568  md_info = md_info_from_string( md_name );
3569  fct_chk( md_info != NULL );
3570 
3571  key_len = unhexify( key_str, "85d402d822114d31abf75526e2538705" );
3572  src_len = unhexify( src_str, "8020d8d98cc2e2298b32879c51c751e1dd5558fe2eabb8f158604297d6d072ce2261a1d6830b7cfe2617b57c7126f99c9476211d6161acd75d266da217ec8174b80484c9dc6f0448a0a036a3fc82e8bf54bdb71549368258d5d41f57978a4c266b92e8783ef66350215573d99be4089144b383ad8f3222bae8f3bf80ffb1bb2b" );
3573 
3574  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3575  hexify( hash_str, output, md_get_size(md_info) );
3576 
3577  fct_chk( strncmp( (char *) hash_str, "2aa0340ac9deafe3be38129daca0", 14 * 2 ) == 0 );
3578  }
3579  FCT_TEST_END();
3580 #endif /* POLARSSL_SHA2_C */
3581 
3582 #ifdef POLARSSL_SHA2_C
3583 
3584  FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_4)
3585  {
3586  char md_name[100];
3587  unsigned char src_str[10000];
3588  unsigned char key_str[10000];
3589  unsigned char hash_str[10000];
3590  unsigned char output[100];
3591  int key_len, src_len;
3592  const md_info_t *md_info = NULL;
3593 
3594  memset(md_name, 0x00, 100);
3595  memset(src_str, 0x00, 10000);
3596  memset(key_str, 0x00, 10000);
3597  memset(hash_str, 0x00, 10000);
3598  memset(output, 0x00, 100);
3599 
3600  strncpy( (char *) md_name, "sha224", 100 );
3601  md_info = md_info_from_string( md_name );
3602  fct_chk( md_info != NULL );
3603 
3604  key_len = unhexify( key_str, "545c6eecc5ee46fa17c59f91a94f81ae" );
3605  src_len = unhexify( src_str, "8fb7f3565593170152ddb2021874784e951977cfdd22f8b72a72a61320a8f2a35697b5e913f717805559b1af1861ee3ed42fb788481e4fd276b17bdbefcae7b4501dc5d20de5b7626dd5efdcd65294db4bdf682c33d9a9255c6435383fa5f1c886326a3acbc6bd50a33ab5b2dbb034ce0112d4e226bbcd57e3731a519aa1d784" );
3606 
3607  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3608  hexify( hash_str, output, md_get_size(md_info) );
3609 
3610  fct_chk( strncmp( (char *) hash_str, "3eb566eac54c4a3a9ef092469f24", 14 * 2 ) == 0 );
3611  }
3612  FCT_TEST_END();
3613 #endif /* POLARSSL_SHA2_C */
3614 
3615 #ifdef POLARSSL_SHA2_C
3616 
3617  FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_5)
3618  {
3619  char md_name[100];
3620  unsigned char src_str[10000];
3621  unsigned char key_str[10000];
3622  unsigned char hash_str[10000];
3623  unsigned char output[100];
3624  int key_len, src_len;
3625  const md_info_t *md_info = NULL;
3626 
3627  memset(md_name, 0x00, 100);
3628  memset(src_str, 0x00, 10000);
3629  memset(key_str, 0x00, 10000);
3630  memset(hash_str, 0x00, 10000);
3631  memset(output, 0x00, 100);
3632 
3633  strncpy( (char *) md_name, "sha224", 100 );
3634  md_info = md_info_from_string( md_name );
3635  fct_chk( md_info != NULL );
3636 
3637  key_len = unhexify( key_str, "4466ab4dc438841a9750c7f173dff02e" );
3638  src_len = unhexify( src_str, "2534c11c78c99cffaec8f722f04adc7045c7324d58ce98e37cfa94b6ed21ed7f58ce55379ef24b72d6d640ee9154f96c614734be9c408e225d7ba4cecc1179cc9f6e1808e1067aa8f244a99bd0c3267594c1887a40d167f8b7cf78db0d19f97b01fc50b8c86def490dfa7a5135002c33e71d77a8cce8ea0f93e0580439a33733" );
3639 
3640  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3641  hexify( hash_str, output, md_get_size(md_info) );
3642 
3643  fct_chk( strncmp( (char *) hash_str, "59f44a9bbed4875b892d22d6b5ab", 14 * 2 ) == 0 );
3644  }
3645  FCT_TEST_END();
3646 #endif /* POLARSSL_SHA2_C */
3647 
3648 #ifdef POLARSSL_SHA2_C
3649 
3650  FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_6)
3651  {
3652  char md_name[100];
3653  unsigned char src_str[10000];
3654  unsigned char key_str[10000];
3655  unsigned char hash_str[10000];
3656  unsigned char output[100];
3657  int key_len, src_len;
3658  const md_info_t *md_info = NULL;
3659 
3660  memset(md_name, 0x00, 100);
3661  memset(src_str, 0x00, 10000);
3662  memset(key_str, 0x00, 10000);
3663  memset(hash_str, 0x00, 10000);
3664  memset(output, 0x00, 100);
3665 
3666  strncpy( (char *) md_name, "sha224", 100 );
3667  md_info = md_info_from_string( md_name );
3668  fct_chk( md_info != NULL );
3669 
3670  key_len = unhexify( key_str, "0e3dd9bb5e4cf0f09a4c11600af56d8d" );
3671  src_len = unhexify( src_str, "f4589fa76c328ea25cf8bae582026ba40a59d45a546ff31cf80eb826088f69bb954c452c74586836416dee90a5255bc5d56d3b405b3705a5197045688b32fa984c3a3dfbdc9c2460a0b5e6312a624048bb6f170306535e9b371a3ab134a2642a230ad03d2c688cca80baeaee9a20e1d4c548b1cede29c6a45bf4df2c8c476f1a" );
3672 
3673  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3674  hexify( hash_str, output, md_get_size(md_info) );
3675 
3676  fct_chk( strncmp( (char *) hash_str, "12175b93e3da4c58217145e4dc0a1cf142fab9319bb501e037b350ba", 28 * 2 ) == 0 );
3677  }
3678  FCT_TEST_END();
3679 #endif /* POLARSSL_SHA2_C */
3680 
3681 #ifdef POLARSSL_SHA2_C
3682 
3683  FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_7)
3684  {
3685  char md_name[100];
3686  unsigned char src_str[10000];
3687  unsigned char key_str[10000];
3688  unsigned char hash_str[10000];
3689  unsigned char output[100];
3690  int key_len, src_len;
3691  const md_info_t *md_info = NULL;
3692 
3693  memset(md_name, 0x00, 100);
3694  memset(src_str, 0x00, 10000);
3695  memset(key_str, 0x00, 10000);
3696  memset(hash_str, 0x00, 10000);
3697  memset(output, 0x00, 100);
3698 
3699  strncpy( (char *) md_name, "sha224", 100 );
3700  md_info = md_info_from_string( md_name );
3701  fct_chk( md_info != NULL );
3702 
3703  key_len = unhexify( key_str, "cda5187b0c5dcb0f8e5a8beed2306584" );
3704  src_len = unhexify( src_str, "9011ae29b44c49b347487ce972965f16ade3c15be0856ce9c853a9739dba07e4f20d594ddc1dfe21560a65a4e458cfa17745575b915a30c7a9412ff8d1d689db9680dd2428c27588bb0dc92d2cd9445fe8f44b840a197c52c3c4333fff45533945134398df6436513cfab06c924046b8c795a5bd92e8d5f2de85bf306f2eed67" );
3705 
3706  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3707  hexify( hash_str, output, md_get_size(md_info) );
3708 
3709  fct_chk( strncmp( (char *) hash_str, "4aaba92b40e2a600feab176eb9b292d814864195c03342aad6f67f08", 28 * 2 ) == 0 );
3710  }
3711  FCT_TEST_END();
3712 #endif /* POLARSSL_SHA2_C */
3713 
3714 #ifdef POLARSSL_SHA2_C
3715 
3716  FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_1)
3717  {
3718  char md_name[100];
3719  unsigned char src_str[10000];
3720  unsigned char key_str[10000];
3721  unsigned char hash_str[10000];
3722  unsigned char output[100];
3723  int key_len, src_len;
3724  const md_info_t *md_info = NULL;
3725 
3726  memset(md_name, 0x00, 100);
3727  memset(src_str, 0x00, 10000);
3728  memset(key_str, 0x00, 10000);
3729  memset(hash_str, 0x00, 10000);
3730  memset(output, 0x00, 100);
3731 
3732  strncpy( (char *) md_name, "sha256", 100 );
3733  md_info = md_info_from_string( md_name );
3734  fct_chk( md_info != NULL );
3735 
3736  key_len = unhexify( key_str, "cdffd34e6b16fdc0" );
3737  src_len = unhexify( src_str, "d83e78b99ab61709608972b36e76a575603db742269cc5dd4e7d5ca7816e26b65151c92632550cb4c5253c885d5fce53bc47459a1dbd5652786c4aac0145a532f12c05138af04cbb558101a7af5df478834c2146594dd73690d01a4fe72545894335f427ac70204798068cb86c5a600b40b414ede23590b41e1192373df84fe3" );
3738 
3739  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3740  hexify( hash_str, output, md_get_size(md_info) );
3741 
3742  fct_chk( strncmp( (char *) hash_str, "c6f0dde266cb4a26d41e8259d33499cc", 16 * 2 ) == 0 );
3743  }
3744  FCT_TEST_END();
3745 #endif /* POLARSSL_SHA2_C */
3746 
3747 #ifdef POLARSSL_SHA2_C
3748 
3749  FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_2)
3750  {
3751  char md_name[100];
3752  unsigned char src_str[10000];
3753  unsigned char key_str[10000];
3754  unsigned char hash_str[10000];
3755  unsigned char output[100];
3756  int key_len, src_len;
3757  const md_info_t *md_info = NULL;
3758 
3759  memset(md_name, 0x00, 100);
3760  memset(src_str, 0x00, 10000);
3761  memset(key_str, 0x00, 10000);
3762  memset(hash_str, 0x00, 10000);
3763  memset(output, 0x00, 100);
3764 
3765  strncpy( (char *) md_name, "sha256", 100 );
3766  md_info = md_info_from_string( md_name );
3767  fct_chk( md_info != NULL );
3768 
3769  key_len = unhexify( key_str, "6d97bb5892245be2" );
3770  src_len = unhexify( src_str, "13c2b391d59c0252ca5d2302beaaf88c4bcd779bb505ad9a122003dfae4cc123ad2bd036f225c4f040021a6b9fb8bd6f0281cf2e2631a732bdc71693cc42ef6d52b6c6912a9ef77b3274eb85ad7f965ae6ed44ac1721962a884ec7acfb4534b1488b1c0c45afa4dae8da1eb7b0a88a3240365d7e4e7d826abbde9f9203fd99d7" );
3771 
3772  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3773  hexify( hash_str, output, md_get_size(md_info) );
3774 
3775  fct_chk( strncmp( (char *) hash_str, "31588e241b015319a5ab8c4527296498", 16 * 2 ) == 0 );
3776  }
3777  FCT_TEST_END();
3778 #endif /* POLARSSL_SHA2_C */
3779 
3780 #ifdef POLARSSL_SHA2_C
3781 
3782  FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_3)
3783  {
3784  char md_name[100];
3785  unsigned char src_str[10000];
3786  unsigned char key_str[10000];
3787  unsigned char hash_str[10000];
3788  unsigned char output[100];
3789  int key_len, src_len;
3790  const md_info_t *md_info = NULL;
3791 
3792  memset(md_name, 0x00, 100);
3793  memset(src_str, 0x00, 10000);
3794  memset(key_str, 0x00, 10000);
3795  memset(hash_str, 0x00, 10000);
3796  memset(output, 0x00, 100);
3797 
3798  strncpy( (char *) md_name, "sha256", 100 );
3799  md_info = md_info_from_string( md_name );
3800  fct_chk( md_info != NULL );
3801 
3802  key_len = unhexify( key_str, "3c7fc8a70b49007a" );
3803  src_len = unhexify( src_str, "60024e428a39c8b8bb2e9591bad9dc2115dfbfd716b6eb7af30a6eb34560caccbbfa47b710fa8d523aca71e9e5ba10fc1feb1a43556d71f07ea4f33496f093044e8caf1d02b79e46eb1288d5964a7a7494f6b92574c35784eece054c6151281d80822f7d47b8231c35d07f5cb5cf4310ddc844845a01c6bfab514c048eccaf9f" );
3804 
3805  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3806  hexify( hash_str, output, md_get_size(md_info) );
3807 
3808  fct_chk( strncmp( (char *) hash_str, "1c98c94a32bec9f253c21070f82f8438", 16 * 2 ) == 0 );
3809  }
3810  FCT_TEST_END();
3811 #endif /* POLARSSL_SHA2_C */
3812 
3813 #ifdef POLARSSL_SHA2_C
3814 
3815  FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_4)
3816  {
3817  char md_name[100];
3818  unsigned char src_str[10000];
3819  unsigned char key_str[10000];
3820  unsigned char hash_str[10000];
3821  unsigned char output[100];
3822  int key_len, src_len;
3823  const md_info_t *md_info = NULL;
3824 
3825  memset(md_name, 0x00, 100);
3826  memset(src_str, 0x00, 10000);
3827  memset(key_str, 0x00, 10000);
3828  memset(hash_str, 0x00, 10000);
3829  memset(output, 0x00, 100);
3830 
3831  strncpy( (char *) md_name, "sha256", 100 );
3832  md_info = md_info_from_string( md_name );
3833  fct_chk( md_info != NULL );
3834 
3835  key_len = unhexify( key_str, "369f33f85b927a07" );
3836  src_len = unhexify( src_str, "ae8e2a94ca386d448cbacdb0e9040ae3cb297c296363052cc157455da29a0c95897315fc11e3f12b81e2418da1ec280bccbc00e847584ce9d14deeba7b3c9b8dba958b04bba37551f6c9ba9c060be1a4b8cf43aa62e5078b76c6512c5619b71a6a7cf5727180e1ff14f5a1a3c1691bf8b6ebad365c151e58d749d57adb3a4986" );
3837 
3838  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3839  hexify( hash_str, output, md_get_size(md_info) );
3840 
3841  fct_chk( strncmp( (char *) hash_str, "60b90383286533d309de46593e6ce39fc51fb00a8d88278c", 24 * 2 ) == 0 );
3842  }
3843  FCT_TEST_END();
3844 #endif /* POLARSSL_SHA2_C */
3845 
3846 #ifdef POLARSSL_SHA2_C
3847 
3848  FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_5)
3849  {
3850  char md_name[100];
3851  unsigned char src_str[10000];
3852  unsigned char key_str[10000];
3853  unsigned char hash_str[10000];
3854  unsigned char output[100];
3855  int key_len, src_len;
3856  const md_info_t *md_info = NULL;
3857 
3858  memset(md_name, 0x00, 100);
3859  memset(src_str, 0x00, 10000);
3860  memset(key_str, 0x00, 10000);
3861  memset(hash_str, 0x00, 10000);
3862  memset(output, 0x00, 100);
3863 
3864  strncpy( (char *) md_name, "sha256", 100 );
3865  md_info = md_info_from_string( md_name );
3866  fct_chk( md_info != NULL );
3867 
3868  key_len = unhexify( key_str, "e5179687582b4dc4" );
3869  src_len = unhexify( src_str, "ce103bdacdf32f614f6727bcb31ca1c2824a850d00f5585b016fb234fe1ef2cd687f302d3c6b738ed89a24060d65c36675d0d96307c72ef3e8a83bfa8402e226de9d5d1724ba75c4879bf41a4a465ce61887d9f49a34757849b48bae81c27ebed76faae2ad669bca04747d409148d40812776e0ae2c395b3cb9c89981ce72d5c" );
3870 
3871  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3872  hexify( hash_str, output, md_get_size(md_info) );
3873 
3874  fct_chk( strncmp( (char *) hash_str, "509581f6816df4b8cc9f2cf42b7cc6e6a5a1e375a16f2412", 24 * 2 ) == 0 );
3875  }
3876  FCT_TEST_END();
3877 #endif /* POLARSSL_SHA2_C */
3878 
3879 #ifdef POLARSSL_SHA2_C
3880 
3881  FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_6)
3882  {
3883  char md_name[100];
3884  unsigned char src_str[10000];
3885  unsigned char key_str[10000];
3886  unsigned char hash_str[10000];
3887  unsigned char output[100];
3888  int key_len, src_len;
3889  const md_info_t *md_info = NULL;
3890 
3891  memset(md_name, 0x00, 100);
3892  memset(src_str, 0x00, 10000);
3893  memset(key_str, 0x00, 10000);
3894  memset(hash_str, 0x00, 10000);
3895  memset(output, 0x00, 100);
3896 
3897  strncpy( (char *) md_name, "sha256", 100 );
3898  md_info = md_info_from_string( md_name );
3899  fct_chk( md_info != NULL );
3900 
3901  key_len = unhexify( key_str, "63cec6246aeb1b61" );
3902  src_len = unhexify( src_str, "c178db908a405fa88aa255b8cad22b4057016585f139ee930388b083d86062fa0b3ea1f23f8a43bd11bee8464bcbd19b5ab9f6a8038d5245516f8274d20c8ee3033a07b908da528fa00343bb595deed500cab9745c4cb6391c23300f0d3584b090b3326c4cfa342620b78f9f5b4f27f7307ed770643ec1764aeae3dcf1a3ec69" );
3903 
3904  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3905  hexify( hash_str, output, md_get_size(md_info) );
3906 
3907  fct_chk( strncmp( (char *) hash_str, "64f3dd861b7c7d29fce9ae0ce9ed954b5d7141806ee9eec7", 24 * 2 ) == 0 );
3908  }
3909  FCT_TEST_END();
3910 #endif /* POLARSSL_SHA2_C */
3911 
3912 #ifdef POLARSSL_SHA4_C
3913 
3914  FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_1)
3915  {
3916  char md_name[100];
3917  unsigned char src_str[10000];
3918  unsigned char key_str[10000];
3919  unsigned char hash_str[10000];
3920  unsigned char output[100];
3921  int key_len, src_len;
3922  const md_info_t *md_info = NULL;
3923 
3924  memset(md_name, 0x00, 100);
3925  memset(src_str, 0x00, 10000);
3926  memset(key_str, 0x00, 10000);
3927  memset(hash_str, 0x00, 10000);
3928  memset(output, 0x00, 100);
3929 
3930  strncpy( (char *) md_name, "sha384", 100 );
3931  md_info = md_info_from_string( md_name );
3932  fct_chk( md_info != NULL );
3933 
3934  key_len = unhexify( key_str, "91a7401817386948ca952f9a20ee55dc" );
3935  src_len = unhexify( src_str, "2fea5b91035d6d501f3a834fa178bff4e64b99a8450432dafd32e4466b0e1e7781166f8a73f7e036b3b0870920f559f47bd1400a1a906e85e0dcf00a6c26862e9148b23806680f285f1fe4f93cdaf924c181a965465739c14f2268c8be8b471847c74b222577a1310bcdc1a85ef1468aa1a3fd4031213c97324b7509c9050a3d" );
3936 
3937  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3938  hexify( hash_str, output, md_get_size(md_info) );
3939 
3940  fct_chk( strncmp( (char *) hash_str, "6d7be9490058cf413cc09fd043c224c2ec4fa7859b13783000a9a593c9f75838", 32 * 2 ) == 0 );
3941  }
3942  FCT_TEST_END();
3943 #endif /* POLARSSL_SHA4_C */
3944 
3945 #ifdef POLARSSL_SHA4_C
3946 
3947  FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_2)
3948  {
3949  char md_name[100];
3950  unsigned char src_str[10000];
3951  unsigned char key_str[10000];
3952  unsigned char hash_str[10000];
3953  unsigned char output[100];
3954  int key_len, src_len;
3955  const md_info_t *md_info = NULL;
3956 
3957  memset(md_name, 0x00, 100);
3958  memset(src_str, 0x00, 10000);
3959  memset(key_str, 0x00, 10000);
3960  memset(hash_str, 0x00, 10000);
3961  memset(output, 0x00, 100);
3962 
3963  strncpy( (char *) md_name, "sha384", 100 );
3964  md_info = md_info_from_string( md_name );
3965  fct_chk( md_info != NULL );
3966 
3967  key_len = unhexify( key_str, "d6cac19657061aa90a6da11cd2e9ea47" );
3968  src_len = unhexify( src_str, "9f482e4655173135dfaa22a11bbbe6af263db48716406c5aec162ba3c4b41cad4f5a91558377521191c7343118beee65982929802913d67b6de5c4bdc3d27299bd722219d5ad2efa5bdb9ff7b229fc4bbc3f60719320cf2e7a51cad1133d21bad2d80919b1836ef825308b7c51c6b7677ac782e2bc30007afba065681cbdd215" );
3969 
3970  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
3971  hexify( hash_str, output, md_get_size(md_info) );
3972 
3973  fct_chk( strncmp( (char *) hash_str, "f3d5f3c008175321aa7b2ea379eaa4f8b9dcc60f895ec8940b8162f80a7dfe9f", 32 * 2 ) == 0 );
3974  }
3975  FCT_TEST_END();
3976 #endif /* POLARSSL_SHA4_C */
3977 
3978 #ifdef POLARSSL_SHA4_C
3979 
3980  FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_3)
3981  {
3982  char md_name[100];
3983  unsigned char src_str[10000];
3984  unsigned char key_str[10000];
3985  unsigned char hash_str[10000];
3986  unsigned char output[100];
3987  int key_len, src_len;
3988  const md_info_t *md_info = NULL;
3989 
3990  memset(md_name, 0x00, 100);
3991  memset(src_str, 0x00, 10000);
3992  memset(key_str, 0x00, 10000);
3993  memset(hash_str, 0x00, 10000);
3994  memset(output, 0x00, 100);
3995 
3996  strncpy( (char *) md_name, "sha384", 100 );
3997  md_info = md_info_from_string( md_name );
3998  fct_chk( md_info != NULL );
3999 
4000  key_len = unhexify( key_str, "e06366ad149b8442cd4c1abdddd0afde" );
4001  src_len = unhexify( src_str, "2d140a194c02a5598f69174834679b8371234a0d505491f1bd03e128dd91a8bca2fb812e9d5da71613b5b00952ea78bf450d5b7547dea79135925085c7d3e6f52009c51ca3d88c6c09e9d074b0ee110736e0ec9b478b93efb34d7bf1c41b54decec43eab077a3aa4998ede53f67b4ea36c266745f9643d5360bdc8337c70dabf" );
4002 
4003  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4004  hexify( hash_str, output, md_get_size(md_info) );
4005 
4006  fct_chk( strncmp( (char *) hash_str, "c19c67eda6fe29f3667bee1c897c333ce7683094ae77e84b4c16378d290895a1", 32 * 2 ) == 0 );
4007  }
4008  FCT_TEST_END();
4009 #endif /* POLARSSL_SHA4_C */
4010 
4011 #ifdef POLARSSL_SHA4_C
4012 
4013  FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_4)
4014  {
4015  char md_name[100];
4016  unsigned char src_str[10000];
4017  unsigned char key_str[10000];
4018  unsigned char hash_str[10000];
4019  unsigned char output[100];
4020  int key_len, src_len;
4021  const md_info_t *md_info = NULL;
4022 
4023  memset(md_name, 0x00, 100);
4024  memset(src_str, 0x00, 10000);
4025  memset(key_str, 0x00, 10000);
4026  memset(hash_str, 0x00, 10000);
4027  memset(output, 0x00, 100);
4028 
4029  strncpy( (char *) md_name, "sha384", 100 );
4030  md_info = md_info_from_string( md_name );
4031  fct_chk( md_info != NULL );
4032 
4033  key_len = unhexify( key_str, "01ac59f42f8bb91d1bd10fe6990d7a87" );
4034  src_len = unhexify( src_str, "3caf18c476edd5615f343ac7b7d3a9da9efade755672d5ba4b8ae8a7505539ea2c124ff755ec0457fbe49e43480b3c71e7f4742ec3693aad115d039f90222b030fdc9440313691716d5302005808c07627483b916fdf61983063c2eb1268f2deeef42fc790334456bc6bad256e31fc9066de7cc7e43d1321b1866db45e905622" );
4035 
4036  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4037  hexify( hash_str, output, md_get_size(md_info) );
4038 
4039  fct_chk( strncmp( (char *) hash_str, "1985fa2163a5943fc5d92f1fe8831215e7e91f0bff5332bc713a072bdb3a8f9e5c5157463a3bfeb36231416e65973e64", 48 * 2 ) == 0 );
4040  }
4041  FCT_TEST_END();
4042 #endif /* POLARSSL_SHA4_C */
4043 
4044 #ifdef POLARSSL_SHA4_C
4045 
4046  FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_5)
4047  {
4048  char md_name[100];
4049  unsigned char src_str[10000];
4050  unsigned char key_str[10000];
4051  unsigned char hash_str[10000];
4052  unsigned char output[100];
4053  int key_len, src_len;
4054  const md_info_t *md_info = NULL;
4055 
4056  memset(md_name, 0x00, 100);
4057  memset(src_str, 0x00, 10000);
4058  memset(key_str, 0x00, 10000);
4059  memset(hash_str, 0x00, 10000);
4060  memset(output, 0x00, 100);
4061 
4062  strncpy( (char *) md_name, "sha384", 100 );
4063  md_info = md_info_from_string( md_name );
4064  fct_chk( md_info != NULL );
4065 
4066  key_len = unhexify( key_str, "fd74b9d9e102a3a80df1baf0cb35bace" );
4067  src_len = unhexify( src_str, "1a068917584813d1689ccbd0370c2114d537cdc8cc52bf6db16d5535f8f7d1ad0c850a9fa0cf62373ffbf7642b1f1e8164010d350721d798d9f99e9724830399c2fce26377e83d38845675457865c03d4a07d741a505ef028343eb29fd46d0f761f3792886998c1e5c32ac3bc7e6f08faed194b34f06eff4d5d4a5b42c481e0e" );
4068 
4069  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4070  hexify( hash_str, output, md_get_size(md_info) );
4071 
4072  fct_chk( strncmp( (char *) hash_str, "a981eaf5de3d78b20ebd4414a4edd0657e3667cd808a0dbc430cf7252f73a5b24efa136039207bd59806897457d74e0c", 48 * 2 ) == 0 );
4073  }
4074  FCT_TEST_END();
4075 #endif /* POLARSSL_SHA4_C */
4076 
4077 #ifdef POLARSSL_SHA4_C
4078 
4079  FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_5)
4080  {
4081  char md_name[100];
4082  unsigned char src_str[10000];
4083  unsigned char key_str[10000];
4084  unsigned char hash_str[10000];
4085  unsigned char output[100];
4086  int key_len, src_len;
4087  const md_info_t *md_info = NULL;
4088 
4089  memset(md_name, 0x00, 100);
4090  memset(src_str, 0x00, 10000);
4091  memset(key_str, 0x00, 10000);
4092  memset(hash_str, 0x00, 10000);
4093  memset(output, 0x00, 100);
4094 
4095  strncpy( (char *) md_name, "sha384", 100 );
4096  md_info = md_info_from_string( md_name );
4097  fct_chk( md_info != NULL );
4098 
4099  key_len = unhexify( key_str, "9fe794f0e26b669fa5f6883149377c6c" );
4100  src_len = unhexify( src_str, "6010c9745e8f1d44cfdc99e7e0fd79bc4271944c2d1d84dba589073dfc4ca5eb98c59356f60cd87bef28aeb83a832bde339b2087daf942aa1f67876c5d5ed33924bed4143bc12a2be532ccaf64daa7e2bc3c8872b9823b0533b6f5159135effe8c61545536975d7c3a61ba7365ec35f165bc92b4d19eb9156ade17dfa1bb4161" );
4101 
4102  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4103  hexify( hash_str, output, md_get_size(md_info) );
4104 
4105  fct_chk( strncmp( (char *) hash_str, "915ae61f8754698c2b6ef9629e93441f8541bd4258a5e05372d19136cfaefc0473b48d96119291b38eb1a3cb1982a986", 48 * 2 ) == 0 );
4106  }
4107  FCT_TEST_END();
4108 #endif /* POLARSSL_SHA4_C */
4109 
4110 #ifdef POLARSSL_SHA4_C
4111 
4112  FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_1)
4113  {
4114  char md_name[100];
4115  unsigned char src_str[10000];
4116  unsigned char key_str[10000];
4117  unsigned char hash_str[10000];
4118  unsigned char output[100];
4119  int key_len, src_len;
4120  const md_info_t *md_info = NULL;
4121 
4122  memset(md_name, 0x00, 100);
4123  memset(src_str, 0x00, 10000);
4124  memset(key_str, 0x00, 10000);
4125  memset(hash_str, 0x00, 10000);
4126  memset(output, 0x00, 100);
4127 
4128  strncpy( (char *) md_name, "sha512", 100 );
4129  md_info = md_info_from_string( md_name );
4130  fct_chk( md_info != NULL );
4131 
4132  key_len = unhexify( key_str, "c95a17c09940a691ed2d621571b0eb844ede55a9" );
4133  src_len = unhexify( src_str, "99cd28262e81f34878cdcebf4128e05e2098a7009278a66f4c785784d0e5678f3f2b22f86e982d273b6273a222ec61750b4556d766f1550a7aedfe83faedbc4bdae83fa560d62df17eb914d05fdaa48940551bac81d700f5fca7147295e386e8120d66742ec65c6ee8d89a92217a0f6266d0ddc60bb20ef679ae8299c8502c2f" );
4134 
4135  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4136  hexify( hash_str, output, md_get_size(md_info) );
4137 
4138  fct_chk( strncmp( (char *) hash_str, "6bc1379d156559ddee2ed420ea5d5c5ff3e454a1059b7ba72c350e77b6e9333c", 32 * 2 ) == 0 );
4139  }
4140  FCT_TEST_END();
4141 #endif /* POLARSSL_SHA4_C */
4142 
4143 #ifdef POLARSSL_SHA4_C
4144 
4145  FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_2)
4146  {
4147  char md_name[100];
4148  unsigned char src_str[10000];
4149  unsigned char key_str[10000];
4150  unsigned char hash_str[10000];
4151  unsigned char output[100];
4152  int key_len, src_len;
4153  const md_info_t *md_info = NULL;
4154 
4155  memset(md_name, 0x00, 100);
4156  memset(src_str, 0x00, 10000);
4157  memset(key_str, 0x00, 10000);
4158  memset(hash_str, 0x00, 10000);
4159  memset(output, 0x00, 100);
4160 
4161  strncpy( (char *) md_name, "sha512", 100 );
4162  md_info = md_info_from_string( md_name );
4163  fct_chk( md_info != NULL );
4164 
4165  key_len = unhexify( key_str, "3b10b8fa718840d1dea8e9fc317476bcf55875fd" );
4166  src_len = unhexify( src_str, "f04f5b7073d7d0274e8354433b390306c5607632f5f589c12edb62d55673aff2366d2e6b24de731adf92e654baa30b1cfd4a069788f65ec1b99b015d904d8832110dbd74eae35a81562d14ce4136d820ad0a55ff5489ba678fbbc1c27663ec1349d70e740f0e0ec27cfbe8971819f4789e486b50a2d7271d77e2aaea50de62fd" );
4167 
4168  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4169  hexify( hash_str, output, md_get_size(md_info) );
4170 
4171  fct_chk( strncmp( (char *) hash_str, "fc3c38c7a17e3ce06db033f1c172866f01a00045db55f2e234f71c82264f2ba2", 32 * 2 ) == 0 );
4172  }
4173  FCT_TEST_END();
4174 #endif /* POLARSSL_SHA4_C */
4175 
4176 #ifdef POLARSSL_SHA4_C
4177 
4178  FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_3)
4179  {
4180  char md_name[100];
4181  unsigned char src_str[10000];
4182  unsigned char key_str[10000];
4183  unsigned char hash_str[10000];
4184  unsigned char output[100];
4185  int key_len, src_len;
4186  const md_info_t *md_info = NULL;
4187 
4188  memset(md_name, 0x00, 100);
4189  memset(src_str, 0x00, 10000);
4190  memset(key_str, 0x00, 10000);
4191  memset(hash_str, 0x00, 10000);
4192  memset(output, 0x00, 100);
4193 
4194  strncpy( (char *) md_name, "sha512", 100 );
4195  md_info = md_info_from_string( md_name );
4196  fct_chk( md_info != NULL );
4197 
4198  key_len = unhexify( key_str, "4803d311394600dc1e0d8fc8cedeb8bde3fe7c42" );
4199  src_len = unhexify( src_str, "a10c125dd702a97153ad923ba5e9889cfac1ba169de370debe51f233735aa6effcc9785c4b5c7e48c477dc5c411ae6a959118584e26adc94b42c2b29b046f3cf01c65b24a24bd2e620bdf650a23bb4a72655b1100d7ce9a4dab697c6379754b4396c825de4b9eb73f2e6a6c0d0353bbdeaf706612800e137b858fdb30f3311c6" );
4200 
4201  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4202  hexify( hash_str, output, md_get_size(md_info) );
4203 
4204  fct_chk( strncmp( (char *) hash_str, "7cd8236c55102e6385f52279506df6fcc388ab75092da21395ce14a82b202ffa", 32 * 2 ) == 0 );
4205  }
4206  FCT_TEST_END();
4207 #endif /* POLARSSL_SHA4_C */
4208 
4209 #ifdef POLARSSL_SHA4_C
4210 
4211  FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_4)
4212  {
4213  char md_name[100];
4214  unsigned char src_str[10000];
4215  unsigned char key_str[10000];
4216  unsigned char hash_str[10000];
4217  unsigned char output[100];
4218  int key_len, src_len;
4219  const md_info_t *md_info = NULL;
4220 
4221  memset(md_name, 0x00, 100);
4222  memset(src_str, 0x00, 10000);
4223  memset(key_str, 0x00, 10000);
4224  memset(hash_str, 0x00, 10000);
4225  memset(output, 0x00, 100);
4226 
4227  strncpy( (char *) md_name, "sha512", 100 );
4228  md_info = md_info_from_string( md_name );
4229  fct_chk( md_info != NULL );
4230 
4231  key_len = unhexify( key_str, "aeb2f3b977fa6c8e71e07c5a5c74ff58166de092" );
4232  src_len = unhexify( src_str, "22457355dc76095abd46846b41cfe49a06ce42ac8857b4702fc771508dfb3626e0bfe851df897a07b36811ec433766e4b4166c26301b3493e7440d4554b0ef6ac20f1a530e58fac8aeba4e9ff2d4898d8a28783b49cd269c2965fd7f8e4f2d60cf1e5284f2495145b72382aad90e153a90ecae125ad75336fb128825c23fb8b0" );
4233 
4234  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4235  hexify( hash_str, output, md_get_size(md_info) );
4236 
4237  fct_chk( strncmp( (char *) hash_str, "fa39bd8fcc3bfa218f9dea5d3b2ce10a7619e31678a56d8a9d927b1fe703b125af445debe9a89a07db6194d27b44d85a", 48 * 2 ) == 0 );
4238  }
4239  FCT_TEST_END();
4240 #endif /* POLARSSL_SHA4_C */
4241 
4242 #ifdef POLARSSL_SHA4_C
4243 
4244  FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_5)
4245  {
4246  char md_name[100];
4247  unsigned char src_str[10000];
4248  unsigned char key_str[10000];
4249  unsigned char hash_str[10000];
4250  unsigned char output[100];
4251  int key_len, src_len;
4252  const md_info_t *md_info = NULL;
4253 
4254  memset(md_name, 0x00, 100);
4255  memset(src_str, 0x00, 10000);
4256  memset(key_str, 0x00, 10000);
4257  memset(hash_str, 0x00, 10000);
4258  memset(output, 0x00, 100);
4259 
4260  strncpy( (char *) md_name, "sha512", 100 );
4261  md_info = md_info_from_string( md_name );
4262  fct_chk( md_info != NULL );
4263 
4264  key_len = unhexify( key_str, "4285d3d7744da52775bb44ca436a3154f7980309" );
4265  src_len = unhexify( src_str, "208f0b6f2de2e5aa5df11927ddc6df485edc1193181c484d0f0a434a95418803101d4de9fdb798f93516a6916fa38a8207de1666fe50fe3441c03b112eaaae6954ed063f7ac4e3c1e3f73b20d153fe9e4857f5e91430f0a70ee820529adac2467469fd18adf10e2af0fea27c0abc83c5a9af77c364a466cffce8bab4e2b70bc1" );
4266 
4267  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4268  hexify( hash_str, output, md_get_size(md_info) );
4269 
4270  fct_chk( strncmp( (char *) hash_str, "fe7603f205b2774fe0f14ecfa3e338e90608a806d11ca459dff5ce36b1b264ecd3af5f0492a7521d8da3102ba20927a5", 48 * 2 ) == 0 );
4271  }
4272  FCT_TEST_END();
4273 #endif /* POLARSSL_SHA4_C */
4274 
4275 #ifdef POLARSSL_SHA4_C
4276 
4277  FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_6)
4278  {
4279  char md_name[100];
4280  unsigned char src_str[10000];
4281  unsigned char key_str[10000];
4282  unsigned char hash_str[10000];
4283  unsigned char output[100];
4284  int key_len, src_len;
4285  const md_info_t *md_info = NULL;
4286 
4287  memset(md_name, 0x00, 100);
4288  memset(src_str, 0x00, 10000);
4289  memset(key_str, 0x00, 10000);
4290  memset(hash_str, 0x00, 10000);
4291  memset(output, 0x00, 100);
4292 
4293  strncpy( (char *) md_name, "sha512", 100 );
4294  md_info = md_info_from_string( md_name );
4295  fct_chk( md_info != NULL );
4296 
4297  key_len = unhexify( key_str, "8ab783d5acf32efa0d9c0a21abce955e96630d89" );
4298  src_len = unhexify( src_str, "17371e013dce839963d54418e97be4bd9fa3cb2a368a5220f5aa1b8aaddfa3bdefc91afe7c717244fd2fb640f5cb9d9bf3e25f7f0c8bc758883b89dcdce6d749d9672fed222277ece3e84b3ec01b96f70c125fcb3cbee6d19b8ef0873f915f173bdb05d81629ba187cc8ac1934b2f75952fb7616ae6bd812946df694bd2763af" );
4299 
4300  fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
4301  hexify( hash_str, output, md_get_size(md_info) );
4302 
4303  fct_chk( strncmp( (char *) hash_str, "9ac7ca8d1aefc166b046e4cf7602ebe181a0e5055474bff5b342106731da0d7e48e4d87bc0a6f05871574289a1b099f8", 48 * 2 ) == 0 );
4304  }
4305  FCT_TEST_END();
4306 #endif /* POLARSSL_SHA4_C */
4307 
4308 #ifdef POLARSSL_SHA1_C
4309 
4310  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_1)
4311  {
4312  char md_name[100];
4313  unsigned char src_str[10000];
4314  unsigned char key_str[10000];
4315  unsigned char hash_str[10000];
4316  unsigned char output[100];
4317  int key_len, src_len;
4318  const md_info_t *md_info = NULL;
4320 
4321  memset(md_name, 0x00, 100);
4322  memset(src_str, 0x00, 10000);
4323  memset(key_str, 0x00, 10000);
4324  memset(hash_str, 0x00, 10000);
4325  memset(output, 0x00, 100);
4326 
4327  strncpy( (char *) md_name, "sha1", 100 );
4328  md_info = md_info_from_string( md_name );
4329  fct_chk( md_info != NULL );
4330  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4331 
4332  key_len = unhexify( key_str, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" );
4333  src_len = unhexify( src_str, "53616d706c65202331" );
4334 
4335  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4336  fct_chk ( ctx.md_ctx != NULL );
4337  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4338  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4339  fct_chk ( 0 == md_free_ctx( &ctx ) );
4340 
4341  hexify( hash_str, output, md_get_size(md_info) );
4342 
4343  fct_chk( strncmp( (char *) hash_str, "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", 20 * 2 ) == 0 );
4344  }
4345  FCT_TEST_END();
4346 #endif /* POLARSSL_SHA1_C */
4347 
4348 #ifdef POLARSSL_SHA1_C
4349 
4350  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_2)
4351  {
4352  char md_name[100];
4353  unsigned char src_str[10000];
4354  unsigned char key_str[10000];
4355  unsigned char hash_str[10000];
4356  unsigned char output[100];
4357  int key_len, src_len;
4358  const md_info_t *md_info = NULL;
4360 
4361  memset(md_name, 0x00, 100);
4362  memset(src_str, 0x00, 10000);
4363  memset(key_str, 0x00, 10000);
4364  memset(hash_str, 0x00, 10000);
4365  memset(output, 0x00, 100);
4366 
4367  strncpy( (char *) md_name, "sha1", 100 );
4368  md_info = md_info_from_string( md_name );
4369  fct_chk( md_info != NULL );
4370  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4371 
4372  key_len = unhexify( key_str, "303132333435363738393a3b3c3d3e3f40414243" );
4373  src_len = unhexify( src_str, "53616d706c65202332" );
4374 
4375  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4376  fct_chk ( ctx.md_ctx != NULL );
4377  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4378  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4379  fct_chk ( 0 == md_free_ctx( &ctx ) );
4380 
4381  hexify( hash_str, output, md_get_size(md_info) );
4382 
4383  fct_chk( strncmp( (char *) hash_str, "0922d3405faa3d194f82a45830737d5cc6c75d24", 20 * 2 ) == 0 );
4384  }
4385  FCT_TEST_END();
4386 #endif /* POLARSSL_SHA1_C */
4387 
4388 #ifdef POLARSSL_SHA1_C
4389 
4390  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_3)
4391  {
4392  char md_name[100];
4393  unsigned char src_str[10000];
4394  unsigned char key_str[10000];
4395  unsigned char hash_str[10000];
4396  unsigned char output[100];
4397  int key_len, src_len;
4398  const md_info_t *md_info = NULL;
4400 
4401  memset(md_name, 0x00, 100);
4402  memset(src_str, 0x00, 10000);
4403  memset(key_str, 0x00, 10000);
4404  memset(hash_str, 0x00, 10000);
4405  memset(output, 0x00, 100);
4406 
4407  strncpy( (char *) md_name, "sha1", 100 );
4408  md_info = md_info_from_string( md_name );
4409  fct_chk( md_info != NULL );
4410  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4411 
4412  key_len = unhexify( key_str, "505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" );
4413  src_len = unhexify( src_str, "53616d706c65202333" );
4414 
4415  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4416  fct_chk ( ctx.md_ctx != NULL );
4417  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4418  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4419  fct_chk ( 0 == md_free_ctx( &ctx ) );
4420 
4421  hexify( hash_str, output, md_get_size(md_info) );
4422 
4423  fct_chk( strncmp( (char *) hash_str, "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", 20 * 2 ) == 0 );
4424  }
4425  FCT_TEST_END();
4426 #endif /* POLARSSL_SHA1_C */
4427 
4428 #ifdef POLARSSL_SHA1_C
4429 
4430  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_4)
4431  {
4432  char md_name[100];
4433  unsigned char src_str[10000];
4434  unsigned char key_str[10000];
4435  unsigned char hash_str[10000];
4436  unsigned char output[100];
4437  int key_len, src_len;
4438  const md_info_t *md_info = NULL;
4440 
4441  memset(md_name, 0x00, 100);
4442  memset(src_str, 0x00, 10000);
4443  memset(key_str, 0x00, 10000);
4444  memset(hash_str, 0x00, 10000);
4445  memset(output, 0x00, 100);
4446 
4447  strncpy( (char *) md_name, "sha1", 100 );
4448  md_info = md_info_from_string( md_name );
4449  fct_chk( md_info != NULL );
4450  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4451 
4452  key_len = unhexify( key_str, "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0" );
4453  src_len = unhexify( src_str, "53616d706c65202334" );
4454 
4455  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4456  fct_chk ( ctx.md_ctx != NULL );
4457  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4458  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4459  fct_chk ( 0 == md_free_ctx( &ctx ) );
4460 
4461  hexify( hash_str, output, md_get_size(md_info) );
4462 
4463  fct_chk( strncmp( (char *) hash_str, "9ea886efe268dbecce420c75", 12 * 2 ) == 0 );
4464  }
4465  FCT_TEST_END();
4466 #endif /* POLARSSL_SHA1_C */
4467 
4468 #ifdef POLARSSL_SHA1_C
4469 
4470  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_1)
4471  {
4472  char md_name[100];
4473  unsigned char src_str[10000];
4474  unsigned char key_str[10000];
4475  unsigned char hash_str[10000];
4476  unsigned char output[100];
4477  int key_len, src_len;
4478  const md_info_t *md_info = NULL;
4480 
4481  memset(md_name, 0x00, 100);
4482  memset(src_str, 0x00, 10000);
4483  memset(key_str, 0x00, 10000);
4484  memset(hash_str, 0x00, 10000);
4485  memset(output, 0x00, 100);
4486 
4487  strncpy( (char *) md_name, "sha1", 100 );
4488  md_info = md_info_from_string( md_name );
4489  fct_chk( md_info != NULL );
4490  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4491 
4492  key_len = unhexify( key_str, "7b10f4124b15c82e" );
4493  src_len = unhexify( src_str, "27dcb5b1daf60cfd3e2f73d4d64ca9c684f8bf71fc682a46793b1790afa4feb100ca7aaff26f58f0e1d0ed42f1cdad1f474afa2e79d53a0c42892c4d7b327cbe46b295ed8da3b6ecab3d4851687a6f812b79df2f6b20f11f6706f5301790ca99625aad7391d84f78043d2a0a239b1477984c157bbc9276064e7a1a406b0612ca" );
4494 
4495  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4496  fct_chk ( ctx.md_ctx != NULL );
4497  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4498  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4499  fct_chk ( 0 == md_free_ctx( &ctx ) );
4500 
4501  hexify( hash_str, output, md_get_size(md_info) );
4502 
4503  fct_chk( strncmp( (char *) hash_str, "4ead12c2fe3d6ea43acb", 10 * 2 ) == 0 );
4504  }
4505  FCT_TEST_END();
4506 #endif /* POLARSSL_SHA1_C */
4507 
4508 #ifdef POLARSSL_SHA1_C
4509 
4510  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_2)
4511  {
4512  char md_name[100];
4513  unsigned char src_str[10000];
4514  unsigned char key_str[10000];
4515  unsigned char hash_str[10000];
4516  unsigned char output[100];
4517  int key_len, src_len;
4518  const md_info_t *md_info = NULL;
4520 
4521  memset(md_name, 0x00, 100);
4522  memset(src_str, 0x00, 10000);
4523  memset(key_str, 0x00, 10000);
4524  memset(hash_str, 0x00, 10000);
4525  memset(output, 0x00, 100);
4526 
4527  strncpy( (char *) md_name, "sha1", 100 );
4528  md_info = md_info_from_string( md_name );
4529  fct_chk( md_info != NULL );
4530  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4531 
4532  key_len = unhexify( key_str, "4fe9fb902172a21b" );
4533  src_len = unhexify( src_str, "4ceb3a7c13659c22fe51134f03dce4c239d181b63c6b0b59d367157fd05cab98384f92dfa482d2d5e78e72eef1b1838af4696026c54233d484ecbbe87f904df5546419f8567eafd232e6c2fcd3ee2b7682c63000524b078dbb2096f585007deae752562df1fe3b01278089e16f3be46e2d0f7cabac2d8e6cc02a2d0ca953425f" );
4534 
4535  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4536  fct_chk ( ctx.md_ctx != NULL );
4537  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4538  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4539  fct_chk ( 0 == md_free_ctx( &ctx ) );
4540 
4541  hexify( hash_str, output, md_get_size(md_info) );
4542 
4543  fct_chk( strncmp( (char *) hash_str, "564428a67be1924b5793", 10 * 2 ) == 0 );
4544  }
4545  FCT_TEST_END();
4546 #endif /* POLARSSL_SHA1_C */
4547 
4548 #ifdef POLARSSL_SHA1_C
4549 
4550  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_3)
4551  {
4552  char md_name[100];
4553  unsigned char src_str[10000];
4554  unsigned char key_str[10000];
4555  unsigned char hash_str[10000];
4556  unsigned char output[100];
4557  int key_len, src_len;
4558  const md_info_t *md_info = NULL;
4560 
4561  memset(md_name, 0x00, 100);
4562  memset(src_str, 0x00, 10000);
4563  memset(key_str, 0x00, 10000);
4564  memset(hash_str, 0x00, 10000);
4565  memset(output, 0x00, 100);
4566 
4567  strncpy( (char *) md_name, "sha1", 100 );
4568  md_info = md_info_from_string( md_name );
4569  fct_chk( md_info != NULL );
4570  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4571 
4572  key_len = unhexify( key_str, "d1f01455f78c4fb4" );
4573  src_len = unhexify( src_str, "00d40f67b57914bec456a3e3201ef1464be319a8d188c02e157af4b54f9b5a66d67f898a9bdbb19ff63a80aba6f246d013575721d52eb1b47a65def884011c49b257bcc2817fc853f106e8138ce386d7a5ac3103de0a3fa0ed6bb7af9ff66ebd1cc46fb86e4da0013d20a3c2dcd8fb828a4b70f7f104b41bf3f44682a66497ea" );
4574 
4575  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4576  fct_chk ( ctx.md_ctx != NULL );
4577  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4578  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4579  fct_chk ( 0 == md_free_ctx( &ctx ) );
4580 
4581  hexify( hash_str, output, md_get_size(md_info) );
4582 
4583  fct_chk( strncmp( (char *) hash_str, "56a665a7cdfe610f9fc5", 10 * 2 ) == 0 );
4584  }
4585  FCT_TEST_END();
4586 #endif /* POLARSSL_SHA1_C */
4587 
4588 #ifdef POLARSSL_SHA1_C
4589 
4590  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_4)
4591  {
4592  char md_name[100];
4593  unsigned char src_str[10000];
4594  unsigned char key_str[10000];
4595  unsigned char hash_str[10000];
4596  unsigned char output[100];
4597  int key_len, src_len;
4598  const md_info_t *md_info = NULL;
4600 
4601  memset(md_name, 0x00, 100);
4602  memset(src_str, 0x00, 10000);
4603  memset(key_str, 0x00, 10000);
4604  memset(hash_str, 0x00, 10000);
4605  memset(output, 0x00, 100);
4606 
4607  strncpy( (char *) md_name, "sha1", 100 );
4608  md_info = md_info_from_string( md_name );
4609  fct_chk( md_info != NULL );
4610  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4611 
4612  key_len = unhexify( key_str, "4e5ef77fdf033a5b" );
4613  src_len = unhexify( src_str, "e59326464e3201d195e29f2a3446ec1b1c9ff31154e2a4d0e40ed466f1bc855d29f76835624fa0127d29c9b1915939a046f385af7e5d47a23ba91f28bd22f811ea258dbbf3332bcd3543b8285d5df41bd064ffd64a341c22c4edb44f9c8d9e6df0c59dbf4a052a6c83da7478e179a6f3839c6870ff8ca8b9497f9ac1d725fdda" );
4614 
4615  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4616  fct_chk ( ctx.md_ctx != NULL );
4617  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4618  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4619  fct_chk ( 0 == md_free_ctx( &ctx ) );
4620 
4621  hexify( hash_str, output, md_get_size(md_info) );
4622 
4623  fct_chk( strncmp( (char *) hash_str, "981c0a7a8423b63a8fa6", 10 * 2 ) == 0 );
4624  }
4625  FCT_TEST_END();
4626 #endif /* POLARSSL_SHA1_C */
4627 
4628 #ifdef POLARSSL_SHA1_C
4629 
4630  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_5)
4631  {
4632  char md_name[100];
4633  unsigned char src_str[10000];
4634  unsigned char key_str[10000];
4635  unsigned char hash_str[10000];
4636  unsigned char output[100];
4637  int key_len, src_len;
4638  const md_info_t *md_info = NULL;
4640 
4641  memset(md_name, 0x00, 100);
4642  memset(src_str, 0x00, 10000);
4643  memset(key_str, 0x00, 10000);
4644  memset(hash_str, 0x00, 10000);
4645  memset(output, 0x00, 100);
4646 
4647  strncpy( (char *) md_name, "sha1", 100 );
4648  md_info = md_info_from_string( md_name );
4649  fct_chk( md_info != NULL );
4650  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4651 
4652  key_len = unhexify( key_str, "bcd9ff8aa60be2be" );
4653  src_len = unhexify( src_str, "51be4d0eb37bab714f92e19e9d70390655b363e8cd346a748245e731f437759cb8206412c8dab2ef1d4f36f880f41ff69d949da4594fdecb65e23cac1329b59e69e29bf875b38c31df6fa546c595f35cc2192aa750679a8a51a65e00e839d73a8d8c598a610d237fbe78955213589d80efcb73b95b8586f96d17b6f51a71c3b8" );
4654 
4655  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4656  fct_chk ( ctx.md_ctx != NULL );
4657  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4658  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4659  fct_chk ( 0 == md_free_ctx( &ctx ) );
4660 
4661  hexify( hash_str, output, md_get_size(md_info) );
4662 
4663  fct_chk( strncmp( (char *) hash_str, "84633f9f5040c8971478", 10 * 2 ) == 0 );
4664  }
4665  FCT_TEST_END();
4666 #endif /* POLARSSL_SHA1_C */
4667 
4668 #ifdef POLARSSL_SHA1_C
4669 
4670  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_6)
4671  {
4672  char md_name[100];
4673  unsigned char src_str[10000];
4674  unsigned char key_str[10000];
4675  unsigned char hash_str[10000];
4676  unsigned char output[100];
4677  int key_len, src_len;
4678  const md_info_t *md_info = NULL;
4680 
4681  memset(md_name, 0x00, 100);
4682  memset(src_str, 0x00, 10000);
4683  memset(key_str, 0x00, 10000);
4684  memset(hash_str, 0x00, 10000);
4685  memset(output, 0x00, 100);
4686 
4687  strncpy( (char *) md_name, "sha1", 100 );
4688  md_info = md_info_from_string( md_name );
4689  fct_chk( md_info != NULL );
4690  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4691 
4692  key_len = unhexify( key_str, "4a661bce6ed86d21" );
4693  src_len = unhexify( src_str, "5ff6c744f1aab1bc29697d71f67541b8b3cec3c7079183b10a83fb98a9ee251d4bac3e1cb581ca972aaed8efd7c2875a6fb4c991132f67c9742d45e53bc7e8eaa94b35b37a907be61086b426cd11088ac118934e85d968c9667fd69fc6f6ea38c0fe34710b7ece91211b9b7ea00acd31f022aa6726368f9928a1352f122233f1" );
4694 
4695  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4696  fct_chk ( ctx.md_ctx != NULL );
4697  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4698  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4699  fct_chk ( 0 == md_free_ctx( &ctx ) );
4700 
4701  hexify( hash_str, output, md_get_size(md_info) );
4702 
4703  fct_chk( strncmp( (char *) hash_str, "739df59353ac6694e55e", 10 * 2 ) == 0 );
4704  }
4705  FCT_TEST_END();
4706 #endif /* POLARSSL_SHA1_C */
4707 
4708 #ifdef POLARSSL_SHA1_C
4709 
4710  FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_7)
4711  {
4712  char md_name[100];
4713  unsigned char src_str[10000];
4714  unsigned char key_str[10000];
4715  unsigned char hash_str[10000];
4716  unsigned char output[100];
4717  int key_len, src_len;
4718  const md_info_t *md_info = NULL;
4720 
4721  memset(md_name, 0x00, 100);
4722  memset(src_str, 0x00, 10000);
4723  memset(key_str, 0x00, 10000);
4724  memset(hash_str, 0x00, 10000);
4725  memset(output, 0x00, 100);
4726 
4727  strncpy( (char *) md_name, "sha1", 100 );
4728  md_info = md_info_from_string( md_name );
4729  fct_chk( md_info != NULL );
4730  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4731 
4732  key_len = unhexify( key_str, "1287e1565a57b547" );
4733  src_len = unhexify( src_str, "390ffdccc6171c11568d85b8f913e019bf4cd982ca9cd21ea730d41bdf3fcc0bc88ff48ba13a8f23deb2d96ec1033e7b2a58ca72b0c1e17bf03330db25d1e360fa6918009c4294bd1215b5ccd159a8f58bc3dc3d490eb7c3b9f887e8c98dbbb274a75373dcb695a59abd0219529d88518a96f92abc0bbcbda985c388f1fbbcc9" );
4734 
4735  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4736  fct_chk ( ctx.md_ctx != NULL );
4737  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4738  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4739  fct_chk ( 0 == md_free_ctx( &ctx ) );
4740 
4741  hexify( hash_str, output, md_get_size(md_info) );
4742 
4743  fct_chk( strncmp( (char *) hash_str, "d78ddf08077c7d9e2ba6", 10 * 2 ) == 0 );
4744  }
4745  FCT_TEST_END();
4746 #endif /* POLARSSL_SHA1_C */
4747 
4748 #ifdef POLARSSL_SHA2_C
4749 
4750  FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_1)
4751  {
4752  char md_name[100];
4753  unsigned char src_str[10000];
4754  unsigned char key_str[10000];
4755  unsigned char hash_str[10000];
4756  unsigned char output[100];
4757  int key_len, src_len;
4758  const md_info_t *md_info = NULL;
4760 
4761  memset(md_name, 0x00, 100);
4762  memset(src_str, 0x00, 10000);
4763  memset(key_str, 0x00, 10000);
4764  memset(hash_str, 0x00, 10000);
4765  memset(output, 0x00, 100);
4766 
4767  strncpy( (char *) md_name, "sha224", 100 );
4768  md_info = md_info_from_string( md_name );
4769  fct_chk( md_info != NULL );
4770  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4771 
4772  key_len = unhexify( key_str, "e055eb756697ee573fd3214811a9f7fa" );
4773  src_len = unhexify( src_str, "3875847012ee42fe54a0027bdf38cca7021b83a2ed0503af69ef6c37c637bc1114fba40096c5947d736e19b7af3c68d95a4e3b8b073adbbb80f47e9db8f2d4f0018ddd847fabfdf9dd9b52c93e40458977725f6b7ba15f0816bb895cdf50401268f5d702b7e6a5f9faef57b8768c8a3fc14f9a4b3182b41d940e337d219b29ff" );
4774 
4775  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4776  fct_chk ( ctx.md_ctx != NULL );
4777  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4778  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4779  fct_chk ( 0 == md_free_ctx( &ctx ) );
4780 
4781  hexify( hash_str, output, md_get_size(md_info) );
4782 
4783  fct_chk( strncmp( (char *) hash_str, "40a453133361cc48da11baf616ee", 14 * 2 ) == 0 );
4784  }
4785  FCT_TEST_END();
4786 #endif /* POLARSSL_SHA2_C */
4787 
4788 #ifdef POLARSSL_SHA2_C
4789 
4790  FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_2)
4791  {
4792  char md_name[100];
4793  unsigned char src_str[10000];
4794  unsigned char key_str[10000];
4795  unsigned char hash_str[10000];
4796  unsigned char output[100];
4797  int key_len, src_len;
4798  const md_info_t *md_info = NULL;
4800 
4801  memset(md_name, 0x00, 100);
4802  memset(src_str, 0x00, 10000);
4803  memset(key_str, 0x00, 10000);
4804  memset(hash_str, 0x00, 10000);
4805  memset(output, 0x00, 100);
4806 
4807  strncpy( (char *) md_name, "sha224", 100 );
4808  md_info = md_info_from_string( md_name );
4809  fct_chk( md_info != NULL );
4810  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4811 
4812  key_len = unhexify( key_str, "88e5258b55b1623385eb9632fa7c57d6" );
4813  src_len = unhexify( src_str, "ada76bb604be14326551701cf30e48a65eee80b44f0b9d4a07b1844543b7844a621097fdc99de57387458ae9354899b620d0617eabcaefa9eef3d413a33628054335ce656c26fa2986e0f111a6351096b283101ec7868871d770b370973c7405983f9756b3005a3eab492cfd0e7eb42e5c2e15fa6be8718c0a50acc4e5717230" );
4814 
4815  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4816  fct_chk ( ctx.md_ctx != NULL );
4817  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4818  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4819  fct_chk ( 0 == md_free_ctx( &ctx ) );
4820 
4821  hexify( hash_str, output, md_get_size(md_info) );
4822 
4823  fct_chk( strncmp( (char *) hash_str, "81c783af538015cef3c60095df53", 14 * 2 ) == 0 );
4824  }
4825  FCT_TEST_END();
4826 #endif /* POLARSSL_SHA2_C */
4827 
4828 #ifdef POLARSSL_SHA2_C
4829 
4830  FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_3)
4831  {
4832  char md_name[100];
4833  unsigned char src_str[10000];
4834  unsigned char key_str[10000];
4835  unsigned char hash_str[10000];
4836  unsigned char output[100];
4837  int key_len, src_len;
4838  const md_info_t *md_info = NULL;
4840 
4841  memset(md_name, 0x00, 100);
4842  memset(src_str, 0x00, 10000);
4843  memset(key_str, 0x00, 10000);
4844  memset(hash_str, 0x00, 10000);
4845  memset(output, 0x00, 100);
4846 
4847  strncpy( (char *) md_name, "sha224", 100 );
4848  md_info = md_info_from_string( md_name );
4849  fct_chk( md_info != NULL );
4850  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4851 
4852  key_len = unhexify( key_str, "85d402d822114d31abf75526e2538705" );
4853  src_len = unhexify( src_str, "8020d8d98cc2e2298b32879c51c751e1dd5558fe2eabb8f158604297d6d072ce2261a1d6830b7cfe2617b57c7126f99c9476211d6161acd75d266da217ec8174b80484c9dc6f0448a0a036a3fc82e8bf54bdb71549368258d5d41f57978a4c266b92e8783ef66350215573d99be4089144b383ad8f3222bae8f3bf80ffb1bb2b" );
4854 
4855  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4856  fct_chk ( ctx.md_ctx != NULL );
4857  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4858  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4859  fct_chk ( 0 == md_free_ctx( &ctx ) );
4860 
4861  hexify( hash_str, output, md_get_size(md_info) );
4862 
4863  fct_chk( strncmp( (char *) hash_str, "2aa0340ac9deafe3be38129daca0", 14 * 2 ) == 0 );
4864  }
4865  FCT_TEST_END();
4866 #endif /* POLARSSL_SHA2_C */
4867 
4868 #ifdef POLARSSL_SHA2_C
4869 
4870  FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_4)
4871  {
4872  char md_name[100];
4873  unsigned char src_str[10000];
4874  unsigned char key_str[10000];
4875  unsigned char hash_str[10000];
4876  unsigned char output[100];
4877  int key_len, src_len;
4878  const md_info_t *md_info = NULL;
4880 
4881  memset(md_name, 0x00, 100);
4882  memset(src_str, 0x00, 10000);
4883  memset(key_str, 0x00, 10000);
4884  memset(hash_str, 0x00, 10000);
4885  memset(output, 0x00, 100);
4886 
4887  strncpy( (char *) md_name, "sha224", 100 );
4888  md_info = md_info_from_string( md_name );
4889  fct_chk( md_info != NULL );
4890  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4891 
4892  key_len = unhexify( key_str, "545c6eecc5ee46fa17c59f91a94f81ae" );
4893  src_len = unhexify( src_str, "8fb7f3565593170152ddb2021874784e951977cfdd22f8b72a72a61320a8f2a35697b5e913f717805559b1af1861ee3ed42fb788481e4fd276b17bdbefcae7b4501dc5d20de5b7626dd5efdcd65294db4bdf682c33d9a9255c6435383fa5f1c886326a3acbc6bd50a33ab5b2dbb034ce0112d4e226bbcd57e3731a519aa1d784" );
4894 
4895  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4896  fct_chk ( ctx.md_ctx != NULL );
4897  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4898  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4899  fct_chk ( 0 == md_free_ctx( &ctx ) );
4900 
4901  hexify( hash_str, output, md_get_size(md_info) );
4902 
4903  fct_chk( strncmp( (char *) hash_str, "3eb566eac54c4a3a9ef092469f24", 14 * 2 ) == 0 );
4904  }
4905  FCT_TEST_END();
4906 #endif /* POLARSSL_SHA2_C */
4907 
4908 #ifdef POLARSSL_SHA2_C
4909 
4910  FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_5)
4911  {
4912  char md_name[100];
4913  unsigned char src_str[10000];
4914  unsigned char key_str[10000];
4915  unsigned char hash_str[10000];
4916  unsigned char output[100];
4917  int key_len, src_len;
4918  const md_info_t *md_info = NULL;
4920 
4921  memset(md_name, 0x00, 100);
4922  memset(src_str, 0x00, 10000);
4923  memset(key_str, 0x00, 10000);
4924  memset(hash_str, 0x00, 10000);
4925  memset(output, 0x00, 100);
4926 
4927  strncpy( (char *) md_name, "sha224", 100 );
4928  md_info = md_info_from_string( md_name );
4929  fct_chk( md_info != NULL );
4930  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4931 
4932  key_len = unhexify( key_str, "4466ab4dc438841a9750c7f173dff02e" );
4933  src_len = unhexify( src_str, "2534c11c78c99cffaec8f722f04adc7045c7324d58ce98e37cfa94b6ed21ed7f58ce55379ef24b72d6d640ee9154f96c614734be9c408e225d7ba4cecc1179cc9f6e1808e1067aa8f244a99bd0c3267594c1887a40d167f8b7cf78db0d19f97b01fc50b8c86def490dfa7a5135002c33e71d77a8cce8ea0f93e0580439a33733" );
4934 
4935  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4936  fct_chk ( ctx.md_ctx != NULL );
4937  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4938  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4939  fct_chk ( 0 == md_free_ctx( &ctx ) );
4940 
4941  hexify( hash_str, output, md_get_size(md_info) );
4942 
4943  fct_chk( strncmp( (char *) hash_str, "59f44a9bbed4875b892d22d6b5ab", 14 * 2 ) == 0 );
4944  }
4945  FCT_TEST_END();
4946 #endif /* POLARSSL_SHA2_C */
4947 
4948 #ifdef POLARSSL_SHA2_C
4949 
4950  FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_6)
4951  {
4952  char md_name[100];
4953  unsigned char src_str[10000];
4954  unsigned char key_str[10000];
4955  unsigned char hash_str[10000];
4956  unsigned char output[100];
4957  int key_len, src_len;
4958  const md_info_t *md_info = NULL;
4960 
4961  memset(md_name, 0x00, 100);
4962  memset(src_str, 0x00, 10000);
4963  memset(key_str, 0x00, 10000);
4964  memset(hash_str, 0x00, 10000);
4965  memset(output, 0x00, 100);
4966 
4967  strncpy( (char *) md_name, "sha224", 100 );
4968  md_info = md_info_from_string( md_name );
4969  fct_chk( md_info != NULL );
4970  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
4971 
4972  key_len = unhexify( key_str, "0e3dd9bb5e4cf0f09a4c11600af56d8d" );
4973  src_len = unhexify( src_str, "f4589fa76c328ea25cf8bae582026ba40a59d45a546ff31cf80eb826088f69bb954c452c74586836416dee90a5255bc5d56d3b405b3705a5197045688b32fa984c3a3dfbdc9c2460a0b5e6312a624048bb6f170306535e9b371a3ab134a2642a230ad03d2c688cca80baeaee9a20e1d4c548b1cede29c6a45bf4df2c8c476f1a" );
4974 
4975  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
4976  fct_chk ( ctx.md_ctx != NULL );
4977  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
4978  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
4979  fct_chk ( 0 == md_free_ctx( &ctx ) );
4980 
4981  hexify( hash_str, output, md_get_size(md_info) );
4982 
4983  fct_chk( strncmp( (char *) hash_str, "12175b93e3da4c58217145e4dc0a1cf142fab9319bb501e037b350ba", 28 * 2 ) == 0 );
4984  }
4985  FCT_TEST_END();
4986 #endif /* POLARSSL_SHA2_C */
4987 
4988 #ifdef POLARSSL_SHA2_C
4989 
4990  FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_7)
4991  {
4992  char md_name[100];
4993  unsigned char src_str[10000];
4994  unsigned char key_str[10000];
4995  unsigned char hash_str[10000];
4996  unsigned char output[100];
4997  int key_len, src_len;
4998  const md_info_t *md_info = NULL;
5000 
5001  memset(md_name, 0x00, 100);
5002  memset(src_str, 0x00, 10000);
5003  memset(key_str, 0x00, 10000);
5004  memset(hash_str, 0x00, 10000);
5005  memset(output, 0x00, 100);
5006 
5007  strncpy( (char *) md_name, "sha224", 100 );
5008  md_info = md_info_from_string( md_name );
5009  fct_chk( md_info != NULL );
5010  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5011 
5012  key_len = unhexify( key_str, "cda5187b0c5dcb0f8e5a8beed2306584" );
5013  src_len = unhexify( src_str, "9011ae29b44c49b347487ce972965f16ade3c15be0856ce9c853a9739dba07e4f20d594ddc1dfe21560a65a4e458cfa17745575b915a30c7a9412ff8d1d689db9680dd2428c27588bb0dc92d2cd9445fe8f44b840a197c52c3c4333fff45533945134398df6436513cfab06c924046b8c795a5bd92e8d5f2de85bf306f2eed67" );
5014 
5015  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5016  fct_chk ( ctx.md_ctx != NULL );
5017  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5018  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5019  fct_chk ( 0 == md_free_ctx( &ctx ) );
5020 
5021  hexify( hash_str, output, md_get_size(md_info) );
5022 
5023  fct_chk( strncmp( (char *) hash_str, "4aaba92b40e2a600feab176eb9b292d814864195c03342aad6f67f08", 28 * 2 ) == 0 );
5024  }
5025  FCT_TEST_END();
5026 #endif /* POLARSSL_SHA2_C */
5027 
5028 #ifdef POLARSSL_SHA2_C
5029 
5030  FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_1)
5031  {
5032  char md_name[100];
5033  unsigned char src_str[10000];
5034  unsigned char key_str[10000];
5035  unsigned char hash_str[10000];
5036  unsigned char output[100];
5037  int key_len, src_len;
5038  const md_info_t *md_info = NULL;
5040 
5041  memset(md_name, 0x00, 100);
5042  memset(src_str, 0x00, 10000);
5043  memset(key_str, 0x00, 10000);
5044  memset(hash_str, 0x00, 10000);
5045  memset(output, 0x00, 100);
5046 
5047  strncpy( (char *) md_name, "sha256", 100 );
5048  md_info = md_info_from_string( md_name );
5049  fct_chk( md_info != NULL );
5050  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5051 
5052  key_len = unhexify( key_str, "cdffd34e6b16fdc0" );
5053  src_len = unhexify( src_str, "d83e78b99ab61709608972b36e76a575603db742269cc5dd4e7d5ca7816e26b65151c92632550cb4c5253c885d5fce53bc47459a1dbd5652786c4aac0145a532f12c05138af04cbb558101a7af5df478834c2146594dd73690d01a4fe72545894335f427ac70204798068cb86c5a600b40b414ede23590b41e1192373df84fe3" );
5054 
5055  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5056  fct_chk ( ctx.md_ctx != NULL );
5057  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5058  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5059  fct_chk ( 0 == md_free_ctx( &ctx ) );
5060 
5061  hexify( hash_str, output, md_get_size(md_info) );
5062 
5063  fct_chk( strncmp( (char *) hash_str, "c6f0dde266cb4a26d41e8259d33499cc", 16 * 2 ) == 0 );
5064  }
5065  FCT_TEST_END();
5066 #endif /* POLARSSL_SHA2_C */
5067 
5068 #ifdef POLARSSL_SHA2_C
5069 
5070  FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_2)
5071  {
5072  char md_name[100];
5073  unsigned char src_str[10000];
5074  unsigned char key_str[10000];
5075  unsigned char hash_str[10000];
5076  unsigned char output[100];
5077  int key_len, src_len;
5078  const md_info_t *md_info = NULL;
5080 
5081  memset(md_name, 0x00, 100);
5082  memset(src_str, 0x00, 10000);
5083  memset(key_str, 0x00, 10000);
5084  memset(hash_str, 0x00, 10000);
5085  memset(output, 0x00, 100);
5086 
5087  strncpy( (char *) md_name, "sha256", 100 );
5088  md_info = md_info_from_string( md_name );
5089  fct_chk( md_info != NULL );
5090  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5091 
5092  key_len = unhexify( key_str, "6d97bb5892245be2" );
5093  src_len = unhexify( src_str, "13c2b391d59c0252ca5d2302beaaf88c4bcd779bb505ad9a122003dfae4cc123ad2bd036f225c4f040021a6b9fb8bd6f0281cf2e2631a732bdc71693cc42ef6d52b6c6912a9ef77b3274eb85ad7f965ae6ed44ac1721962a884ec7acfb4534b1488b1c0c45afa4dae8da1eb7b0a88a3240365d7e4e7d826abbde9f9203fd99d7" );
5094 
5095  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5096  fct_chk ( ctx.md_ctx != NULL );
5097  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5098  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5099  fct_chk ( 0 == md_free_ctx( &ctx ) );
5100 
5101  hexify( hash_str, output, md_get_size(md_info) );
5102 
5103  fct_chk( strncmp( (char *) hash_str, "31588e241b015319a5ab8c4527296498", 16 * 2 ) == 0 );
5104  }
5105  FCT_TEST_END();
5106 #endif /* POLARSSL_SHA2_C */
5107 
5108 #ifdef POLARSSL_SHA2_C
5109 
5110  FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_3)
5111  {
5112  char md_name[100];
5113  unsigned char src_str[10000];
5114  unsigned char key_str[10000];
5115  unsigned char hash_str[10000];
5116  unsigned char output[100];
5117  int key_len, src_len;
5118  const md_info_t *md_info = NULL;
5120 
5121  memset(md_name, 0x00, 100);
5122  memset(src_str, 0x00, 10000);
5123  memset(key_str, 0x00, 10000);
5124  memset(hash_str, 0x00, 10000);
5125  memset(output, 0x00, 100);
5126 
5127  strncpy( (char *) md_name, "sha256", 100 );
5128  md_info = md_info_from_string( md_name );
5129  fct_chk( md_info != NULL );
5130  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5131 
5132  key_len = unhexify( key_str, "3c7fc8a70b49007a" );
5133  src_len = unhexify( src_str, "60024e428a39c8b8bb2e9591bad9dc2115dfbfd716b6eb7af30a6eb34560caccbbfa47b710fa8d523aca71e9e5ba10fc1feb1a43556d71f07ea4f33496f093044e8caf1d02b79e46eb1288d5964a7a7494f6b92574c35784eece054c6151281d80822f7d47b8231c35d07f5cb5cf4310ddc844845a01c6bfab514c048eccaf9f" );
5134 
5135  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5136  fct_chk ( ctx.md_ctx != NULL );
5137  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5138  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5139  fct_chk ( 0 == md_free_ctx( &ctx ) );
5140 
5141  hexify( hash_str, output, md_get_size(md_info) );
5142 
5143  fct_chk( strncmp( (char *) hash_str, "1c98c94a32bec9f253c21070f82f8438", 16 * 2 ) == 0 );
5144  }
5145  FCT_TEST_END();
5146 #endif /* POLARSSL_SHA2_C */
5147 
5148 #ifdef POLARSSL_SHA2_C
5149 
5150  FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_4)
5151  {
5152  char md_name[100];
5153  unsigned char src_str[10000];
5154  unsigned char key_str[10000];
5155  unsigned char hash_str[10000];
5156  unsigned char output[100];
5157  int key_len, src_len;
5158  const md_info_t *md_info = NULL;
5160 
5161  memset(md_name, 0x00, 100);
5162  memset(src_str, 0x00, 10000);
5163  memset(key_str, 0x00, 10000);
5164  memset(hash_str, 0x00, 10000);
5165  memset(output, 0x00, 100);
5166 
5167  strncpy( (char *) md_name, "sha256", 100 );
5168  md_info = md_info_from_string( md_name );
5169  fct_chk( md_info != NULL );
5170  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5171 
5172  key_len = unhexify( key_str, "369f33f85b927a07" );
5173  src_len = unhexify( src_str, "ae8e2a94ca386d448cbacdb0e9040ae3cb297c296363052cc157455da29a0c95897315fc11e3f12b81e2418da1ec280bccbc00e847584ce9d14deeba7b3c9b8dba958b04bba37551f6c9ba9c060be1a4b8cf43aa62e5078b76c6512c5619b71a6a7cf5727180e1ff14f5a1a3c1691bf8b6ebad365c151e58d749d57adb3a4986" );
5174 
5175  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5176  fct_chk ( ctx.md_ctx != NULL );
5177  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5178  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5179  fct_chk ( 0 == md_free_ctx( &ctx ) );
5180 
5181  hexify( hash_str, output, md_get_size(md_info) );
5182 
5183  fct_chk( strncmp( (char *) hash_str, "60b90383286533d309de46593e6ce39fc51fb00a8d88278c", 24 * 2 ) == 0 );
5184  }
5185  FCT_TEST_END();
5186 #endif /* POLARSSL_SHA2_C */
5187 
5188 #ifdef POLARSSL_SHA2_C
5189 
5190  FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_5)
5191  {
5192  char md_name[100];
5193  unsigned char src_str[10000];
5194  unsigned char key_str[10000];
5195  unsigned char hash_str[10000];
5196  unsigned char output[100];
5197  int key_len, src_len;
5198  const md_info_t *md_info = NULL;
5200 
5201  memset(md_name, 0x00, 100);
5202  memset(src_str, 0x00, 10000);
5203  memset(key_str, 0x00, 10000);
5204  memset(hash_str, 0x00, 10000);
5205  memset(output, 0x00, 100);
5206 
5207  strncpy( (char *) md_name, "sha256", 100 );
5208  md_info = md_info_from_string( md_name );
5209  fct_chk( md_info != NULL );
5210  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5211 
5212  key_len = unhexify( key_str, "e5179687582b4dc4" );
5213  src_len = unhexify( src_str, "ce103bdacdf32f614f6727bcb31ca1c2824a850d00f5585b016fb234fe1ef2cd687f302d3c6b738ed89a24060d65c36675d0d96307c72ef3e8a83bfa8402e226de9d5d1724ba75c4879bf41a4a465ce61887d9f49a34757849b48bae81c27ebed76faae2ad669bca04747d409148d40812776e0ae2c395b3cb9c89981ce72d5c" );
5214 
5215  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5216  fct_chk ( ctx.md_ctx != NULL );
5217  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5218  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5219  fct_chk ( 0 == md_free_ctx( &ctx ) );
5220 
5221  hexify( hash_str, output, md_get_size(md_info) );
5222 
5223  fct_chk( strncmp( (char *) hash_str, "509581f6816df4b8cc9f2cf42b7cc6e6a5a1e375a16f2412", 24 * 2 ) == 0 );
5224  }
5225  FCT_TEST_END();
5226 #endif /* POLARSSL_SHA2_C */
5227 
5228 #ifdef POLARSSL_SHA2_C
5229 
5230  FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_6)
5231  {
5232  char md_name[100];
5233  unsigned char src_str[10000];
5234  unsigned char key_str[10000];
5235  unsigned char hash_str[10000];
5236  unsigned char output[100];
5237  int key_len, src_len;
5238  const md_info_t *md_info = NULL;
5240 
5241  memset(md_name, 0x00, 100);
5242  memset(src_str, 0x00, 10000);
5243  memset(key_str, 0x00, 10000);
5244  memset(hash_str, 0x00, 10000);
5245  memset(output, 0x00, 100);
5246 
5247  strncpy( (char *) md_name, "sha256", 100 );
5248  md_info = md_info_from_string( md_name );
5249  fct_chk( md_info != NULL );
5250  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5251 
5252  key_len = unhexify( key_str, "63cec6246aeb1b61" );
5253  src_len = unhexify( src_str, "c178db908a405fa88aa255b8cad22b4057016585f139ee930388b083d86062fa0b3ea1f23f8a43bd11bee8464bcbd19b5ab9f6a8038d5245516f8274d20c8ee3033a07b908da528fa00343bb595deed500cab9745c4cb6391c23300f0d3584b090b3326c4cfa342620b78f9f5b4f27f7307ed770643ec1764aeae3dcf1a3ec69" );
5254 
5255  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5256  fct_chk ( ctx.md_ctx != NULL );
5257  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5258  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5259  fct_chk ( 0 == md_free_ctx( &ctx ) );
5260 
5261  hexify( hash_str, output, md_get_size(md_info) );
5262 
5263  fct_chk( strncmp( (char *) hash_str, "64f3dd861b7c7d29fce9ae0ce9ed954b5d7141806ee9eec7", 24 * 2 ) == 0 );
5264  }
5265  FCT_TEST_END();
5266 #endif /* POLARSSL_SHA2_C */
5267 
5268 #ifdef POLARSSL_SHA4_C
5269 
5270  FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_1)
5271  {
5272  char md_name[100];
5273  unsigned char src_str[10000];
5274  unsigned char key_str[10000];
5275  unsigned char hash_str[10000];
5276  unsigned char output[100];
5277  int key_len, src_len;
5278  const md_info_t *md_info = NULL;
5280 
5281  memset(md_name, 0x00, 100);
5282  memset(src_str, 0x00, 10000);
5283  memset(key_str, 0x00, 10000);
5284  memset(hash_str, 0x00, 10000);
5285  memset(output, 0x00, 100);
5286 
5287  strncpy( (char *) md_name, "sha384", 100 );
5288  md_info = md_info_from_string( md_name );
5289  fct_chk( md_info != NULL );
5290  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5291 
5292  key_len = unhexify( key_str, "91a7401817386948ca952f9a20ee55dc" );
5293  src_len = unhexify( src_str, "2fea5b91035d6d501f3a834fa178bff4e64b99a8450432dafd32e4466b0e1e7781166f8a73f7e036b3b0870920f559f47bd1400a1a906e85e0dcf00a6c26862e9148b23806680f285f1fe4f93cdaf924c181a965465739c14f2268c8be8b471847c74b222577a1310bcdc1a85ef1468aa1a3fd4031213c97324b7509c9050a3d" );
5294 
5295  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5296  fct_chk ( ctx.md_ctx != NULL );
5297  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5298  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5299  fct_chk ( 0 == md_free_ctx( &ctx ) );
5300 
5301  hexify( hash_str, output, md_get_size(md_info) );
5302 
5303  fct_chk( strncmp( (char *) hash_str, "6d7be9490058cf413cc09fd043c224c2ec4fa7859b13783000a9a593c9f75838", 32 * 2 ) == 0 );
5304  }
5305  FCT_TEST_END();
5306 #endif /* POLARSSL_SHA4_C */
5307 
5308 #ifdef POLARSSL_SHA4_C
5309 
5310  FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_2)
5311  {
5312  char md_name[100];
5313  unsigned char src_str[10000];
5314  unsigned char key_str[10000];
5315  unsigned char hash_str[10000];
5316  unsigned char output[100];
5317  int key_len, src_len;
5318  const md_info_t *md_info = NULL;
5320 
5321  memset(md_name, 0x00, 100);
5322  memset(src_str, 0x00, 10000);
5323  memset(key_str, 0x00, 10000);
5324  memset(hash_str, 0x00, 10000);
5325  memset(output, 0x00, 100);
5326 
5327  strncpy( (char *) md_name, "sha384", 100 );
5328  md_info = md_info_from_string( md_name );
5329  fct_chk( md_info != NULL );
5330  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5331 
5332  key_len = unhexify( key_str, "d6cac19657061aa90a6da11cd2e9ea47" );
5333  src_len = unhexify( src_str, "9f482e4655173135dfaa22a11bbbe6af263db48716406c5aec162ba3c4b41cad4f5a91558377521191c7343118beee65982929802913d67b6de5c4bdc3d27299bd722219d5ad2efa5bdb9ff7b229fc4bbc3f60719320cf2e7a51cad1133d21bad2d80919b1836ef825308b7c51c6b7677ac782e2bc30007afba065681cbdd215" );
5334 
5335  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5336  fct_chk ( ctx.md_ctx != NULL );
5337  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5338  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5339  fct_chk ( 0 == md_free_ctx( &ctx ) );
5340 
5341  hexify( hash_str, output, md_get_size(md_info) );
5342 
5343  fct_chk( strncmp( (char *) hash_str, "f3d5f3c008175321aa7b2ea379eaa4f8b9dcc60f895ec8940b8162f80a7dfe9f", 32 * 2 ) == 0 );
5344  }
5345  FCT_TEST_END();
5346 #endif /* POLARSSL_SHA4_C */
5347 
5348 #ifdef POLARSSL_SHA4_C
5349 
5350  FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_3)
5351  {
5352  char md_name[100];
5353  unsigned char src_str[10000];
5354  unsigned char key_str[10000];
5355  unsigned char hash_str[10000];
5356  unsigned char output[100];
5357  int key_len, src_len;
5358  const md_info_t *md_info = NULL;
5360 
5361  memset(md_name, 0x00, 100);
5362  memset(src_str, 0x00, 10000);
5363  memset(key_str, 0x00, 10000);
5364  memset(hash_str, 0x00, 10000);
5365  memset(output, 0x00, 100);
5366 
5367  strncpy( (char *) md_name, "sha384", 100 );
5368  md_info = md_info_from_string( md_name );
5369  fct_chk( md_info != NULL );
5370  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5371 
5372  key_len = unhexify( key_str, "e06366ad149b8442cd4c1abdddd0afde" );
5373  src_len = unhexify( src_str, "2d140a194c02a5598f69174834679b8371234a0d505491f1bd03e128dd91a8bca2fb812e9d5da71613b5b00952ea78bf450d5b7547dea79135925085c7d3e6f52009c51ca3d88c6c09e9d074b0ee110736e0ec9b478b93efb34d7bf1c41b54decec43eab077a3aa4998ede53f67b4ea36c266745f9643d5360bdc8337c70dabf" );
5374 
5375  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5376  fct_chk ( ctx.md_ctx != NULL );
5377  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5378  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5379  fct_chk ( 0 == md_free_ctx( &ctx ) );
5380 
5381  hexify( hash_str, output, md_get_size(md_info) );
5382 
5383  fct_chk( strncmp( (char *) hash_str, "c19c67eda6fe29f3667bee1c897c333ce7683094ae77e84b4c16378d290895a1", 32 * 2 ) == 0 );
5384  }
5385  FCT_TEST_END();
5386 #endif /* POLARSSL_SHA4_C */
5387 
5388 #ifdef POLARSSL_SHA4_C
5389 
5390  FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_4)
5391  {
5392  char md_name[100];
5393  unsigned char src_str[10000];
5394  unsigned char key_str[10000];
5395  unsigned char hash_str[10000];
5396  unsigned char output[100];
5397  int key_len, src_len;
5398  const md_info_t *md_info = NULL;
5400 
5401  memset(md_name, 0x00, 100);
5402  memset(src_str, 0x00, 10000);
5403  memset(key_str, 0x00, 10000);
5404  memset(hash_str, 0x00, 10000);
5405  memset(output, 0x00, 100);
5406 
5407  strncpy( (char *) md_name, "sha384", 100 );
5408  md_info = md_info_from_string( md_name );
5409  fct_chk( md_info != NULL );
5410  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5411 
5412  key_len = unhexify( key_str, "01ac59f42f8bb91d1bd10fe6990d7a87" );
5413  src_len = unhexify( src_str, "3caf18c476edd5615f343ac7b7d3a9da9efade755672d5ba4b8ae8a7505539ea2c124ff755ec0457fbe49e43480b3c71e7f4742ec3693aad115d039f90222b030fdc9440313691716d5302005808c07627483b916fdf61983063c2eb1268f2deeef42fc790334456bc6bad256e31fc9066de7cc7e43d1321b1866db45e905622" );
5414 
5415  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5416  fct_chk ( ctx.md_ctx != NULL );
5417  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5418  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5419  fct_chk ( 0 == md_free_ctx( &ctx ) );
5420 
5421  hexify( hash_str, output, md_get_size(md_info) );
5422 
5423  fct_chk( strncmp( (char *) hash_str, "1985fa2163a5943fc5d92f1fe8831215e7e91f0bff5332bc713a072bdb3a8f9e5c5157463a3bfeb36231416e65973e64", 48 * 2 ) == 0 );
5424  }
5425  FCT_TEST_END();
5426 #endif /* POLARSSL_SHA4_C */
5427 
5428 #ifdef POLARSSL_SHA4_C
5429 
5430  FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_5)
5431  {
5432  char md_name[100];
5433  unsigned char src_str[10000];
5434  unsigned char key_str[10000];
5435  unsigned char hash_str[10000];
5436  unsigned char output[100];
5437  int key_len, src_len;
5438  const md_info_t *md_info = NULL;
5440 
5441  memset(md_name, 0x00, 100);
5442  memset(src_str, 0x00, 10000);
5443  memset(key_str, 0x00, 10000);
5444  memset(hash_str, 0x00, 10000);
5445  memset(output, 0x00, 100);
5446 
5447  strncpy( (char *) md_name, "sha384", 100 );
5448  md_info = md_info_from_string( md_name );
5449  fct_chk( md_info != NULL );
5450  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5451 
5452  key_len = unhexify( key_str, "fd74b9d9e102a3a80df1baf0cb35bace" );
5453  src_len = unhexify( src_str, "1a068917584813d1689ccbd0370c2114d537cdc8cc52bf6db16d5535f8f7d1ad0c850a9fa0cf62373ffbf7642b1f1e8164010d350721d798d9f99e9724830399c2fce26377e83d38845675457865c03d4a07d741a505ef028343eb29fd46d0f761f3792886998c1e5c32ac3bc7e6f08faed194b34f06eff4d5d4a5b42c481e0e" );
5454 
5455  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5456  fct_chk ( ctx.md_ctx != NULL );
5457  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5458  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5459  fct_chk ( 0 == md_free_ctx( &ctx ) );
5460 
5461  hexify( hash_str, output, md_get_size(md_info) );
5462 
5463  fct_chk( strncmp( (char *) hash_str, "a981eaf5de3d78b20ebd4414a4edd0657e3667cd808a0dbc430cf7252f73a5b24efa136039207bd59806897457d74e0c", 48 * 2 ) == 0 );
5464  }
5465  FCT_TEST_END();
5466 #endif /* POLARSSL_SHA4_C */
5467 
5468 #ifdef POLARSSL_SHA4_C
5469 
5470  FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_5)
5471  {
5472  char md_name[100];
5473  unsigned char src_str[10000];
5474  unsigned char key_str[10000];
5475  unsigned char hash_str[10000];
5476  unsigned char output[100];
5477  int key_len, src_len;
5478  const md_info_t *md_info = NULL;
5480 
5481  memset(md_name, 0x00, 100);
5482  memset(src_str, 0x00, 10000);
5483  memset(key_str, 0x00, 10000);
5484  memset(hash_str, 0x00, 10000);
5485  memset(output, 0x00, 100);
5486 
5487  strncpy( (char *) md_name, "sha384", 100 );
5488  md_info = md_info_from_string( md_name );
5489  fct_chk( md_info != NULL );
5490  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5491 
5492  key_len = unhexify( key_str, "9fe794f0e26b669fa5f6883149377c6c" );
5493  src_len = unhexify( src_str, "6010c9745e8f1d44cfdc99e7e0fd79bc4271944c2d1d84dba589073dfc4ca5eb98c59356f60cd87bef28aeb83a832bde339b2087daf942aa1f67876c5d5ed33924bed4143bc12a2be532ccaf64daa7e2bc3c8872b9823b0533b6f5159135effe8c61545536975d7c3a61ba7365ec35f165bc92b4d19eb9156ade17dfa1bb4161" );
5494 
5495  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5496  fct_chk ( ctx.md_ctx != NULL );
5497  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5498  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5499  fct_chk ( 0 == md_free_ctx( &ctx ) );
5500 
5501  hexify( hash_str, output, md_get_size(md_info) );
5502 
5503  fct_chk( strncmp( (char *) hash_str, "915ae61f8754698c2b6ef9629e93441f8541bd4258a5e05372d19136cfaefc0473b48d96119291b38eb1a3cb1982a986", 48 * 2 ) == 0 );
5504  }
5505  FCT_TEST_END();
5506 #endif /* POLARSSL_SHA4_C */
5507 
5508 #ifdef POLARSSL_SHA4_C
5509 
5510  FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_1)
5511  {
5512  char md_name[100];
5513  unsigned char src_str[10000];
5514  unsigned char key_str[10000];
5515  unsigned char hash_str[10000];
5516  unsigned char output[100];
5517  int key_len, src_len;
5518  const md_info_t *md_info = NULL;
5520 
5521  memset(md_name, 0x00, 100);
5522  memset(src_str, 0x00, 10000);
5523  memset(key_str, 0x00, 10000);
5524  memset(hash_str, 0x00, 10000);
5525  memset(output, 0x00, 100);
5526 
5527  strncpy( (char *) md_name, "sha512", 100 );
5528  md_info = md_info_from_string( md_name );
5529  fct_chk( md_info != NULL );
5530  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5531 
5532  key_len = unhexify( key_str, "c95a17c09940a691ed2d621571b0eb844ede55a9" );
5533  src_len = unhexify( src_str, "99cd28262e81f34878cdcebf4128e05e2098a7009278a66f4c785784d0e5678f3f2b22f86e982d273b6273a222ec61750b4556d766f1550a7aedfe83faedbc4bdae83fa560d62df17eb914d05fdaa48940551bac81d700f5fca7147295e386e8120d66742ec65c6ee8d89a92217a0f6266d0ddc60bb20ef679ae8299c8502c2f" );
5534 
5535  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5536  fct_chk ( ctx.md_ctx != NULL );
5537  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5538  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5539  fct_chk ( 0 == md_free_ctx( &ctx ) );
5540 
5541  hexify( hash_str, output, md_get_size(md_info) );
5542 
5543  fct_chk( strncmp( (char *) hash_str, "6bc1379d156559ddee2ed420ea5d5c5ff3e454a1059b7ba72c350e77b6e9333c", 32 * 2 ) == 0 );
5544  }
5545  FCT_TEST_END();
5546 #endif /* POLARSSL_SHA4_C */
5547 
5548 #ifdef POLARSSL_SHA4_C
5549 
5550  FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_2)
5551  {
5552  char md_name[100];
5553  unsigned char src_str[10000];
5554  unsigned char key_str[10000];
5555  unsigned char hash_str[10000];
5556  unsigned char output[100];
5557  int key_len, src_len;
5558  const md_info_t *md_info = NULL;
5560 
5561  memset(md_name, 0x00, 100);
5562  memset(src_str, 0x00, 10000);
5563  memset(key_str, 0x00, 10000);
5564  memset(hash_str, 0x00, 10000);
5565  memset(output, 0x00, 100);
5566 
5567  strncpy( (char *) md_name, "sha512", 100 );
5568  md_info = md_info_from_string( md_name );
5569  fct_chk( md_info != NULL );
5570  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5571 
5572  key_len = unhexify( key_str, "3b10b8fa718840d1dea8e9fc317476bcf55875fd" );
5573  src_len = unhexify( src_str, "f04f5b7073d7d0274e8354433b390306c5607632f5f589c12edb62d55673aff2366d2e6b24de731adf92e654baa30b1cfd4a069788f65ec1b99b015d904d8832110dbd74eae35a81562d14ce4136d820ad0a55ff5489ba678fbbc1c27663ec1349d70e740f0e0ec27cfbe8971819f4789e486b50a2d7271d77e2aaea50de62fd" );
5574 
5575  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5576  fct_chk ( ctx.md_ctx != NULL );
5577  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5578  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5579  fct_chk ( 0 == md_free_ctx( &ctx ) );
5580 
5581  hexify( hash_str, output, md_get_size(md_info) );
5582 
5583  fct_chk( strncmp( (char *) hash_str, "fc3c38c7a17e3ce06db033f1c172866f01a00045db55f2e234f71c82264f2ba2", 32 * 2 ) == 0 );
5584  }
5585  FCT_TEST_END();
5586 #endif /* POLARSSL_SHA4_C */
5587 
5588 #ifdef POLARSSL_SHA4_C
5589 
5590  FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_3)
5591  {
5592  char md_name[100];
5593  unsigned char src_str[10000];
5594  unsigned char key_str[10000];
5595  unsigned char hash_str[10000];
5596  unsigned char output[100];
5597  int key_len, src_len;
5598  const md_info_t *md_info = NULL;
5600 
5601  memset(md_name, 0x00, 100);
5602  memset(src_str, 0x00, 10000);
5603  memset(key_str, 0x00, 10000);
5604  memset(hash_str, 0x00, 10000);
5605  memset(output, 0x00, 100);
5606 
5607  strncpy( (char *) md_name, "sha512", 100 );
5608  md_info = md_info_from_string( md_name );
5609  fct_chk( md_info != NULL );
5610  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5611 
5612  key_len = unhexify( key_str, "4803d311394600dc1e0d8fc8cedeb8bde3fe7c42" );
5613  src_len = unhexify( src_str, "a10c125dd702a97153ad923ba5e9889cfac1ba169de370debe51f233735aa6effcc9785c4b5c7e48c477dc5c411ae6a959118584e26adc94b42c2b29b046f3cf01c65b24a24bd2e620bdf650a23bb4a72655b1100d7ce9a4dab697c6379754b4396c825de4b9eb73f2e6a6c0d0353bbdeaf706612800e137b858fdb30f3311c6" );
5614 
5615  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5616  fct_chk ( ctx.md_ctx != NULL );
5617  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5618  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5619  fct_chk ( 0 == md_free_ctx( &ctx ) );
5620 
5621  hexify( hash_str, output, md_get_size(md_info) );
5622 
5623  fct_chk( strncmp( (char *) hash_str, "7cd8236c55102e6385f52279506df6fcc388ab75092da21395ce14a82b202ffa", 32 * 2 ) == 0 );
5624  }
5625  FCT_TEST_END();
5626 #endif /* POLARSSL_SHA4_C */
5627 
5628 #ifdef POLARSSL_SHA4_C
5629 
5630  FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_4)
5631  {
5632  char md_name[100];
5633  unsigned char src_str[10000];
5634  unsigned char key_str[10000];
5635  unsigned char hash_str[10000];
5636  unsigned char output[100];
5637  int key_len, src_len;
5638  const md_info_t *md_info = NULL;
5640 
5641  memset(md_name, 0x00, 100);
5642  memset(src_str, 0x00, 10000);
5643  memset(key_str, 0x00, 10000);
5644  memset(hash_str, 0x00, 10000);
5645  memset(output, 0x00, 100);
5646 
5647  strncpy( (char *) md_name, "sha512", 100 );
5648  md_info = md_info_from_string( md_name );
5649  fct_chk( md_info != NULL );
5650  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5651 
5652  key_len = unhexify( key_str, "aeb2f3b977fa6c8e71e07c5a5c74ff58166de092" );
5653  src_len = unhexify( src_str, "22457355dc76095abd46846b41cfe49a06ce42ac8857b4702fc771508dfb3626e0bfe851df897a07b36811ec433766e4b4166c26301b3493e7440d4554b0ef6ac20f1a530e58fac8aeba4e9ff2d4898d8a28783b49cd269c2965fd7f8e4f2d60cf1e5284f2495145b72382aad90e153a90ecae125ad75336fb128825c23fb8b0" );
5654 
5655  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5656  fct_chk ( ctx.md_ctx != NULL );
5657  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5658  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5659  fct_chk ( 0 == md_free_ctx( &ctx ) );
5660 
5661  hexify( hash_str, output, md_get_size(md_info) );
5662 
5663  fct_chk( strncmp( (char *) hash_str, "fa39bd8fcc3bfa218f9dea5d3b2ce10a7619e31678a56d8a9d927b1fe703b125af445debe9a89a07db6194d27b44d85a", 48 * 2 ) == 0 );
5664  }
5665  FCT_TEST_END();
5666 #endif /* POLARSSL_SHA4_C */
5667 
5668 #ifdef POLARSSL_SHA4_C
5669 
5670  FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_5)
5671  {
5672  char md_name[100];
5673  unsigned char src_str[10000];
5674  unsigned char key_str[10000];
5675  unsigned char hash_str[10000];
5676  unsigned char output[100];
5677  int key_len, src_len;
5678  const md_info_t *md_info = NULL;
5680 
5681  memset(md_name, 0x00, 100);
5682  memset(src_str, 0x00, 10000);
5683  memset(key_str, 0x00, 10000);
5684  memset(hash_str, 0x00, 10000);
5685  memset(output, 0x00, 100);
5686 
5687  strncpy( (char *) md_name, "sha512", 100 );
5688  md_info = md_info_from_string( md_name );
5689  fct_chk( md_info != NULL );
5690  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5691 
5692  key_len = unhexify( key_str, "4285d3d7744da52775bb44ca436a3154f7980309" );
5693  src_len = unhexify( src_str, "208f0b6f2de2e5aa5df11927ddc6df485edc1193181c484d0f0a434a95418803101d4de9fdb798f93516a6916fa38a8207de1666fe50fe3441c03b112eaaae6954ed063f7ac4e3c1e3f73b20d153fe9e4857f5e91430f0a70ee820529adac2467469fd18adf10e2af0fea27c0abc83c5a9af77c364a466cffce8bab4e2b70bc1" );
5694 
5695  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5696  fct_chk ( ctx.md_ctx != NULL );
5697  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5698  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5699  fct_chk ( 0 == md_free_ctx( &ctx ) );
5700 
5701  hexify( hash_str, output, md_get_size(md_info) );
5702 
5703  fct_chk( strncmp( (char *) hash_str, "fe7603f205b2774fe0f14ecfa3e338e90608a806d11ca459dff5ce36b1b264ecd3af5f0492a7521d8da3102ba20927a5", 48 * 2 ) == 0 );
5704  }
5705  FCT_TEST_END();
5706 #endif /* POLARSSL_SHA4_C */
5707 
5708 #ifdef POLARSSL_SHA4_C
5709 
5710  FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_6)
5711  {
5712  char md_name[100];
5713  unsigned char src_str[10000];
5714  unsigned char key_str[10000];
5715  unsigned char hash_str[10000];
5716  unsigned char output[100];
5717  int key_len, src_len;
5718  const md_info_t *md_info = NULL;
5720 
5721  memset(md_name, 0x00, 100);
5722  memset(src_str, 0x00, 10000);
5723  memset(key_str, 0x00, 10000);
5724  memset(hash_str, 0x00, 10000);
5725  memset(output, 0x00, 100);
5726 
5727  strncpy( (char *) md_name, "sha512", 100 );
5728  md_info = md_info_from_string( md_name );
5729  fct_chk( md_info != NULL );
5730  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
5731 
5732  key_len = unhexify( key_str, "8ab783d5acf32efa0d9c0a21abce955e96630d89" );
5733  src_len = unhexify( src_str, "17371e013dce839963d54418e97be4bd9fa3cb2a368a5220f5aa1b8aaddfa3bdefc91afe7c717244fd2fb640f5cb9d9bf3e25f7f0c8bc758883b89dcdce6d749d9672fed222277ece3e84b3ec01b96f70c125fcb3cbee6d19b8ef0873f915f173bdb05d81629ba187cc8ac1934b2f75952fb7616ae6bd812946df694bd2763af" );
5734 
5735  fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
5736  fct_chk ( ctx.md_ctx != NULL );
5737  fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
5738  fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
5739  fct_chk ( 0 == md_free_ctx( &ctx ) );
5740 
5741  hexify( hash_str, output, md_get_size(md_info) );
5742 
5743  fct_chk( strncmp( (char *) hash_str, "9ac7ca8d1aefc166b046e4cf7602ebe181a0e5055474bff5b342106731da0d7e48e4d87bc0a6f05871574289a1b099f8", 48 * 2 ) == 0 );
5744  }
5745  FCT_TEST_END();
5746 #endif /* POLARSSL_SHA4_C */
5747 
5748 #ifdef POLARSSL_SHA1_C
5749 
5750  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_1)
5751  {
5752  char md_name[100];
5753  unsigned char src_str[10000];
5754  unsigned char hash_str[10000];
5755  unsigned char output[100];
5756  int src_len;
5757  const md_info_t *md_info = NULL;
5758 
5759  memset(md_name, 0x00, 100);
5760  memset(src_str, 0x00, 10000);
5761  memset(hash_str, 0x00, 10000);
5762  memset(output, 0x00, 100);
5763 
5764  strncpy( (char *) md_name, "sha1", 100 );
5765  md_info = md_info_from_string(md_name);
5766  fct_chk( md_info != NULL );
5767 
5768  src_len = unhexify( src_str, "" );
5769  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5770 
5771  hexify( hash_str, output, md_get_size(md_info) );
5772 
5773  fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
5774  }
5775  FCT_TEST_END();
5776 #endif /* POLARSSL_SHA1_C */
5777 
5778 #ifdef POLARSSL_SHA1_C
5779 
5780  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_2)
5781  {
5782  char md_name[100];
5783  unsigned char src_str[10000];
5784  unsigned char hash_str[10000];
5785  unsigned char output[100];
5786  int src_len;
5787  const md_info_t *md_info = NULL;
5788 
5789  memset(md_name, 0x00, 100);
5790  memset(src_str, 0x00, 10000);
5791  memset(hash_str, 0x00, 10000);
5792  memset(output, 0x00, 100);
5793 
5794  strncpy( (char *) md_name, "sha1", 100 );
5795  md_info = md_info_from_string(md_name);
5796  fct_chk( md_info != NULL );
5797 
5798  src_len = unhexify( src_str, "a8" );
5799  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5800 
5801  hexify( hash_str, output, md_get_size(md_info) );
5802 
5803  fct_chk( strcmp( (char *) hash_str, "99f2aa95e36f95c2acb0eaf23998f030638f3f15" ) == 0 );
5804  }
5805  FCT_TEST_END();
5806 #endif /* POLARSSL_SHA1_C */
5807 
5808 #ifdef POLARSSL_SHA1_C
5809 
5810  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_3)
5811  {
5812  char md_name[100];
5813  unsigned char src_str[10000];
5814  unsigned char hash_str[10000];
5815  unsigned char output[100];
5816  int src_len;
5817  const md_info_t *md_info = NULL;
5818 
5819  memset(md_name, 0x00, 100);
5820  memset(src_str, 0x00, 10000);
5821  memset(hash_str, 0x00, 10000);
5822  memset(output, 0x00, 100);
5823 
5824  strncpy( (char *) md_name, "sha1", 100 );
5825  md_info = md_info_from_string(md_name);
5826  fct_chk( md_info != NULL );
5827 
5828  src_len = unhexify( src_str, "3000" );
5829  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5830 
5831  hexify( hash_str, output, md_get_size(md_info) );
5832 
5833  fct_chk( strcmp( (char *) hash_str, "f944dcd635f9801f7ac90a407fbc479964dec024" ) == 0 );
5834  }
5835  FCT_TEST_END();
5836 #endif /* POLARSSL_SHA1_C */
5837 
5838 #ifdef POLARSSL_SHA1_C
5839 
5840  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_4)
5841  {
5842  char md_name[100];
5843  unsigned char src_str[10000];
5844  unsigned char hash_str[10000];
5845  unsigned char output[100];
5846  int src_len;
5847  const md_info_t *md_info = NULL;
5848 
5849  memset(md_name, 0x00, 100);
5850  memset(src_str, 0x00, 10000);
5851  memset(hash_str, 0x00, 10000);
5852  memset(output, 0x00, 100);
5853 
5854  strncpy( (char *) md_name, "sha1", 100 );
5855  md_info = md_info_from_string(md_name);
5856  fct_chk( md_info != NULL );
5857 
5858  src_len = unhexify( src_str, "42749e" );
5859  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5860 
5861  hexify( hash_str, output, md_get_size(md_info) );
5862 
5863  fct_chk( strcmp( (char *) hash_str, "a444319e9b6cc1e8464c511ec0969c37d6bb2619" ) == 0 );
5864  }
5865  FCT_TEST_END();
5866 #endif /* POLARSSL_SHA1_C */
5867 
5868 #ifdef POLARSSL_SHA1_C
5869 
5870  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_5)
5871  {
5872  char md_name[100];
5873  unsigned char src_str[10000];
5874  unsigned char hash_str[10000];
5875  unsigned char output[100];
5876  int src_len;
5877  const md_info_t *md_info = NULL;
5878 
5879  memset(md_name, 0x00, 100);
5880  memset(src_str, 0x00, 10000);
5881  memset(hash_str, 0x00, 10000);
5882  memset(output, 0x00, 100);
5883 
5884  strncpy( (char *) md_name, "sha1", 100 );
5885  md_info = md_info_from_string(md_name);
5886  fct_chk( md_info != NULL );
5887 
5888  src_len = unhexify( src_str, "9fc3fe08" );
5889  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5890 
5891  hexify( hash_str, output, md_get_size(md_info) );
5892 
5893  fct_chk( strcmp( (char *) hash_str, "16a0ff84fcc156fd5d3ca3a744f20a232d172253" ) == 0 );
5894  }
5895  FCT_TEST_END();
5896 #endif /* POLARSSL_SHA1_C */
5897 
5898 #ifdef POLARSSL_SHA1_C
5899 
5900  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_6)
5901  {
5902  char md_name[100];
5903  unsigned char src_str[10000];
5904  unsigned char hash_str[10000];
5905  unsigned char output[100];
5906  int src_len;
5907  const md_info_t *md_info = NULL;
5908 
5909  memset(md_name, 0x00, 100);
5910  memset(src_str, 0x00, 10000);
5911  memset(hash_str, 0x00, 10000);
5912  memset(output, 0x00, 100);
5913 
5914  strncpy( (char *) md_name, "sha1", 100 );
5915  md_info = md_info_from_string(md_name);
5916  fct_chk( md_info != NULL );
5917 
5918  src_len = unhexify( src_str, "b5c1c6f1af" );
5919  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5920 
5921  hexify( hash_str, output, md_get_size(md_info) );
5922 
5923  fct_chk( strcmp( (char *) hash_str, "fec9deebfcdedaf66dda525e1be43597a73a1f93" ) == 0 );
5924  }
5925  FCT_TEST_END();
5926 #endif /* POLARSSL_SHA1_C */
5927 
5928 #ifdef POLARSSL_SHA1_C
5929 
5930  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_7)
5931  {
5932  char md_name[100];
5933  unsigned char src_str[10000];
5934  unsigned char hash_str[10000];
5935  unsigned char output[100];
5936  int src_len;
5937  const md_info_t *md_info = NULL;
5938 
5939  memset(md_name, 0x00, 100);
5940  memset(src_str, 0x00, 10000);
5941  memset(hash_str, 0x00, 10000);
5942  memset(output, 0x00, 100);
5943 
5944  strncpy( (char *) md_name, "sha1", 100 );
5945  md_info = md_info_from_string(md_name);
5946  fct_chk( md_info != NULL );
5947 
5948  src_len = unhexify( src_str, "ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b2548035185813e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a5305da4b1b737fce7cd21c0eb7728d08235a9011" );
5949  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5950 
5951  hexify( hash_str, output, md_get_size(md_info) );
5952 
5953  fct_chk( strcmp( (char *) hash_str, "970111c4e77bcc88cc20459c02b69b4aa8f58217" ) == 0 );
5954  }
5955  FCT_TEST_END();
5956 #endif /* POLARSSL_SHA1_C */
5957 
5958 #ifdef POLARSSL_SHA1_C
5959 
5960  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_8)
5961  {
5962  char md_name[100];
5963  unsigned char src_str[10000];
5964  unsigned char hash_str[10000];
5965  unsigned char output[100];
5966  int src_len;
5967  const md_info_t *md_info = NULL;
5968 
5969  memset(md_name, 0x00, 100);
5970  memset(src_str, 0x00, 10000);
5971  memset(hash_str, 0x00, 10000);
5972  memset(output, 0x00, 100);
5973 
5974  strncpy( (char *) md_name, "sha1", 100 );
5975  md_info = md_info_from_string(md_name);
5976  fct_chk( md_info != NULL );
5977 
5978  src_len = unhexify( src_str, "5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652afe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba553d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38ae485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77414197422be3d36a6080" );
5979  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
5980 
5981  hexify( hash_str, output, md_get_size(md_info) );
5982 
5983  fct_chk( strcmp( (char *) hash_str, "0423dc76a8791107d14e13f5265b343f24cc0f19" ) == 0 );
5984  }
5985  FCT_TEST_END();
5986 #endif /* POLARSSL_SHA1_C */
5987 
5988 #ifdef POLARSSL_SHA1_C
5989 
5990  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_9)
5991  {
5992  char md_name[100];
5993  unsigned char src_str[10000];
5994  unsigned char hash_str[10000];
5995  unsigned char output[100];
5996  int src_len;
5997  const md_info_t *md_info = NULL;
5998 
5999  memset(md_name, 0x00, 100);
6000  memset(src_str, 0x00, 10000);
6001  memset(hash_str, 0x00, 10000);
6002  memset(output, 0x00, 100);
6003 
6004  strncpy( (char *) md_name, "sha1", 100 );
6005  md_info = md_info_from_string(md_name);
6006  fct_chk( md_info != NULL );
6007 
6008  src_len = unhexify( src_str, "0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a007ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec428c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30baa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff57800e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee71366afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32beaea" );
6009  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6010 
6011  hexify( hash_str, output, md_get_size(md_info) );
6012 
6013  fct_chk( strcmp( (char *) hash_str, "6692a71d73e00f27df976bc56df4970650d90e45" ) == 0 );
6014  }
6015  FCT_TEST_END();
6016 #endif /* POLARSSL_SHA1_C */
6017 
6018 #ifdef POLARSSL_SHA1_C
6019 
6020  FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_10)
6021  {
6022  char md_name[100];
6023  unsigned char src_str[10000];
6024  unsigned char hash_str[10000];
6025  unsigned char output[100];
6026  int src_len;
6027  const md_info_t *md_info = NULL;
6028 
6029  memset(md_name, 0x00, 100);
6030  memset(src_str, 0x00, 10000);
6031  memset(hash_str, 0x00, 10000);
6032  memset(output, 0x00, 100);
6033 
6034  strncpy( (char *) md_name, "sha1", 100 );
6035  md_info = md_info_from_string(md_name);
6036  fct_chk( md_info != NULL );
6037 
6038  src_len = unhexify( src_str, "8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff" );
6039  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6040 
6041  hexify( hash_str, output, md_get_size(md_info) );
6042 
6043  fct_chk( strcmp( (char *) hash_str, "11863b483809ef88413ca9b0084ac4a5390640af" ) == 0 );
6044  }
6045  FCT_TEST_END();
6046 #endif /* POLARSSL_SHA1_C */
6047 
6048 #ifdef POLARSSL_SHA2_C
6049 
6050  FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_1)
6051  {
6052  char md_name[100];
6053  unsigned char src_str[10000];
6054  unsigned char hash_str[10000];
6055  unsigned char output[100];
6056  int src_len;
6057  const md_info_t *md_info = NULL;
6058 
6059  memset(md_name, 0x00, 100);
6060  memset(src_str, 0x00, 10000);
6061  memset(hash_str, 0x00, 10000);
6062  memset(output, 0x00, 100);
6063 
6064  strncpy( (char *) md_name, "sha224", 100 );
6065  md_info = md_info_from_string(md_name);
6066  fct_chk( md_info != NULL );
6067 
6068  src_len = unhexify( src_str, "" );
6069  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6070 
6071  hexify( hash_str, output, md_get_size(md_info) );
6072 
6073  fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
6074  }
6075  FCT_TEST_END();
6076 #endif /* POLARSSL_SHA2_C */
6077 
6078 #ifdef POLARSSL_SHA2_C
6079 
6080  FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_2)
6081  {
6082  char md_name[100];
6083  unsigned char src_str[10000];
6084  unsigned char hash_str[10000];
6085  unsigned char output[100];
6086  int src_len;
6087  const md_info_t *md_info = NULL;
6088 
6089  memset(md_name, 0x00, 100);
6090  memset(src_str, 0x00, 10000);
6091  memset(hash_str, 0x00, 10000);
6092  memset(output, 0x00, 100);
6093 
6094  strncpy( (char *) md_name, "sha224", 100 );
6095  md_info = md_info_from_string(md_name);
6096  fct_chk( md_info != NULL );
6097 
6098  src_len = unhexify( src_str, "ff" );
6099  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6100 
6101  hexify( hash_str, output, md_get_size(md_info) );
6102 
6103  fct_chk( strcmp( (char *) hash_str, "e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5" ) == 0 );
6104  }
6105  FCT_TEST_END();
6106 #endif /* POLARSSL_SHA2_C */
6107 
6108 #ifdef POLARSSL_SHA2_C
6109 
6110  FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_3)
6111  {
6112  char md_name[100];
6113  unsigned char src_str[10000];
6114  unsigned char hash_str[10000];
6115  unsigned char output[100];
6116  int src_len;
6117  const md_info_t *md_info = NULL;
6118 
6119  memset(md_name, 0x00, 100);
6120  memset(src_str, 0x00, 10000);
6121  memset(hash_str, 0x00, 10000);
6122  memset(output, 0x00, 100);
6123 
6124  strncpy( (char *) md_name, "sha224", 100 );
6125  md_info = md_info_from_string(md_name);
6126  fct_chk( md_info != NULL );
6127 
6128  src_len = unhexify( src_str, "984c" );
6129  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6130 
6131  hexify( hash_str, output, md_get_size(md_info) );
6132 
6133  fct_chk( strcmp( (char *) hash_str, "2fa9df9157d9e027cfbc4c6a9df32e1adc0cbe2328ec2a63c5ae934e" ) == 0 );
6134  }
6135  FCT_TEST_END();
6136 #endif /* POLARSSL_SHA2_C */
6137 
6138 #ifdef POLARSSL_SHA2_C
6139 
6140  FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_4)
6141  {
6142  char md_name[100];
6143  unsigned char src_str[10000];
6144  unsigned char hash_str[10000];
6145  unsigned char output[100];
6146  int src_len;
6147  const md_info_t *md_info = NULL;
6148 
6149  memset(md_name, 0x00, 100);
6150  memset(src_str, 0x00, 10000);
6151  memset(hash_str, 0x00, 10000);
6152  memset(output, 0x00, 100);
6153 
6154  strncpy( (char *) md_name, "sha224", 100 );
6155  md_info = md_info_from_string(md_name);
6156  fct_chk( md_info != NULL );
6157 
6158  src_len = unhexify( src_str, "50efd0" );
6159  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6160 
6161  hexify( hash_str, output, md_get_size(md_info) );
6162 
6163  fct_chk( strcmp( (char *) hash_str, "b5a9820413c2bf8211fbbf5df1337043b32fa4eafaf61a0c8e9ccede" ) == 0 );
6164  }
6165  FCT_TEST_END();
6166 #endif /* POLARSSL_SHA2_C */
6167 
6168 #ifdef POLARSSL_SHA2_C
6169 
6170  FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_5)
6171  {
6172  char md_name[100];
6173  unsigned char src_str[10000];
6174  unsigned char hash_str[10000];
6175  unsigned char output[100];
6176  int src_len;
6177  const md_info_t *md_info = NULL;
6178 
6179  memset(md_name, 0x00, 100);
6180  memset(src_str, 0x00, 10000);
6181  memset(hash_str, 0x00, 10000);
6182  memset(output, 0x00, 100);
6183 
6184  strncpy( (char *) md_name, "sha224", 100 );
6185  md_info = md_info_from_string(md_name);
6186  fct_chk( md_info != NULL );
6187 
6188  src_len = unhexify( src_str, "e5e09924" );
6189  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6190 
6191  hexify( hash_str, output, md_get_size(md_info) );
6192 
6193  fct_chk( strcmp( (char *) hash_str, "fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d" ) == 0 );
6194  }
6195  FCT_TEST_END();
6196 #endif /* POLARSSL_SHA2_C */
6197 
6198 #ifdef POLARSSL_SHA2_C
6199 
6200  FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_6)
6201  {
6202  char md_name[100];
6203  unsigned char src_str[10000];
6204  unsigned char hash_str[10000];
6205  unsigned char output[100];
6206  int src_len;
6207  const md_info_t *md_info = NULL;
6208 
6209  memset(md_name, 0x00, 100);
6210  memset(src_str, 0x00, 10000);
6211  memset(hash_str, 0x00, 10000);
6212  memset(output, 0x00, 100);
6213 
6214  strncpy( (char *) md_name, "sha224", 100 );
6215  md_info = md_info_from_string(md_name);
6216  fct_chk( md_info != NULL );
6217 
6218  src_len = unhexify( src_str, "21ebecb914" );
6219  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6220 
6221  hexify( hash_str, output, md_get_size(md_info) );
6222 
6223  fct_chk( strcmp( (char *) hash_str, "78f4a71c21c694499ce1c7866611b14ace70d905012c356323c7c713" ) == 0 );
6224  }
6225  FCT_TEST_END();
6226 #endif /* POLARSSL_SHA2_C */
6227 
6228 #ifdef POLARSSL_SHA2_C
6229 
6230  FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_7)
6231  {
6232  char md_name[100];
6233  unsigned char src_str[10000];
6234  unsigned char hash_str[10000];
6235  unsigned char output[100];
6236  int src_len;
6237  const md_info_t *md_info = NULL;
6238 
6239  memset(md_name, 0x00, 100);
6240  memset(src_str, 0x00, 10000);
6241  memset(hash_str, 0x00, 10000);
6242  memset(output, 0x00, 100);
6243 
6244  strncpy( (char *) md_name, "sha224", 100 );
6245  md_info = md_info_from_string(md_name);
6246  fct_chk( md_info != NULL );
6247 
6248  src_len = unhexify( src_str, "fc488947c1a7a589726b15436b4f3d9556262f98fc6422fc5cdf20f0fad7fe427a3491c86d101ffe6b7514f06268f65b2d269b0f69ad9a97847eff1c16a2438775eb7be6847ccf11cb8b2e8dcd6640b095b49c0693fe3cf4a66e2d9b7ad68bff14f3ad69abf49d0aba36cbe0535202deb6599a47225ef05beb351335cd7bc0f480d691198c7e71305ffd53b39d33242bb79cfd98bfd69e137b5d18b2b89ac9ace01c8dbdcf2533cce3682ecc52118de0c1062ec2126c2e657d6ea3d9e2398e705d4b0b1f1ceecb266dffc4f31bf42744fb1e938dc22a889919ee1e73f463f7871fed720519e32186264b7ef2a0e5d9a18e6c95c0781894f77967f048951dec3b4d892a38710b1e3436d3c29088eb8b3da1789c25db3d3bc6c26081206e7155d210a89b80ca6ea877c41ff9947c0f25625dcb118294a163501f6239c326661a958fd12da4cd15a899f8b88cc723589056eaec5aa04a4cf5dbb6f480f9660423ccf38c486e210707e0fb25e1f126ceb2616f63e147a647dab0af9ebe89d65458bf636154a46e4cab95f5ee62da2c7974cd14b90d3e4f99f81733e85b3c1d5da2b508d9b90f5eed7eff0d9c7649de62bee00375454fee4a39576a5bbfdae428e7f8097bdf7797f167686cb68407e49079e4611ff3402b6384ba7b7e522bd2bb11ce8fd02ea4c1604d163ac4f6dde50b8b1f593f7edaadeac0868ed97df690200680c25f0f5d85431a529e4f339089dcdeda105e4ee51dead704cdf5a605c55fb055c9b0e86b8ba1b564c0dea3eb790a595cb103cb292268b07c5e59371e1a7ef597cd4b22977a820694c9f9aeb55d9de3ef62b75d6e656e3336698d960a3787bf8cf5b926a7faeef52ae128bcb5dc9e66d94b016c7b8e034879171a2d91c381f57e6a815b63b5ee6a6d2ff435b49f14c963966960194430d78f8f87627a67757fb3532b289550894da6dce4817a4e07f4d56877a1102ffcc8befa5c9f8fca6a4574d93ff70376c8861e0f8108cf907fce77ecb49728f86f034f80224b9695682e0824462f76cdb1fd1af151337b0d85419047a7aa284791718a4860cd586f7824b95bc837b6fd4f9be5aade68456e20356aa4d943dac36bf8b67b9e8f9d01a00fcda74b798bafa746c661b010f75b59904b29d0c8041504811c4065f82cf2ead58d2f595cbd8bc3e7043f4d94577b373b7cfe16a36fe564f505c03b70cfeb5e5f411c79481338aa67e86b3f5a2e77c21e454c333ae3da943ab723ab5f4c940395319534a5575f64acba0d0ecc43f60221ed3badf7289c9b3a7b903a2d6c94e15fa4c310dc4fa7faa0c24f405160a1002dbef20e4105d481db982f7243f79400a6e4cd9753c4b9732a47575f504b20c328fe9add7f432a4f075829da07b53b695037dc51737d3cd731934df333cd1a53fcf65aa31baa450ca501a6fae26e322347e618c5a444d92e9fec5a8261ae38b98fee5be77c02cec09ddccd5b3de92036" );
6249  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6250 
6251  hexify( hash_str, output, md_get_size(md_info) );
6252 
6253  fct_chk( strcmp( (char *) hash_str, "1302149d1e197c41813b054c942329d420e366530f5517b470e964fe" ) == 0 );
6254  }
6255  FCT_TEST_END();
6256 #endif /* POLARSSL_SHA2_C */
6257 
6258 #ifdef POLARSSL_SHA2_C
6259 
6260  FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_1)
6261  {
6262  char md_name[100];
6263  unsigned char src_str[10000];
6264  unsigned char hash_str[10000];
6265  unsigned char output[100];
6266  int src_len;
6267  const md_info_t *md_info = NULL;
6268 
6269  memset(md_name, 0x00, 100);
6270  memset(src_str, 0x00, 10000);
6271  memset(hash_str, 0x00, 10000);
6272  memset(output, 0x00, 100);
6273 
6274  strncpy( (char *) md_name, "sha256", 100 );
6275  md_info = md_info_from_string(md_name);
6276  fct_chk( md_info != NULL );
6277 
6278  src_len = unhexify( src_str, "" );
6279  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6280 
6281  hexify( hash_str, output, md_get_size(md_info) );
6282 
6283  fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
6284  }
6285  FCT_TEST_END();
6286 #endif /* POLARSSL_SHA2_C */
6287 
6288 #ifdef POLARSSL_SHA2_C
6289 
6290  FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_2)
6291  {
6292  char md_name[100];
6293  unsigned char src_str[10000];
6294  unsigned char hash_str[10000];
6295  unsigned char output[100];
6296  int src_len;
6297  const md_info_t *md_info = NULL;
6298 
6299  memset(md_name, 0x00, 100);
6300  memset(src_str, 0x00, 10000);
6301  memset(hash_str, 0x00, 10000);
6302  memset(output, 0x00, 100);
6303 
6304  strncpy( (char *) md_name, "sha256", 100 );
6305  md_info = md_info_from_string(md_name);
6306  fct_chk( md_info != NULL );
6307 
6308  src_len = unhexify( src_str, "bd" );
6309  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6310 
6311  hexify( hash_str, output, md_get_size(md_info) );
6312 
6313  fct_chk( strcmp( (char *) hash_str, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b" ) == 0 );
6314  }
6315  FCT_TEST_END();
6316 #endif /* POLARSSL_SHA2_C */
6317 
6318 #ifdef POLARSSL_SHA2_C
6319 
6320  FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_3)
6321  {
6322  char md_name[100];
6323  unsigned char src_str[10000];
6324  unsigned char hash_str[10000];
6325  unsigned char output[100];
6326  int src_len;
6327  const md_info_t *md_info = NULL;
6328 
6329  memset(md_name, 0x00, 100);
6330  memset(src_str, 0x00, 10000);
6331  memset(hash_str, 0x00, 10000);
6332  memset(output, 0x00, 100);
6333 
6334  strncpy( (char *) md_name, "sha256", 100 );
6335  md_info = md_info_from_string(md_name);
6336  fct_chk( md_info != NULL );
6337 
6338  src_len = unhexify( src_str, "5fd4" );
6339  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6340 
6341  hexify( hash_str, output, md_get_size(md_info) );
6342 
6343  fct_chk( strcmp( (char *) hash_str, "7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788" ) == 0 );
6344  }
6345  FCT_TEST_END();
6346 #endif /* POLARSSL_SHA2_C */
6347 
6348 #ifdef POLARSSL_SHA2_C
6349 
6350  FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_4)
6351  {
6352  char md_name[100];
6353  unsigned char src_str[10000];
6354  unsigned char hash_str[10000];
6355  unsigned char output[100];
6356  int src_len;
6357  const md_info_t *md_info = NULL;
6358 
6359  memset(md_name, 0x00, 100);
6360  memset(src_str, 0x00, 10000);
6361  memset(hash_str, 0x00, 10000);
6362  memset(output, 0x00, 100);
6363 
6364  strncpy( (char *) md_name, "sha256", 100 );
6365  md_info = md_info_from_string(md_name);
6366  fct_chk( md_info != NULL );
6367 
6368  src_len = unhexify( src_str, "b0bd69" );
6369  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6370 
6371  hexify( hash_str, output, md_get_size(md_info) );
6372 
6373  fct_chk( strcmp( (char *) hash_str, "4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803" ) == 0 );
6374  }
6375  FCT_TEST_END();
6376 #endif /* POLARSSL_SHA2_C */
6377 
6378 #ifdef POLARSSL_SHA2_C
6379 
6380  FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_5)
6381  {
6382  char md_name[100];
6383  unsigned char src_str[10000];
6384  unsigned char hash_str[10000];
6385  unsigned char output[100];
6386  int src_len;
6387  const md_info_t *md_info = NULL;
6388 
6389  memset(md_name, 0x00, 100);
6390  memset(src_str, 0x00, 10000);
6391  memset(hash_str, 0x00, 10000);
6392  memset(output, 0x00, 100);
6393 
6394  strncpy( (char *) md_name, "sha256", 100 );
6395  md_info = md_info_from_string(md_name);
6396  fct_chk( md_info != NULL );
6397 
6398  src_len = unhexify( src_str, "c98c8e55" );
6399  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6400 
6401  hexify( hash_str, output, md_get_size(md_info) );
6402 
6403  fct_chk( strcmp( (char *) hash_str, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504" ) == 0 );
6404  }
6405  FCT_TEST_END();
6406 #endif /* POLARSSL_SHA2_C */
6407 
6408 #ifdef POLARSSL_SHA2_C
6409 
6410  FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_6)
6411  {
6412  char md_name[100];
6413  unsigned char src_str[10000];
6414  unsigned char hash_str[10000];
6415  unsigned char output[100];
6416  int src_len;
6417  const md_info_t *md_info = NULL;
6418 
6419  memset(md_name, 0x00, 100);
6420  memset(src_str, 0x00, 10000);
6421  memset(hash_str, 0x00, 10000);
6422  memset(output, 0x00, 100);
6423 
6424  strncpy( (char *) md_name, "sha256", 100 );
6425  md_info = md_info_from_string(md_name);
6426  fct_chk( md_info != NULL );
6427 
6428  src_len = unhexify( src_str, "81a723d966" );
6429  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6430 
6431  hexify( hash_str, output, md_get_size(md_info) );
6432 
6433  fct_chk( strcmp( (char *) hash_str, "7516fb8bb11350df2bf386bc3c33bd0f52cb4c67c6e4745e0488e62c2aea2605" ) == 0 );
6434  }
6435  FCT_TEST_END();
6436 #endif /* POLARSSL_SHA2_C */
6437 
6438 #ifdef POLARSSL_SHA2_C
6439 
6440  FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_7)
6441  {
6442  char md_name[100];
6443  unsigned char src_str[10000];
6444  unsigned char hash_str[10000];
6445  unsigned char output[100];
6446  int src_len;
6447  const md_info_t *md_info = NULL;
6448 
6449  memset(md_name, 0x00, 100);
6450  memset(src_str, 0x00, 10000);
6451  memset(hash_str, 0x00, 10000);
6452  memset(output, 0x00, 100);
6453 
6454  strncpy( (char *) md_name, "sha256", 100 );
6455  md_info = md_info_from_string(md_name);
6456  fct_chk( md_info != NULL );
6457 
6458  src_len = unhexify( src_str, "8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e" );
6459  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6460 
6461  hexify( hash_str, output, md_get_size(md_info) );
6462 
6463  fct_chk( strcmp( (char *) hash_str, "4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e" ) == 0 );
6464  }
6465  FCT_TEST_END();
6466 #endif /* POLARSSL_SHA2_C */
6467 
6468 #ifdef POLARSSL_SHA4_C
6469 
6470  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_1)
6471  {
6472  char md_name[100];
6473  unsigned char src_str[10000];
6474  unsigned char hash_str[10000];
6475  unsigned char output[100];
6476  int src_len;
6477  const md_info_t *md_info = NULL;
6478 
6479  memset(md_name, 0x00, 100);
6480  memset(src_str, 0x00, 10000);
6481  memset(hash_str, 0x00, 10000);
6482  memset(output, 0x00, 100);
6483 
6484  strncpy( (char *) md_name, "sha384", 100 );
6485  md_info = md_info_from_string(md_name);
6486  fct_chk( md_info != NULL );
6487 
6488  src_len = unhexify( src_str, "" );
6489  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6490 
6491  hexify( hash_str, output, md_get_size(md_info) );
6492 
6493  fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
6494  }
6495  FCT_TEST_END();
6496 #endif /* POLARSSL_SHA4_C */
6497 
6498 #ifdef POLARSSL_SHA4_C
6499 
6500  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_2)
6501  {
6502  char md_name[100];
6503  unsigned char src_str[10000];
6504  unsigned char hash_str[10000];
6505  unsigned char output[100];
6506  int src_len;
6507  const md_info_t *md_info = NULL;
6508 
6509  memset(md_name, 0x00, 100);
6510  memset(src_str, 0x00, 10000);
6511  memset(hash_str, 0x00, 10000);
6512  memset(output, 0x00, 100);
6513 
6514  strncpy( (char *) md_name, "sha384", 100 );
6515  md_info = md_info_from_string(md_name);
6516  fct_chk( md_info != NULL );
6517 
6518  src_len = unhexify( src_str, "ab" );
6519  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6520 
6521  hexify( hash_str, output, md_get_size(md_info) );
6522 
6523  fct_chk( strcmp( (char *) hash_str, "fb94d5be118865f6fcbc978b825da82cff188faec2f66cb84b2537d74b4938469854b0ca89e66fa2e182834736629f3d" ) == 0 );
6524  }
6525  FCT_TEST_END();
6526 #endif /* POLARSSL_SHA4_C */
6527 
6528 #ifdef POLARSSL_SHA4_C
6529 
6530  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_3)
6531  {
6532  char md_name[100];
6533  unsigned char src_str[10000];
6534  unsigned char hash_str[10000];
6535  unsigned char output[100];
6536  int src_len;
6537  const md_info_t *md_info = NULL;
6538 
6539  memset(md_name, 0x00, 100);
6540  memset(src_str, 0x00, 10000);
6541  memset(hash_str, 0x00, 10000);
6542  memset(output, 0x00, 100);
6543 
6544  strncpy( (char *) md_name, "sha384", 100 );
6545  md_info = md_info_from_string(md_name);
6546  fct_chk( md_info != NULL );
6547 
6548  src_len = unhexify( src_str, "7c27" );
6549  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6550 
6551  hexify( hash_str, output, md_get_size(md_info) );
6552 
6553  fct_chk( strcmp( (char *) hash_str, "3d80be467df86d63abb9ea1d3f9cb39cd19890e7f2c53a6200bedc5006842b35e820dc4e0ca90ca9b97ab23ef07080fc" ) == 0 );
6554  }
6555  FCT_TEST_END();
6556 #endif /* POLARSSL_SHA4_C */
6557 
6558 #ifdef POLARSSL_SHA4_C
6559 
6560  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_4)
6561  {
6562  char md_name[100];
6563  unsigned char src_str[10000];
6564  unsigned char hash_str[10000];
6565  unsigned char output[100];
6566  int src_len;
6567  const md_info_t *md_info = NULL;
6568 
6569  memset(md_name, 0x00, 100);
6570  memset(src_str, 0x00, 10000);
6571  memset(hash_str, 0x00, 10000);
6572  memset(output, 0x00, 100);
6573 
6574  strncpy( (char *) md_name, "sha384", 100 );
6575  md_info = md_info_from_string(md_name);
6576  fct_chk( md_info != NULL );
6577 
6578  src_len = unhexify( src_str, "31f5ca" );
6579  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6580 
6581  hexify( hash_str, output, md_get_size(md_info) );
6582 
6583  fct_chk( strcmp( (char *) hash_str, "78d54b943421fdf7ba90a7fb9637c2073aa480454bd841d39ff72f4511fc21fb67797b652c0c823229342873d3bef955" ) == 0 );
6584  }
6585  FCT_TEST_END();
6586 #endif /* POLARSSL_SHA4_C */
6587 
6588 #ifdef POLARSSL_SHA4_C
6589 
6590  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_5)
6591  {
6592  char md_name[100];
6593  unsigned char src_str[10000];
6594  unsigned char hash_str[10000];
6595  unsigned char output[100];
6596  int src_len;
6597  const md_info_t *md_info = NULL;
6598 
6599  memset(md_name, 0x00, 100);
6600  memset(src_str, 0x00, 10000);
6601  memset(hash_str, 0x00, 10000);
6602  memset(output, 0x00, 100);
6603 
6604  strncpy( (char *) md_name, "sha384", 100 );
6605  md_info = md_info_from_string(md_name);
6606  fct_chk( md_info != NULL );
6607 
6608  src_len = unhexify( src_str, "7bdee3f8" );
6609  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6610 
6611  hexify( hash_str, output, md_get_size(md_info) );
6612 
6613  fct_chk( strcmp( (char *) hash_str, "8bdafba0777ee446c3431c2d7b1fbb631089f71d2ca417abc1d230e1aba64ec2f1c187474a6f4077d372c14ad407f99a" ) == 0 );
6614  }
6615  FCT_TEST_END();
6616 #endif /* POLARSSL_SHA4_C */
6617 
6618 #ifdef POLARSSL_SHA4_C
6619 
6620  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_6)
6621  {
6622  char md_name[100];
6623  unsigned char src_str[10000];
6624  unsigned char hash_str[10000];
6625  unsigned char output[100];
6626  int src_len;
6627  const md_info_t *md_info = NULL;
6628 
6629  memset(md_name, 0x00, 100);
6630  memset(src_str, 0x00, 10000);
6631  memset(hash_str, 0x00, 10000);
6632  memset(output, 0x00, 100);
6633 
6634  strncpy( (char *) md_name, "sha384", 100 );
6635  md_info = md_info_from_string(md_name);
6636  fct_chk( md_info != NULL );
6637 
6638  src_len = unhexify( src_str, "8f05604915" );
6639  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6640 
6641  hexify( hash_str, output, md_get_size(md_info) );
6642 
6643  fct_chk( strcmp( (char *) hash_str, "504e414bf1db1060f14c8c799e25b1e0c4dcf1504ebbd129998f0ae283e6de86e0d3c7e879c73ec3b1836c3ee89c2649" ) == 0 );
6644  }
6645  FCT_TEST_END();
6646 #endif /* POLARSSL_SHA4_C */
6647 
6648 #ifdef POLARSSL_SHA4_C
6649 
6650  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_7)
6651  {
6652  char md_name[100];
6653  unsigned char src_str[10000];
6654  unsigned char hash_str[10000];
6655  unsigned char output[100];
6656  int src_len;
6657  const md_info_t *md_info = NULL;
6658 
6659  memset(md_name, 0x00, 100);
6660  memset(src_str, 0x00, 10000);
6661  memset(hash_str, 0x00, 10000);
6662  memset(output, 0x00, 100);
6663 
6664  strncpy( (char *) md_name, "sha384", 100 );
6665  md_info = md_info_from_string(md_name);
6666  fct_chk( md_info != NULL );
6667 
6668  src_len = unhexify( src_str, "665da6eda214" );
6669  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6670 
6671  hexify( hash_str, output, md_get_size(md_info) );
6672 
6673  fct_chk( strcmp( (char *) hash_str, "4c022f112010908848312f8b8f1072625fd5c105399d562ea1d56130619a7eac8dfc3748fd05ee37e4b690be9daa9980" ) == 0 );
6674  }
6675  FCT_TEST_END();
6676 #endif /* POLARSSL_SHA4_C */
6677 
6678 #ifdef POLARSSL_SHA4_C
6679 
6680  FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_8)
6681  {
6682  char md_name[100];
6683  unsigned char src_str[10000];
6684  unsigned char hash_str[10000];
6685  unsigned char output[100];
6686  int src_len;
6687  const md_info_t *md_info = NULL;
6688 
6689  memset(md_name, 0x00, 100);
6690  memset(src_str, 0x00, 10000);
6691  memset(hash_str, 0x00, 10000);
6692  memset(output, 0x00, 100);
6693 
6694  strncpy( (char *) md_name, "sha384", 100 );
6695  md_info = md_info_from_string(md_name);
6696  fct_chk( md_info != NULL );
6697 
6698  src_len = unhexify( src_str, "7f46ce506d593c4ed53c82edeb602037e0485befbee03f7f930fe532d18ff2a3f5fd6076672c8145a1bf40dd94f7abab47c9ae71c234213d2ad1069c2dac0b0ba15257ae672b8245960ae55bd50315c0097daa3a318745788d70d14706910809ca6e396237fe4934fa46f9ce782d66606d8bd6b2d283b1160513ce9c24e9f084b97891f99d4cdefc169a029e431ca772ba1bba426fce6f01d8e286014e5acc66b799e4db62bd4783322f8a32ff78e0de3957df50ce10871f4e0680df4e8ca3960af9bc6f4efa8eb3962d18f474eb178c3265cc46b8f2ff5ab1a7449fea297dfcfabfa01f28abbb7289bb354b691b5664ec6d098af51be19947ec5ba7ebd66380d1141953ba78d4aa5401679fa7b0a44db1981f864d3535c45afe4c61183d5b0ad51fae71ca07e34240283959f7530a32c70d95a088e501c230059f333b0670825009e7e22103ef22935830df1fac8ef877f5f3426dd54f7d1128dd871ad9a7d088f94c0e8712013295b8d69ae7623b880978c2d3c6ad26dc478f8dc47f5c0adcc618665dc3dc205a9071b2f2191e16cac5bd89bb59148fc719633752303aa08e518dbc389f0a5482caaa4c507b8729a6f3edd061efb39026cecc6399f51971cf7381d605e144a5928c8c2d1ad7467b05da2f202f4f3234e1aff19a0198a28685721c3d2d52311c721e3fdcbaf30214cdc3acff8c433880e104fb63f2df7ce69a97857819ba7ac00ac8eae1969764fde8f68cf8e0916d7e0c151147d4944f99f42ae50f30e1c79a42d2b6c5188d133d3cbbf69094027b354b295ccd0f7dc5a87d73638bd98ebfb00383ca0fa69cb8dcb35a12510e5e07ad8789047d0b63841a1bb928737e8b0a0c33254f47aa8bfbe3341a09c2b76dbcefa67e30df300d34f7b8465c4f869e51b6bcfe6cf68b238359a645036bf7f63f02924e087ce7457e483b6025a859903cb484574aa3b12cf946f32127d537c33bee3141b5db96d10a148c50ae045f287210757710d6846e04b202f79e87dd9a56bc6da15f84a77a7f63935e1dee00309cd276a8e7176cb04da6bb0e9009534438732cb42d008008853d38d19beba46e61006e30f7efd1bc7c2906b024e4ff898a1b58c448d68b43c6ab63f34f85b3ac6aa4475867e51b583844cb23829f4b30f4bdd817d88e2ef3e7b4fc0a624395b05ec5e8686082b24d29fef2b0d3c29e031d5f94f504b1d3df9361eb5ffbadb242e66c39a8094cfe62f85f639f3fd65fc8ae0c74a8f4c6e1d070b9183a434c722caaa0225f8bcd68614d6f0738ed62f8484ec96077d155c08e26c46be262a73e3551698bd70d8d5610cf37c4c306eed04ba6a040a9c3e6d7e15e8acda17f477c2484cf5c56b813313927be8387b1024f995e98fc87f1029091c01424bdc2b296c2eadb7d25b3e762a2fd0c2dcd1727ddf91db97c5984305265f3695a7f5472f2d72c94d68c27914f14f82aa8dd5fe4e2348b0ca967a3f98626a091552f5d0ffa2bf10350d23c996256c01fdeffb2c2c612519869f877e4929c6e95ff15040f1485e22ed14119880232fef3b57b3848f15b1766a5552879df8f06" );
6699  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6700 
6701  hexify( hash_str, output, md_get_size(md_info) );
6702 
6703  fct_chk( strcmp( (char *) hash_str, "cba9e3eb12a6f83db11e8a6ff40d1049854ee094416bc527fea931d8585428a8ed6242ce81f6769b36e2123a5c23483e" ) == 0 );
6704  }
6705  FCT_TEST_END();
6706 #endif /* POLARSSL_SHA4_C */
6707 
6708 #ifdef POLARSSL_SHA4_C
6709 
6710  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_1)
6711  {
6712  char md_name[100];
6713  unsigned char src_str[10000];
6714  unsigned char hash_str[10000];
6715  unsigned char output[100];
6716  int src_len;
6717  const md_info_t *md_info = NULL;
6718 
6719  memset(md_name, 0x00, 100);
6720  memset(src_str, 0x00, 10000);
6721  memset(hash_str, 0x00, 10000);
6722  memset(output, 0x00, 100);
6723 
6724  strncpy( (char *) md_name, "sha512", 100 );
6725  md_info = md_info_from_string(md_name);
6726  fct_chk( md_info != NULL );
6727 
6728  src_len = unhexify( src_str, "" );
6729  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6730 
6731  hexify( hash_str, output, md_get_size(md_info) );
6732 
6733  fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
6734  }
6735  FCT_TEST_END();
6736 #endif /* POLARSSL_SHA4_C */
6737 
6738 #ifdef POLARSSL_SHA4_C
6739 
6740  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_2)
6741  {
6742  char md_name[100];
6743  unsigned char src_str[10000];
6744  unsigned char hash_str[10000];
6745  unsigned char output[100];
6746  int src_len;
6747  const md_info_t *md_info = NULL;
6748 
6749  memset(md_name, 0x00, 100);
6750  memset(src_str, 0x00, 10000);
6751  memset(hash_str, 0x00, 10000);
6752  memset(output, 0x00, 100);
6753 
6754  strncpy( (char *) md_name, "sha512", 100 );
6755  md_info = md_info_from_string(md_name);
6756  fct_chk( md_info != NULL );
6757 
6758  src_len = unhexify( src_str, "8f" );
6759  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6760 
6761  hexify( hash_str, output, md_get_size(md_info) );
6762 
6763  fct_chk( strcmp( (char *) hash_str, "e4cd2d19931b5aad9c920f45f56f6ce34e3d38c6d319a6e11d0588ab8b838576d6ce6d68eea7c830de66e2bd96458bfa7aafbcbec981d4ed040498c3dd95f22a" ) == 0 );
6764  }
6765  FCT_TEST_END();
6766 #endif /* POLARSSL_SHA4_C */
6767 
6768 #ifdef POLARSSL_SHA4_C
6769 
6770  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_3)
6771  {
6772  char md_name[100];
6773  unsigned char src_str[10000];
6774  unsigned char hash_str[10000];
6775  unsigned char output[100];
6776  int src_len;
6777  const md_info_t *md_info = NULL;
6778 
6779  memset(md_name, 0x00, 100);
6780  memset(src_str, 0x00, 10000);
6781  memset(hash_str, 0x00, 10000);
6782  memset(output, 0x00, 100);
6783 
6784  strncpy( (char *) md_name, "sha512", 100 );
6785  md_info = md_info_from_string(md_name);
6786  fct_chk( md_info != NULL );
6787 
6788  src_len = unhexify( src_str, "e724" );
6789  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6790 
6791  hexify( hash_str, output, md_get_size(md_info) );
6792 
6793  fct_chk( strcmp( (char *) hash_str, "7dbb520221a70287b23dbcf62bfc1b73136d858e86266732a7fffa875ecaa2c1b8f673b5c065d360c563a7b9539349f5f59bef8c0c593f9587e3cd50bb26a231" ) == 0 );
6794  }
6795  FCT_TEST_END();
6796 #endif /* POLARSSL_SHA4_C */
6797 
6798 #ifdef POLARSSL_SHA4_C
6799 
6800  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_4)
6801  {
6802  char md_name[100];
6803  unsigned char src_str[10000];
6804  unsigned char hash_str[10000];
6805  unsigned char output[100];
6806  int src_len;
6807  const md_info_t *md_info = NULL;
6808 
6809  memset(md_name, 0x00, 100);
6810  memset(src_str, 0x00, 10000);
6811  memset(hash_str, 0x00, 10000);
6812  memset(output, 0x00, 100);
6813 
6814  strncpy( (char *) md_name, "sha512", 100 );
6815  md_info = md_info_from_string(md_name);
6816  fct_chk( md_info != NULL );
6817 
6818  src_len = unhexify( src_str, "de4c90" );
6819  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6820 
6821  hexify( hash_str, output, md_get_size(md_info) );
6822 
6823  fct_chk( strcmp( (char *) hash_str, "33ce98281045a5c4c9df0363d8196f1d7dfcd5ee46ac89776fd8a4344c12f123a66788af5bd41ceff1941aa5637654b4064c88c14e00465ab79a2fc6c97e1014" ) == 0 );
6824  }
6825  FCT_TEST_END();
6826 #endif /* POLARSSL_SHA4_C */
6827 
6828 #ifdef POLARSSL_SHA4_C
6829 
6830  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_5)
6831  {
6832  char md_name[100];
6833  unsigned char src_str[10000];
6834  unsigned char hash_str[10000];
6835  unsigned char output[100];
6836  int src_len;
6837  const md_info_t *md_info = NULL;
6838 
6839  memset(md_name, 0x00, 100);
6840  memset(src_str, 0x00, 10000);
6841  memset(hash_str, 0x00, 10000);
6842  memset(output, 0x00, 100);
6843 
6844  strncpy( (char *) md_name, "sha512", 100 );
6845  md_info = md_info_from_string(md_name);
6846  fct_chk( md_info != NULL );
6847 
6848  src_len = unhexify( src_str, "a801e94b" );
6849  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6850 
6851  hexify( hash_str, output, md_get_size(md_info) );
6852 
6853  fct_chk( strcmp( (char *) hash_str, "dadb1b5a27f9fece8d86adb2a51879beb1787ff28f4e8ce162cad7fee0f942efcabbf738bc6f797fc7cc79a3a75048cd4c82ca0757a324695bfb19a557e56e2f" ) == 0 );
6854  }
6855  FCT_TEST_END();
6856 #endif /* POLARSSL_SHA4_C */
6857 
6858 #ifdef POLARSSL_SHA4_C
6859 
6860  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_6)
6861  {
6862  char md_name[100];
6863  unsigned char src_str[10000];
6864  unsigned char hash_str[10000];
6865  unsigned char output[100];
6866  int src_len;
6867  const md_info_t *md_info = NULL;
6868 
6869  memset(md_name, 0x00, 100);
6870  memset(src_str, 0x00, 10000);
6871  memset(hash_str, 0x00, 10000);
6872  memset(output, 0x00, 100);
6873 
6874  strncpy( (char *) md_name, "sha512", 100 );
6875  md_info = md_info_from_string(md_name);
6876  fct_chk( md_info != NULL );
6877 
6878  src_len = unhexify( src_str, "94390d3502" );
6879  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6880 
6881  hexify( hash_str, output, md_get_size(md_info) );
6882 
6883  fct_chk( strcmp( (char *) hash_str, "b6175c4c4cccf69e0ce5f0312010886ea6b34d43673f942ae42483f9cbb7da817de4e11b5d58e25a3d9bd721a22cdffe1c40411cc45df1911fa5506129b69297" ) == 0 );
6884  }
6885  FCT_TEST_END();
6886 #endif /* POLARSSL_SHA4_C */
6887 
6888 #ifdef POLARSSL_SHA4_C
6889 
6890  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_7)
6891  {
6892  char md_name[100];
6893  unsigned char src_str[10000];
6894  unsigned char hash_str[10000];
6895  unsigned char output[100];
6896  int src_len;
6897  const md_info_t *md_info = NULL;
6898 
6899  memset(md_name, 0x00, 100);
6900  memset(src_str, 0x00, 10000);
6901  memset(hash_str, 0x00, 10000);
6902  memset(output, 0x00, 100);
6903 
6904  strncpy( (char *) md_name, "sha512", 100 );
6905  md_info = md_info_from_string(md_name);
6906  fct_chk( md_info != NULL );
6907 
6908  src_len = unhexify( src_str, "49297dd63e5f" );
6909  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6910 
6911  hexify( hash_str, output, md_get_size(md_info) );
6912 
6913  fct_chk( strcmp( (char *) hash_str, "1fcc1e6f6870859d11649f5e5336a9cd16329c029baf04d5a6edf257889a2e9522b497dd656bb402da461307c4ee382e2e89380c8e6e6e7697f1e439f650fa94" ) == 0 );
6914  }
6915  FCT_TEST_END();
6916 #endif /* POLARSSL_SHA4_C */
6917 
6918 #ifdef POLARSSL_SHA4_C
6919 
6920  FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_8)
6921  {
6922  char md_name[100];
6923  unsigned char src_str[10000];
6924  unsigned char hash_str[10000];
6925  unsigned char output[100];
6926  int src_len;
6927  const md_info_t *md_info = NULL;
6928 
6929  memset(md_name, 0x00, 100);
6930  memset(src_str, 0x00, 10000);
6931  memset(hash_str, 0x00, 10000);
6932  memset(output, 0x00, 100);
6933 
6934  strncpy( (char *) md_name, "sha512", 100 );
6935  md_info = md_info_from_string(md_name);
6936  fct_chk( md_info != NULL );
6937 
6938  src_len = unhexify( src_str, "990d1ae71a62d7bda9bfdaa1762a68d296eee72a4cd946f287a898fbabc002ea941fd8d4d991030b4d27a637cce501a834bb95eab1b7889a3e784c7968e67cbf552006b206b68f76d9191327524fcc251aeb56af483d10b4e0c6c5e599ee8c0fe4faeca8293844a8547c6a9a90d093f2526873a19ad4a5e776794c68c742fb834793d2dfcb7fea46c63af4b70fd11cb6e41834e72ee40edb067b292a794990c288d5007e73f349fb383af6a756b8301ad6e5e0aa8cd614399bb3a452376b1575afa6bdaeaafc286cb064bb91edef97c632b6c1113d107fa93a0905098a105043c2f05397f702514439a08a9e5ddc196100721d45c8fc17d2ed659376f8a00bd5cb9a0860e26d8a29d8d6aaf52de97e9346033d6db501a35dbbaf97c20b830cd2d18c2532f3a59cc497ee64c0e57d8d060e5069b28d86edf1adcf59144b221ce3ddaef134b3124fbc7dd000240eff0f5f5f41e83cd7f5bb37c9ae21953fe302b0f6e8b68fa91c6ab99265c64b2fd9cd4942be04321bb5d6d71932376c6f2f88e02422ba6a5e2cb765df93fd5dd0728c6abdaf03bce22e0678a544e2c3636f741b6f4447ee58a8fc656b43ef817932176adbfc2e04b2c812c273cd6cbfa4098f0be036a34221fa02643f5ee2e0b38135f2a18ecd2f16ebc45f8eb31b8ab967a1567ee016904188910861ca1fa205c7adaa194b286893ffe2f4fbe0384c2aef72a4522aeafd3ebc71f9db71eeeef86c48394a1c86d5b36c352cc33a0a2c800bc99e62fd65b3a2fd69e0b53996ec13d8ce483ce9319efd9a85acefabdb5342226febb83fd1daf4b24265f50c61c6de74077ef89b6fecf9f29a1f871af1e9f89b2d345cda7499bd45c42fa5d195a1e1a6ba84851889e730da3b2b916e96152ae0c92154b49719841db7e7cc707ba8a5d7b101eb4ac7b629bb327817910fff61580b59aab78182d1a2e33473d05b00b170b29e331870826cfe45af206aa7d0246bbd8566ca7cfb2d3c10bfa1db7dd48dd786036469ce7282093d78b5e1a5b0fc81a54c8ed4ceac1e5305305e78284ac276f5d7862727aff246e17addde50c670028d572cbfc0be2e4f8b2eb28fa68ad7b4c6c2a239c460441bfb5ea049f23b08563b4e47729a59e5986a61a6093dbd54f8c36ebe87edae01f251cb060ad1364ce677d7e8d5a4a4ca966a7241cc360bc2acb280e5f9e9c1b032ad6a180a35e0c5180b9d16d026c865b252098cc1d99ba7375ca31c7702c0d943d5e3dd2f6861fa55bd46d94b67ed3e52eccd8dd06d968e01897d6de97ed3058d91dd" );
6939  fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
6940 
6941  hexify( hash_str, output, md_get_size(md_info) );
6942 
6943  fct_chk( strcmp( (char *) hash_str, "8e4bc6f8b8c60fe4d68c61d9b159c8693c3151c46749af58da228442d927f23359bd6ccd6c2ec8fa3f00a86cecbfa728e1ad60b821ed22fcd309ba91a4138bc9" ) == 0 );
6944  }
6945  FCT_TEST_END();
6946 #endif /* POLARSSL_SHA4_C */
6947 
6948 #ifdef POLARSSL_SHA1_C
6949 
6950  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_1)
6951  {
6952  char md_name[100];
6953  unsigned char src_str[10000];
6954  unsigned char hash_str[10000];
6955  unsigned char output[100];
6956  int src_len;
6957  const md_info_t *md_info = NULL;
6959 
6960  memset(md_name, 0x00, 100);
6961  memset(src_str, 0x00, 10000);
6962  memset(hash_str, 0x00, 10000);
6963  memset(output, 0x00, 100);
6964 
6965  strncpy( (char *) md_name, "sha1", 100 );
6966  md_info = md_info_from_string(md_name);
6967  fct_chk( md_info != NULL );
6968  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
6969 
6970  src_len = unhexify( src_str, "" );
6971 
6972  fct_chk ( 0 == md_starts( &ctx ) );
6973  fct_chk ( ctx.md_ctx != NULL );
6974  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
6975  fct_chk ( 0 == md_finish( &ctx, output ) );
6976  fct_chk ( 0 == md_free_ctx( &ctx ) );
6977 
6978  hexify( hash_str, output, md_get_size(md_info) );
6979 
6980  fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
6981  }
6982  FCT_TEST_END();
6983 #endif /* POLARSSL_SHA1_C */
6984 
6985 #ifdef POLARSSL_SHA1_C
6986 
6987  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_2)
6988  {
6989  char md_name[100];
6990  unsigned char src_str[10000];
6991  unsigned char hash_str[10000];
6992  unsigned char output[100];
6993  int src_len;
6994  const md_info_t *md_info = NULL;
6996 
6997  memset(md_name, 0x00, 100);
6998  memset(src_str, 0x00, 10000);
6999  memset(hash_str, 0x00, 10000);
7000  memset(output, 0x00, 100);
7001 
7002  strncpy( (char *) md_name, "sha1", 100 );
7003  md_info = md_info_from_string(md_name);
7004  fct_chk( md_info != NULL );
7005  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7006 
7007  src_len = unhexify( src_str, "a8" );
7008 
7009  fct_chk ( 0 == md_starts( &ctx ) );
7010  fct_chk ( ctx.md_ctx != NULL );
7011  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7012  fct_chk ( 0 == md_finish( &ctx, output ) );
7013  fct_chk ( 0 == md_free_ctx( &ctx ) );
7014 
7015  hexify( hash_str, output, md_get_size(md_info) );
7016 
7017  fct_chk( strcmp( (char *) hash_str, "99f2aa95e36f95c2acb0eaf23998f030638f3f15" ) == 0 );
7018  }
7019  FCT_TEST_END();
7020 #endif /* POLARSSL_SHA1_C */
7021 
7022 #ifdef POLARSSL_SHA1_C
7023 
7024  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_3)
7025  {
7026  char md_name[100];
7027  unsigned char src_str[10000];
7028  unsigned char hash_str[10000];
7029  unsigned char output[100];
7030  int src_len;
7031  const md_info_t *md_info = NULL;
7033 
7034  memset(md_name, 0x00, 100);
7035  memset(src_str, 0x00, 10000);
7036  memset(hash_str, 0x00, 10000);
7037  memset(output, 0x00, 100);
7038 
7039  strncpy( (char *) md_name, "sha1", 100 );
7040  md_info = md_info_from_string(md_name);
7041  fct_chk( md_info != NULL );
7042  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7043 
7044  src_len = unhexify( src_str, "3000" );
7045 
7046  fct_chk ( 0 == md_starts( &ctx ) );
7047  fct_chk ( ctx.md_ctx != NULL );
7048  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7049  fct_chk ( 0 == md_finish( &ctx, output ) );
7050  fct_chk ( 0 == md_free_ctx( &ctx ) );
7051 
7052  hexify( hash_str, output, md_get_size(md_info) );
7053 
7054  fct_chk( strcmp( (char *) hash_str, "f944dcd635f9801f7ac90a407fbc479964dec024" ) == 0 );
7055  }
7056  FCT_TEST_END();
7057 #endif /* POLARSSL_SHA1_C */
7058 
7059 #ifdef POLARSSL_SHA1_C
7060 
7061  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_4)
7062  {
7063  char md_name[100];
7064  unsigned char src_str[10000];
7065  unsigned char hash_str[10000];
7066  unsigned char output[100];
7067  int src_len;
7068  const md_info_t *md_info = NULL;
7070 
7071  memset(md_name, 0x00, 100);
7072  memset(src_str, 0x00, 10000);
7073  memset(hash_str, 0x00, 10000);
7074  memset(output, 0x00, 100);
7075 
7076  strncpy( (char *) md_name, "sha1", 100 );
7077  md_info = md_info_from_string(md_name);
7078  fct_chk( md_info != NULL );
7079  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7080 
7081  src_len = unhexify( src_str, "42749e" );
7082 
7083  fct_chk ( 0 == md_starts( &ctx ) );
7084  fct_chk ( ctx.md_ctx != NULL );
7085  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7086  fct_chk ( 0 == md_finish( &ctx, output ) );
7087  fct_chk ( 0 == md_free_ctx( &ctx ) );
7088 
7089  hexify( hash_str, output, md_get_size(md_info) );
7090 
7091  fct_chk( strcmp( (char *) hash_str, "a444319e9b6cc1e8464c511ec0969c37d6bb2619" ) == 0 );
7092  }
7093  FCT_TEST_END();
7094 #endif /* POLARSSL_SHA1_C */
7095 
7096 #ifdef POLARSSL_SHA1_C
7097 
7098  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_5)
7099  {
7100  char md_name[100];
7101  unsigned char src_str[10000];
7102  unsigned char hash_str[10000];
7103  unsigned char output[100];
7104  int src_len;
7105  const md_info_t *md_info = NULL;
7107 
7108  memset(md_name, 0x00, 100);
7109  memset(src_str, 0x00, 10000);
7110  memset(hash_str, 0x00, 10000);
7111  memset(output, 0x00, 100);
7112 
7113  strncpy( (char *) md_name, "sha1", 100 );
7114  md_info = md_info_from_string(md_name);
7115  fct_chk( md_info != NULL );
7116  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7117 
7118  src_len = unhexify( src_str, "9fc3fe08" );
7119 
7120  fct_chk ( 0 == md_starts( &ctx ) );
7121  fct_chk ( ctx.md_ctx != NULL );
7122  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7123  fct_chk ( 0 == md_finish( &ctx, output ) );
7124  fct_chk ( 0 == md_free_ctx( &ctx ) );
7125 
7126  hexify( hash_str, output, md_get_size(md_info) );
7127 
7128  fct_chk( strcmp( (char *) hash_str, "16a0ff84fcc156fd5d3ca3a744f20a232d172253" ) == 0 );
7129  }
7130  FCT_TEST_END();
7131 #endif /* POLARSSL_SHA1_C */
7132 
7133 #ifdef POLARSSL_SHA1_C
7134 
7135  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_6)
7136  {
7137  char md_name[100];
7138  unsigned char src_str[10000];
7139  unsigned char hash_str[10000];
7140  unsigned char output[100];
7141  int src_len;
7142  const md_info_t *md_info = NULL;
7144 
7145  memset(md_name, 0x00, 100);
7146  memset(src_str, 0x00, 10000);
7147  memset(hash_str, 0x00, 10000);
7148  memset(output, 0x00, 100);
7149 
7150  strncpy( (char *) md_name, "sha1", 100 );
7151  md_info = md_info_from_string(md_name);
7152  fct_chk( md_info != NULL );
7153  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7154 
7155  src_len = unhexify( src_str, "b5c1c6f1af" );
7156 
7157  fct_chk ( 0 == md_starts( &ctx ) );
7158  fct_chk ( ctx.md_ctx != NULL );
7159  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7160  fct_chk ( 0 == md_finish( &ctx, output ) );
7161  fct_chk ( 0 == md_free_ctx( &ctx ) );
7162 
7163  hexify( hash_str, output, md_get_size(md_info) );
7164 
7165  fct_chk( strcmp( (char *) hash_str, "fec9deebfcdedaf66dda525e1be43597a73a1f93" ) == 0 );
7166  }
7167  FCT_TEST_END();
7168 #endif /* POLARSSL_SHA1_C */
7169 
7170 #ifdef POLARSSL_SHA1_C
7171 
7172  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_7)
7173  {
7174  char md_name[100];
7175  unsigned char src_str[10000];
7176  unsigned char hash_str[10000];
7177  unsigned char output[100];
7178  int src_len;
7179  const md_info_t *md_info = NULL;
7181 
7182  memset(md_name, 0x00, 100);
7183  memset(src_str, 0x00, 10000);
7184  memset(hash_str, 0x00, 10000);
7185  memset(output, 0x00, 100);
7186 
7187  strncpy( (char *) md_name, "sha1", 100 );
7188  md_info = md_info_from_string(md_name);
7189  fct_chk( md_info != NULL );
7190  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7191 
7192  src_len = unhexify( src_str, "ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b2548035185813e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a5305da4b1b737fce7cd21c0eb7728d08235a9011" );
7193 
7194  fct_chk ( 0 == md_starts( &ctx ) );
7195  fct_chk ( ctx.md_ctx != NULL );
7196  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7197  fct_chk ( 0 == md_finish( &ctx, output ) );
7198  fct_chk ( 0 == md_free_ctx( &ctx ) );
7199 
7200  hexify( hash_str, output, md_get_size(md_info) );
7201 
7202  fct_chk( strcmp( (char *) hash_str, "970111c4e77bcc88cc20459c02b69b4aa8f58217" ) == 0 );
7203  }
7204  FCT_TEST_END();
7205 #endif /* POLARSSL_SHA1_C */
7206 
7207 #ifdef POLARSSL_SHA1_C
7208 
7209  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_8)
7210  {
7211  char md_name[100];
7212  unsigned char src_str[10000];
7213  unsigned char hash_str[10000];
7214  unsigned char output[100];
7215  int src_len;
7216  const md_info_t *md_info = NULL;
7218 
7219  memset(md_name, 0x00, 100);
7220  memset(src_str, 0x00, 10000);
7221  memset(hash_str, 0x00, 10000);
7222  memset(output, 0x00, 100);
7223 
7224  strncpy( (char *) md_name, "sha1", 100 );
7225  md_info = md_info_from_string(md_name);
7226  fct_chk( md_info != NULL );
7227  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7228 
7229  src_len = unhexify( src_str, "5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652afe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba553d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38ae485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77414197422be3d36a6080" );
7230 
7231  fct_chk ( 0 == md_starts( &ctx ) );
7232  fct_chk ( ctx.md_ctx != NULL );
7233  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7234  fct_chk ( 0 == md_finish( &ctx, output ) );
7235  fct_chk ( 0 == md_free_ctx( &ctx ) );
7236 
7237  hexify( hash_str, output, md_get_size(md_info) );
7238 
7239  fct_chk( strcmp( (char *) hash_str, "0423dc76a8791107d14e13f5265b343f24cc0f19" ) == 0 );
7240  }
7241  FCT_TEST_END();
7242 #endif /* POLARSSL_SHA1_C */
7243 
7244 #ifdef POLARSSL_SHA1_C
7245 
7246  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_9)
7247  {
7248  char md_name[100];
7249  unsigned char src_str[10000];
7250  unsigned char hash_str[10000];
7251  unsigned char output[100];
7252  int src_len;
7253  const md_info_t *md_info = NULL;
7255 
7256  memset(md_name, 0x00, 100);
7257  memset(src_str, 0x00, 10000);
7258  memset(hash_str, 0x00, 10000);
7259  memset(output, 0x00, 100);
7260 
7261  strncpy( (char *) md_name, "sha1", 100 );
7262  md_info = md_info_from_string(md_name);
7263  fct_chk( md_info != NULL );
7264  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7265 
7266  src_len = unhexify( src_str, "0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a007ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec428c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30baa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff57800e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee71366afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32beaea" );
7267 
7268  fct_chk ( 0 == md_starts( &ctx ) );
7269  fct_chk ( ctx.md_ctx != NULL );
7270  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7271  fct_chk ( 0 == md_finish( &ctx, output ) );
7272  fct_chk ( 0 == md_free_ctx( &ctx ) );
7273 
7274  hexify( hash_str, output, md_get_size(md_info) );
7275 
7276  fct_chk( strcmp( (char *) hash_str, "6692a71d73e00f27df976bc56df4970650d90e45" ) == 0 );
7277  }
7278  FCT_TEST_END();
7279 #endif /* POLARSSL_SHA1_C */
7280 
7281 #ifdef POLARSSL_SHA1_C
7282 
7283  FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_10)
7284  {
7285  char md_name[100];
7286  unsigned char src_str[10000];
7287  unsigned char hash_str[10000];
7288  unsigned char output[100];
7289  int src_len;
7290  const md_info_t *md_info = NULL;
7292 
7293  memset(md_name, 0x00, 100);
7294  memset(src_str, 0x00, 10000);
7295  memset(hash_str, 0x00, 10000);
7296  memset(output, 0x00, 100);
7297 
7298  strncpy( (char *) md_name, "sha1", 100 );
7299  md_info = md_info_from_string(md_name);
7300  fct_chk( md_info != NULL );
7301  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7302 
7303  src_len = unhexify( src_str, "8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff" );
7304 
7305  fct_chk ( 0 == md_starts( &ctx ) );
7306  fct_chk ( ctx.md_ctx != NULL );
7307  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7308  fct_chk ( 0 == md_finish( &ctx, output ) );
7309  fct_chk ( 0 == md_free_ctx( &ctx ) );
7310 
7311  hexify( hash_str, output, md_get_size(md_info) );
7312 
7313  fct_chk( strcmp( (char *) hash_str, "11863b483809ef88413ca9b0084ac4a5390640af" ) == 0 );
7314  }
7315  FCT_TEST_END();
7316 #endif /* POLARSSL_SHA1_C */
7317 
7318 #ifdef POLARSSL_SHA2_C
7319 
7320  FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_1)
7321  {
7322  char md_name[100];
7323  unsigned char src_str[10000];
7324  unsigned char hash_str[10000];
7325  unsigned char output[100];
7326  int src_len;
7327  const md_info_t *md_info = NULL;
7329 
7330  memset(md_name, 0x00, 100);
7331  memset(src_str, 0x00, 10000);
7332  memset(hash_str, 0x00, 10000);
7333  memset(output, 0x00, 100);
7334 
7335  strncpy( (char *) md_name, "sha224", 100 );
7336  md_info = md_info_from_string(md_name);
7337  fct_chk( md_info != NULL );
7338  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7339 
7340  src_len = unhexify( src_str, "" );
7341 
7342  fct_chk ( 0 == md_starts( &ctx ) );
7343  fct_chk ( ctx.md_ctx != NULL );
7344  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7345  fct_chk ( 0 == md_finish( &ctx, output ) );
7346  fct_chk ( 0 == md_free_ctx( &ctx ) );
7347 
7348  hexify( hash_str, output, md_get_size(md_info) );
7349 
7350  fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
7351  }
7352  FCT_TEST_END();
7353 #endif /* POLARSSL_SHA2_C */
7354 
7355 #ifdef POLARSSL_SHA2_C
7356 
7357  FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_2)
7358  {
7359  char md_name[100];
7360  unsigned char src_str[10000];
7361  unsigned char hash_str[10000];
7362  unsigned char output[100];
7363  int src_len;
7364  const md_info_t *md_info = NULL;
7366 
7367  memset(md_name, 0x00, 100);
7368  memset(src_str, 0x00, 10000);
7369  memset(hash_str, 0x00, 10000);
7370  memset(output, 0x00, 100);
7371 
7372  strncpy( (char *) md_name, "sha224", 100 );
7373  md_info = md_info_from_string(md_name);
7374  fct_chk( md_info != NULL );
7375  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7376 
7377  src_len = unhexify( src_str, "ff" );
7378 
7379  fct_chk ( 0 == md_starts( &ctx ) );
7380  fct_chk ( ctx.md_ctx != NULL );
7381  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7382  fct_chk ( 0 == md_finish( &ctx, output ) );
7383  fct_chk ( 0 == md_free_ctx( &ctx ) );
7384 
7385  hexify( hash_str, output, md_get_size(md_info) );
7386 
7387  fct_chk( strcmp( (char *) hash_str, "e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5" ) == 0 );
7388  }
7389  FCT_TEST_END();
7390 #endif /* POLARSSL_SHA2_C */
7391 
7392 #ifdef POLARSSL_SHA2_C
7393 
7394  FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_3)
7395  {
7396  char md_name[100];
7397  unsigned char src_str[10000];
7398  unsigned char hash_str[10000];
7399  unsigned char output[100];
7400  int src_len;
7401  const md_info_t *md_info = NULL;
7403 
7404  memset(md_name, 0x00, 100);
7405  memset(src_str, 0x00, 10000);
7406  memset(hash_str, 0x00, 10000);
7407  memset(output, 0x00, 100);
7408 
7409  strncpy( (char *) md_name, "sha224", 100 );
7410  md_info = md_info_from_string(md_name);
7411  fct_chk( md_info != NULL );
7412  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7413 
7414  src_len = unhexify( src_str, "984c" );
7415 
7416  fct_chk ( 0 == md_starts( &ctx ) );
7417  fct_chk ( ctx.md_ctx != NULL );
7418  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7419  fct_chk ( 0 == md_finish( &ctx, output ) );
7420  fct_chk ( 0 == md_free_ctx( &ctx ) );
7421 
7422  hexify( hash_str, output, md_get_size(md_info) );
7423 
7424  fct_chk( strcmp( (char *) hash_str, "2fa9df9157d9e027cfbc4c6a9df32e1adc0cbe2328ec2a63c5ae934e" ) == 0 );
7425  }
7426  FCT_TEST_END();
7427 #endif /* POLARSSL_SHA2_C */
7428 
7429 #ifdef POLARSSL_SHA2_C
7430 
7431  FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_4)
7432  {
7433  char md_name[100];
7434  unsigned char src_str[10000];
7435  unsigned char hash_str[10000];
7436  unsigned char output[100];
7437  int src_len;
7438  const md_info_t *md_info = NULL;
7440 
7441  memset(md_name, 0x00, 100);
7442  memset(src_str, 0x00, 10000);
7443  memset(hash_str, 0x00, 10000);
7444  memset(output, 0x00, 100);
7445 
7446  strncpy( (char *) md_name, "sha224", 100 );
7447  md_info = md_info_from_string(md_name);
7448  fct_chk( md_info != NULL );
7449  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7450 
7451  src_len = unhexify( src_str, "50efd0" );
7452 
7453  fct_chk ( 0 == md_starts( &ctx ) );
7454  fct_chk ( ctx.md_ctx != NULL );
7455  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7456  fct_chk ( 0 == md_finish( &ctx, output ) );
7457  fct_chk ( 0 == md_free_ctx( &ctx ) );
7458 
7459  hexify( hash_str, output, md_get_size(md_info) );
7460 
7461  fct_chk( strcmp( (char *) hash_str, "b5a9820413c2bf8211fbbf5df1337043b32fa4eafaf61a0c8e9ccede" ) == 0 );
7462  }
7463  FCT_TEST_END();
7464 #endif /* POLARSSL_SHA2_C */
7465 
7466 #ifdef POLARSSL_SHA2_C
7467 
7468  FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_5)
7469  {
7470  char md_name[100];
7471  unsigned char src_str[10000];
7472  unsigned char hash_str[10000];
7473  unsigned char output[100];
7474  int src_len;
7475  const md_info_t *md_info = NULL;
7477 
7478  memset(md_name, 0x00, 100);
7479  memset(src_str, 0x00, 10000);
7480  memset(hash_str, 0x00, 10000);
7481  memset(output, 0x00, 100);
7482 
7483  strncpy( (char *) md_name, "sha224", 100 );
7484  md_info = md_info_from_string(md_name);
7485  fct_chk( md_info != NULL );
7486  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7487 
7488  src_len = unhexify( src_str, "e5e09924" );
7489 
7490  fct_chk ( 0 == md_starts( &ctx ) );
7491  fct_chk ( ctx.md_ctx != NULL );
7492  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7493  fct_chk ( 0 == md_finish( &ctx, output ) );
7494  fct_chk ( 0 == md_free_ctx( &ctx ) );
7495 
7496  hexify( hash_str, output, md_get_size(md_info) );
7497 
7498  fct_chk( strcmp( (char *) hash_str, "fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d" ) == 0 );
7499  }
7500  FCT_TEST_END();
7501 #endif /* POLARSSL_SHA2_C */
7502 
7503 #ifdef POLARSSL_SHA2_C
7504 
7505  FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_6)
7506  {
7507  char md_name[100];
7508  unsigned char src_str[10000];
7509  unsigned char hash_str[10000];
7510  unsigned char output[100];
7511  int src_len;
7512  const md_info_t *md_info = NULL;
7514 
7515  memset(md_name, 0x00, 100);
7516  memset(src_str, 0x00, 10000);
7517  memset(hash_str, 0x00, 10000);
7518  memset(output, 0x00, 100);
7519 
7520  strncpy( (char *) md_name, "sha224", 100 );
7521  md_info = md_info_from_string(md_name);
7522  fct_chk( md_info != NULL );
7523  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7524 
7525  src_len = unhexify( src_str, "21ebecb914" );
7526 
7527  fct_chk ( 0 == md_starts( &ctx ) );
7528  fct_chk ( ctx.md_ctx != NULL );
7529  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7530  fct_chk ( 0 == md_finish( &ctx, output ) );
7531  fct_chk ( 0 == md_free_ctx( &ctx ) );
7532 
7533  hexify( hash_str, output, md_get_size(md_info) );
7534 
7535  fct_chk( strcmp( (char *) hash_str, "78f4a71c21c694499ce1c7866611b14ace70d905012c356323c7c713" ) == 0 );
7536  }
7537  FCT_TEST_END();
7538 #endif /* POLARSSL_SHA2_C */
7539 
7540 #ifdef POLARSSL_SHA2_C
7541 
7542  FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_7)
7543  {
7544  char md_name[100];
7545  unsigned char src_str[10000];
7546  unsigned char hash_str[10000];
7547  unsigned char output[100];
7548  int src_len;
7549  const md_info_t *md_info = NULL;
7551 
7552  memset(md_name, 0x00, 100);
7553  memset(src_str, 0x00, 10000);
7554  memset(hash_str, 0x00, 10000);
7555  memset(output, 0x00, 100);
7556 
7557  strncpy( (char *) md_name, "sha224", 100 );
7558  md_info = md_info_from_string(md_name);
7559  fct_chk( md_info != NULL );
7560  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7561 
7562  src_len = unhexify( src_str, "fc488947c1a7a589726b15436b4f3d9556262f98fc6422fc5cdf20f0fad7fe427a3491c86d101ffe6b7514f06268f65b2d269b0f69ad9a97847eff1c16a2438775eb7be6847ccf11cb8b2e8dcd6640b095b49c0693fe3cf4a66e2d9b7ad68bff14f3ad69abf49d0aba36cbe0535202deb6599a47225ef05beb351335cd7bc0f480d691198c7e71305ffd53b39d33242bb79cfd98bfd69e137b5d18b2b89ac9ace01c8dbdcf2533cce3682ecc52118de0c1062ec2126c2e657d6ea3d9e2398e705d4b0b1f1ceecb266dffc4f31bf42744fb1e938dc22a889919ee1e73f463f7871fed720519e32186264b7ef2a0e5d9a18e6c95c0781894f77967f048951dec3b4d892a38710b1e3436d3c29088eb8b3da1789c25db3d3bc6c26081206e7155d210a89b80ca6ea877c41ff9947c0f25625dcb118294a163501f6239c326661a958fd12da4cd15a899f8b88cc723589056eaec5aa04a4cf5dbb6f480f9660423ccf38c486e210707e0fb25e1f126ceb2616f63e147a647dab0af9ebe89d65458bf636154a46e4cab95f5ee62da2c7974cd14b90d3e4f99f81733e85b3c1d5da2b508d9b90f5eed7eff0d9c7649de62bee00375454fee4a39576a5bbfdae428e7f8097bdf7797f167686cb68407e49079e4611ff3402b6384ba7b7e522bd2bb11ce8fd02ea4c1604d163ac4f6dde50b8b1f593f7edaadeac0868ed97df690200680c25f0f5d85431a529e4f339089dcdeda105e4ee51dead704cdf5a605c55fb055c9b0e86b8ba1b564c0dea3eb790a595cb103cb292268b07c5e59371e1a7ef597cd4b22977a820694c9f9aeb55d9de3ef62b75d6e656e3336698d960a3787bf8cf5b926a7faeef52ae128bcb5dc9e66d94b016c7b8e034879171a2d91c381f57e6a815b63b5ee6a6d2ff435b49f14c963966960194430d78f8f87627a67757fb3532b289550894da6dce4817a4e07f4d56877a1102ffcc8befa5c9f8fca6a4574d93ff70376c8861e0f8108cf907fce77ecb49728f86f034f80224b9695682e0824462f76cdb1fd1af151337b0d85419047a7aa284791718a4860cd586f7824b95bc837b6fd4f9be5aade68456e20356aa4d943dac36bf8b67b9e8f9d01a00fcda74b798bafa746c661b010f75b59904b29d0c8041504811c4065f82cf2ead58d2f595cbd8bc3e7043f4d94577b373b7cfe16a36fe564f505c03b70cfeb5e5f411c79481338aa67e86b3f5a2e77c21e454c333ae3da943ab723ab5f4c940395319534a5575f64acba0d0ecc43f60221ed3badf7289c9b3a7b903a2d6c94e15fa4c310dc4fa7faa0c24f405160a1002dbef20e4105d481db982f7243f79400a6e4cd9753c4b9732a47575f504b20c328fe9add7f432a4f075829da07b53b695037dc51737d3cd731934df333cd1a53fcf65aa31baa450ca501a6fae26e322347e618c5a444d92e9fec5a8261ae38b98fee5be77c02cec09ddccd5b3de92036" );
7563 
7564  fct_chk ( 0 == md_starts( &ctx ) );
7565  fct_chk ( ctx.md_ctx != NULL );
7566  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7567  fct_chk ( 0 == md_finish( &ctx, output ) );
7568  fct_chk ( 0 == md_free_ctx( &ctx ) );
7569 
7570  hexify( hash_str, output, md_get_size(md_info) );
7571 
7572  fct_chk( strcmp( (char *) hash_str, "1302149d1e197c41813b054c942329d420e366530f5517b470e964fe" ) == 0 );
7573  }
7574  FCT_TEST_END();
7575 #endif /* POLARSSL_SHA2_C */
7576 
7577 #ifdef POLARSSL_SHA2_C
7578 
7579  FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_1)
7580  {
7581  char md_name[100];
7582  unsigned char src_str[10000];
7583  unsigned char hash_str[10000];
7584  unsigned char output[100];
7585  int src_len;
7586  const md_info_t *md_info = NULL;
7588 
7589  memset(md_name, 0x00, 100);
7590  memset(src_str, 0x00, 10000);
7591  memset(hash_str, 0x00, 10000);
7592  memset(output, 0x00, 100);
7593 
7594  strncpy( (char *) md_name, "sha256", 100 );
7595  md_info = md_info_from_string(md_name);
7596  fct_chk( md_info != NULL );
7597  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7598 
7599  src_len = unhexify( src_str, "" );
7600 
7601  fct_chk ( 0 == md_starts( &ctx ) );
7602  fct_chk ( ctx.md_ctx != NULL );
7603  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7604  fct_chk ( 0 == md_finish( &ctx, output ) );
7605  fct_chk ( 0 == md_free_ctx( &ctx ) );
7606 
7607  hexify( hash_str, output, md_get_size(md_info) );
7608 
7609  fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
7610  }
7611  FCT_TEST_END();
7612 #endif /* POLARSSL_SHA2_C */
7613 
7614 #ifdef POLARSSL_SHA2_C
7615 
7616  FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_2)
7617  {
7618  char md_name[100];
7619  unsigned char src_str[10000];
7620  unsigned char hash_str[10000];
7621  unsigned char output[100];
7622  int src_len;
7623  const md_info_t *md_info = NULL;
7625 
7626  memset(md_name, 0x00, 100);
7627  memset(src_str, 0x00, 10000);
7628  memset(hash_str, 0x00, 10000);
7629  memset(output, 0x00, 100);
7630 
7631  strncpy( (char *) md_name, "sha256", 100 );
7632  md_info = md_info_from_string(md_name);
7633  fct_chk( md_info != NULL );
7634  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7635 
7636  src_len = unhexify( src_str, "bd" );
7637 
7638  fct_chk ( 0 == md_starts( &ctx ) );
7639  fct_chk ( ctx.md_ctx != NULL );
7640  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7641  fct_chk ( 0 == md_finish( &ctx, output ) );
7642  fct_chk ( 0 == md_free_ctx( &ctx ) );
7643 
7644  hexify( hash_str, output, md_get_size(md_info) );
7645 
7646  fct_chk( strcmp( (char *) hash_str, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b" ) == 0 );
7647  }
7648  FCT_TEST_END();
7649 #endif /* POLARSSL_SHA2_C */
7650 
7651 #ifdef POLARSSL_SHA2_C
7652 
7653  FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_3)
7654  {
7655  char md_name[100];
7656  unsigned char src_str[10000];
7657  unsigned char hash_str[10000];
7658  unsigned char output[100];
7659  int src_len;
7660  const md_info_t *md_info = NULL;
7662 
7663  memset(md_name, 0x00, 100);
7664  memset(src_str, 0x00, 10000);
7665  memset(hash_str, 0x00, 10000);
7666  memset(output, 0x00, 100);
7667 
7668  strncpy( (char *) md_name, "sha256", 100 );
7669  md_info = md_info_from_string(md_name);
7670  fct_chk( md_info != NULL );
7671  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7672 
7673  src_len = unhexify( src_str, "5fd4" );
7674 
7675  fct_chk ( 0 == md_starts( &ctx ) );
7676  fct_chk ( ctx.md_ctx != NULL );
7677  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7678  fct_chk ( 0 == md_finish( &ctx, output ) );
7679  fct_chk ( 0 == md_free_ctx( &ctx ) );
7680 
7681  hexify( hash_str, output, md_get_size(md_info) );
7682 
7683  fct_chk( strcmp( (char *) hash_str, "7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788" ) == 0 );
7684  }
7685  FCT_TEST_END();
7686 #endif /* POLARSSL_SHA2_C */
7687 
7688 #ifdef POLARSSL_SHA2_C
7689 
7690  FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_4)
7691  {
7692  char md_name[100];
7693  unsigned char src_str[10000];
7694  unsigned char hash_str[10000];
7695  unsigned char output[100];
7696  int src_len;
7697  const md_info_t *md_info = NULL;
7699 
7700  memset(md_name, 0x00, 100);
7701  memset(src_str, 0x00, 10000);
7702  memset(hash_str, 0x00, 10000);
7703  memset(output, 0x00, 100);
7704 
7705  strncpy( (char *) md_name, "sha256", 100 );
7706  md_info = md_info_from_string(md_name);
7707  fct_chk( md_info != NULL );
7708  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7709 
7710  src_len = unhexify( src_str, "b0bd69" );
7711 
7712  fct_chk ( 0 == md_starts( &ctx ) );
7713  fct_chk ( ctx.md_ctx != NULL );
7714  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7715  fct_chk ( 0 == md_finish( &ctx, output ) );
7716  fct_chk ( 0 == md_free_ctx( &ctx ) );
7717 
7718  hexify( hash_str, output, md_get_size(md_info) );
7719 
7720  fct_chk( strcmp( (char *) hash_str, "4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803" ) == 0 );
7721  }
7722  FCT_TEST_END();
7723 #endif /* POLARSSL_SHA2_C */
7724 
7725 #ifdef POLARSSL_SHA2_C
7726 
7727  FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_5)
7728  {
7729  char md_name[100];
7730  unsigned char src_str[10000];
7731  unsigned char hash_str[10000];
7732  unsigned char output[100];
7733  int src_len;
7734  const md_info_t *md_info = NULL;
7736 
7737  memset(md_name, 0x00, 100);
7738  memset(src_str, 0x00, 10000);
7739  memset(hash_str, 0x00, 10000);
7740  memset(output, 0x00, 100);
7741 
7742  strncpy( (char *) md_name, "sha256", 100 );
7743  md_info = md_info_from_string(md_name);
7744  fct_chk( md_info != NULL );
7745  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7746 
7747  src_len = unhexify( src_str, "c98c8e55" );
7748 
7749  fct_chk ( 0 == md_starts( &ctx ) );
7750  fct_chk ( ctx.md_ctx != NULL );
7751  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7752  fct_chk ( 0 == md_finish( &ctx, output ) );
7753  fct_chk ( 0 == md_free_ctx( &ctx ) );
7754 
7755  hexify( hash_str, output, md_get_size(md_info) );
7756 
7757  fct_chk( strcmp( (char *) hash_str, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504" ) == 0 );
7758  }
7759  FCT_TEST_END();
7760 #endif /* POLARSSL_SHA2_C */
7761 
7762 #ifdef POLARSSL_SHA2_C
7763 
7764  FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_6)
7765  {
7766  char md_name[100];
7767  unsigned char src_str[10000];
7768  unsigned char hash_str[10000];
7769  unsigned char output[100];
7770  int src_len;
7771  const md_info_t *md_info = NULL;
7773 
7774  memset(md_name, 0x00, 100);
7775  memset(src_str, 0x00, 10000);
7776  memset(hash_str, 0x00, 10000);
7777  memset(output, 0x00, 100);
7778 
7779  strncpy( (char *) md_name, "sha256", 100 );
7780  md_info = md_info_from_string(md_name);
7781  fct_chk( md_info != NULL );
7782  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7783 
7784  src_len = unhexify( src_str, "81a723d966" );
7785 
7786  fct_chk ( 0 == md_starts( &ctx ) );
7787  fct_chk ( ctx.md_ctx != NULL );
7788  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7789  fct_chk ( 0 == md_finish( &ctx, output ) );
7790  fct_chk ( 0 == md_free_ctx( &ctx ) );
7791 
7792  hexify( hash_str, output, md_get_size(md_info) );
7793 
7794  fct_chk( strcmp( (char *) hash_str, "7516fb8bb11350df2bf386bc3c33bd0f52cb4c67c6e4745e0488e62c2aea2605" ) == 0 );
7795  }
7796  FCT_TEST_END();
7797 #endif /* POLARSSL_SHA2_C */
7798 
7799 #ifdef POLARSSL_SHA2_C
7800 
7801  FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_7)
7802  {
7803  char md_name[100];
7804  unsigned char src_str[10000];
7805  unsigned char hash_str[10000];
7806  unsigned char output[100];
7807  int src_len;
7808  const md_info_t *md_info = NULL;
7810 
7811  memset(md_name, 0x00, 100);
7812  memset(src_str, 0x00, 10000);
7813  memset(hash_str, 0x00, 10000);
7814  memset(output, 0x00, 100);
7815 
7816  strncpy( (char *) md_name, "sha256", 100 );
7817  md_info = md_info_from_string(md_name);
7818  fct_chk( md_info != NULL );
7819  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7820 
7821  src_len = unhexify( src_str, "8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e" );
7822 
7823  fct_chk ( 0 == md_starts( &ctx ) );
7824  fct_chk ( ctx.md_ctx != NULL );
7825  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7826  fct_chk ( 0 == md_finish( &ctx, output ) );
7827  fct_chk ( 0 == md_free_ctx( &ctx ) );
7828 
7829  hexify( hash_str, output, md_get_size(md_info) );
7830 
7831  fct_chk( strcmp( (char *) hash_str, "4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e" ) == 0 );
7832  }
7833  FCT_TEST_END();
7834 #endif /* POLARSSL_SHA2_C */
7835 
7836 #ifdef POLARSSL_SHA4_C
7837 
7838  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_1)
7839  {
7840  char md_name[100];
7841  unsigned char src_str[10000];
7842  unsigned char hash_str[10000];
7843  unsigned char output[100];
7844  int src_len;
7845  const md_info_t *md_info = NULL;
7847 
7848  memset(md_name, 0x00, 100);
7849  memset(src_str, 0x00, 10000);
7850  memset(hash_str, 0x00, 10000);
7851  memset(output, 0x00, 100);
7852 
7853  strncpy( (char *) md_name, "sha384", 100 );
7854  md_info = md_info_from_string(md_name);
7855  fct_chk( md_info != NULL );
7856  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7857 
7858  src_len = unhexify( src_str, "" );
7859 
7860  fct_chk ( 0 == md_starts( &ctx ) );
7861  fct_chk ( ctx.md_ctx != NULL );
7862  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7863  fct_chk ( 0 == md_finish( &ctx, output ) );
7864  fct_chk ( 0 == md_free_ctx( &ctx ) );
7865 
7866  hexify( hash_str, output, md_get_size(md_info) );
7867 
7868  fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
7869  }
7870  FCT_TEST_END();
7871 #endif /* POLARSSL_SHA4_C */
7872 
7873 #ifdef POLARSSL_SHA4_C
7874 
7875  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_2)
7876  {
7877  char md_name[100];
7878  unsigned char src_str[10000];
7879  unsigned char hash_str[10000];
7880  unsigned char output[100];
7881  int src_len;
7882  const md_info_t *md_info = NULL;
7884 
7885  memset(md_name, 0x00, 100);
7886  memset(src_str, 0x00, 10000);
7887  memset(hash_str, 0x00, 10000);
7888  memset(output, 0x00, 100);
7889 
7890  strncpy( (char *) md_name, "sha384", 100 );
7891  md_info = md_info_from_string(md_name);
7892  fct_chk( md_info != NULL );
7893  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7894 
7895  src_len = unhexify( src_str, "ab" );
7896 
7897  fct_chk ( 0 == md_starts( &ctx ) );
7898  fct_chk ( ctx.md_ctx != NULL );
7899  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7900  fct_chk ( 0 == md_finish( &ctx, output ) );
7901  fct_chk ( 0 == md_free_ctx( &ctx ) );
7902 
7903  hexify( hash_str, output, md_get_size(md_info) );
7904 
7905  fct_chk( strcmp( (char *) hash_str, "fb94d5be118865f6fcbc978b825da82cff188faec2f66cb84b2537d74b4938469854b0ca89e66fa2e182834736629f3d" ) == 0 );
7906  }
7907  FCT_TEST_END();
7908 #endif /* POLARSSL_SHA4_C */
7909 
7910 #ifdef POLARSSL_SHA4_C
7911 
7912  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_3)
7913  {
7914  char md_name[100];
7915  unsigned char src_str[10000];
7916  unsigned char hash_str[10000];
7917  unsigned char output[100];
7918  int src_len;
7919  const md_info_t *md_info = NULL;
7921 
7922  memset(md_name, 0x00, 100);
7923  memset(src_str, 0x00, 10000);
7924  memset(hash_str, 0x00, 10000);
7925  memset(output, 0x00, 100);
7926 
7927  strncpy( (char *) md_name, "sha384", 100 );
7928  md_info = md_info_from_string(md_name);
7929  fct_chk( md_info != NULL );
7930  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7931 
7932  src_len = unhexify( src_str, "7c27" );
7933 
7934  fct_chk ( 0 == md_starts( &ctx ) );
7935  fct_chk ( ctx.md_ctx != NULL );
7936  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7937  fct_chk ( 0 == md_finish( &ctx, output ) );
7938  fct_chk ( 0 == md_free_ctx( &ctx ) );
7939 
7940  hexify( hash_str, output, md_get_size(md_info) );
7941 
7942  fct_chk( strcmp( (char *) hash_str, "3d80be467df86d63abb9ea1d3f9cb39cd19890e7f2c53a6200bedc5006842b35e820dc4e0ca90ca9b97ab23ef07080fc" ) == 0 );
7943  }
7944  FCT_TEST_END();
7945 #endif /* POLARSSL_SHA4_C */
7946 
7947 #ifdef POLARSSL_SHA4_C
7948 
7949  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_4)
7950  {
7951  char md_name[100];
7952  unsigned char src_str[10000];
7953  unsigned char hash_str[10000];
7954  unsigned char output[100];
7955  int src_len;
7956  const md_info_t *md_info = NULL;
7958 
7959  memset(md_name, 0x00, 100);
7960  memset(src_str, 0x00, 10000);
7961  memset(hash_str, 0x00, 10000);
7962  memset(output, 0x00, 100);
7963 
7964  strncpy( (char *) md_name, "sha384", 100 );
7965  md_info = md_info_from_string(md_name);
7966  fct_chk( md_info != NULL );
7967  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
7968 
7969  src_len = unhexify( src_str, "31f5ca" );
7970 
7971  fct_chk ( 0 == md_starts( &ctx ) );
7972  fct_chk ( ctx.md_ctx != NULL );
7973  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
7974  fct_chk ( 0 == md_finish( &ctx, output ) );
7975  fct_chk ( 0 == md_free_ctx( &ctx ) );
7976 
7977  hexify( hash_str, output, md_get_size(md_info) );
7978 
7979  fct_chk( strcmp( (char *) hash_str, "78d54b943421fdf7ba90a7fb9637c2073aa480454bd841d39ff72f4511fc21fb67797b652c0c823229342873d3bef955" ) == 0 );
7980  }
7981  FCT_TEST_END();
7982 #endif /* POLARSSL_SHA4_C */
7983 
7984 #ifdef POLARSSL_SHA4_C
7985 
7986  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_5)
7987  {
7988  char md_name[100];
7989  unsigned char src_str[10000];
7990  unsigned char hash_str[10000];
7991  unsigned char output[100];
7992  int src_len;
7993  const md_info_t *md_info = NULL;
7995 
7996  memset(md_name, 0x00, 100);
7997  memset(src_str, 0x00, 10000);
7998  memset(hash_str, 0x00, 10000);
7999  memset(output, 0x00, 100);
8000 
8001  strncpy( (char *) md_name, "sha384", 100 );
8002  md_info = md_info_from_string(md_name);
8003  fct_chk( md_info != NULL );
8004  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8005 
8006  src_len = unhexify( src_str, "7bdee3f8" );
8007 
8008  fct_chk ( 0 == md_starts( &ctx ) );
8009  fct_chk ( ctx.md_ctx != NULL );
8010  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8011  fct_chk ( 0 == md_finish( &ctx, output ) );
8012  fct_chk ( 0 == md_free_ctx( &ctx ) );
8013 
8014  hexify( hash_str, output, md_get_size(md_info) );
8015 
8016  fct_chk( strcmp( (char *) hash_str, "8bdafba0777ee446c3431c2d7b1fbb631089f71d2ca417abc1d230e1aba64ec2f1c187474a6f4077d372c14ad407f99a" ) == 0 );
8017  }
8018  FCT_TEST_END();
8019 #endif /* POLARSSL_SHA4_C */
8020 
8021 #ifdef POLARSSL_SHA4_C
8022 
8023  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_6)
8024  {
8025  char md_name[100];
8026  unsigned char src_str[10000];
8027  unsigned char hash_str[10000];
8028  unsigned char output[100];
8029  int src_len;
8030  const md_info_t *md_info = NULL;
8032 
8033  memset(md_name, 0x00, 100);
8034  memset(src_str, 0x00, 10000);
8035  memset(hash_str, 0x00, 10000);
8036  memset(output, 0x00, 100);
8037 
8038  strncpy( (char *) md_name, "sha384", 100 );
8039  md_info = md_info_from_string(md_name);
8040  fct_chk( md_info != NULL );
8041  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8042 
8043  src_len = unhexify( src_str, "8f05604915" );
8044 
8045  fct_chk ( 0 == md_starts( &ctx ) );
8046  fct_chk ( ctx.md_ctx != NULL );
8047  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8048  fct_chk ( 0 == md_finish( &ctx, output ) );
8049  fct_chk ( 0 == md_free_ctx( &ctx ) );
8050 
8051  hexify( hash_str, output, md_get_size(md_info) );
8052 
8053  fct_chk( strcmp( (char *) hash_str, "504e414bf1db1060f14c8c799e25b1e0c4dcf1504ebbd129998f0ae283e6de86e0d3c7e879c73ec3b1836c3ee89c2649" ) == 0 );
8054  }
8055  FCT_TEST_END();
8056 #endif /* POLARSSL_SHA4_C */
8057 
8058 #ifdef POLARSSL_SHA4_C
8059 
8060  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_7)
8061  {
8062  char md_name[100];
8063  unsigned char src_str[10000];
8064  unsigned char hash_str[10000];
8065  unsigned char output[100];
8066  int src_len;
8067  const md_info_t *md_info = NULL;
8069 
8070  memset(md_name, 0x00, 100);
8071  memset(src_str, 0x00, 10000);
8072  memset(hash_str, 0x00, 10000);
8073  memset(output, 0x00, 100);
8074 
8075  strncpy( (char *) md_name, "sha384", 100 );
8076  md_info = md_info_from_string(md_name);
8077  fct_chk( md_info != NULL );
8078  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8079 
8080  src_len = unhexify( src_str, "665da6eda214" );
8081 
8082  fct_chk ( 0 == md_starts( &ctx ) );
8083  fct_chk ( ctx.md_ctx != NULL );
8084  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8085  fct_chk ( 0 == md_finish( &ctx, output ) );
8086  fct_chk ( 0 == md_free_ctx( &ctx ) );
8087 
8088  hexify( hash_str, output, md_get_size(md_info) );
8089 
8090  fct_chk( strcmp( (char *) hash_str, "4c022f112010908848312f8b8f1072625fd5c105399d562ea1d56130619a7eac8dfc3748fd05ee37e4b690be9daa9980" ) == 0 );
8091  }
8092  FCT_TEST_END();
8093 #endif /* POLARSSL_SHA4_C */
8094 
8095 #ifdef POLARSSL_SHA4_C
8096 
8097  FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_8)
8098  {
8099  char md_name[100];
8100  unsigned char src_str[10000];
8101  unsigned char hash_str[10000];
8102  unsigned char output[100];
8103  int src_len;
8104  const md_info_t *md_info = NULL;
8106 
8107  memset(md_name, 0x00, 100);
8108  memset(src_str, 0x00, 10000);
8109  memset(hash_str, 0x00, 10000);
8110  memset(output, 0x00, 100);
8111 
8112  strncpy( (char *) md_name, "sha384", 100 );
8113  md_info = md_info_from_string(md_name);
8114  fct_chk( md_info != NULL );
8115  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8116 
8117  src_len = unhexify( src_str, "7f46ce506d593c4ed53c82edeb602037e0485befbee03f7f930fe532d18ff2a3f5fd6076672c8145a1bf40dd94f7abab47c9ae71c234213d2ad1069c2dac0b0ba15257ae672b8245960ae55bd50315c0097daa3a318745788d70d14706910809ca6e396237fe4934fa46f9ce782d66606d8bd6b2d283b1160513ce9c24e9f084b97891f99d4cdefc169a029e431ca772ba1bba426fce6f01d8e286014e5acc66b799e4db62bd4783322f8a32ff78e0de3957df50ce10871f4e0680df4e8ca3960af9bc6f4efa8eb3962d18f474eb178c3265cc46b8f2ff5ab1a7449fea297dfcfabfa01f28abbb7289bb354b691b5664ec6d098af51be19947ec5ba7ebd66380d1141953ba78d4aa5401679fa7b0a44db1981f864d3535c45afe4c61183d5b0ad51fae71ca07e34240283959f7530a32c70d95a088e501c230059f333b0670825009e7e22103ef22935830df1fac8ef877f5f3426dd54f7d1128dd871ad9a7d088f94c0e8712013295b8d69ae7623b880978c2d3c6ad26dc478f8dc47f5c0adcc618665dc3dc205a9071b2f2191e16cac5bd89bb59148fc719633752303aa08e518dbc389f0a5482caaa4c507b8729a6f3edd061efb39026cecc6399f51971cf7381d605e144a5928c8c2d1ad7467b05da2f202f4f3234e1aff19a0198a28685721c3d2d52311c721e3fdcbaf30214cdc3acff8c433880e104fb63f2df7ce69a97857819ba7ac00ac8eae1969764fde8f68cf8e0916d7e0c151147d4944f99f42ae50f30e1c79a42d2b6c5188d133d3cbbf69094027b354b295ccd0f7dc5a87d73638bd98ebfb00383ca0fa69cb8dcb35a12510e5e07ad8789047d0b63841a1bb928737e8b0a0c33254f47aa8bfbe3341a09c2b76dbcefa67e30df300d34f7b8465c4f869e51b6bcfe6cf68b238359a645036bf7f63f02924e087ce7457e483b6025a859903cb484574aa3b12cf946f32127d537c33bee3141b5db96d10a148c50ae045f287210757710d6846e04b202f79e87dd9a56bc6da15f84a77a7f63935e1dee00309cd276a8e7176cb04da6bb0e9009534438732cb42d008008853d38d19beba46e61006e30f7efd1bc7c2906b024e4ff898a1b58c448d68b43c6ab63f34f85b3ac6aa4475867e51b583844cb23829f4b30f4bdd817d88e2ef3e7b4fc0a624395b05ec5e8686082b24d29fef2b0d3c29e031d5f94f504b1d3df9361eb5ffbadb242e66c39a8094cfe62f85f639f3fd65fc8ae0c74a8f4c6e1d070b9183a434c722caaa0225f8bcd68614d6f0738ed62f8484ec96077d155c08e26c46be262a73e3551698bd70d8d5610cf37c4c306eed04ba6a040a9c3e6d7e15e8acda17f477c2484cf5c56b813313927be8387b1024f995e98fc87f1029091c01424bdc2b296c2eadb7d25b3e762a2fd0c2dcd1727ddf91db97c5984305265f3695a7f5472f2d72c94d68c27914f14f82aa8dd5fe4e2348b0ca967a3f98626a091552f5d0ffa2bf10350d23c996256c01fdeffb2c2c612519869f877e4929c6e95ff15040f1485e22ed14119880232fef3b57b3848f15b1766a5552879df8f06" );
8118 
8119  fct_chk ( 0 == md_starts( &ctx ) );
8120  fct_chk ( ctx.md_ctx != NULL );
8121  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8122  fct_chk ( 0 == md_finish( &ctx, output ) );
8123  fct_chk ( 0 == md_free_ctx( &ctx ) );
8124 
8125  hexify( hash_str, output, md_get_size(md_info) );
8126 
8127  fct_chk( strcmp( (char *) hash_str, "cba9e3eb12a6f83db11e8a6ff40d1049854ee094416bc527fea931d8585428a8ed6242ce81f6769b36e2123a5c23483e" ) == 0 );
8128  }
8129  FCT_TEST_END();
8130 #endif /* POLARSSL_SHA4_C */
8131 
8132 #ifdef POLARSSL_SHA4_C
8133 
8134  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_1)
8135  {
8136  char md_name[100];
8137  unsigned char src_str[10000];
8138  unsigned char hash_str[10000];
8139  unsigned char output[100];
8140  int src_len;
8141  const md_info_t *md_info = NULL;
8143 
8144  memset(md_name, 0x00, 100);
8145  memset(src_str, 0x00, 10000);
8146  memset(hash_str, 0x00, 10000);
8147  memset(output, 0x00, 100);
8148 
8149  strncpy( (char *) md_name, "sha512", 100 );
8150  md_info = md_info_from_string(md_name);
8151  fct_chk( md_info != NULL );
8152  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8153 
8154  src_len = unhexify( src_str, "" );
8155 
8156  fct_chk ( 0 == md_starts( &ctx ) );
8157  fct_chk ( ctx.md_ctx != NULL );
8158  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8159  fct_chk ( 0 == md_finish( &ctx, output ) );
8160  fct_chk ( 0 == md_free_ctx( &ctx ) );
8161 
8162  hexify( hash_str, output, md_get_size(md_info) );
8163 
8164  fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
8165  }
8166  FCT_TEST_END();
8167 #endif /* POLARSSL_SHA4_C */
8168 
8169 #ifdef POLARSSL_SHA4_C
8170 
8171  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_2)
8172  {
8173  char md_name[100];
8174  unsigned char src_str[10000];
8175  unsigned char hash_str[10000];
8176  unsigned char output[100];
8177  int src_len;
8178  const md_info_t *md_info = NULL;
8180 
8181  memset(md_name, 0x00, 100);
8182  memset(src_str, 0x00, 10000);
8183  memset(hash_str, 0x00, 10000);
8184  memset(output, 0x00, 100);
8185 
8186  strncpy( (char *) md_name, "sha512", 100 );
8187  md_info = md_info_from_string(md_name);
8188  fct_chk( md_info != NULL );
8189  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8190 
8191  src_len = unhexify( src_str, "8f" );
8192 
8193  fct_chk ( 0 == md_starts( &ctx ) );
8194  fct_chk ( ctx.md_ctx != NULL );
8195  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8196  fct_chk ( 0 == md_finish( &ctx, output ) );
8197  fct_chk ( 0 == md_free_ctx( &ctx ) );
8198 
8199  hexify( hash_str, output, md_get_size(md_info) );
8200 
8201  fct_chk( strcmp( (char *) hash_str, "e4cd2d19931b5aad9c920f45f56f6ce34e3d38c6d319a6e11d0588ab8b838576d6ce6d68eea7c830de66e2bd96458bfa7aafbcbec981d4ed040498c3dd95f22a" ) == 0 );
8202  }
8203  FCT_TEST_END();
8204 #endif /* POLARSSL_SHA4_C */
8205 
8206 #ifdef POLARSSL_SHA4_C
8207 
8208  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_3)
8209  {
8210  char md_name[100];
8211  unsigned char src_str[10000];
8212  unsigned char hash_str[10000];
8213  unsigned char output[100];
8214  int src_len;
8215  const md_info_t *md_info = NULL;
8217 
8218  memset(md_name, 0x00, 100);
8219  memset(src_str, 0x00, 10000);
8220  memset(hash_str, 0x00, 10000);
8221  memset(output, 0x00, 100);
8222 
8223  strncpy( (char *) md_name, "sha512", 100 );
8224  md_info = md_info_from_string(md_name);
8225  fct_chk( md_info != NULL );
8226  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8227 
8228  src_len = unhexify( src_str, "e724" );
8229 
8230  fct_chk ( 0 == md_starts( &ctx ) );
8231  fct_chk ( ctx.md_ctx != NULL );
8232  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8233  fct_chk ( 0 == md_finish( &ctx, output ) );
8234  fct_chk ( 0 == md_free_ctx( &ctx ) );
8235 
8236  hexify( hash_str, output, md_get_size(md_info) );
8237 
8238  fct_chk( strcmp( (char *) hash_str, "7dbb520221a70287b23dbcf62bfc1b73136d858e86266732a7fffa875ecaa2c1b8f673b5c065d360c563a7b9539349f5f59bef8c0c593f9587e3cd50bb26a231" ) == 0 );
8239  }
8240  FCT_TEST_END();
8241 #endif /* POLARSSL_SHA4_C */
8242 
8243 #ifdef POLARSSL_SHA4_C
8244 
8245  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_4)
8246  {
8247  char md_name[100];
8248  unsigned char src_str[10000];
8249  unsigned char hash_str[10000];
8250  unsigned char output[100];
8251  int src_len;
8252  const md_info_t *md_info = NULL;
8254 
8255  memset(md_name, 0x00, 100);
8256  memset(src_str, 0x00, 10000);
8257  memset(hash_str, 0x00, 10000);
8258  memset(output, 0x00, 100);
8259 
8260  strncpy( (char *) md_name, "sha512", 100 );
8261  md_info = md_info_from_string(md_name);
8262  fct_chk( md_info != NULL );
8263  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8264 
8265  src_len = unhexify( src_str, "de4c90" );
8266 
8267  fct_chk ( 0 == md_starts( &ctx ) );
8268  fct_chk ( ctx.md_ctx != NULL );
8269  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8270  fct_chk ( 0 == md_finish( &ctx, output ) );
8271  fct_chk ( 0 == md_free_ctx( &ctx ) );
8272 
8273  hexify( hash_str, output, md_get_size(md_info) );
8274 
8275  fct_chk( strcmp( (char *) hash_str, "33ce98281045a5c4c9df0363d8196f1d7dfcd5ee46ac89776fd8a4344c12f123a66788af5bd41ceff1941aa5637654b4064c88c14e00465ab79a2fc6c97e1014" ) == 0 );
8276  }
8277  FCT_TEST_END();
8278 #endif /* POLARSSL_SHA4_C */
8279 
8280 #ifdef POLARSSL_SHA4_C
8281 
8282  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_5)
8283  {
8284  char md_name[100];
8285  unsigned char src_str[10000];
8286  unsigned char hash_str[10000];
8287  unsigned char output[100];
8288  int src_len;
8289  const md_info_t *md_info = NULL;
8291 
8292  memset(md_name, 0x00, 100);
8293  memset(src_str, 0x00, 10000);
8294  memset(hash_str, 0x00, 10000);
8295  memset(output, 0x00, 100);
8296 
8297  strncpy( (char *) md_name, "sha512", 100 );
8298  md_info = md_info_from_string(md_name);
8299  fct_chk( md_info != NULL );
8300  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8301 
8302  src_len = unhexify( src_str, "a801e94b" );
8303 
8304  fct_chk ( 0 == md_starts( &ctx ) );
8305  fct_chk ( ctx.md_ctx != NULL );
8306  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8307  fct_chk ( 0 == md_finish( &ctx, output ) );
8308  fct_chk ( 0 == md_free_ctx( &ctx ) );
8309 
8310  hexify( hash_str, output, md_get_size(md_info) );
8311 
8312  fct_chk( strcmp( (char *) hash_str, "dadb1b5a27f9fece8d86adb2a51879beb1787ff28f4e8ce162cad7fee0f942efcabbf738bc6f797fc7cc79a3a75048cd4c82ca0757a324695bfb19a557e56e2f" ) == 0 );
8313  }
8314  FCT_TEST_END();
8315 #endif /* POLARSSL_SHA4_C */
8316 
8317 #ifdef POLARSSL_SHA4_C
8318 
8319  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_6)
8320  {
8321  char md_name[100];
8322  unsigned char src_str[10000];
8323  unsigned char hash_str[10000];
8324  unsigned char output[100];
8325  int src_len;
8326  const md_info_t *md_info = NULL;
8328 
8329  memset(md_name, 0x00, 100);
8330  memset(src_str, 0x00, 10000);
8331  memset(hash_str, 0x00, 10000);
8332  memset(output, 0x00, 100);
8333 
8334  strncpy( (char *) md_name, "sha512", 100 );
8335  md_info = md_info_from_string(md_name);
8336  fct_chk( md_info != NULL );
8337  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8338 
8339  src_len = unhexify( src_str, "94390d3502" );
8340 
8341  fct_chk ( 0 == md_starts( &ctx ) );
8342  fct_chk ( ctx.md_ctx != NULL );
8343  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8344  fct_chk ( 0 == md_finish( &ctx, output ) );
8345  fct_chk ( 0 == md_free_ctx( &ctx ) );
8346 
8347  hexify( hash_str, output, md_get_size(md_info) );
8348 
8349  fct_chk( strcmp( (char *) hash_str, "b6175c4c4cccf69e0ce5f0312010886ea6b34d43673f942ae42483f9cbb7da817de4e11b5d58e25a3d9bd721a22cdffe1c40411cc45df1911fa5506129b69297" ) == 0 );
8350  }
8351  FCT_TEST_END();
8352 #endif /* POLARSSL_SHA4_C */
8353 
8354 #ifdef POLARSSL_SHA4_C
8355 
8356  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_7)
8357  {
8358  char md_name[100];
8359  unsigned char src_str[10000];
8360  unsigned char hash_str[10000];
8361  unsigned char output[100];
8362  int src_len;
8363  const md_info_t *md_info = NULL;
8365 
8366  memset(md_name, 0x00, 100);
8367  memset(src_str, 0x00, 10000);
8368  memset(hash_str, 0x00, 10000);
8369  memset(output, 0x00, 100);
8370 
8371  strncpy( (char *) md_name, "sha512", 100 );
8372  md_info = md_info_from_string(md_name);
8373  fct_chk( md_info != NULL );
8374  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8375 
8376  src_len = unhexify( src_str, "49297dd63e5f" );
8377 
8378  fct_chk ( 0 == md_starts( &ctx ) );
8379  fct_chk ( ctx.md_ctx != NULL );
8380  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8381  fct_chk ( 0 == md_finish( &ctx, output ) );
8382  fct_chk ( 0 == md_free_ctx( &ctx ) );
8383 
8384  hexify( hash_str, output, md_get_size(md_info) );
8385 
8386  fct_chk( strcmp( (char *) hash_str, "1fcc1e6f6870859d11649f5e5336a9cd16329c029baf04d5a6edf257889a2e9522b497dd656bb402da461307c4ee382e2e89380c8e6e6e7697f1e439f650fa94" ) == 0 );
8387  }
8388  FCT_TEST_END();
8389 #endif /* POLARSSL_SHA4_C */
8390 
8391 #ifdef POLARSSL_SHA4_C
8392 
8393  FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_8)
8394  {
8395  char md_name[100];
8396  unsigned char src_str[10000];
8397  unsigned char hash_str[10000];
8398  unsigned char output[100];
8399  int src_len;
8400  const md_info_t *md_info = NULL;
8402 
8403  memset(md_name, 0x00, 100);
8404  memset(src_str, 0x00, 10000);
8405  memset(hash_str, 0x00, 10000);
8406  memset(output, 0x00, 100);
8407 
8408  strncpy( (char *) md_name, "sha512", 100 );
8409  md_info = md_info_from_string(md_name);
8410  fct_chk( md_info != NULL );
8411  fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
8412 
8413  src_len = unhexify( src_str, "990d1ae71a62d7bda9bfdaa1762a68d296eee72a4cd946f287a898fbabc002ea941fd8d4d991030b4d27a637cce501a834bb95eab1b7889a3e784c7968e67cbf552006b206b68f76d9191327524fcc251aeb56af483d10b4e0c6c5e599ee8c0fe4faeca8293844a8547c6a9a90d093f2526873a19ad4a5e776794c68c742fb834793d2dfcb7fea46c63af4b70fd11cb6e41834e72ee40edb067b292a794990c288d5007e73f349fb383af6a756b8301ad6e5e0aa8cd614399bb3a452376b1575afa6bdaeaafc286cb064bb91edef97c632b6c1113d107fa93a0905098a105043c2f05397f702514439a08a9e5ddc196100721d45c8fc17d2ed659376f8a00bd5cb9a0860e26d8a29d8d6aaf52de97e9346033d6db501a35dbbaf97c20b830cd2d18c2532f3a59cc497ee64c0e57d8d060e5069b28d86edf1adcf59144b221ce3ddaef134b3124fbc7dd000240eff0f5f5f41e83cd7f5bb37c9ae21953fe302b0f6e8b68fa91c6ab99265c64b2fd9cd4942be04321bb5d6d71932376c6f2f88e02422ba6a5e2cb765df93fd5dd0728c6abdaf03bce22e0678a544e2c3636f741b6f4447ee58a8fc656b43ef817932176adbfc2e04b2c812c273cd6cbfa4098f0be036a34221fa02643f5ee2e0b38135f2a18ecd2f16ebc45f8eb31b8ab967a1567ee016904188910861ca1fa205c7adaa194b286893ffe2f4fbe0384c2aef72a4522aeafd3ebc71f9db71eeeef86c48394a1c86d5b36c352cc33a0a2c800bc99e62fd65b3a2fd69e0b53996ec13d8ce483ce9319efd9a85acefabdb5342226febb83fd1daf4b24265f50c61c6de74077ef89b6fecf9f29a1f871af1e9f89b2d345cda7499bd45c42fa5d195a1e1a6ba84851889e730da3b2b916e96152ae0c92154b49719841db7e7cc707ba8a5d7b101eb4ac7b629bb327817910fff61580b59aab78182d1a2e33473d05b00b170b29e331870826cfe45af206aa7d0246bbd8566ca7cfb2d3c10bfa1db7dd48dd786036469ce7282093d78b5e1a5b0fc81a54c8ed4ceac1e5305305e78284ac276f5d7862727aff246e17addde50c670028d572cbfc0be2e4f8b2eb28fa68ad7b4c6c2a239c460441bfb5ea049f23b08563b4e47729a59e5986a61a6093dbd54f8c36ebe87edae01f251cb060ad1364ce677d7e8d5a4a4ca966a7241cc360bc2acb280e5f9e9c1b032ad6a180a35e0c5180b9d16d026c865b252098cc1d99ba7375ca31c7702c0d943d5e3dd2f6861fa55bd46d94b67ed3e52eccd8dd06d968e01897d6de97ed3058d91dd" );
8414 
8415  fct_chk ( 0 == md_starts( &ctx ) );
8416  fct_chk ( ctx.md_ctx != NULL );
8417  fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
8418  fct_chk ( 0 == md_finish( &ctx, output ) );
8419  fct_chk ( 0 == md_free_ctx( &ctx ) );
8420 
8421  hexify( hash_str, output, md_get_size(md_info) );
8422 
8423  fct_chk( strcmp( (char *) hash_str, "8e4bc6f8b8c60fe4d68c61d9b159c8693c3151c46749af58da228442d927f23359bd6ccd6c2ec8fa3f00a86cecbfa728e1ad60b821ed22fcd309ba91a4138bc9" ) == 0 );
8424  }
8425  FCT_TEST_END();
8426 #endif /* POLARSSL_SHA4_C */
8427 
8428 #ifdef POLARSSL_SHA1_C
8429 #ifdef POLARSSL_FS_IO
8430 
8431  FCT_TEST_BGN(generic_sha1_hash_file_1)
8432  {
8433  char md_name[100];
8434  unsigned char hash_str[1000];
8435  unsigned char output[100];
8436  const md_info_t *md_info = NULL;
8437 
8438  memset(md_name, 0x00, 100);
8439  memset(hash_str, 0x00, 1000);
8440  memset(output, 0x00, 100);
8441 
8442  strncpy( (char *) md_name, "sha1", 100 );
8443  md_info = md_info_from_string( md_name );
8444  fct_chk( md_info != NULL );
8445 
8446  md_file( md_info, "data_files/hash_file_1", output);
8447  hexify( hash_str, output, md_get_size(md_info) );
8448 
8449  fct_chk( strcmp( (char *) hash_str, "d21c965b1e768bd7a6aa6869f5f821901d255f9f" ) == 0 );
8450  }
8451  FCT_TEST_END();
8452 #endif /* POLARSSL_SHA1_C */
8453 #endif /* POLARSSL_FS_IO */
8454 
8455 #ifdef POLARSSL_SHA1_C
8456 #ifdef POLARSSL_FS_IO
8457 
8458  FCT_TEST_BGN(generic_sha1_hash_file_2)
8459  {
8460  char md_name[100];
8461  unsigned char hash_str[1000];
8462  unsigned char output[100];
8463  const md_info_t *md_info = NULL;
8464 
8465  memset(md_name, 0x00, 100);
8466  memset(hash_str, 0x00, 1000);
8467  memset(output, 0x00, 100);
8468 
8469  strncpy( (char *) md_name, "sha1", 100 );
8470  md_info = md_info_from_string( md_name );
8471  fct_chk( md_info != NULL );
8472 
8473  md_file( md_info, "data_files/hash_file_2", output);
8474  hexify( hash_str, output, md_get_size(md_info) );
8475 
8476  fct_chk( strcmp( (char *) hash_str, "353f34271f2aef49d23a8913d4a6bd82b2cecdc6" ) == 0 );
8477  }
8478  FCT_TEST_END();
8479 #endif /* POLARSSL_SHA1_C */
8480 #endif /* POLARSSL_FS_IO */
8481 
8482 #ifdef POLARSSL_SHA1_C
8483 #ifdef POLARSSL_FS_IO
8484 
8485  FCT_TEST_BGN(generic_sha1_hash_file_3)
8486  {
8487  char md_name[100];
8488  unsigned char hash_str[1000];
8489  unsigned char output[100];
8490  const md_info_t *md_info = NULL;
8491 
8492  memset(md_name, 0x00, 100);
8493  memset(hash_str, 0x00, 1000);
8494  memset(output, 0x00, 100);
8495 
8496  strncpy( (char *) md_name, "sha1", 100 );
8497  md_info = md_info_from_string( md_name );
8498  fct_chk( md_info != NULL );
8499 
8500  md_file( md_info, "data_files/hash_file_3", output);
8501  hexify( hash_str, output, md_get_size(md_info) );
8502 
8503  fct_chk( strcmp( (char *) hash_str, "93640ed592076328096270c756db2fba9c486b35" ) == 0 );
8504  }
8505  FCT_TEST_END();
8506 #endif /* POLARSSL_SHA1_C */
8507 #endif /* POLARSSL_FS_IO */
8508 
8509 #ifdef POLARSSL_SHA1_C
8510 #ifdef POLARSSL_FS_IO
8511 
8512  FCT_TEST_BGN(generic_sha1_hash_file_4)
8513  {
8514  char md_name[100];
8515  unsigned char hash_str[1000];
8516  unsigned char output[100];
8517  const md_info_t *md_info = NULL;
8518 
8519  memset(md_name, 0x00, 100);
8520  memset(hash_str, 0x00, 1000);
8521  memset(output, 0x00, 100);
8522 
8523  strncpy( (char *) md_name, "sha1", 100 );
8524  md_info = md_info_from_string( md_name );
8525  fct_chk( md_info != NULL );
8526 
8527  md_file( md_info, "data_files/hash_file_4", output);
8528  hexify( hash_str, output, md_get_size(md_info) );
8529 
8530  fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
8531  }
8532  FCT_TEST_END();
8533 #endif /* POLARSSL_SHA1_C */
8534 #endif /* POLARSSL_FS_IO */
8535 
8536 #ifdef POLARSSL_SHA2_C
8537 #ifdef POLARSSL_FS_IO
8538 
8539  FCT_TEST_BGN(generic_sha_224_hash_file_1)
8540  {
8541  char md_name[100];
8542  unsigned char hash_str[1000];
8543  unsigned char output[100];
8544  const md_info_t *md_info = NULL;
8545 
8546  memset(md_name, 0x00, 100);
8547  memset(hash_str, 0x00, 1000);
8548  memset(output, 0x00, 100);
8549 
8550  strncpy( (char *) md_name, "sha224", 100 );
8551  md_info = md_info_from_string( md_name );
8552  fct_chk( md_info != NULL );
8553 
8554  md_file( md_info, "data_files/hash_file_1", output);
8555  hexify( hash_str, output, md_get_size(md_info) );
8556 
8557  fct_chk( strcmp( (char *) hash_str, "8606da018870f0c16834a21bc3385704cb1683b9dbab04c5ddb90a48" ) == 0 );
8558  }
8559  FCT_TEST_END();
8560 #endif /* POLARSSL_SHA2_C */
8561 #endif /* POLARSSL_FS_IO */
8562 
8563 #ifdef POLARSSL_SHA2_C
8564 #ifdef POLARSSL_FS_IO
8565 
8566  FCT_TEST_BGN(generic_sha_224_hash_file_2)
8567  {
8568  char md_name[100];
8569  unsigned char hash_str[1000];
8570  unsigned char output[100];
8571  const md_info_t *md_info = NULL;
8572 
8573  memset(md_name, 0x00, 100);
8574  memset(hash_str, 0x00, 1000);
8575  memset(output, 0x00, 100);
8576 
8577  strncpy( (char *) md_name, "sha224", 100 );
8578  md_info = md_info_from_string( md_name );
8579  fct_chk( md_info != NULL );
8580 
8581  md_file( md_info, "data_files/hash_file_2", output);
8582  hexify( hash_str, output, md_get_size(md_info) );
8583 
8584  fct_chk( strcmp( (char *) hash_str, "733b2ab97b6f63f2e29b9a2089756d81e14c93fe4cc9615c0d5e8a03" ) == 0 );
8585  }
8586  FCT_TEST_END();
8587 #endif /* POLARSSL_SHA2_C */
8588 #endif /* POLARSSL_FS_IO */
8589 
8590 #ifdef POLARSSL_SHA2_C
8591 #ifdef POLARSSL_FS_IO
8592 
8593  FCT_TEST_BGN(generic_sha_224_hash_file_3)
8594  {
8595  char md_name[100];
8596  unsigned char hash_str[1000];
8597  unsigned char output[100];
8598  const md_info_t *md_info = NULL;
8599 
8600  memset(md_name, 0x00, 100);
8601  memset(hash_str, 0x00, 1000);
8602  memset(output, 0x00, 100);
8603 
8604  strncpy( (char *) md_name, "sha224", 100 );
8605  md_info = md_info_from_string( md_name );
8606  fct_chk( md_info != NULL );
8607 
8608  md_file( md_info, "data_files/hash_file_3", output);
8609  hexify( hash_str, output, md_get_size(md_info) );
8610 
8611  fct_chk( strcmp( (char *) hash_str, "e1df95867580e2cc2100e9565bf9c2e42c24fe5250c19efe33d1c4fe" ) == 0 );
8612  }
8613  FCT_TEST_END();
8614 #endif /* POLARSSL_SHA2_C */
8615 #endif /* POLARSSL_FS_IO */
8616 
8617 #ifdef POLARSSL_SHA2_C
8618 #ifdef POLARSSL_FS_IO
8619 
8620  FCT_TEST_BGN(generic_sha_224_hash_file_4)
8621  {
8622  char md_name[100];
8623  unsigned char hash_str[1000];
8624  unsigned char output[100];
8625  const md_info_t *md_info = NULL;
8626 
8627  memset(md_name, 0x00, 100);
8628  memset(hash_str, 0x00, 1000);
8629  memset(output, 0x00, 100);
8630 
8631  strncpy( (char *) md_name, "sha224", 100 );
8632  md_info = md_info_from_string( md_name );
8633  fct_chk( md_info != NULL );
8634 
8635  md_file( md_info, "data_files/hash_file_4", output);
8636  hexify( hash_str, output, md_get_size(md_info) );
8637 
8638  fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
8639  }
8640  FCT_TEST_END();
8641 #endif /* POLARSSL_SHA2_C */
8642 #endif /* POLARSSL_FS_IO */
8643 
8644 #ifdef POLARSSL_SHA2_C
8645 #ifdef POLARSSL_FS_IO
8646 
8647  FCT_TEST_BGN(generic_sha_256_hash_file_1)
8648  {
8649  char md_name[100];
8650  unsigned char hash_str[1000];
8651  unsigned char output[100];
8652  const md_info_t *md_info = NULL;
8653 
8654  memset(md_name, 0x00, 100);
8655  memset(hash_str, 0x00, 1000);
8656  memset(output, 0x00, 100);
8657 
8658  strncpy( (char *) md_name, "sha256", 100 );
8659  md_info = md_info_from_string( md_name );
8660  fct_chk( md_info != NULL );
8661 
8662  md_file( md_info, "data_files/hash_file_1", output);
8663  hexify( hash_str, output, md_get_size(md_info) );
8664 
8665  fct_chk( strcmp( (char *) hash_str, "975d0c620d3936886f8a3665e585a3e84aa0501f4225bf53029710242823e391" ) == 0 );
8666  }
8667  FCT_TEST_END();
8668 #endif /* POLARSSL_SHA2_C */
8669 #endif /* POLARSSL_FS_IO */
8670 
8671 #ifdef POLARSSL_SHA2_C
8672 #ifdef POLARSSL_FS_IO
8673 
8674  FCT_TEST_BGN(generic_sha_256_hash_file_2)
8675  {
8676  char md_name[100];
8677  unsigned char hash_str[1000];
8678  unsigned char output[100];
8679  const md_info_t *md_info = NULL;
8680 
8681  memset(md_name, 0x00, 100);
8682  memset(hash_str, 0x00, 1000);
8683  memset(output, 0x00, 100);
8684 
8685  strncpy( (char *) md_name, "sha256", 100 );
8686  md_info = md_info_from_string( md_name );
8687  fct_chk( md_info != NULL );
8688 
8689  md_file( md_info, "data_files/hash_file_2", output);
8690  hexify( hash_str, output, md_get_size(md_info) );
8691 
8692  fct_chk( strcmp( (char *) hash_str, "11fcbf1baa36ca45745f10cc5467aee86f066f80ba2c46806d876bf783022ad2" ) == 0 );
8693  }
8694  FCT_TEST_END();
8695 #endif /* POLARSSL_SHA2_C */
8696 #endif /* POLARSSL_FS_IO */
8697 
8698 #ifdef POLARSSL_SHA2_C
8699 #ifdef POLARSSL_FS_IO
8700 
8701  FCT_TEST_BGN(generic_sha_256_hash_file_3)
8702  {
8703  char md_name[100];
8704  unsigned char hash_str[1000];
8705  unsigned char output[100];
8706  const md_info_t *md_info = NULL;
8707 
8708  memset(md_name, 0x00, 100);
8709  memset(hash_str, 0x00, 1000);
8710  memset(output, 0x00, 100);
8711 
8712  strncpy( (char *) md_name, "sha256", 100 );
8713  md_info = md_info_from_string( md_name );
8714  fct_chk( md_info != NULL );
8715 
8716  md_file( md_info, "data_files/hash_file_3", output);
8717  hexify( hash_str, output, md_get_size(md_info) );
8718 
8719  fct_chk( strcmp( (char *) hash_str, "9ae4b369f9f4f03b86505b46a5469542e00aaff7cf7417a71af6d6d0aba3b70c" ) == 0 );
8720  }
8721  FCT_TEST_END();
8722 #endif /* POLARSSL_SHA2_C */
8723 #endif /* POLARSSL_FS_IO */
8724 
8725 #ifdef POLARSSL_SHA2_C
8726 #ifdef POLARSSL_FS_IO
8727 
8728  FCT_TEST_BGN(generic_sha_256_hash_file_4)
8729  {
8730  char md_name[100];
8731  unsigned char hash_str[1000];
8732  unsigned char output[100];
8733  const md_info_t *md_info = NULL;
8734 
8735  memset(md_name, 0x00, 100);
8736  memset(hash_str, 0x00, 1000);
8737  memset(output, 0x00, 100);
8738 
8739  strncpy( (char *) md_name, "sha256", 100 );
8740  md_info = md_info_from_string( md_name );
8741  fct_chk( md_info != NULL );
8742 
8743  md_file( md_info, "data_files/hash_file_4", output);
8744  hexify( hash_str, output, md_get_size(md_info) );
8745 
8746  fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
8747  }
8748  FCT_TEST_END();
8749 #endif /* POLARSSL_SHA2_C */
8750 #endif /* POLARSSL_FS_IO */
8751 
8752 #ifdef POLARSSL_SHA4_C
8753 #ifdef POLARSSL_FS_IO
8754 
8755  FCT_TEST_BGN(generic_sha_384_hash_file_1)
8756  {
8757  char md_name[100];
8758  unsigned char hash_str[1000];
8759  unsigned char output[100];
8760  const md_info_t *md_info = NULL;
8761 
8762  memset(md_name, 0x00, 100);
8763  memset(hash_str, 0x00, 1000);
8764  memset(output, 0x00, 100);
8765 
8766  strncpy( (char *) md_name, "sha384", 100 );
8767  md_info = md_info_from_string( md_name );
8768  fct_chk( md_info != NULL );
8769 
8770  md_file( md_info, "data_files/hash_file_1", output);
8771  hexify( hash_str, output, md_get_size(md_info) );
8772 
8773  fct_chk( strcmp( (char *) hash_str, "e0a3e6259d6378001b54ef82f5dd087009c5fad86d8db226a9fe1d14ecbe33a6fc916e3a4b16f5f286424de15d5a8e0e" ) == 0 );
8774  }
8775  FCT_TEST_END();
8776 #endif /* POLARSSL_SHA4_C */
8777 #endif /* POLARSSL_FS_IO */
8778 
8779 #ifdef POLARSSL_SHA4_C
8780 #ifdef POLARSSL_FS_IO
8781 
8782  FCT_TEST_BGN(generic_sha_384_hash_file_2)
8783  {
8784  char md_name[100];
8785  unsigned char hash_str[1000];
8786  unsigned char output[100];
8787  const md_info_t *md_info = NULL;
8788 
8789  memset(md_name, 0x00, 100);
8790  memset(hash_str, 0x00, 1000);
8791  memset(output, 0x00, 100);
8792 
8793  strncpy( (char *) md_name, "sha384", 100 );
8794  md_info = md_info_from_string( md_name );
8795  fct_chk( md_info != NULL );
8796 
8797  md_file( md_info, "data_files/hash_file_2", output);
8798  hexify( hash_str, output, md_get_size(md_info) );
8799 
8800  fct_chk( strcmp( (char *) hash_str, "eff727afc8495c92e2f370f97a317f93c3350324b0646b0f0e264708b3c97d3d332d3c5390e1e47130f5c92f1ef4b9cf" ) == 0 );
8801  }
8802  FCT_TEST_END();
8803 #endif /* POLARSSL_SHA4_C */
8804 #endif /* POLARSSL_FS_IO */
8805 
8806 #ifdef POLARSSL_SHA4_C
8807 #ifdef POLARSSL_FS_IO
8808 
8809  FCT_TEST_BGN(generic_sha_384_hash_file_3)
8810  {
8811  char md_name[100];
8812  unsigned char hash_str[1000];
8813  unsigned char output[100];
8814  const md_info_t *md_info = NULL;
8815 
8816  memset(md_name, 0x00, 100);
8817  memset(hash_str, 0x00, 1000);
8818  memset(output, 0x00, 100);
8819 
8820  strncpy( (char *) md_name, "sha384", 100 );
8821  md_info = md_info_from_string( md_name );
8822  fct_chk( md_info != NULL );
8823 
8824  md_file( md_info, "data_files/hash_file_3", output);
8825  hexify( hash_str, output, md_get_size(md_info) );
8826 
8827  fct_chk( strcmp( (char *) hash_str, "6fc10ebda96a1ccf61777cac72f6034f92533d42052a4bf9f9d929c672973c71e5aeb1213268043c21527ac0f7f349c4" ) == 0 );
8828  }
8829  FCT_TEST_END();
8830 #endif /* POLARSSL_SHA4_C */
8831 #endif /* POLARSSL_FS_IO */
8832 
8833 #ifdef POLARSSL_SHA4_C
8834 #ifdef POLARSSL_FS_IO
8835 
8836  FCT_TEST_BGN(generic_sha_384_hash_file_4)
8837  {
8838  char md_name[100];
8839  unsigned char hash_str[1000];
8840  unsigned char output[100];
8841  const md_info_t *md_info = NULL;
8842 
8843  memset(md_name, 0x00, 100);
8844  memset(hash_str, 0x00, 1000);
8845  memset(output, 0x00, 100);
8846 
8847  strncpy( (char *) md_name, "sha384", 100 );
8848  md_info = md_info_from_string( md_name );
8849  fct_chk( md_info != NULL );
8850 
8851  md_file( md_info, "data_files/hash_file_4", output);
8852  hexify( hash_str, output, md_get_size(md_info) );
8853 
8854  fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
8855  }
8856  FCT_TEST_END();
8857 #endif /* POLARSSL_SHA4_C */
8858 #endif /* POLARSSL_FS_IO */
8859 
8860 #ifdef POLARSSL_SHA4_C
8861 #ifdef POLARSSL_FS_IO
8862 
8863  FCT_TEST_BGN(generic_sha_512_hash_file_1)
8864  {
8865  char md_name[100];
8866  unsigned char hash_str[1000];
8867  unsigned char output[100];
8868  const md_info_t *md_info = NULL;
8869 
8870  memset(md_name, 0x00, 100);
8871  memset(hash_str, 0x00, 1000);
8872  memset(output, 0x00, 100);
8873 
8874  strncpy( (char *) md_name, "sha512", 100 );
8875  md_info = md_info_from_string( md_name );
8876  fct_chk( md_info != NULL );
8877 
8878  md_file( md_info, "data_files/hash_file_1", output);
8879  hexify( hash_str, output, md_get_size(md_info) );
8880 
8881  fct_chk( strcmp( (char *) hash_str, "d8207a2e1ff2b424f2c4163fe1b723c9bd42e464061eb411e8df730bcd24a7ab3956a6f3ff044a52eb2d262f9e4ca6b524092b544ab78f14d6f9c4cc8ddf335a" ) == 0 );
8882  }
8883  FCT_TEST_END();
8884 #endif /* POLARSSL_SHA4_C */
8885 #endif /* POLARSSL_FS_IO */
8886 
8887 #ifdef POLARSSL_SHA4_C
8888 #ifdef POLARSSL_FS_IO
8889 
8890  FCT_TEST_BGN(generic_sha_512_hash_file_2)
8891  {
8892  char md_name[100];
8893  unsigned char hash_str[1000];
8894  unsigned char output[100];
8895  const md_info_t *md_info = NULL;
8896 
8897  memset(md_name, 0x00, 100);
8898  memset(hash_str, 0x00, 1000);
8899  memset(output, 0x00, 100);
8900 
8901  strncpy( (char *) md_name, "sha512", 100 );
8902  md_info = md_info_from_string( md_name );
8903  fct_chk( md_info != NULL );
8904 
8905  md_file( md_info, "data_files/hash_file_2", output);
8906  hexify( hash_str, output, md_get_size(md_info) );
8907 
8908  fct_chk( strcmp( (char *) hash_str, "ecbb7f0ed8a702b49f16ad3088bcc06ea93451912a7187db15f64d93517b09630b039293aed418d4a00695777b758b1f381548c2fd7b92ce5ed996b32c8734e7" ) == 0 );
8909  }
8910  FCT_TEST_END();
8911 #endif /* POLARSSL_SHA4_C */
8912 #endif /* POLARSSL_FS_IO */
8913 
8914 #ifdef POLARSSL_SHA4_C
8915 #ifdef POLARSSL_FS_IO
8916 
8917  FCT_TEST_BGN(generic_sha_512_hash_file_3)
8918  {
8919  char md_name[100];
8920  unsigned char hash_str[1000];
8921  unsigned char output[100];
8922  const md_info_t *md_info = NULL;
8923 
8924  memset(md_name, 0x00, 100);
8925  memset(hash_str, 0x00, 1000);
8926  memset(output, 0x00, 100);
8927 
8928  strncpy( (char *) md_name, "sha512", 100 );
8929  md_info = md_info_from_string( md_name );
8930  fct_chk( md_info != NULL );
8931 
8932  md_file( md_info, "data_files/hash_file_3", output);
8933  hexify( hash_str, output, md_get_size(md_info) );
8934 
8935  fct_chk( strcmp( (char *) hash_str, "7ccc9b2da71ffde9966c3ce44d7f20945fccf33b1fade4da152b021f1afcc7293382944aa6c09eac67af25f22026758e2bf6bed86ae2a43592677ee50f8eea41" ) == 0 );
8936  }
8937  FCT_TEST_END();
8938 #endif /* POLARSSL_SHA4_C */
8939 #endif /* POLARSSL_FS_IO */
8940 
8941 #ifdef POLARSSL_SHA4_C
8942 #ifdef POLARSSL_FS_IO
8943 
8944  FCT_TEST_BGN(generic_sha_512_hash_file_4)
8945  {
8946  char md_name[100];
8947  unsigned char hash_str[1000];
8948  unsigned char output[100];
8949  const md_info_t *md_info = NULL;
8950 
8951  memset(md_name, 0x00, 100);
8952  memset(hash_str, 0x00, 1000);
8953  memset(output, 0x00, 100);
8954 
8955  strncpy( (char *) md_name, "sha512", 100 );
8956  md_info = md_info_from_string( md_name );
8957  fct_chk( md_info != NULL );
8958 
8959  md_file( md_info, "data_files/hash_file_4", output);
8960  hexify( hash_str, output, md_get_size(md_info) );
8961 
8962  fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
8963  }
8964  FCT_TEST_END();
8965 #endif /* POLARSSL_SHA4_C */
8966 #endif /* POLARSSL_FS_IO */
8967 
8968  }
8969  FCT_SUITE_END();
8970 
8971 #endif /* POLARSSL_MD_C */
8972 
8973 }
8974 FCT_END();
8975