PolarSSL v1.2.5
test_suite_mdx.c
Go to the documentation of this file.
1 #include "fct.h"
2 
3 #include <polarssl/md2.h>
4 #include <polarssl/md4.h>
5 #include <polarssl/md5.h>
6 
7 #include <polarssl/config.h>
8 
9 #ifdef _MSC_VER
10 #include <basetsd.h>
11 typedef UINT32 uint32_t;
12 #else
13 #include <inttypes.h>
14 #endif
15 
16 /*
17  * 32-bit integer manipulation macros (big endian)
18  */
19 #ifndef GET_UINT32_BE
20 #define GET_UINT32_BE(n,b,i) \
21 { \
22  (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
23  | ( (uint32_t) (b)[(i) + 1] << 16 ) \
24  | ( (uint32_t) (b)[(i) + 2] << 8 ) \
25  | ( (uint32_t) (b)[(i) + 3] ); \
26 }
27 #endif
28 
29 #ifndef PUT_UINT32_BE
30 #define PUT_UINT32_BE(n,b,i) \
31 { \
32  (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
33  (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
34  (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
35  (b)[(i) + 3] = (unsigned char) ( (n) ); \
36 }
37 #endif
38 
39 int unhexify(unsigned char *obuf, const char *ibuf)
40 {
41  unsigned char c, c2;
42  int len = strlen(ibuf) / 2;
43  assert(!(strlen(ibuf) %1)); // must be even number of bytes
44 
45  while (*ibuf != 0)
46  {
47  c = *ibuf++;
48  if( c >= '0' && c <= '9' )
49  c -= '0';
50  else if( c >= 'a' && c <= 'f' )
51  c -= 'a' - 10;
52  else if( c >= 'A' && c <= 'F' )
53  c -= 'A' - 10;
54  else
55  assert( 0 );
56 
57  c2 = *ibuf++;
58  if( c2 >= '0' && c2 <= '9' )
59  c2 -= '0';
60  else if( c2 >= 'a' && c2 <= 'f' )
61  c2 -= 'a' - 10;
62  else if( c2 >= 'A' && c2 <= 'F' )
63  c2 -= 'A' - 10;
64  else
65  assert( 0 );
66 
67  *obuf++ = ( c << 4 ) | c2;
68  }
69 
70  return len;
71 }
72 
73 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
74 {
75  unsigned char l, h;
76 
77  while (len != 0)
78  {
79  h = (*ibuf) / 16;
80  l = (*ibuf) % 16;
81 
82  if( h < 10 )
83  *obuf++ = '0' + h;
84  else
85  *obuf++ = 'a' + h - 10;
86 
87  if( l < 10 )
88  *obuf++ = '0' + l;
89  else
90  *obuf++ = 'a' + l - 10;
91 
92  ++ibuf;
93  len--;
94  }
95 }
96 
106 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
107 {
108  size_t i;
109 
110  if( rng_state != NULL )
111  rng_state = NULL;
112 
113  for( i = 0; i < len; ++i )
114  output[i] = rand();
115 
116  return( 0 );
117 }
118 
124 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
125 {
126  if( rng_state != NULL )
127  rng_state = NULL;
128 
129  memset( output, 0, len );
130 
131  return( 0 );
132 }
133 
134 typedef struct
135 {
136  unsigned char *buf;
137  size_t length;
138 } rnd_buf_info;
139 
151 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
152 {
153  rnd_buf_info *info = (rnd_buf_info *) rng_state;
154  size_t use_len;
155 
156  if( rng_state == NULL )
157  return( rnd_std_rand( NULL, output, len ) );
158 
159  use_len = len;
160  if( len > info->length )
161  use_len = info->length;
162 
163  if( use_len )
164  {
165  memcpy( output, info->buf, use_len );
166  info->buf += use_len;
167  info->length -= use_len;
168  }
169 
170  if( len - use_len > 0 )
171  return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
172 
173  return( 0 );
174 }
175 
183 typedef struct
184 {
185  uint32_t key[16];
186  uint32_t v0, v1;
188 
197 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
198 {
199  rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
200  uint32_t i, *k, sum, delta=0x9E3779B9;
201  unsigned char result[4];
202 
203  if( rng_state == NULL )
204  return( rnd_std_rand( NULL, output, len ) );
205 
206  k = info->key;
207 
208  while( len > 0 )
209  {
210  size_t use_len = ( len > 4 ) ? 4 : len;
211  sum = 0;
212 
213  for( i = 0; i < 32; i++ )
214  {
215  info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
216  sum += delta;
217  info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
218  }
219 
220  PUT_UINT32_BE( info->v0, result, 0 );
221  memcpy( output, result, use_len );
222  len -= use_len;
223  }
224 
225  return( 0 );
226 }
227 
228 
230 {
231 
232 
233  FCT_SUITE_BGN(test_suite_mdx)
234  {
235 #ifdef POLARSSL_MD2_C
236 
237  FCT_TEST_BGN(md2_test_vector_rfc1319_1)
238  {
239  unsigned char src_str[1000];
240  unsigned char hash_str[1000];
241  unsigned char output[33];
242 
243  memset(src_str, 0x00, 1000);
244  memset(hash_str, 0x00, 1000);
245  memset(output, 0x00, 33);
246 
247  strcpy( (char *) src_str, "" );
248 
249  md2( src_str, strlen( (char *) src_str ), output );
250  hexify( hash_str, output, 16 );
251 
252  fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
253  }
254  FCT_TEST_END();
255 #endif /* POLARSSL_MD2_C */
256 
257 #ifdef POLARSSL_MD2_C
258 
259  FCT_TEST_BGN(md2_test_vector_rfc1319_2)
260  {
261  unsigned char src_str[1000];
262  unsigned char hash_str[1000];
263  unsigned char output[33];
264 
265  memset(src_str, 0x00, 1000);
266  memset(hash_str, 0x00, 1000);
267  memset(output, 0x00, 33);
268 
269  strcpy( (char *) src_str, "a" );
270 
271  md2( src_str, strlen( (char *) src_str ), output );
272  hexify( hash_str, output, 16 );
273 
274  fct_chk( strcmp( (char *) hash_str, "32ec01ec4a6dac72c0ab96fb34c0b5d1" ) == 0 );
275  }
276  FCT_TEST_END();
277 #endif /* POLARSSL_MD2_C */
278 
279 #ifdef POLARSSL_MD2_C
280 
281  FCT_TEST_BGN(md2_test_vector_rfc1319_3)
282  {
283  unsigned char src_str[1000];
284  unsigned char hash_str[1000];
285  unsigned char output[33];
286 
287  memset(src_str, 0x00, 1000);
288  memset(hash_str, 0x00, 1000);
289  memset(output, 0x00, 33);
290 
291  strcpy( (char *) src_str, "abc" );
292 
293  md2( src_str, strlen( (char *) src_str ), output );
294  hexify( hash_str, output, 16 );
295 
296  fct_chk( strcmp( (char *) hash_str, "da853b0d3f88d99b30283a69e6ded6bb" ) == 0 );
297  }
298  FCT_TEST_END();
299 #endif /* POLARSSL_MD2_C */
300 
301 #ifdef POLARSSL_MD2_C
302 
303  FCT_TEST_BGN(md2_test_vector_rfc1319_4)
304  {
305  unsigned char src_str[1000];
306  unsigned char hash_str[1000];
307  unsigned char output[33];
308 
309  memset(src_str, 0x00, 1000);
310  memset(hash_str, 0x00, 1000);
311  memset(output, 0x00, 33);
312 
313  strcpy( (char *) src_str, "message digest" );
314 
315  md2( src_str, strlen( (char *) src_str ), output );
316  hexify( hash_str, output, 16 );
317 
318  fct_chk( strcmp( (char *) hash_str, "ab4f496bfb2a530b219ff33031fe06b0" ) == 0 );
319  }
320  FCT_TEST_END();
321 #endif /* POLARSSL_MD2_C */
322 
323 #ifdef POLARSSL_MD2_C
324 
325  FCT_TEST_BGN(md2_test_vector_rfc1319_5)
326  {
327  unsigned char src_str[1000];
328  unsigned char hash_str[1000];
329  unsigned char output[33];
330 
331  memset(src_str, 0x00, 1000);
332  memset(hash_str, 0x00, 1000);
333  memset(output, 0x00, 33);
334 
335  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
336 
337  md2( src_str, strlen( (char *) src_str ), output );
338  hexify( hash_str, output, 16 );
339 
340  fct_chk( strcmp( (char *) hash_str, "4e8ddff3650292ab5a4108c3aa47940b" ) == 0 );
341  }
342  FCT_TEST_END();
343 #endif /* POLARSSL_MD2_C */
344 
345 #ifdef POLARSSL_MD2_C
346 
347  FCT_TEST_BGN(md2_test_vector_rfc1319_6)
348  {
349  unsigned char src_str[1000];
350  unsigned char hash_str[1000];
351  unsigned char output[33];
352 
353  memset(src_str, 0x00, 1000);
354  memset(hash_str, 0x00, 1000);
355  memset(output, 0x00, 33);
356 
357  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
358 
359  md2( src_str, strlen( (char *) src_str ), output );
360  hexify( hash_str, output, 16 );
361 
362  fct_chk( strcmp( (char *) hash_str, "da33def2a42df13975352846c30338cd" ) == 0 );
363  }
364  FCT_TEST_END();
365 #endif /* POLARSSL_MD2_C */
366 
367 #ifdef POLARSSL_MD2_C
368 
369  FCT_TEST_BGN(md2_test_vector_rfc1319_7)
370  {
371  unsigned char src_str[1000];
372  unsigned char hash_str[1000];
373  unsigned char output[33];
374 
375  memset(src_str, 0x00, 1000);
376  memset(hash_str, 0x00, 1000);
377  memset(output, 0x00, 33);
378 
379  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
380 
381  md2( src_str, strlen( (char *) src_str ), output );
382  hexify( hash_str, output, 16 );
383 
384  fct_chk( strcmp( (char *) hash_str, "d5976f79d83d3a0dc9806c3c66f3efd8" ) == 0 );
385  }
386  FCT_TEST_END();
387 #endif /* POLARSSL_MD2_C */
388 
389 #ifdef POLARSSL_MD4_C
390 
391  FCT_TEST_BGN(md4_test_vector_rfc1320_1)
392  {
393  unsigned char src_str[1000];
394  unsigned char hash_str[1000];
395  unsigned char output[33];
396 
397  memset(src_str, 0x00, 1000);
398  memset(hash_str, 0x00, 1000);
399  memset(output, 0x00, 33);
400 
401  strcpy( (char *) src_str, "" );
402 
403  md4( src_str, strlen( (char *) src_str ), output );
404  hexify( hash_str, output, 16 );
405 
406  fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
407  }
408  FCT_TEST_END();
409 #endif /* POLARSSL_MD4_C */
410 
411 #ifdef POLARSSL_MD4_C
412 
413  FCT_TEST_BGN(md4_test_vector_rfc1320_2)
414  {
415  unsigned char src_str[1000];
416  unsigned char hash_str[1000];
417  unsigned char output[33];
418 
419  memset(src_str, 0x00, 1000);
420  memset(hash_str, 0x00, 1000);
421  memset(output, 0x00, 33);
422 
423  strcpy( (char *) src_str, "a" );
424 
425  md4( src_str, strlen( (char *) src_str ), output );
426  hexify( hash_str, output, 16 );
427 
428  fct_chk( strcmp( (char *) hash_str, "bde52cb31de33e46245e05fbdbd6fb24" ) == 0 );
429  }
430  FCT_TEST_END();
431 #endif /* POLARSSL_MD4_C */
432 
433 #ifdef POLARSSL_MD4_C
434 
435  FCT_TEST_BGN(md4_test_vector_rfc1320_3)
436  {
437  unsigned char src_str[1000];
438  unsigned char hash_str[1000];
439  unsigned char output[33];
440 
441  memset(src_str, 0x00, 1000);
442  memset(hash_str, 0x00, 1000);
443  memset(output, 0x00, 33);
444 
445  strcpy( (char *) src_str, "abc" );
446 
447  md4( src_str, strlen( (char *) src_str ), output );
448  hexify( hash_str, output, 16 );
449 
450  fct_chk( strcmp( (char *) hash_str, "a448017aaf21d8525fc10ae87aa6729d" ) == 0 );
451  }
452  FCT_TEST_END();
453 #endif /* POLARSSL_MD4_C */
454 
455 #ifdef POLARSSL_MD4_C
456 
457  FCT_TEST_BGN(md4_test_vector_rfc1320_4)
458  {
459  unsigned char src_str[1000];
460  unsigned char hash_str[1000];
461  unsigned char output[33];
462 
463  memset(src_str, 0x00, 1000);
464  memset(hash_str, 0x00, 1000);
465  memset(output, 0x00, 33);
466 
467  strcpy( (char *) src_str, "message digest" );
468 
469  md4( src_str, strlen( (char *) src_str ), output );
470  hexify( hash_str, output, 16 );
471 
472  fct_chk( strcmp( (char *) hash_str, "d9130a8164549fe818874806e1c7014b" ) == 0 );
473  }
474  FCT_TEST_END();
475 #endif /* POLARSSL_MD4_C */
476 
477 #ifdef POLARSSL_MD4_C
478 
479  FCT_TEST_BGN(md4_test_vector_rfc1320_5)
480  {
481  unsigned char src_str[1000];
482  unsigned char hash_str[1000];
483  unsigned char output[33];
484 
485  memset(src_str, 0x00, 1000);
486  memset(hash_str, 0x00, 1000);
487  memset(output, 0x00, 33);
488 
489  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
490 
491  md4( src_str, strlen( (char *) src_str ), output );
492  hexify( hash_str, output, 16 );
493 
494  fct_chk( strcmp( (char *) hash_str, "d79e1c308aa5bbcdeea8ed63df412da9" ) == 0 );
495  }
496  FCT_TEST_END();
497 #endif /* POLARSSL_MD4_C */
498 
499 #ifdef POLARSSL_MD4_C
500 
501  FCT_TEST_BGN(md4_test_vector_rfc1320_6)
502  {
503  unsigned char src_str[1000];
504  unsigned char hash_str[1000];
505  unsigned char output[33];
506 
507  memset(src_str, 0x00, 1000);
508  memset(hash_str, 0x00, 1000);
509  memset(output, 0x00, 33);
510 
511  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
512 
513  md4( src_str, strlen( (char *) src_str ), output );
514  hexify( hash_str, output, 16 );
515 
516  fct_chk( strcmp( (char *) hash_str, "043f8582f241db351ce627e153e7f0e4" ) == 0 );
517  }
518  FCT_TEST_END();
519 #endif /* POLARSSL_MD4_C */
520 
521 #ifdef POLARSSL_MD4_C
522 
523  FCT_TEST_BGN(md4_test_vector_rfc1320_7)
524  {
525  unsigned char src_str[1000];
526  unsigned char hash_str[1000];
527  unsigned char output[33];
528 
529  memset(src_str, 0x00, 1000);
530  memset(hash_str, 0x00, 1000);
531  memset(output, 0x00, 33);
532 
533  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
534 
535  md4( src_str, strlen( (char *) src_str ), output );
536  hexify( hash_str, output, 16 );
537 
538  fct_chk( strcmp( (char *) hash_str, "e33b4ddc9c38f2199c3e7b164fcc0536" ) == 0 );
539  }
540  FCT_TEST_END();
541 #endif /* POLARSSL_MD4_C */
542 
543 #ifdef POLARSSL_MD5_C
544 
545  FCT_TEST_BGN(md5_test_vector_rfc1321_1)
546  {
547  unsigned char src_str[1000];
548  unsigned char hash_str[1000];
549  unsigned char output[33];
550 
551  memset(src_str, 0x00, 1000);
552  memset(hash_str, 0x00, 1000);
553  memset(output, 0x00, 33);
554 
555  strcpy( (char *) src_str, "" );
556 
557  md5( src_str, strlen( (char *) src_str ), output );
558  hexify( hash_str, output, 16 );
559 
560  fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
561  }
562  FCT_TEST_END();
563 #endif /* POLARSSL_MD5_C */
564 
565 #ifdef POLARSSL_MD5_C
566 
567  FCT_TEST_BGN(md5_test_vector_rfc1321_2)
568  {
569  unsigned char src_str[1000];
570  unsigned char hash_str[1000];
571  unsigned char output[33];
572 
573  memset(src_str, 0x00, 1000);
574  memset(hash_str, 0x00, 1000);
575  memset(output, 0x00, 33);
576 
577  strcpy( (char *) src_str, "a" );
578 
579  md5( src_str, strlen( (char *) src_str ), output );
580  hexify( hash_str, output, 16 );
581 
582  fct_chk( strcmp( (char *) hash_str, "0cc175b9c0f1b6a831c399e269772661" ) == 0 );
583  }
584  FCT_TEST_END();
585 #endif /* POLARSSL_MD5_C */
586 
587 #ifdef POLARSSL_MD5_C
588 
589  FCT_TEST_BGN(md5_test_vector_rfc1321_3)
590  {
591  unsigned char src_str[1000];
592  unsigned char hash_str[1000];
593  unsigned char output[33];
594 
595  memset(src_str, 0x00, 1000);
596  memset(hash_str, 0x00, 1000);
597  memset(output, 0x00, 33);
598 
599  strcpy( (char *) src_str, "abc" );
600 
601  md5( src_str, strlen( (char *) src_str ), output );
602  hexify( hash_str, output, 16 );
603 
604  fct_chk( strcmp( (char *) hash_str, "900150983cd24fb0d6963f7d28e17f72" ) == 0 );
605  }
606  FCT_TEST_END();
607 #endif /* POLARSSL_MD5_C */
608 
609 #ifdef POLARSSL_MD5_C
610 
611  FCT_TEST_BGN(md5_test_vector_rfc1321_4)
612  {
613  unsigned char src_str[1000];
614  unsigned char hash_str[1000];
615  unsigned char output[33];
616 
617  memset(src_str, 0x00, 1000);
618  memset(hash_str, 0x00, 1000);
619  memset(output, 0x00, 33);
620 
621  strcpy( (char *) src_str, "message digest" );
622 
623  md5( src_str, strlen( (char *) src_str ), output );
624  hexify( hash_str, output, 16 );
625 
626  fct_chk( strcmp( (char *) hash_str, "f96b697d7cb7938d525a2f31aaf161d0" ) == 0 );
627  }
628  FCT_TEST_END();
629 #endif /* POLARSSL_MD5_C */
630 
631 #ifdef POLARSSL_MD5_C
632 
633  FCT_TEST_BGN(md5_test_vector_rfc1321_5)
634  {
635  unsigned char src_str[1000];
636  unsigned char hash_str[1000];
637  unsigned char output[33];
638 
639  memset(src_str, 0x00, 1000);
640  memset(hash_str, 0x00, 1000);
641  memset(output, 0x00, 33);
642 
643  strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
644 
645  md5( src_str, strlen( (char *) src_str ), output );
646  hexify( hash_str, output, 16 );
647 
648  fct_chk( strcmp( (char *) hash_str, "c3fcd3d76192e4007dfb496cca67e13b" ) == 0 );
649  }
650  FCT_TEST_END();
651 #endif /* POLARSSL_MD5_C */
652 
653 #ifdef POLARSSL_MD5_C
654 
655  FCT_TEST_BGN(md5_test_vector_rfc1321_6)
656  {
657  unsigned char src_str[1000];
658  unsigned char hash_str[1000];
659  unsigned char output[33];
660 
661  memset(src_str, 0x00, 1000);
662  memset(hash_str, 0x00, 1000);
663  memset(output, 0x00, 33);
664 
665  strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
666 
667  md5( src_str, strlen( (char *) src_str ), output );
668  hexify( hash_str, output, 16 );
669 
670  fct_chk( strcmp( (char *) hash_str, "d174ab98d277d9f5a5611c2c9f419d9f" ) == 0 );
671  }
672  FCT_TEST_END();
673 #endif /* POLARSSL_MD5_C */
674 
675 #ifdef POLARSSL_MD5_C
676 
677  FCT_TEST_BGN(md5_test_vector_rfc1321_7)
678  {
679  unsigned char src_str[1000];
680  unsigned char hash_str[1000];
681  unsigned char output[33];
682 
683  memset(src_str, 0x00, 1000);
684  memset(hash_str, 0x00, 1000);
685  memset(output, 0x00, 33);
686 
687  strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
688 
689  md5( src_str, strlen( (char *) src_str ), output );
690  hexify( hash_str, output, 16 );
691 
692  fct_chk( strcmp( (char *) hash_str, "57edf4a22be3c955ac49da2e2107b67a" ) == 0 );
693  }
694  FCT_TEST_END();
695 #endif /* POLARSSL_MD5_C */
696 
697 #ifdef POLARSSL_MD2_C
698 
699  FCT_TEST_BGN(hmac_md2_hash_file_openssl_test_1)
700  {
701  unsigned char src_str[10000];
702  unsigned char key_str[10000];
703  unsigned char hash_str[10000];
704  unsigned char output[33];
705  int key_len, src_len;
706 
707  memset(src_str, 0x00, 10000);
708  memset(key_str, 0x00, 10000);
709  memset(hash_str, 0x00, 10000);
710  memset(output, 0x00, 33);
711 
712  key_len = unhexify( key_str, "61616161616161616161616161616161" );
713  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
714 
715  md2_hmac( key_str, key_len, src_str, src_len, output );
716  hexify( hash_str, output, 16 );
717 
718  fct_chk( strncmp( (char *) hash_str, "d5732582f494f5ddf35efd166c85af9c", 16 * 2 ) == 0 );
719  }
720  FCT_TEST_END();
721 #endif /* POLARSSL_MD2_C */
722 
723 #ifdef POLARSSL_MD2_C
724 
725  FCT_TEST_BGN(hmac_md2_hash_file_openssl_test_2)
726  {
727  unsigned char src_str[10000];
728  unsigned char key_str[10000];
729  unsigned char hash_str[10000];
730  unsigned char output[33];
731  int key_len, src_len;
732 
733  memset(src_str, 0x00, 10000);
734  memset(key_str, 0x00, 10000);
735  memset(hash_str, 0x00, 10000);
736  memset(output, 0x00, 33);
737 
738  key_len = unhexify( key_str, "61616161616161616161616161616161" );
739  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
740 
741  md2_hmac( key_str, key_len, src_str, src_len, output );
742  hexify( hash_str, output, 16 );
743 
744  fct_chk( strncmp( (char *) hash_str, "54ab68503f7d1b5c7741340dff2722a9", 16 * 2 ) == 0 );
745  }
746  FCT_TEST_END();
747 #endif /* POLARSSL_MD2_C */
748 
749 #ifdef POLARSSL_MD2_C
750 
751  FCT_TEST_BGN(hmac_md2_hash_file_openssl_test_3)
752  {
753  unsigned char src_str[10000];
754  unsigned char key_str[10000];
755  unsigned char hash_str[10000];
756  unsigned char output[33];
757  int key_len, src_len;
758 
759  memset(src_str, 0x00, 10000);
760  memset(key_str, 0x00, 10000);
761  memset(hash_str, 0x00, 10000);
762  memset(output, 0x00, 33);
763 
764  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
765  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
766 
767  md2_hmac( key_str, key_len, src_str, src_len, output );
768  hexify( hash_str, output, 16 );
769 
770  fct_chk( strncmp( (char *) hash_str, "d850e5f554558cf0fe79a0612e1d0365", 16 * 2 ) == 0 );
771  }
772  FCT_TEST_END();
773 #endif /* POLARSSL_MD2_C */
774 
775 #ifdef POLARSSL_MD4_C
776 
777  FCT_TEST_BGN(hmac_md4_hash_file_openssl_test_1)
778  {
779  unsigned char src_str[10000];
780  unsigned char key_str[10000];
781  unsigned char hash_str[10000];
782  unsigned char output[33];
783  int key_len, src_len;
784 
785  memset(src_str, 0x00, 10000);
786  memset(key_str, 0x00, 10000);
787  memset(hash_str, 0x00, 10000);
788  memset(output, 0x00, 33);
789 
790  key_len = unhexify( key_str, "61616161616161616161616161616161" );
791  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
792 
793  md4_hmac( key_str, key_len, src_str, src_len, output );
794  hexify( hash_str, output, 16 );
795 
796  fct_chk( strncmp( (char *) hash_str, "eabd0fbefb82fb0063a25a6d7b8bdc0f", 16 * 2 ) == 0 );
797  }
798  FCT_TEST_END();
799 #endif /* POLARSSL_MD4_C */
800 
801 #ifdef POLARSSL_MD4_C
802 
803  FCT_TEST_BGN(hmac_md4_hash_file_openssl_test_2)
804  {
805  unsigned char src_str[10000];
806  unsigned char key_str[10000];
807  unsigned char hash_str[10000];
808  unsigned char output[33];
809  int key_len, src_len;
810 
811  memset(src_str, 0x00, 10000);
812  memset(key_str, 0x00, 10000);
813  memset(hash_str, 0x00, 10000);
814  memset(output, 0x00, 33);
815 
816  key_len = unhexify( key_str, "61616161616161616161616161616161" );
817  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
818 
819  md4_hmac( key_str, key_len, src_str, src_len, output );
820  hexify( hash_str, output, 16 );
821 
822  fct_chk( strncmp( (char *) hash_str, "cec3c5e421a7b783aa89cacf78daf6dc", 16 * 2 ) == 0 );
823  }
824  FCT_TEST_END();
825 #endif /* POLARSSL_MD4_C */
826 
827 #ifdef POLARSSL_MD4_C
828 
829  FCT_TEST_BGN(hmac_md4_hash_file_openssl_test_3)
830  {
831  unsigned char src_str[10000];
832  unsigned char key_str[10000];
833  unsigned char hash_str[10000];
834  unsigned char output[33];
835  int key_len, src_len;
836 
837  memset(src_str, 0x00, 10000);
838  memset(key_str, 0x00, 10000);
839  memset(hash_str, 0x00, 10000);
840  memset(output, 0x00, 33);
841 
842  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
843  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
844 
845  md4_hmac( key_str, key_len, src_str, src_len, output );
846  hexify( hash_str, output, 16 );
847 
848  fct_chk( strncmp( (char *) hash_str, "ad5f0a04116109b397b57f9cc9b6df4b", 16 * 2 ) == 0 );
849  }
850  FCT_TEST_END();
851 #endif /* POLARSSL_MD4_C */
852 
853 #ifdef POLARSSL_MD5_C
854 
855  FCT_TEST_BGN(hmac_md5_hash_file_openssl_test_1)
856  {
857  unsigned char src_str[10000];
858  unsigned char key_str[10000];
859  unsigned char hash_str[10000];
860  unsigned char output[33];
861  int key_len, src_len;
862 
863  memset(src_str, 0x00, 10000);
864  memset(key_str, 0x00, 10000);
865  memset(hash_str, 0x00, 10000);
866  memset(output, 0x00, 33);
867 
868  key_len = unhexify( key_str, "61616161616161616161616161616161" );
869  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
870 
871  md5_hmac( key_str, key_len, src_str, src_len, output );
872  hexify( hash_str, output, 16 );
873 
874  fct_chk( strncmp( (char *) hash_str, "42552882f00bd4633ea81135a184b284", 16 * 2 ) == 0 );
875  }
876  FCT_TEST_END();
877 #endif /* POLARSSL_MD5_C */
878 
879 #ifdef POLARSSL_MD5_C
880 
881  FCT_TEST_BGN(hmac_md5_hash_file_openssl_test_2)
882  {
883  unsigned char src_str[10000];
884  unsigned char key_str[10000];
885  unsigned char hash_str[10000];
886  unsigned char output[33];
887  int key_len, src_len;
888 
889  memset(src_str, 0x00, 10000);
890  memset(key_str, 0x00, 10000);
891  memset(hash_str, 0x00, 10000);
892  memset(output, 0x00, 33);
893 
894  key_len = unhexify( key_str, "61616161616161616161616161616161" );
895  src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
896 
897  md5_hmac( key_str, key_len, src_str, src_len, output );
898  hexify( hash_str, output, 16 );
899 
900  fct_chk( strncmp( (char *) hash_str, "a16a842891786d01fe50ba7731db7464", 16 * 2 ) == 0 );
901  }
902  FCT_TEST_END();
903 #endif /* POLARSSL_MD5_C */
904 
905 #ifdef POLARSSL_MD5_C
906 
907  FCT_TEST_BGN(hmac_md5_hash_file_openssl_test_3)
908  {
909  unsigned char src_str[10000];
910  unsigned char key_str[10000];
911  unsigned char hash_str[10000];
912  unsigned char output[33];
913  int key_len, src_len;
914 
915  memset(src_str, 0x00, 10000);
916  memset(key_str, 0x00, 10000);
917  memset(hash_str, 0x00, 10000);
918  memset(output, 0x00, 33);
919 
920  key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
921  src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
922 
923  md5_hmac( key_str, key_len, src_str, src_len, output );
924  hexify( hash_str, output, 16 );
925 
926  fct_chk( strncmp( (char *) hash_str, "e97f623936f98a7f741c4bd0612fecc2", 16 * 2 ) == 0 );
927  }
928  FCT_TEST_END();
929 #endif /* POLARSSL_MD5_C */
930 
931 #ifdef POLARSSL_MD5_C
932 
933  FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_1)
934  {
935  unsigned char src_str[10000];
936  unsigned char key_str[10000];
937  unsigned char hash_str[10000];
938  unsigned char output[33];
939  int key_len, src_len;
940 
941  memset(src_str, 0x00, 10000);
942  memset(key_str, 0x00, 10000);
943  memset(hash_str, 0x00, 10000);
944  memset(output, 0x00, 33);
945 
946  key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
947  src_len = unhexify( src_str, "4869205468657265" );
948 
949  md5_hmac( key_str, key_len, src_str, src_len, output );
950  hexify( hash_str, output, 16 );
951 
952  fct_chk( strncmp( (char *) hash_str, "9294727a3638bb1c13f48ef8158bfc9d", 16 * 2 ) == 0 );
953  }
954  FCT_TEST_END();
955 #endif /* POLARSSL_MD5_C */
956 
957 #ifdef POLARSSL_MD5_C
958 
959  FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_2)
960  {
961  unsigned char src_str[10000];
962  unsigned char key_str[10000];
963  unsigned char hash_str[10000];
964  unsigned char output[33];
965  int key_len, src_len;
966 
967  memset(src_str, 0x00, 10000);
968  memset(key_str, 0x00, 10000);
969  memset(hash_str, 0x00, 10000);
970  memset(output, 0x00, 33);
971 
972  key_len = unhexify( key_str, "4a656665" );
973  src_len = unhexify( src_str, "7768617420646f2079612077616e7420666f72206e6f7468696e673f" );
974 
975  md5_hmac( key_str, key_len, src_str, src_len, output );
976  hexify( hash_str, output, 16 );
977 
978  fct_chk( strncmp( (char *) hash_str, "750c783e6ab0b503eaa86e310a5db738", 16 * 2 ) == 0 );
979  }
980  FCT_TEST_END();
981 #endif /* POLARSSL_MD5_C */
982 
983 #ifdef POLARSSL_MD5_C
984 
985  FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_3)
986  {
987  unsigned char src_str[10000];
988  unsigned char key_str[10000];
989  unsigned char hash_str[10000];
990  unsigned char output[33];
991  int key_len, src_len;
992 
993  memset(src_str, 0x00, 10000);
994  memset(key_str, 0x00, 10000);
995  memset(hash_str, 0x00, 10000);
996  memset(output, 0x00, 33);
997 
998  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
999  src_len = unhexify( src_str, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" );
1000 
1001  md5_hmac( key_str, key_len, src_str, src_len, output );
1002  hexify( hash_str, output, 16 );
1003 
1004  fct_chk( strncmp( (char *) hash_str, "56be34521d144c88dbb8c733f0e8b3f6", 16 * 2 ) == 0 );
1005  }
1006  FCT_TEST_END();
1007 #endif /* POLARSSL_MD5_C */
1008 
1009 #ifdef POLARSSL_MD5_C
1010 
1011  FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_4)
1012  {
1013  unsigned char src_str[10000];
1014  unsigned char key_str[10000];
1015  unsigned char hash_str[10000];
1016  unsigned char output[33];
1017  int key_len, src_len;
1018 
1019  memset(src_str, 0x00, 10000);
1020  memset(key_str, 0x00, 10000);
1021  memset(hash_str, 0x00, 10000);
1022  memset(output, 0x00, 33);
1023 
1024  key_len = unhexify( key_str, "0102030405060708090a0b0c0d0e0f10111213141516171819" );
1025  src_len = unhexify( src_str, "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
1026 
1027  md5_hmac( key_str, key_len, src_str, src_len, output );
1028  hexify( hash_str, output, 16 );
1029 
1030  fct_chk( strncmp( (char *) hash_str, "697eaf0aca3a3aea3a75164746ffaa79", 16 * 2 ) == 0 );
1031  }
1032  FCT_TEST_END();
1033 #endif /* POLARSSL_MD5_C */
1034 
1035 #ifdef POLARSSL_MD5_C
1036 
1037  FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_5)
1038  {
1039  unsigned char src_str[10000];
1040  unsigned char key_str[10000];
1041  unsigned char hash_str[10000];
1042  unsigned char output[33];
1043  int key_len, src_len;
1044 
1045  memset(src_str, 0x00, 10000);
1046  memset(key_str, 0x00, 10000);
1047  memset(hash_str, 0x00, 10000);
1048  memset(output, 0x00, 33);
1049 
1050  key_len = unhexify( key_str, "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" );
1051  src_len = unhexify( src_str, "546573742057697468205472756e636174696f6e" );
1052 
1053  md5_hmac( key_str, key_len, src_str, src_len, output );
1054  hexify( hash_str, output, 16 );
1055 
1056  fct_chk( strncmp( (char *) hash_str, "56461ef2342edc00f9bab995", 12 * 2 ) == 0 );
1057  }
1058  FCT_TEST_END();
1059 #endif /* POLARSSL_MD5_C */
1060 
1061 #ifdef POLARSSL_MD5_C
1062 
1063  FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_6)
1064  {
1065  unsigned char src_str[10000];
1066  unsigned char key_str[10000];
1067  unsigned char hash_str[10000];
1068  unsigned char output[33];
1069  int key_len, src_len;
1070 
1071  memset(src_str, 0x00, 10000);
1072  memset(key_str, 0x00, 10000);
1073  memset(hash_str, 0x00, 10000);
1074  memset(output, 0x00, 33);
1075 
1076  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
1077  src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374" );
1078 
1079  md5_hmac( key_str, key_len, src_str, src_len, output );
1080  hexify( hash_str, output, 16 );
1081 
1082  fct_chk( strncmp( (char *) hash_str, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", 16 * 2 ) == 0 );
1083  }
1084  FCT_TEST_END();
1085 #endif /* POLARSSL_MD5_C */
1086 
1087 #ifdef POLARSSL_MD5_C
1088 
1089  FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_7)
1090  {
1091  unsigned char src_str[10000];
1092  unsigned char key_str[10000];
1093  unsigned char hash_str[10000];
1094  unsigned char output[33];
1095  int key_len, src_len;
1096 
1097  memset(src_str, 0x00, 10000);
1098  memset(key_str, 0x00, 10000);
1099  memset(hash_str, 0x00, 10000);
1100  memset(output, 0x00, 33);
1101 
1102  key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
1103  src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461" );
1104 
1105  md5_hmac( key_str, key_len, src_str, src_len, output );
1106  hexify( hash_str, output, 16 );
1107 
1108  fct_chk( strncmp( (char *) hash_str, "6f630fad67cda0ee1fb1f562db3aa53e", 16 * 2 ) == 0 );
1109  }
1110  FCT_TEST_END();
1111 #endif /* POLARSSL_MD5_C */
1112 
1113 #ifdef POLARSSL_MD2_C
1114 
1115  FCT_TEST_BGN(hmac_md2_bouncy_castle_test_1)
1116  {
1117  unsigned char src_str[10000];
1118  unsigned char key_str[10000];
1119  unsigned char hash_str[10000];
1120  unsigned char output[33];
1121  int key_len, src_len;
1122 
1123  memset(src_str, 0x00, 10000);
1124  memset(key_str, 0x00, 10000);
1125  memset(hash_str, 0x00, 10000);
1126  memset(output, 0x00, 33);
1127 
1128  key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
1129  src_len = unhexify( src_str, "4869205468657265" );
1130 
1131  md2_hmac( key_str, key_len, src_str, src_len, output );
1132  hexify( hash_str, output, 16 );
1133 
1134  fct_chk( strncmp( (char *) hash_str, "dc1923ef5f161d35bef839ca8c807808", 16 * 2 ) == 0 );
1135  }
1136  FCT_TEST_END();
1137 #endif /* POLARSSL_MD2_C */
1138 
1139 #ifdef POLARSSL_MD4_C
1140 
1141  FCT_TEST_BGN(hmac_md4_bouncy_castle_test_1)
1142  {
1143  unsigned char src_str[10000];
1144  unsigned char key_str[10000];
1145  unsigned char hash_str[10000];
1146  unsigned char output[33];
1147  int key_len, src_len;
1148 
1149  memset(src_str, 0x00, 10000);
1150  memset(key_str, 0x00, 10000);
1151  memset(hash_str, 0x00, 10000);
1152  memset(output, 0x00, 33);
1153 
1154  key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
1155  src_len = unhexify( src_str, "4869205468657265" );
1156 
1157  md4_hmac( key_str, key_len, src_str, src_len, output );
1158  hexify( hash_str, output, 16 );
1159 
1160  fct_chk( strncmp( (char *) hash_str, "5570ce964ba8c11756cdc3970278ff5a", 16 * 2 ) == 0 );
1161  }
1162  FCT_TEST_END();
1163 #endif /* POLARSSL_MD4_C */
1164 
1165 #ifdef POLARSSL_MD5_C
1166 
1167  FCT_TEST_BGN(hmac_md5_bouncy_castle_test_1)
1168  {
1169  unsigned char src_str[10000];
1170  unsigned char key_str[10000];
1171  unsigned char hash_str[10000];
1172  unsigned char output[33];
1173  int key_len, src_len;
1174 
1175  memset(src_str, 0x00, 10000);
1176  memset(key_str, 0x00, 10000);
1177  memset(hash_str, 0x00, 10000);
1178  memset(output, 0x00, 33);
1179 
1180  key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
1181  src_len = unhexify( src_str, "4869205468657265" );
1182 
1183  md5_hmac( key_str, key_len, src_str, src_len, output );
1184  hexify( hash_str, output, 16 );
1185 
1186  fct_chk( strncmp( (char *) hash_str, "5ccec34ea9656392457fa1ac27f08fbc", 16 * 2 ) == 0 );
1187  }
1188  FCT_TEST_END();
1189 #endif /* POLARSSL_MD5_C */
1190 
1191 #ifdef POLARSSL_MD2_C
1192 #ifdef POLARSSL_FS_IO
1193 
1194  FCT_TEST_BGN(md2_hash_file_1)
1195  {
1196  unsigned char hash_str[65];
1197  unsigned char output[33];
1198 
1199  memset(hash_str, 0x00, 65);
1200  memset(output, 0x00, 33);
1201 
1202  md2_file( "data_files/hash_file_1", output);
1203  hexify( hash_str, output, 16 );
1204 
1205  fct_chk( strcmp( (char *) hash_str, "b593c098712d2e21628c8986695451a8" ) == 0 );
1206  }
1207  FCT_TEST_END();
1208 #endif /* POLARSSL_MD2_C */
1209 #endif /* POLARSSL_FS_IO */
1210 
1211 #ifdef POLARSSL_MD2_C
1212 #ifdef POLARSSL_FS_IO
1213 
1214  FCT_TEST_BGN(md2_hash_file_2)
1215  {
1216  unsigned char hash_str[65];
1217  unsigned char output[33];
1218 
1219  memset(hash_str, 0x00, 65);
1220  memset(output, 0x00, 33);
1221 
1222  md2_file( "data_files/hash_file_2", output);
1223  hexify( hash_str, output, 16 );
1224 
1225  fct_chk( strcmp( (char *) hash_str, "3c027b7409909a4c4b26bbab69ad9f4f" ) == 0 );
1226  }
1227  FCT_TEST_END();
1228 #endif /* POLARSSL_MD2_C */
1229 #endif /* POLARSSL_FS_IO */
1230 
1231 #ifdef POLARSSL_MD2_C
1232 #ifdef POLARSSL_FS_IO
1233 
1234  FCT_TEST_BGN(md2_hash_file_3)
1235  {
1236  unsigned char hash_str[65];
1237  unsigned char output[33];
1238 
1239  memset(hash_str, 0x00, 65);
1240  memset(output, 0x00, 33);
1241 
1242  md2_file( "data_files/hash_file_3", output);
1243  hexify( hash_str, output, 16 );
1244 
1245  fct_chk( strcmp( (char *) hash_str, "6bb43eb285e81f414083a94cdbe2989d" ) == 0 );
1246  }
1247  FCT_TEST_END();
1248 #endif /* POLARSSL_MD2_C */
1249 #endif /* POLARSSL_FS_IO */
1250 
1251 #ifdef POLARSSL_MD2_C
1252 #ifdef POLARSSL_FS_IO
1253 
1254  FCT_TEST_BGN(md2_hash_file_4)
1255  {
1256  unsigned char hash_str[65];
1257  unsigned char output[33];
1258 
1259  memset(hash_str, 0x00, 65);
1260  memset(output, 0x00, 33);
1261 
1262  md2_file( "data_files/hash_file_4", output);
1263  hexify( hash_str, output, 16 );
1264 
1265  fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
1266  }
1267  FCT_TEST_END();
1268 #endif /* POLARSSL_MD2_C */
1269 #endif /* POLARSSL_FS_IO */
1270 
1271 #ifdef POLARSSL_MD4_C
1272 #ifdef POLARSSL_FS_IO
1273 
1274  FCT_TEST_BGN(md4_hash_file_1)
1275  {
1276  unsigned char hash_str[65];
1277  unsigned char output[33];
1278 
1279  memset(hash_str, 0x00, 65);
1280  memset(output, 0x00, 33);
1281 
1282  md4_file( "data_files/hash_file_1", output);
1283  hexify( hash_str, output, 16 );
1284 
1285  fct_chk( strcmp( (char *) hash_str, "8d19772c176bd27153b9486715e2c0b9" ) == 0 );
1286  }
1287  FCT_TEST_END();
1288 #endif /* POLARSSL_MD4_C */
1289 #endif /* POLARSSL_FS_IO */
1290 
1291 #ifdef POLARSSL_MD4_C
1292 #ifdef POLARSSL_FS_IO
1293 
1294  FCT_TEST_BGN(md4_hash_file_2)
1295  {
1296  unsigned char hash_str[65];
1297  unsigned char output[33];
1298 
1299  memset(hash_str, 0x00, 65);
1300  memset(output, 0x00, 33);
1301 
1302  md4_file( "data_files/hash_file_2", output);
1303  hexify( hash_str, output, 16 );
1304 
1305  fct_chk( strcmp( (char *) hash_str, "f2ac53b8542882a5a0007c6f84b4d9fd" ) == 0 );
1306  }
1307  FCT_TEST_END();
1308 #endif /* POLARSSL_MD4_C */
1309 #endif /* POLARSSL_FS_IO */
1310 
1311 #ifdef POLARSSL_MD4_C
1312 #ifdef POLARSSL_FS_IO
1313 
1314  FCT_TEST_BGN(md4_hash_file_3)
1315  {
1316  unsigned char hash_str[65];
1317  unsigned char output[33];
1318 
1319  memset(hash_str, 0x00, 65);
1320  memset(output, 0x00, 33);
1321 
1322  md4_file( "data_files/hash_file_3", output);
1323  hexify( hash_str, output, 16 );
1324 
1325  fct_chk( strcmp( (char *) hash_str, "195c15158e2d07881d9a654095ce4a42" ) == 0 );
1326  }
1327  FCT_TEST_END();
1328 #endif /* POLARSSL_MD4_C */
1329 #endif /* POLARSSL_FS_IO */
1330 
1331 #ifdef POLARSSL_MD4_C
1332 #ifdef POLARSSL_FS_IO
1333 
1334  FCT_TEST_BGN(md4_hash_file_4)
1335  {
1336  unsigned char hash_str[65];
1337  unsigned char output[33];
1338 
1339  memset(hash_str, 0x00, 65);
1340  memset(output, 0x00, 33);
1341 
1342  md4_file( "data_files/hash_file_4", output);
1343  hexify( hash_str, output, 16 );
1344 
1345  fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
1346  }
1347  FCT_TEST_END();
1348 #endif /* POLARSSL_MD4_C */
1349 #endif /* POLARSSL_FS_IO */
1350 
1351 #ifdef POLARSSL_MD5_C
1352 #ifdef POLARSSL_FS_IO
1353 
1354  FCT_TEST_BGN(md5_hash_file_1)
1355  {
1356  unsigned char hash_str[65];
1357  unsigned char output[33];
1358 
1359  memset(hash_str, 0x00, 65);
1360  memset(output, 0x00, 33);
1361 
1362  md5_file( "data_files/hash_file_1", output);
1363  hexify( hash_str, output, 16 );
1364 
1365  fct_chk( strcmp( (char *) hash_str, "52bcdc983c9ed64fc148a759b3c7a415" ) == 0 );
1366  }
1367  FCT_TEST_END();
1368 #endif /* POLARSSL_MD5_C */
1369 #endif /* POLARSSL_FS_IO */
1370 
1371 #ifdef POLARSSL_MD5_C
1372 #ifdef POLARSSL_FS_IO
1373 
1374  FCT_TEST_BGN(md5_hash_file_2)
1375  {
1376  unsigned char hash_str[65];
1377  unsigned char output[33];
1378 
1379  memset(hash_str, 0x00, 65);
1380  memset(output, 0x00, 33);
1381 
1382  md5_file( "data_files/hash_file_2", output);
1383  hexify( hash_str, output, 16 );
1384 
1385  fct_chk( strcmp( (char *) hash_str, "d17d466f15891df10542207ae78277f0" ) == 0 );
1386  }
1387  FCT_TEST_END();
1388 #endif /* POLARSSL_MD5_C */
1389 #endif /* POLARSSL_FS_IO */
1390 
1391 #ifdef POLARSSL_MD5_C
1392 #ifdef POLARSSL_FS_IO
1393 
1394  FCT_TEST_BGN(md5_hash_file_3)
1395  {
1396  unsigned char hash_str[65];
1397  unsigned char output[33];
1398 
1399  memset(hash_str, 0x00, 65);
1400  memset(output, 0x00, 33);
1401 
1402  md5_file( "data_files/hash_file_3", output);
1403  hexify( hash_str, output, 16 );
1404 
1405  fct_chk( strcmp( (char *) hash_str, "d945bcc6200ea95d061a2a818167d920" ) == 0 );
1406  }
1407  FCT_TEST_END();
1408 #endif /* POLARSSL_MD5_C */
1409 #endif /* POLARSSL_FS_IO */
1410 
1411 #ifdef POLARSSL_MD5_C
1412 #ifdef POLARSSL_FS_IO
1413 
1414  FCT_TEST_BGN(md5_hash_file_4)
1415  {
1416  unsigned char hash_str[65];
1417  unsigned char output[33];
1418 
1419  memset(hash_str, 0x00, 65);
1420  memset(output, 0x00, 33);
1421 
1422  md5_file( "data_files/hash_file_4", output);
1423  hexify( hash_str, output, 16 );
1424 
1425  fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
1426  }
1427  FCT_TEST_END();
1428 #endif /* POLARSSL_MD5_C */
1429 #endif /* POLARSSL_FS_IO */
1430 
1431 #ifdef POLARSSL_MD2_C
1432 #ifdef POLARSSL_SELF_TEST
1433 
1434  FCT_TEST_BGN(md2_selftest)
1435  {
1436  fct_chk( md2_self_test( 0 ) == 0 );
1437  }
1438  FCT_TEST_END();
1439 #endif /* POLARSSL_MD2_C */
1440 #endif /* POLARSSL_SELF_TEST */
1441 
1442 #ifdef POLARSSL_MD4_C
1443 #ifdef POLARSSL_SELF_TEST
1444 
1445  FCT_TEST_BGN(md4_selftest)
1446  {
1447  fct_chk( md4_self_test( 0 ) == 0 );
1448  }
1449  FCT_TEST_END();
1450 #endif /* POLARSSL_MD4_C */
1451 #endif /* POLARSSL_SELF_TEST */
1452 
1453 #ifdef POLARSSL_MD5_C
1454 #ifdef POLARSSL_SELF_TEST
1455 
1456  FCT_TEST_BGN(md5_selftest)
1457  {
1458  fct_chk( md5_self_test( 0 ) == 0 );
1459  }
1460  FCT_TEST_END();
1461 #endif /* POLARSSL_MD5_C */
1462 #endif /* POLARSSL_SELF_TEST */
1463 
1464  }
1465  FCT_SUITE_END();
1466 
1467 
1468 }
1469 FCT_END();
1470