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