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