PolarSSL v1.1.4
test_suite_shax.c
Go to the documentation of this file.
1 #include "fct.h"
2 
3 #include <polarssl/sha1.h>
4 #include <polarssl/sha2.h>
5 #include <polarssl/sha4.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_ULONG_BE
20 #define GET_ULONG_BE(n,b,i) \
21 { \
22  (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
23  | ( (unsigned long) (b)[(i) + 1] << 16 ) \
24  | ( (unsigned long) (b)[(i) + 2] << 8 ) \
25  | ( (unsigned long) (b)[(i) + 3] ); \
26 }
27 #endif
28 
29 #ifndef PUT_ULONG_BE
30 #define PUT_ULONG_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_ULONG_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_shax)
234  {
235 #ifdef POLARSSL_SHA1_C
236 
237  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_1)
238  {
239  unsigned char src_str[10000];
240  unsigned char hash_str[10000];
241  unsigned char output[41];
242  int src_len;
243 
244  memset(src_str, 0x00, 10000);
245  memset(hash_str, 0x00, 10000);
246  memset(output, 0x00, 41);
247 
248  src_len = unhexify( src_str, "" );
249 
250  sha1( src_str, src_len, output );
251  hexify( hash_str, output, 20 );
252 
253  fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
254  }
255  FCT_TEST_END();
256 #endif /* POLARSSL_SHA1_C */
257 
258 #ifdef POLARSSL_SHA1_C
259 
260  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_2)
261  {
262  unsigned char src_str[10000];
263  unsigned char hash_str[10000];
264  unsigned char output[41];
265  int src_len;
266 
267  memset(src_str, 0x00, 10000);
268  memset(hash_str, 0x00, 10000);
269  memset(output, 0x00, 41);
270 
271  src_len = unhexify( src_str, "a8" );
272 
273  sha1( src_str, src_len, output );
274  hexify( hash_str, output, 20 );
275 
276  fct_chk( strcmp( (char *) hash_str, "99f2aa95e36f95c2acb0eaf23998f030638f3f15" ) == 0 );
277  }
278  FCT_TEST_END();
279 #endif /* POLARSSL_SHA1_C */
280 
281 #ifdef POLARSSL_SHA1_C
282 
283  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_3)
284  {
285  unsigned char src_str[10000];
286  unsigned char hash_str[10000];
287  unsigned char output[41];
288  int src_len;
289 
290  memset(src_str, 0x00, 10000);
291  memset(hash_str, 0x00, 10000);
292  memset(output, 0x00, 41);
293 
294  src_len = unhexify( src_str, "3000" );
295 
296  sha1( src_str, src_len, output );
297  hexify( hash_str, output, 20 );
298 
299  fct_chk( strcmp( (char *) hash_str, "f944dcd635f9801f7ac90a407fbc479964dec024" ) == 0 );
300  }
301  FCT_TEST_END();
302 #endif /* POLARSSL_SHA1_C */
303 
304 #ifdef POLARSSL_SHA1_C
305 
306  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_4)
307  {
308  unsigned char src_str[10000];
309  unsigned char hash_str[10000];
310  unsigned char output[41];
311  int src_len;
312 
313  memset(src_str, 0x00, 10000);
314  memset(hash_str, 0x00, 10000);
315  memset(output, 0x00, 41);
316 
317  src_len = unhexify( src_str, "42749e" );
318 
319  sha1( src_str, src_len, output );
320  hexify( hash_str, output, 20 );
321 
322  fct_chk( strcmp( (char *) hash_str, "a444319e9b6cc1e8464c511ec0969c37d6bb2619" ) == 0 );
323  }
324  FCT_TEST_END();
325 #endif /* POLARSSL_SHA1_C */
326 
327 #ifdef POLARSSL_SHA1_C
328 
329  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_5)
330  {
331  unsigned char src_str[10000];
332  unsigned char hash_str[10000];
333  unsigned char output[41];
334  int src_len;
335 
336  memset(src_str, 0x00, 10000);
337  memset(hash_str, 0x00, 10000);
338  memset(output, 0x00, 41);
339 
340  src_len = unhexify( src_str, "9fc3fe08" );
341 
342  sha1( src_str, src_len, output );
343  hexify( hash_str, output, 20 );
344 
345  fct_chk( strcmp( (char *) hash_str, "16a0ff84fcc156fd5d3ca3a744f20a232d172253" ) == 0 );
346  }
347  FCT_TEST_END();
348 #endif /* POLARSSL_SHA1_C */
349 
350 #ifdef POLARSSL_SHA1_C
351 
352  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_6)
353  {
354  unsigned char src_str[10000];
355  unsigned char hash_str[10000];
356  unsigned char output[41];
357  int src_len;
358 
359  memset(src_str, 0x00, 10000);
360  memset(hash_str, 0x00, 10000);
361  memset(output, 0x00, 41);
362 
363  src_len = unhexify( src_str, "b5c1c6f1af" );
364 
365  sha1( src_str, src_len, output );
366  hexify( hash_str, output, 20 );
367 
368  fct_chk( strcmp( (char *) hash_str, "fec9deebfcdedaf66dda525e1be43597a73a1f93" ) == 0 );
369  }
370  FCT_TEST_END();
371 #endif /* POLARSSL_SHA1_C */
372 
373 #ifdef POLARSSL_SHA1_C
374 
375  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_7)
376  {
377  unsigned char src_str[10000];
378  unsigned char hash_str[10000];
379  unsigned char output[41];
380  int src_len;
381 
382  memset(src_str, 0x00, 10000);
383  memset(hash_str, 0x00, 10000);
384  memset(output, 0x00, 41);
385 
386  src_len = unhexify( src_str, "ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b2548035185813e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a5305da4b1b737fce7cd21c0eb7728d08235a9011" );
387 
388  sha1( src_str, src_len, output );
389  hexify( hash_str, output, 20 );
390 
391  fct_chk( strcmp( (char *) hash_str, "970111c4e77bcc88cc20459c02b69b4aa8f58217" ) == 0 );
392  }
393  FCT_TEST_END();
394 #endif /* POLARSSL_SHA1_C */
395 
396 #ifdef POLARSSL_SHA1_C
397 
398  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_8)
399  {
400  unsigned char src_str[10000];
401  unsigned char hash_str[10000];
402  unsigned char output[41];
403  int src_len;
404 
405  memset(src_str, 0x00, 10000);
406  memset(hash_str, 0x00, 10000);
407  memset(output, 0x00, 41);
408 
409  src_len = unhexify( src_str, "5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652afe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba553d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38ae485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77414197422be3d36a6080" );
410 
411  sha1( src_str, src_len, output );
412  hexify( hash_str, output, 20 );
413 
414  fct_chk( strcmp( (char *) hash_str, "0423dc76a8791107d14e13f5265b343f24cc0f19" ) == 0 );
415  }
416  FCT_TEST_END();
417 #endif /* POLARSSL_SHA1_C */
418 
419 #ifdef POLARSSL_SHA1_C
420 
421  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_9)
422  {
423  unsigned char src_str[10000];
424  unsigned char hash_str[10000];
425  unsigned char output[41];
426  int src_len;
427 
428  memset(src_str, 0x00, 10000);
429  memset(hash_str, 0x00, 10000);
430  memset(output, 0x00, 41);
431 
432  src_len = unhexify( src_str, "0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a007ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec428c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30baa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff57800e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee71366afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32beaea" );
433 
434  sha1( src_str, src_len, output );
435  hexify( hash_str, output, 20 );
436 
437  fct_chk( strcmp( (char *) hash_str, "6692a71d73e00f27df976bc56df4970650d90e45" ) == 0 );
438  }
439  FCT_TEST_END();
440 #endif /* POLARSSL_SHA1_C */
441 
442 #ifdef POLARSSL_SHA1_C
443 
444  FCT_TEST_BGN(sha_1_test_vector_nist_cavs_10)
445  {
446  unsigned char src_str[10000];
447  unsigned char hash_str[10000];
448  unsigned char output[41];
449  int src_len;
450 
451  memset(src_str, 0x00, 10000);
452  memset(hash_str, 0x00, 10000);
453  memset(output, 0x00, 41);
454 
455  src_len = unhexify( src_str, "8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff" );
456 
457  sha1( src_str, src_len, output );
458  hexify( hash_str, output, 20 );
459 
460  fct_chk( strcmp( (char *) hash_str, "11863b483809ef88413ca9b0084ac4a5390640af" ) == 0 );
461  }
462  FCT_TEST_END();
463 #endif /* POLARSSL_SHA1_C */
464 
465 #ifdef POLARSSL_SHA2_C
466 
467  FCT_TEST_BGN(sha_224_test_vector_nist_cavs_1)
468  {
469  unsigned char src_str[10000];
470  unsigned char hash_str[10000];
471  unsigned char output[57];
472  int src_len;
473 
474  memset(src_str, 0x00, 10000);
475  memset(hash_str, 0x00, 10000);
476  memset(output, 0x00, 57);
477 
478  src_len = unhexify( src_str, "" );
479 
480  sha2( src_str, src_len, output, 1 );
481  hexify( hash_str, output, 28 );
482 
483  fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
484  }
485  FCT_TEST_END();
486 #endif /* POLARSSL_SHA2_C */
487 
488 #ifdef POLARSSL_SHA2_C
489 
490  FCT_TEST_BGN(sha_224_test_vector_nist_cavs_2)
491  {
492  unsigned char src_str[10000];
493  unsigned char hash_str[10000];
494  unsigned char output[57];
495  int src_len;
496 
497  memset(src_str, 0x00, 10000);
498  memset(hash_str, 0x00, 10000);
499  memset(output, 0x00, 57);
500 
501  src_len = unhexify( src_str, "ff" );
502 
503  sha2( src_str, src_len, output, 1 );
504  hexify( hash_str, output, 28 );
505 
506  fct_chk( strcmp( (char *) hash_str, "e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5" ) == 0 );
507  }
508  FCT_TEST_END();
509 #endif /* POLARSSL_SHA2_C */
510 
511 #ifdef POLARSSL_SHA2_C
512 
513  FCT_TEST_BGN(sha_224_test_vector_nist_cavs_3)
514  {
515  unsigned char src_str[10000];
516  unsigned char hash_str[10000];
517  unsigned char output[57];
518  int src_len;
519 
520  memset(src_str, 0x00, 10000);
521  memset(hash_str, 0x00, 10000);
522  memset(output, 0x00, 57);
523 
524  src_len = unhexify( src_str, "984c" );
525 
526  sha2( src_str, src_len, output, 1 );
527  hexify( hash_str, output, 28 );
528 
529  fct_chk( strcmp( (char *) hash_str, "2fa9df9157d9e027cfbc4c6a9df32e1adc0cbe2328ec2a63c5ae934e" ) == 0 );
530  }
531  FCT_TEST_END();
532 #endif /* POLARSSL_SHA2_C */
533 
534 #ifdef POLARSSL_SHA2_C
535 
536  FCT_TEST_BGN(sha_224_test_vector_nist_cavs_4)
537  {
538  unsigned char src_str[10000];
539  unsigned char hash_str[10000];
540  unsigned char output[57];
541  int src_len;
542 
543  memset(src_str, 0x00, 10000);
544  memset(hash_str, 0x00, 10000);
545  memset(output, 0x00, 57);
546 
547  src_len = unhexify( src_str, "50efd0" );
548 
549  sha2( src_str, src_len, output, 1 );
550  hexify( hash_str, output, 28 );
551 
552  fct_chk( strcmp( (char *) hash_str, "b5a9820413c2bf8211fbbf5df1337043b32fa4eafaf61a0c8e9ccede" ) == 0 );
553  }
554  FCT_TEST_END();
555 #endif /* POLARSSL_SHA2_C */
556 
557 #ifdef POLARSSL_SHA2_C
558 
559  FCT_TEST_BGN(sha_224_test_vector_nist_cavs_5)
560  {
561  unsigned char src_str[10000];
562  unsigned char hash_str[10000];
563  unsigned char output[57];
564  int src_len;
565 
566  memset(src_str, 0x00, 10000);
567  memset(hash_str, 0x00, 10000);
568  memset(output, 0x00, 57);
569 
570  src_len = unhexify( src_str, "e5e09924" );
571 
572  sha2( src_str, src_len, output, 1 );
573  hexify( hash_str, output, 28 );
574 
575  fct_chk( strcmp( (char *) hash_str, "fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d" ) == 0 );
576  }
577  FCT_TEST_END();
578 #endif /* POLARSSL_SHA2_C */
579 
580 #ifdef POLARSSL_SHA2_C
581 
582  FCT_TEST_BGN(sha_224_test_vector_nist_cavs_6)
583  {
584  unsigned char src_str[10000];
585  unsigned char hash_str[10000];
586  unsigned char output[57];
587  int src_len;
588 
589  memset(src_str, 0x00, 10000);
590  memset(hash_str, 0x00, 10000);
591  memset(output, 0x00, 57);
592 
593  src_len = unhexify( src_str, "21ebecb914" );
594 
595  sha2( src_str, src_len, output, 1 );
596  hexify( hash_str, output, 28 );
597 
598  fct_chk( strcmp( (char *) hash_str, "78f4a71c21c694499ce1c7866611b14ace70d905012c356323c7c713" ) == 0 );
599  }
600  FCT_TEST_END();
601 #endif /* POLARSSL_SHA2_C */
602 
603 #ifdef POLARSSL_SHA2_C
604 
605  FCT_TEST_BGN(sha_224_test_vector_nist_cavs_7)
606  {
607  unsigned char src_str[10000];
608  unsigned char hash_str[10000];
609  unsigned char output[57];
610  int src_len;
611 
612  memset(src_str, 0x00, 10000);
613  memset(hash_str, 0x00, 10000);
614  memset(output, 0x00, 57);
615 
616  src_len = unhexify( src_str, "fc488947c1a7a589726b15436b4f3d9556262f98fc6422fc5cdf20f0fad7fe427a3491c86d101ffe6b7514f06268f65b2d269b0f69ad9a97847eff1c16a2438775eb7be6847ccf11cb8b2e8dcd6640b095b49c0693fe3cf4a66e2d9b7ad68bff14f3ad69abf49d0aba36cbe0535202deb6599a47225ef05beb351335cd7bc0f480d691198c7e71305ffd53b39d33242bb79cfd98bfd69e137b5d18b2b89ac9ace01c8dbdcf2533cce3682ecc52118de0c1062ec2126c2e657d6ea3d9e2398e705d4b0b1f1ceecb266dffc4f31bf42744fb1e938dc22a889919ee1e73f463f7871fed720519e32186264b7ef2a0e5d9a18e6c95c0781894f77967f048951dec3b4d892a38710b1e3436d3c29088eb8b3da1789c25db3d3bc6c26081206e7155d210a89b80ca6ea877c41ff9947c0f25625dcb118294a163501f6239c326661a958fd12da4cd15a899f8b88cc723589056eaec5aa04a4cf5dbb6f480f9660423ccf38c486e210707e0fb25e1f126ceb2616f63e147a647dab0af9ebe89d65458bf636154a46e4cab95f5ee62da2c7974cd14b90d3e4f99f81733e85b3c1d5da2b508d9b90f5eed7eff0d9c7649de62bee00375454fee4a39576a5bbfdae428e7f8097bdf7797f167686cb68407e49079e4611ff3402b6384ba7b7e522bd2bb11ce8fd02ea4c1604d163ac4f6dde50b8b1f593f7edaadeac0868ed97df690200680c25f0f5d85431a529e4f339089dcdeda105e4ee51dead704cdf5a605c55fb055c9b0e86b8ba1b564c0dea3eb790a595cb103cb292268b07c5e59371e1a7ef597cd4b22977a820694c9f9aeb55d9de3ef62b75d6e656e3336698d960a3787bf8cf5b926a7faeef52ae128bcb5dc9e66d94b016c7b8e034879171a2d91c381f57e6a815b63b5ee6a6d2ff435b49f14c963966960194430d78f8f87627a67757fb3532b289550894da6dce4817a4e07f4d56877a1102ffcc8befa5c9f8fca6a4574d93ff70376c8861e0f8108cf907fce77ecb49728f86f034f80224b9695682e0824462f76cdb1fd1af151337b0d85419047a7aa284791718a4860cd586f7824b95bc837b6fd4f9be5aade68456e20356aa4d943dac36bf8b67b9e8f9d01a00fcda74b798bafa746c661b010f75b59904b29d0c8041504811c4065f82cf2ead58d2f595cbd8bc3e7043f4d94577b373b7cfe16a36fe564f505c03b70cfeb5e5f411c79481338aa67e86b3f5a2e77c21e454c333ae3da943ab723ab5f4c940395319534a5575f64acba0d0ecc43f60221ed3badf7289c9b3a7b903a2d6c94e15fa4c310dc4fa7faa0c24f405160a1002dbef20e4105d481db982f7243f79400a6e4cd9753c4b9732a47575f504b20c328fe9add7f432a4f075829da07b53b695037dc51737d3cd731934df333cd1a53fcf65aa31baa450ca501a6fae26e322347e618c5a444d92e9fec5a8261ae38b98fee5be77c02cec09ddccd5b3de92036" );
617 
618  sha2( src_str, src_len, output, 1 );
619  hexify( hash_str, output, 28 );
620 
621  fct_chk( strcmp( (char *) hash_str, "1302149d1e197c41813b054c942329d420e366530f5517b470e964fe" ) == 0 );
622  }
623  FCT_TEST_END();
624 #endif /* POLARSSL_SHA2_C */
625 
626 #ifdef POLARSSL_SHA2_C
627 
628  FCT_TEST_BGN(sha_256_test_vector_nist_cavs_1)
629  {
630  unsigned char src_str[10000];
631  unsigned char hash_str[10000];
632  unsigned char output[65];
633  int src_len;
634 
635  memset(src_str, 0x00, 10000);
636  memset(hash_str, 0x00, 10000);
637  memset(output, 0x00, 65);
638 
639  src_len = unhexify( src_str, "" );
640 
641  sha2( src_str, src_len, output, 0 );
642  hexify( hash_str, output, 32 );
643 
644  fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
645  }
646  FCT_TEST_END();
647 #endif /* POLARSSL_SHA2_C */
648 
649 #ifdef POLARSSL_SHA2_C
650 
651  FCT_TEST_BGN(sha_256_test_vector_nist_cavs_2)
652  {
653  unsigned char src_str[10000];
654  unsigned char hash_str[10000];
655  unsigned char output[65];
656  int src_len;
657 
658  memset(src_str, 0x00, 10000);
659  memset(hash_str, 0x00, 10000);
660  memset(output, 0x00, 65);
661 
662  src_len = unhexify( src_str, "bd" );
663 
664  sha2( src_str, src_len, output, 0 );
665  hexify( hash_str, output, 32 );
666 
667  fct_chk( strcmp( (char *) hash_str, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b" ) == 0 );
668  }
669  FCT_TEST_END();
670 #endif /* POLARSSL_SHA2_C */
671 
672 #ifdef POLARSSL_SHA2_C
673 
674  FCT_TEST_BGN(sha_256_test_vector_nist_cavs_3)
675  {
676  unsigned char src_str[10000];
677  unsigned char hash_str[10000];
678  unsigned char output[65];
679  int src_len;
680 
681  memset(src_str, 0x00, 10000);
682  memset(hash_str, 0x00, 10000);
683  memset(output, 0x00, 65);
684 
685  src_len = unhexify( src_str, "5fd4" );
686 
687  sha2( src_str, src_len, output, 0 );
688  hexify( hash_str, output, 32 );
689 
690  fct_chk( strcmp( (char *) hash_str, "7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788" ) == 0 );
691  }
692  FCT_TEST_END();
693 #endif /* POLARSSL_SHA2_C */
694 
695 #ifdef POLARSSL_SHA2_C
696 
697  FCT_TEST_BGN(sha_256_test_vector_nist_cavs_4)
698  {
699  unsigned char src_str[10000];
700  unsigned char hash_str[10000];
701  unsigned char output[65];
702  int src_len;
703 
704  memset(src_str, 0x00, 10000);
705  memset(hash_str, 0x00, 10000);
706  memset(output, 0x00, 65);
707 
708  src_len = unhexify( src_str, "b0bd69" );
709 
710  sha2( src_str, src_len, output, 0 );
711  hexify( hash_str, output, 32 );
712 
713  fct_chk( strcmp( (char *) hash_str, "4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803" ) == 0 );
714  }
715  FCT_TEST_END();
716 #endif /* POLARSSL_SHA2_C */
717 
718 #ifdef POLARSSL_SHA2_C
719 
720  FCT_TEST_BGN(sha_256_test_vector_nist_cavs_5)
721  {
722  unsigned char src_str[10000];
723  unsigned char hash_str[10000];
724  unsigned char output[65];
725  int src_len;
726 
727  memset(src_str, 0x00, 10000);
728  memset(hash_str, 0x00, 10000);
729  memset(output, 0x00, 65);
730 
731  src_len = unhexify( src_str, "c98c8e55" );
732 
733  sha2( src_str, src_len, output, 0 );
734  hexify( hash_str, output, 32 );
735 
736  fct_chk( strcmp( (char *) hash_str, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504" ) == 0 );
737  }
738  FCT_TEST_END();
739 #endif /* POLARSSL_SHA2_C */
740 
741 #ifdef POLARSSL_SHA2_C
742 
743  FCT_TEST_BGN(sha_256_test_vector_nist_cavs_6)
744  {
745  unsigned char src_str[10000];
746  unsigned char hash_str[10000];
747  unsigned char output[65];
748  int src_len;
749 
750  memset(src_str, 0x00, 10000);
751  memset(hash_str, 0x00, 10000);
752  memset(output, 0x00, 65);
753 
754  src_len = unhexify( src_str, "81a723d966" );
755 
756  sha2( src_str, src_len, output, 0 );
757  hexify( hash_str, output, 32 );
758 
759  fct_chk( strcmp( (char *) hash_str, "7516fb8bb11350df2bf386bc3c33bd0f52cb4c67c6e4745e0488e62c2aea2605" ) == 0 );
760  }
761  FCT_TEST_END();
762 #endif /* POLARSSL_SHA2_C */
763 
764 #ifdef POLARSSL_SHA2_C
765 
766  FCT_TEST_BGN(sha_256_test_vector_nist_cavs_7)
767  {
768  unsigned char src_str[10000];
769  unsigned char hash_str[10000];
770  unsigned char output[65];
771  int src_len;
772 
773  memset(src_str, 0x00, 10000);
774  memset(hash_str, 0x00, 10000);
775  memset(output, 0x00, 65);
776 
777  src_len = unhexify( src_str, "8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e" );
778 
779  sha2( src_str, src_len, output, 0 );
780  hexify( hash_str, output, 32 );
781 
782  fct_chk( strcmp( (char *) hash_str, "4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e" ) == 0 );
783  }
784  FCT_TEST_END();
785 #endif /* POLARSSL_SHA2_C */
786 
787 #ifdef POLARSSL_SHA4_C
788 
789  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_1)
790  {
791  unsigned char src_str[10000];
792  unsigned char hash_str[10000];
793  unsigned char output[97];
794  int src_len;
795 
796  memset(src_str, 0x00, 10000);
797  memset(hash_str, 0x00, 10000);
798  memset(output, 0x00, 97);
799 
800  src_len = unhexify( src_str, "" );
801 
802  sha4( src_str, src_len, output, 1 );
803  hexify( hash_str, output, 48 );
804 
805  fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
806  }
807  FCT_TEST_END();
808 #endif /* POLARSSL_SHA4_C */
809 
810 #ifdef POLARSSL_SHA4_C
811 
812  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_2)
813  {
814  unsigned char src_str[10000];
815  unsigned char hash_str[10000];
816  unsigned char output[97];
817  int src_len;
818 
819  memset(src_str, 0x00, 10000);
820  memset(hash_str, 0x00, 10000);
821  memset(output, 0x00, 97);
822 
823  src_len = unhexify( src_str, "ab" );
824 
825  sha4( src_str, src_len, output, 1 );
826  hexify( hash_str, output, 48 );
827 
828  fct_chk( strcmp( (char *) hash_str, "fb94d5be118865f6fcbc978b825da82cff188faec2f66cb84b2537d74b4938469854b0ca89e66fa2e182834736629f3d" ) == 0 );
829  }
830  FCT_TEST_END();
831 #endif /* POLARSSL_SHA4_C */
832 
833 #ifdef POLARSSL_SHA4_C
834 
835  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_3)
836  {
837  unsigned char src_str[10000];
838  unsigned char hash_str[10000];
839  unsigned char output[97];
840  int src_len;
841 
842  memset(src_str, 0x00, 10000);
843  memset(hash_str, 0x00, 10000);
844  memset(output, 0x00, 97);
845 
846  src_len = unhexify( src_str, "7c27" );
847 
848  sha4( src_str, src_len, output, 1 );
849  hexify( hash_str, output, 48 );
850 
851  fct_chk( strcmp( (char *) hash_str, "3d80be467df86d63abb9ea1d3f9cb39cd19890e7f2c53a6200bedc5006842b35e820dc4e0ca90ca9b97ab23ef07080fc" ) == 0 );
852  }
853  FCT_TEST_END();
854 #endif /* POLARSSL_SHA4_C */
855 
856 #ifdef POLARSSL_SHA4_C
857 
858  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_4)
859  {
860  unsigned char src_str[10000];
861  unsigned char hash_str[10000];
862  unsigned char output[97];
863  int src_len;
864 
865  memset(src_str, 0x00, 10000);
866  memset(hash_str, 0x00, 10000);
867  memset(output, 0x00, 97);
868 
869  src_len = unhexify( src_str, "31f5ca" );
870 
871  sha4( src_str, src_len, output, 1 );
872  hexify( hash_str, output, 48 );
873 
874  fct_chk( strcmp( (char *) hash_str, "78d54b943421fdf7ba90a7fb9637c2073aa480454bd841d39ff72f4511fc21fb67797b652c0c823229342873d3bef955" ) == 0 );
875  }
876  FCT_TEST_END();
877 #endif /* POLARSSL_SHA4_C */
878 
879 #ifdef POLARSSL_SHA4_C
880 
881  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_5)
882  {
883  unsigned char src_str[10000];
884  unsigned char hash_str[10000];
885  unsigned char output[97];
886  int src_len;
887 
888  memset(src_str, 0x00, 10000);
889  memset(hash_str, 0x00, 10000);
890  memset(output, 0x00, 97);
891 
892  src_len = unhexify( src_str, "7bdee3f8" );
893 
894  sha4( src_str, src_len, output, 1 );
895  hexify( hash_str, output, 48 );
896 
897  fct_chk( strcmp( (char *) hash_str, "8bdafba0777ee446c3431c2d7b1fbb631089f71d2ca417abc1d230e1aba64ec2f1c187474a6f4077d372c14ad407f99a" ) == 0 );
898  }
899  FCT_TEST_END();
900 #endif /* POLARSSL_SHA4_C */
901 
902 #ifdef POLARSSL_SHA4_C
903 
904  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_6)
905  {
906  unsigned char src_str[10000];
907  unsigned char hash_str[10000];
908  unsigned char output[97];
909  int src_len;
910 
911  memset(src_str, 0x00, 10000);
912  memset(hash_str, 0x00, 10000);
913  memset(output, 0x00, 97);
914 
915  src_len = unhexify( src_str, "8f05604915" );
916 
917  sha4( src_str, src_len, output, 1 );
918  hexify( hash_str, output, 48 );
919 
920  fct_chk( strcmp( (char *) hash_str, "504e414bf1db1060f14c8c799e25b1e0c4dcf1504ebbd129998f0ae283e6de86e0d3c7e879c73ec3b1836c3ee89c2649" ) == 0 );
921  }
922  FCT_TEST_END();
923 #endif /* POLARSSL_SHA4_C */
924 
925 #ifdef POLARSSL_SHA4_C
926 
927  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_7)
928  {
929  unsigned char src_str[10000];
930  unsigned char hash_str[10000];
931  unsigned char output[97];
932  int src_len;
933 
934  memset(src_str, 0x00, 10000);
935  memset(hash_str, 0x00, 10000);
936  memset(output, 0x00, 97);
937 
938  src_len = unhexify( src_str, "665da6eda214" );
939 
940  sha4( src_str, src_len, output, 1 );
941  hexify( hash_str, output, 48 );
942 
943  fct_chk( strcmp( (char *) hash_str, "4c022f112010908848312f8b8f1072625fd5c105399d562ea1d56130619a7eac8dfc3748fd05ee37e4b690be9daa9980" ) == 0 );
944  }
945  FCT_TEST_END();
946 #endif /* POLARSSL_SHA4_C */
947 
948 #ifdef POLARSSL_SHA4_C
949 
950  FCT_TEST_BGN(sha_384_test_vector_nist_cavs_8)
951  {
952  unsigned char src_str[10000];
953  unsigned char hash_str[10000];
954  unsigned char output[97];
955  int src_len;
956 
957  memset(src_str, 0x00, 10000);
958  memset(hash_str, 0x00, 10000);
959  memset(output, 0x00, 97);
960 
961  src_len = unhexify( src_str, "7f46ce506d593c4ed53c82edeb602037e0485befbee03f7f930fe532d18ff2a3f5fd6076672c8145a1bf40dd94f7abab47c9ae71c234213d2ad1069c2dac0b0ba15257ae672b8245960ae55bd50315c0097daa3a318745788d70d14706910809ca6e396237fe4934fa46f9ce782d66606d8bd6b2d283b1160513ce9c24e9f084b97891f99d4cdefc169a029e431ca772ba1bba426fce6f01d8e286014e5acc66b799e4db62bd4783322f8a32ff78e0de3957df50ce10871f4e0680df4e8ca3960af9bc6f4efa8eb3962d18f474eb178c3265cc46b8f2ff5ab1a7449fea297dfcfabfa01f28abbb7289bb354b691b5664ec6d098af51be19947ec5ba7ebd66380d1141953ba78d4aa5401679fa7b0a44db1981f864d3535c45afe4c61183d5b0ad51fae71ca07e34240283959f7530a32c70d95a088e501c230059f333b0670825009e7e22103ef22935830df1fac8ef877f5f3426dd54f7d1128dd871ad9a7d088f94c0e8712013295b8d69ae7623b880978c2d3c6ad26dc478f8dc47f5c0adcc618665dc3dc205a9071b2f2191e16cac5bd89bb59148fc719633752303aa08e518dbc389f0a5482caaa4c507b8729a6f3edd061efb39026cecc6399f51971cf7381d605e144a5928c8c2d1ad7467b05da2f202f4f3234e1aff19a0198a28685721c3d2d52311c721e3fdcbaf30214cdc3acff8c433880e104fb63f2df7ce69a97857819ba7ac00ac8eae1969764fde8f68cf8e0916d7e0c151147d4944f99f42ae50f30e1c79a42d2b6c5188d133d3cbbf69094027b354b295ccd0f7dc5a87d73638bd98ebfb00383ca0fa69cb8dcb35a12510e5e07ad8789047d0b63841a1bb928737e8b0a0c33254f47aa8bfbe3341a09c2b76dbcefa67e30df300d34f7b8465c4f869e51b6bcfe6cf68b238359a645036bf7f63f02924e087ce7457e483b6025a859903cb484574aa3b12cf946f32127d537c33bee3141b5db96d10a148c50ae045f287210757710d6846e04b202f79e87dd9a56bc6da15f84a77a7f63935e1dee00309cd276a8e7176cb04da6bb0e9009534438732cb42d008008853d38d19beba46e61006e30f7efd1bc7c2906b024e4ff898a1b58c448d68b43c6ab63f34f85b3ac6aa4475867e51b583844cb23829f4b30f4bdd817d88e2ef3e7b4fc0a624395b05ec5e8686082b24d29fef2b0d3c29e031d5f94f504b1d3df9361eb5ffbadb242e66c39a8094cfe62f85f639f3fd65fc8ae0c74a8f4c6e1d070b9183a434c722caaa0225f8bcd68614d6f0738ed62f8484ec96077d155c08e26c46be262a73e3551698bd70d8d5610cf37c4c306eed04ba6a040a9c3e6d7e15e8acda17f477c2484cf5c56b813313927be8387b1024f995e98fc87f1029091c01424bdc2b296c2eadb7d25b3e762a2fd0c2dcd1727ddf91db97c5984305265f3695a7f5472f2d72c94d68c27914f14f82aa8dd5fe4e2348b0ca967a3f98626a091552f5d0ffa2bf10350d23c996256c01fdeffb2c2c612519869f877e4929c6e95ff15040f1485e22ed14119880232fef3b57b3848f15b1766a5552879df8f06" );
962 
963  sha4( src_str, src_len, output, 1 );
964  hexify( hash_str, output, 48 );
965 
966  fct_chk( strcmp( (char *) hash_str, "cba9e3eb12a6f83db11e8a6ff40d1049854ee094416bc527fea931d8585428a8ed6242ce81f6769b36e2123a5c23483e" ) == 0 );
967  }
968  FCT_TEST_END();
969 #endif /* POLARSSL_SHA4_C */
970 
971 #ifdef POLARSSL_SHA4_C
972 
973  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_1)
974  {
975  unsigned char src_str[10000];
976  unsigned char hash_str[10000];
977  unsigned char output[129];
978  int src_len;
979 
980  memset(src_str, 0x00, 10000);
981  memset(hash_str, 0x00, 10000);
982  memset(output, 0x00, 129);
983 
984  src_len = unhexify( src_str, "" );
985 
986  sha4( src_str, src_len, output, 0);
987  hexify( hash_str, output, 64 );
988 
989  fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
990  }
991  FCT_TEST_END();
992 #endif /* POLARSSL_SHA4_C */
993 
994 #ifdef POLARSSL_SHA4_C
995 
996  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_2)
997  {
998  unsigned char src_str[10000];
999  unsigned char hash_str[10000];
1000  unsigned char output[129];
1001  int src_len;
1002 
1003  memset(src_str, 0x00, 10000);
1004  memset(hash_str, 0x00, 10000);
1005  memset(output, 0x00, 129);
1006 
1007  src_len = unhexify( src_str, "8f" );
1008 
1009  sha4( src_str, src_len, output, 0);
1010  hexify( hash_str, output, 64 );
1011 
1012  fct_chk( strcmp( (char *) hash_str, "e4cd2d19931b5aad9c920f45f56f6ce34e3d38c6d319a6e11d0588ab8b838576d6ce6d68eea7c830de66e2bd96458bfa7aafbcbec981d4ed040498c3dd95f22a" ) == 0 );
1013  }
1014  FCT_TEST_END();
1015 #endif /* POLARSSL_SHA4_C */
1016 
1017 #ifdef POLARSSL_SHA4_C
1018 
1019  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_3)
1020  {
1021  unsigned char src_str[10000];
1022  unsigned char hash_str[10000];
1023  unsigned char output[129];
1024  int src_len;
1025 
1026  memset(src_str, 0x00, 10000);
1027  memset(hash_str, 0x00, 10000);
1028  memset(output, 0x00, 129);
1029 
1030  src_len = unhexify( src_str, "e724" );
1031 
1032  sha4( src_str, src_len, output, 0);
1033  hexify( hash_str, output, 64 );
1034 
1035  fct_chk( strcmp( (char *) hash_str, "7dbb520221a70287b23dbcf62bfc1b73136d858e86266732a7fffa875ecaa2c1b8f673b5c065d360c563a7b9539349f5f59bef8c0c593f9587e3cd50bb26a231" ) == 0 );
1036  }
1037  FCT_TEST_END();
1038 #endif /* POLARSSL_SHA4_C */
1039 
1040 #ifdef POLARSSL_SHA4_C
1041 
1042  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_4)
1043  {
1044  unsigned char src_str[10000];
1045  unsigned char hash_str[10000];
1046  unsigned char output[129];
1047  int src_len;
1048 
1049  memset(src_str, 0x00, 10000);
1050  memset(hash_str, 0x00, 10000);
1051  memset(output, 0x00, 129);
1052 
1053  src_len = unhexify( src_str, "de4c90" );
1054 
1055  sha4( src_str, src_len, output, 0);
1056  hexify( hash_str, output, 64 );
1057 
1058  fct_chk( strcmp( (char *) hash_str, "33ce98281045a5c4c9df0363d8196f1d7dfcd5ee46ac89776fd8a4344c12f123a66788af5bd41ceff1941aa5637654b4064c88c14e00465ab79a2fc6c97e1014" ) == 0 );
1059  }
1060  FCT_TEST_END();
1061 #endif /* POLARSSL_SHA4_C */
1062 
1063 #ifdef POLARSSL_SHA4_C
1064 
1065  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_5)
1066  {
1067  unsigned char src_str[10000];
1068  unsigned char hash_str[10000];
1069  unsigned char output[129];
1070  int src_len;
1071 
1072  memset(src_str, 0x00, 10000);
1073  memset(hash_str, 0x00, 10000);
1074  memset(output, 0x00, 129);
1075 
1076  src_len = unhexify( src_str, "a801e94b" );
1077 
1078  sha4( src_str, src_len, output, 0);
1079  hexify( hash_str, output, 64 );
1080 
1081  fct_chk( strcmp( (char *) hash_str, "dadb1b5a27f9fece8d86adb2a51879beb1787ff28f4e8ce162cad7fee0f942efcabbf738bc6f797fc7cc79a3a75048cd4c82ca0757a324695bfb19a557e56e2f" ) == 0 );
1082  }
1083  FCT_TEST_END();
1084 #endif /* POLARSSL_SHA4_C */
1085 
1086 #ifdef POLARSSL_SHA4_C
1087 
1088  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_6)
1089  {
1090  unsigned char src_str[10000];
1091  unsigned char hash_str[10000];
1092  unsigned char output[129];
1093  int src_len;
1094 
1095  memset(src_str, 0x00, 10000);
1096  memset(hash_str, 0x00, 10000);
1097  memset(output, 0x00, 129);
1098 
1099  src_len = unhexify( src_str, "94390d3502" );
1100 
1101  sha4( src_str, src_len, output, 0);
1102  hexify( hash_str, output, 64 );
1103 
1104  fct_chk( strcmp( (char *) hash_str, "b6175c4c4cccf69e0ce5f0312010886ea6b34d43673f942ae42483f9cbb7da817de4e11b5d58e25a3d9bd721a22cdffe1c40411cc45df1911fa5506129b69297" ) == 0 );
1105  }
1106  FCT_TEST_END();
1107 #endif /* POLARSSL_SHA4_C */
1108 
1109 #ifdef POLARSSL_SHA4_C
1110 
1111  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_7)
1112  {
1113  unsigned char src_str[10000];
1114  unsigned char hash_str[10000];
1115  unsigned char output[129];
1116  int src_len;
1117 
1118  memset(src_str, 0x00, 10000);
1119  memset(hash_str, 0x00, 10000);
1120  memset(output, 0x00, 129);
1121 
1122  src_len = unhexify( src_str, "49297dd63e5f" );
1123 
1124  sha4( src_str, src_len, output, 0);
1125  hexify( hash_str, output, 64 );
1126 
1127  fct_chk( strcmp( (char *) hash_str, "1fcc1e6f6870859d11649f5e5336a9cd16329c029baf04d5a6edf257889a2e9522b497dd656bb402da461307c4ee382e2e89380c8e6e6e7697f1e439f650fa94" ) == 0 );
1128  }
1129  FCT_TEST_END();
1130 #endif /* POLARSSL_SHA4_C */
1131 
1132 #ifdef POLARSSL_SHA4_C
1133 
1134  FCT_TEST_BGN(sha_512_test_vector_nist_cavs_8)
1135  {
1136  unsigned char src_str[10000];
1137  unsigned char hash_str[10000];
1138  unsigned char output[129];
1139  int src_len;
1140 
1141  memset(src_str, 0x00, 10000);
1142  memset(hash_str, 0x00, 10000);
1143  memset(output, 0x00, 129);
1144 
1145  src_len = unhexify( src_str, "990d1ae71a62d7bda9bfdaa1762a68d296eee72a4cd946f287a898fbabc002ea941fd8d4d991030b4d27a637cce501a834bb95eab1b7889a3e784c7968e67cbf552006b206b68f76d9191327524fcc251aeb56af483d10b4e0c6c5e599ee8c0fe4faeca8293844a8547c6a9a90d093f2526873a19ad4a5e776794c68c742fb834793d2dfcb7fea46c63af4b70fd11cb6e41834e72ee40edb067b292a794990c288d5007e73f349fb383af6a756b8301ad6e5e0aa8cd614399bb3a452376b1575afa6bdaeaafc286cb064bb91edef97c632b6c1113d107fa93a0905098a105043c2f05397f702514439a08a9e5ddc196100721d45c8fc17d2ed659376f8a00bd5cb9a0860e26d8a29d8d6aaf52de97e9346033d6db501a35dbbaf97c20b830cd2d18c2532f3a59cc497ee64c0e57d8d060e5069b28d86edf1adcf59144b221ce3ddaef134b3124fbc7dd000240eff0f5f5f41e83cd7f5bb37c9ae21953fe302b0f6e8b68fa91c6ab99265c64b2fd9cd4942be04321bb5d6d71932376c6f2f88e02422ba6a5e2cb765df93fd5dd0728c6abdaf03bce22e0678a544e2c3636f741b6f4447ee58a8fc656b43ef817932176adbfc2e04b2c812c273cd6cbfa4098f0be036a34221fa02643f5ee2e0b38135f2a18ecd2f16ebc45f8eb31b8ab967a1567ee016904188910861ca1fa205c7adaa194b286893ffe2f4fbe0384c2aef72a4522aeafd3ebc71f9db71eeeef86c48394a1c86d5b36c352cc33a0a2c800bc99e62fd65b3a2fd69e0b53996ec13d8ce483ce9319efd9a85acefabdb5342226febb83fd1daf4b24265f50c61c6de74077ef89b6fecf9f29a1f871af1e9f89b2d345cda7499bd45c42fa5d195a1e1a6ba84851889e730da3b2b916e96152ae0c92154b49719841db7e7cc707ba8a5d7b101eb4ac7b629bb327817910fff61580b59aab78182d1a2e33473d05b00b170b29e331870826cfe45af206aa7d0246bbd8566ca7cfb2d3c10bfa1db7dd48dd786036469ce7282093d78b5e1a5b0fc81a54c8ed4ceac1e5305305e78284ac276f5d7862727aff246e17addde50c670028d572cbfc0be2e4f8b2eb28fa68ad7b4c6c2a239c460441bfb5ea049f23b08563b4e47729a59e5986a61a6093dbd54f8c36ebe87edae01f251cb060ad1364ce677d7e8d5a4a4ca966a7241cc360bc2acb280e5f9e9c1b032ad6a180a35e0c5180b9d16d026c865b252098cc1d99ba7375ca31c7702c0d943d5e3dd2f6861fa55bd46d94b67ed3e52eccd8dd06d968e01897d6de97ed3058d91dd" );
1146 
1147  sha4( src_str, src_len, output, 0);
1148  hexify( hash_str, output, 64 );
1149 
1150  fct_chk( strcmp( (char *) hash_str, "8e4bc6f8b8c60fe4d68c61d9b159c8693c3151c46749af58da228442d927f23359bd6ccd6c2ec8fa3f00a86cecbfa728e1ad60b821ed22fcd309ba91a4138bc9" ) == 0 );
1151  }
1152  FCT_TEST_END();
1153 #endif /* POLARSSL_SHA4_C */
1154 
1155 #ifdef POLARSSL_FS_IO
1156 #ifdef POLARSSL_SHA1_C
1157 
1158  FCT_TEST_BGN(sha1_hash_file_1)
1159  {
1160  unsigned char hash_str[41];
1161  unsigned char output[21];
1162 
1163  memset(hash_str, 0x00, 41);
1164  memset(output, 0x00, 21);
1165 
1166  sha1_file( "data_files/hash_file_1", output);
1167  hexify( hash_str, output, 20 );
1168 
1169  fct_chk( strcmp( (char *) hash_str, "d21c965b1e768bd7a6aa6869f5f821901d255f9f" ) == 0 );
1170  }
1171  FCT_TEST_END();
1172 #endif /* POLARSSL_FS_IO */
1173 #endif /* POLARSSL_SHA1_C */
1174 
1175 #ifdef POLARSSL_FS_IO
1176 #ifdef POLARSSL_SHA1_C
1177 
1178  FCT_TEST_BGN(sha1_hash_file_2)
1179  {
1180  unsigned char hash_str[41];
1181  unsigned char output[21];
1182 
1183  memset(hash_str, 0x00, 41);
1184  memset(output, 0x00, 21);
1185 
1186  sha1_file( "data_files/hash_file_2", output);
1187  hexify( hash_str, output, 20 );
1188 
1189  fct_chk( strcmp( (char *) hash_str, "353f34271f2aef49d23a8913d4a6bd82b2cecdc6" ) == 0 );
1190  }
1191  FCT_TEST_END();
1192 #endif /* POLARSSL_FS_IO */
1193 #endif /* POLARSSL_SHA1_C */
1194 
1195 #ifdef POLARSSL_FS_IO
1196 #ifdef POLARSSL_SHA1_C
1197 
1198  FCT_TEST_BGN(sha1_hash_file_3)
1199  {
1200  unsigned char hash_str[41];
1201  unsigned char output[21];
1202 
1203  memset(hash_str, 0x00, 41);
1204  memset(output, 0x00, 21);
1205 
1206  sha1_file( "data_files/hash_file_3", output);
1207  hexify( hash_str, output, 20 );
1208 
1209  fct_chk( strcmp( (char *) hash_str, "93640ed592076328096270c756db2fba9c486b35" ) == 0 );
1210  }
1211  FCT_TEST_END();
1212 #endif /* POLARSSL_FS_IO */
1213 #endif /* POLARSSL_SHA1_C */
1214 
1215 #ifdef POLARSSL_FS_IO
1216 #ifdef POLARSSL_SHA1_C
1217 
1218  FCT_TEST_BGN(sha1_hash_file_4)
1219  {
1220  unsigned char hash_str[41];
1221  unsigned char output[21];
1222 
1223  memset(hash_str, 0x00, 41);
1224  memset(output, 0x00, 21);
1225 
1226  sha1_file( "data_files/hash_file_4", output);
1227  hexify( hash_str, output, 20 );
1228 
1229  fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
1230  }
1231  FCT_TEST_END();
1232 #endif /* POLARSSL_FS_IO */
1233 #endif /* POLARSSL_SHA1_C */
1234 
1235 #ifdef POLARSSL_FS_IO
1236 #ifdef POLARSSL_SHA2_C
1237 
1238  FCT_TEST_BGN(sha_224_hash_file_1)
1239  {
1240  unsigned char hash_str[57];
1241  unsigned char output[29];
1242 
1243  memset(hash_str, 0x00, 57);
1244  memset(output, 0x00, 29);
1245 
1246  sha2_file( "data_files/hash_file_1", output, 1);
1247  hexify( hash_str, output, 28 );
1248 
1249  fct_chk( strcmp( (char *) hash_str, "8606da018870f0c16834a21bc3385704cb1683b9dbab04c5ddb90a48" ) == 0 );
1250  }
1251  FCT_TEST_END();
1252 #endif /* POLARSSL_FS_IO */
1253 #endif /* POLARSSL_SHA2_C */
1254 
1255 #ifdef POLARSSL_FS_IO
1256 #ifdef POLARSSL_SHA2_C
1257 
1258  FCT_TEST_BGN(sha_224_hash_file_2)
1259  {
1260  unsigned char hash_str[57];
1261  unsigned char output[29];
1262 
1263  memset(hash_str, 0x00, 57);
1264  memset(output, 0x00, 29);
1265 
1266  sha2_file( "data_files/hash_file_2", output, 1);
1267  hexify( hash_str, output, 28 );
1268 
1269  fct_chk( strcmp( (char *) hash_str, "733b2ab97b6f63f2e29b9a2089756d81e14c93fe4cc9615c0d5e8a03" ) == 0 );
1270  }
1271  FCT_TEST_END();
1272 #endif /* POLARSSL_FS_IO */
1273 #endif /* POLARSSL_SHA2_C */
1274 
1275 #ifdef POLARSSL_FS_IO
1276 #ifdef POLARSSL_SHA2_C
1277 
1278  FCT_TEST_BGN(sha_224_hash_file_3)
1279  {
1280  unsigned char hash_str[57];
1281  unsigned char output[29];
1282 
1283  memset(hash_str, 0x00, 57);
1284  memset(output, 0x00, 29);
1285 
1286  sha2_file( "data_files/hash_file_3", output, 1);
1287  hexify( hash_str, output, 28 );
1288 
1289  fct_chk( strcmp( (char *) hash_str, "e1df95867580e2cc2100e9565bf9c2e42c24fe5250c19efe33d1c4fe" ) == 0 );
1290  }
1291  FCT_TEST_END();
1292 #endif /* POLARSSL_FS_IO */
1293 #endif /* POLARSSL_SHA2_C */
1294 
1295 #ifdef POLARSSL_FS_IO
1296 #ifdef POLARSSL_SHA2_C
1297 
1298  FCT_TEST_BGN(sha_224_hash_file_4)
1299  {
1300  unsigned char hash_str[57];
1301  unsigned char output[29];
1302 
1303  memset(hash_str, 0x00, 57);
1304  memset(output, 0x00, 29);
1305 
1306  sha2_file( "data_files/hash_file_4", output, 1);
1307  hexify( hash_str, output, 28 );
1308 
1309  fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
1310  }
1311  FCT_TEST_END();
1312 #endif /* POLARSSL_FS_IO */
1313 #endif /* POLARSSL_SHA2_C */
1314 
1315 #ifdef POLARSSL_FS_IO
1316 #ifdef POLARSSL_SHA2_C
1317 
1318  FCT_TEST_BGN(sha_256_hash_file_1)
1319  {
1320  unsigned char hash_str[65];
1321  unsigned char output[33];
1322 
1323  memset(hash_str, 0x00, 65);
1324  memset(output, 0x00, 33);
1325 
1326  sha2_file( "data_files/hash_file_1", output, 0);
1327  hexify( hash_str, output, 32 );
1328 
1329  fct_chk( strcmp( (char *) hash_str, "975d0c620d3936886f8a3665e585a3e84aa0501f4225bf53029710242823e391" ) == 0 );
1330  }
1331  FCT_TEST_END();
1332 #endif /* POLARSSL_FS_IO */
1333 #endif /* POLARSSL_SHA2_C */
1334 
1335 #ifdef POLARSSL_FS_IO
1336 #ifdef POLARSSL_SHA2_C
1337 
1338  FCT_TEST_BGN(sha_256_hash_file_2)
1339  {
1340  unsigned char hash_str[65];
1341  unsigned char output[33];
1342 
1343  memset(hash_str, 0x00, 65);
1344  memset(output, 0x00, 33);
1345 
1346  sha2_file( "data_files/hash_file_2", output, 0);
1347  hexify( hash_str, output, 32 );
1348 
1349  fct_chk( strcmp( (char *) hash_str, "11fcbf1baa36ca45745f10cc5467aee86f066f80ba2c46806d876bf783022ad2" ) == 0 );
1350  }
1351  FCT_TEST_END();
1352 #endif /* POLARSSL_FS_IO */
1353 #endif /* POLARSSL_SHA2_C */
1354 
1355 #ifdef POLARSSL_FS_IO
1356 #ifdef POLARSSL_SHA2_C
1357 
1358  FCT_TEST_BGN(sha_256_hash_file_3)
1359  {
1360  unsigned char hash_str[65];
1361  unsigned char output[33];
1362 
1363  memset(hash_str, 0x00, 65);
1364  memset(output, 0x00, 33);
1365 
1366  sha2_file( "data_files/hash_file_3", output, 0);
1367  hexify( hash_str, output, 32 );
1368 
1369  fct_chk( strcmp( (char *) hash_str, "9ae4b369f9f4f03b86505b46a5469542e00aaff7cf7417a71af6d6d0aba3b70c" ) == 0 );
1370  }
1371  FCT_TEST_END();
1372 #endif /* POLARSSL_FS_IO */
1373 #endif /* POLARSSL_SHA2_C */
1374 
1375 #ifdef POLARSSL_FS_IO
1376 #ifdef POLARSSL_SHA2_C
1377 
1378  FCT_TEST_BGN(sha_256_hash_file_4)
1379  {
1380  unsigned char hash_str[65];
1381  unsigned char output[33];
1382 
1383  memset(hash_str, 0x00, 65);
1384  memset(output, 0x00, 33);
1385 
1386  sha2_file( "data_files/hash_file_4", output, 0);
1387  hexify( hash_str, output, 32 );
1388 
1389  fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
1390  }
1391  FCT_TEST_END();
1392 #endif /* POLARSSL_FS_IO */
1393 #endif /* POLARSSL_SHA2_C */
1394 
1395 #ifdef POLARSSL_FS_IO
1396 #ifdef POLARSSL_SHA4_C
1397 
1398  FCT_TEST_BGN(sha_384_hash_file_1)
1399  {
1400  unsigned char hash_str[97];
1401  unsigned char output[49];
1402 
1403  memset(hash_str, 0x00, 97);
1404  memset(output, 0x00, 49);
1405 
1406  sha4_file( "data_files/hash_file_1", output, 1);
1407  hexify( hash_str, output, 48 );
1408 
1409  fct_chk( strcmp( (char *) hash_str, "e0a3e6259d6378001b54ef82f5dd087009c5fad86d8db226a9fe1d14ecbe33a6fc916e3a4b16f5f286424de15d5a8e0e" ) == 0 );
1410  }
1411  FCT_TEST_END();
1412 #endif /* POLARSSL_FS_IO */
1413 #endif /* POLARSSL_SHA4_C */
1414 
1415 #ifdef POLARSSL_FS_IO
1416 #ifdef POLARSSL_SHA4_C
1417 
1418  FCT_TEST_BGN(sha_384_hash_file_2)
1419  {
1420  unsigned char hash_str[97];
1421  unsigned char output[49];
1422 
1423  memset(hash_str, 0x00, 97);
1424  memset(output, 0x00, 49);
1425 
1426  sha4_file( "data_files/hash_file_2", output, 1);
1427  hexify( hash_str, output, 48 );
1428 
1429  fct_chk( strcmp( (char *) hash_str, "eff727afc8495c92e2f370f97a317f93c3350324b0646b0f0e264708b3c97d3d332d3c5390e1e47130f5c92f1ef4b9cf" ) == 0 );
1430  }
1431  FCT_TEST_END();
1432 #endif /* POLARSSL_FS_IO */
1433 #endif /* POLARSSL_SHA4_C */
1434 
1435 #ifdef POLARSSL_FS_IO
1436 #ifdef POLARSSL_SHA4_C
1437 
1438  FCT_TEST_BGN(sha_384_hash_file_3)
1439  {
1440  unsigned char hash_str[97];
1441  unsigned char output[49];
1442 
1443  memset(hash_str, 0x00, 97);
1444  memset(output, 0x00, 49);
1445 
1446  sha4_file( "data_files/hash_file_3", output, 1);
1447  hexify( hash_str, output, 48 );
1448 
1449  fct_chk( strcmp( (char *) hash_str, "6fc10ebda96a1ccf61777cac72f6034f92533d42052a4bf9f9d929c672973c71e5aeb1213268043c21527ac0f7f349c4" ) == 0 );
1450  }
1451  FCT_TEST_END();
1452 #endif /* POLARSSL_FS_IO */
1453 #endif /* POLARSSL_SHA4_C */
1454 
1455 #ifdef POLARSSL_FS_IO
1456 #ifdef POLARSSL_SHA4_C
1457 
1458  FCT_TEST_BGN(sha_384_hash_file_4)
1459  {
1460  unsigned char hash_str[97];
1461  unsigned char output[49];
1462 
1463  memset(hash_str, 0x00, 97);
1464  memset(output, 0x00, 49);
1465 
1466  sha4_file( "data_files/hash_file_4", output, 1);
1467  hexify( hash_str, output, 48 );
1468 
1469  fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
1470  }
1471  FCT_TEST_END();
1472 #endif /* POLARSSL_FS_IO */
1473 #endif /* POLARSSL_SHA4_C */
1474 
1475 #ifdef POLARSSL_FS_IO
1476 #ifdef POLARSSL_SHA4_C
1477 
1478  FCT_TEST_BGN(sha_512_hash_file_1)
1479  {
1480  unsigned char hash_str[129];
1481  unsigned char output[65];
1482 
1483  memset(hash_str, 0x00, 129);
1484  memset(output, 0x00, 65);
1485 
1486  sha4_file( "data_files/hash_file_1", output, 0);
1487  hexify( hash_str, output, 64 );
1488 
1489  fct_chk( strcmp( (char *) hash_str, "d8207a2e1ff2b424f2c4163fe1b723c9bd42e464061eb411e8df730bcd24a7ab3956a6f3ff044a52eb2d262f9e4ca6b524092b544ab78f14d6f9c4cc8ddf335a" ) == 0 );
1490  }
1491  FCT_TEST_END();
1492 #endif /* POLARSSL_FS_IO */
1493 #endif /* POLARSSL_SHA4_C */
1494 
1495 #ifdef POLARSSL_FS_IO
1496 #ifdef POLARSSL_SHA4_C
1497 
1498  FCT_TEST_BGN(sha_512_hash_file_2)
1499  {
1500  unsigned char hash_str[129];
1501  unsigned char output[65];
1502 
1503  memset(hash_str, 0x00, 129);
1504  memset(output, 0x00, 65);
1505 
1506  sha4_file( "data_files/hash_file_2", output, 0);
1507  hexify( hash_str, output, 64 );
1508 
1509  fct_chk( strcmp( (char *) hash_str, "ecbb7f0ed8a702b49f16ad3088bcc06ea93451912a7187db15f64d93517b09630b039293aed418d4a00695777b758b1f381548c2fd7b92ce5ed996b32c8734e7" ) == 0 );
1510  }
1511  FCT_TEST_END();
1512 #endif /* POLARSSL_FS_IO */
1513 #endif /* POLARSSL_SHA4_C */
1514 
1515 #ifdef POLARSSL_FS_IO
1516 #ifdef POLARSSL_SHA4_C
1517 
1518  FCT_TEST_BGN(sha_512_hash_file_3)
1519  {
1520  unsigned char hash_str[129];
1521  unsigned char output[65];
1522 
1523  memset(hash_str, 0x00, 129);
1524  memset(output, 0x00, 65);
1525 
1526  sha4_file( "data_files/hash_file_3", output, 0);
1527  hexify( hash_str, output, 64 );
1528 
1529  fct_chk( strcmp( (char *) hash_str, "7ccc9b2da71ffde9966c3ce44d7f20945fccf33b1fade4da152b021f1afcc7293382944aa6c09eac67af25f22026758e2bf6bed86ae2a43592677ee50f8eea41" ) == 0 );
1530  }
1531  FCT_TEST_END();
1532 #endif /* POLARSSL_FS_IO */
1533 #endif /* POLARSSL_SHA4_C */
1534 
1535 #ifdef POLARSSL_FS_IO
1536 #ifdef POLARSSL_SHA4_C
1537 
1538  FCT_TEST_BGN(sha_512_hash_file_4)
1539  {
1540  unsigned char hash_str[129];
1541  unsigned char output[65];
1542 
1543  memset(hash_str, 0x00, 129);
1544  memset(output, 0x00, 65);
1545 
1546  sha4_file( "data_files/hash_file_4", output, 0);
1547  hexify( hash_str, output, 64 );
1548 
1549  fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
1550  }
1551  FCT_TEST_END();
1552 #endif /* POLARSSL_FS_IO */
1553 #endif /* POLARSSL_SHA4_C */
1554 
1555 #ifdef POLARSSL_SELF_TEST
1556 #ifdef POLARSSL_SHA1_C
1557 
1558  FCT_TEST_BGN(sha_1_selftest)
1559  {
1560  fct_chk( sha1_self_test( 0 ) == 0 );
1561  }
1562  FCT_TEST_END();
1563 #endif /* POLARSSL_SELF_TEST */
1564 #endif /* POLARSSL_SHA1_C */
1565 
1566 #ifdef POLARSSL_SELF_TEST
1567 #ifdef POLARSSL_SHA2_C
1568 
1569  FCT_TEST_BGN(sha_2_selftest)
1570  {
1571  fct_chk( sha2_self_test( 0 ) == 0 );
1572  }
1573  FCT_TEST_END();
1574 #endif /* POLARSSL_SELF_TEST */
1575 #endif /* POLARSSL_SHA2_C */
1576 
1577 #ifdef POLARSSL_SELF_TEST
1578 #ifdef POLARSSL_SHA4_C
1579 
1580  FCT_TEST_BGN(sha_4_selftest)
1581  {
1582  fct_chk( sha4_self_test( 0 ) == 0 );
1583  }
1584  FCT_TEST_END();
1585 #endif /* POLARSSL_SELF_TEST */
1586 #endif /* POLARSSL_SHA4_C */
1587 
1588  }
1589  FCT_SUITE_END();
1590 
1591 
1592 }
1593 FCT_END();
1594