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