PolarSSL v1.1.4
test_suite_hmac_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_hmac_shax)
234  {
235 #ifdef POLARSSL_SHA1_C
236 
237  FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_1)
238  {
239  unsigned char src_str[10000];
240  unsigned char key_str[10000];
241  unsigned char hash_str[10000];
242  unsigned char output[41];
243  int key_len, src_len;
244 
245  memset(src_str, 0x00, 10000);
246  memset(key_str, 0x00, 10000);
247  memset(hash_str, 0x00, 10000);
248  memset(output, 0x00, 41);
249 
250  key_len = unhexify( key_str, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" );
251  src_len = unhexify( src_str, "53616d706c65202331" );
252 
253  sha1_hmac( key_str, key_len, src_str, src_len, output );
254  hexify( hash_str, output, 20 );
255 
256  fct_chk( strncmp( (char *) hash_str, "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", 20 * 2 ) == 0 );
257  }
258  FCT_TEST_END();
259 #endif /* POLARSSL_SHA1_C */
260 
261 #ifdef POLARSSL_SHA1_C
262 
263  FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_2)
264  {
265  unsigned char src_str[10000];
266  unsigned char key_str[10000];
267  unsigned char hash_str[10000];
268  unsigned char output[41];
269  int key_len, src_len;
270 
271  memset(src_str, 0x00, 10000);
272  memset(key_str, 0x00, 10000);
273  memset(hash_str, 0x00, 10000);
274  memset(output, 0x00, 41);
275 
276  key_len = unhexify( key_str, "303132333435363738393a3b3c3d3e3f40414243" );
277  src_len = unhexify( src_str, "53616d706c65202332" );
278 
279  sha1_hmac( key_str, key_len, src_str, src_len, output );
280  hexify( hash_str, output, 20 );
281 
282  fct_chk( strncmp( (char *) hash_str, "0922d3405faa3d194f82a45830737d5cc6c75d24", 20 * 2 ) == 0 );
283  }
284  FCT_TEST_END();
285 #endif /* POLARSSL_SHA1_C */
286 
287 #ifdef POLARSSL_SHA1_C
288 
289  FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_3)
290  {
291  unsigned char src_str[10000];
292  unsigned char key_str[10000];
293  unsigned char hash_str[10000];
294  unsigned char output[41];
295  int key_len, src_len;
296 
297  memset(src_str, 0x00, 10000);
298  memset(key_str, 0x00, 10000);
299  memset(hash_str, 0x00, 10000);
300  memset(output, 0x00, 41);
301 
302  key_len = unhexify( key_str, "505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" );
303  src_len = unhexify( src_str, "53616d706c65202333" );
304 
305  sha1_hmac( key_str, key_len, src_str, src_len, output );
306  hexify( hash_str, output, 20 );
307 
308  fct_chk( strncmp( (char *) hash_str, "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", 20 * 2 ) == 0 );
309  }
310  FCT_TEST_END();
311 #endif /* POLARSSL_SHA1_C */
312 
313 #ifdef POLARSSL_SHA1_C
314 
315  FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_4)
316  {
317  unsigned char src_str[10000];
318  unsigned char key_str[10000];
319  unsigned char hash_str[10000];
320  unsigned char output[41];
321  int key_len, src_len;
322 
323  memset(src_str, 0x00, 10000);
324  memset(key_str, 0x00, 10000);
325  memset(hash_str, 0x00, 10000);
326  memset(output, 0x00, 41);
327 
328  key_len = unhexify( key_str, "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0" );
329  src_len = unhexify( src_str, "53616d706c65202334" );
330 
331  sha1_hmac( key_str, key_len, src_str, src_len, output );
332  hexify( hash_str, output, 20 );
333 
334  fct_chk( strncmp( (char *) hash_str, "9ea886efe268dbecce420c75", 12 * 2 ) == 0 );
335  }
336  FCT_TEST_END();
337 #endif /* POLARSSL_SHA1_C */
338 
339 #ifdef POLARSSL_SHA1_C
340 
341  FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_1)
342  {
343  unsigned char src_str[10000];
344  unsigned char key_str[10000];
345  unsigned char hash_str[10000];
346  unsigned char output[41];
347  int key_len, src_len;
348 
349  memset(src_str, 0x00, 10000);
350  memset(key_str, 0x00, 10000);
351  memset(hash_str, 0x00, 10000);
352  memset(output, 0x00, 41);
353 
354  key_len = unhexify( key_str, "7b10f4124b15c82e" );
355  src_len = unhexify( src_str, "27dcb5b1daf60cfd3e2f73d4d64ca9c684f8bf71fc682a46793b1790afa4feb100ca7aaff26f58f0e1d0ed42f1cdad1f474afa2e79d53a0c42892c4d7b327cbe46b295ed8da3b6ecab3d4851687a6f812b79df2f6b20f11f6706f5301790ca99625aad7391d84f78043d2a0a239b1477984c157bbc9276064e7a1a406b0612ca" );
356 
357  sha1_hmac( key_str, key_len, src_str, src_len, output );
358  hexify( hash_str, output, 20 );
359 
360  fct_chk( strncmp( (char *) hash_str, "4ead12c2fe3d6ea43acb", 10 * 2 ) == 0 );
361  }
362  FCT_TEST_END();
363 #endif /* POLARSSL_SHA1_C */
364 
365 #ifdef POLARSSL_SHA1_C
366 
367  FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_2)
368  {
369  unsigned char src_str[10000];
370  unsigned char key_str[10000];
371  unsigned char hash_str[10000];
372  unsigned char output[41];
373  int key_len, src_len;
374 
375  memset(src_str, 0x00, 10000);
376  memset(key_str, 0x00, 10000);
377  memset(hash_str, 0x00, 10000);
378  memset(output, 0x00, 41);
379 
380  key_len = unhexify( key_str, "4fe9fb902172a21b" );
381  src_len = unhexify( src_str, "4ceb3a7c13659c22fe51134f03dce4c239d181b63c6b0b59d367157fd05cab98384f92dfa482d2d5e78e72eef1b1838af4696026c54233d484ecbbe87f904df5546419f8567eafd232e6c2fcd3ee2b7682c63000524b078dbb2096f585007deae752562df1fe3b01278089e16f3be46e2d0f7cabac2d8e6cc02a2d0ca953425f" );
382 
383  sha1_hmac( key_str, key_len, src_str, src_len, output );
384  hexify( hash_str, output, 20 );
385 
386  fct_chk( strncmp( (char *) hash_str, "564428a67be1924b5793", 10 * 2 ) == 0 );
387  }
388  FCT_TEST_END();
389 #endif /* POLARSSL_SHA1_C */
390 
391 #ifdef POLARSSL_SHA1_C
392 
393  FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_3)
394  {
395  unsigned char src_str[10000];
396  unsigned char key_str[10000];
397  unsigned char hash_str[10000];
398  unsigned char output[41];
399  int key_len, src_len;
400 
401  memset(src_str, 0x00, 10000);
402  memset(key_str, 0x00, 10000);
403  memset(hash_str, 0x00, 10000);
404  memset(output, 0x00, 41);
405 
406  key_len = unhexify( key_str, "d1f01455f78c4fb4" );
407  src_len = unhexify( src_str, "00d40f67b57914bec456a3e3201ef1464be319a8d188c02e157af4b54f9b5a66d67f898a9bdbb19ff63a80aba6f246d013575721d52eb1b47a65def884011c49b257bcc2817fc853f106e8138ce386d7a5ac3103de0a3fa0ed6bb7af9ff66ebd1cc46fb86e4da0013d20a3c2dcd8fb828a4b70f7f104b41bf3f44682a66497ea" );
408 
409  sha1_hmac( key_str, key_len, src_str, src_len, output );
410  hexify( hash_str, output, 20 );
411 
412  fct_chk( strncmp( (char *) hash_str, "56a665a7cdfe610f9fc5", 10 * 2 ) == 0 );
413  }
414  FCT_TEST_END();
415 #endif /* POLARSSL_SHA1_C */
416 
417 #ifdef POLARSSL_SHA1_C
418 
419  FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_4)
420  {
421  unsigned char src_str[10000];
422  unsigned char key_str[10000];
423  unsigned char hash_str[10000];
424  unsigned char output[41];
425  int key_len, src_len;
426 
427  memset(src_str, 0x00, 10000);
428  memset(key_str, 0x00, 10000);
429  memset(hash_str, 0x00, 10000);
430  memset(output, 0x00, 41);
431 
432  key_len = unhexify( key_str, "4e5ef77fdf033a5b" );
433  src_len = unhexify( src_str, "e59326464e3201d195e29f2a3446ec1b1c9ff31154e2a4d0e40ed466f1bc855d29f76835624fa0127d29c9b1915939a046f385af7e5d47a23ba91f28bd22f811ea258dbbf3332bcd3543b8285d5df41bd064ffd64a341c22c4edb44f9c8d9e6df0c59dbf4a052a6c83da7478e179a6f3839c6870ff8ca8b9497f9ac1d725fdda" );
434 
435  sha1_hmac( key_str, key_len, src_str, src_len, output );
436  hexify( hash_str, output, 20 );
437 
438  fct_chk( strncmp( (char *) hash_str, "981c0a7a8423b63a8fa6", 10 * 2 ) == 0 );
439  }
440  FCT_TEST_END();
441 #endif /* POLARSSL_SHA1_C */
442 
443 #ifdef POLARSSL_SHA1_C
444 
445  FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_5)
446  {
447  unsigned char src_str[10000];
448  unsigned char key_str[10000];
449  unsigned char hash_str[10000];
450  unsigned char output[41];
451  int key_len, src_len;
452 
453  memset(src_str, 0x00, 10000);
454  memset(key_str, 0x00, 10000);
455  memset(hash_str, 0x00, 10000);
456  memset(output, 0x00, 41);
457 
458  key_len = unhexify( key_str, "bcd9ff8aa60be2be" );
459  src_len = unhexify( src_str, "51be4d0eb37bab714f92e19e9d70390655b363e8cd346a748245e731f437759cb8206412c8dab2ef1d4f36f880f41ff69d949da4594fdecb65e23cac1329b59e69e29bf875b38c31df6fa546c595f35cc2192aa750679a8a51a65e00e839d73a8d8c598a610d237fbe78955213589d80efcb73b95b8586f96d17b6f51a71c3b8" );
460 
461  sha1_hmac( key_str, key_len, src_str, src_len, output );
462  hexify( hash_str, output, 20 );
463 
464  fct_chk( strncmp( (char *) hash_str, "84633f9f5040c8971478", 10 * 2 ) == 0 );
465  }
466  FCT_TEST_END();
467 #endif /* POLARSSL_SHA1_C */
468 
469 #ifdef POLARSSL_SHA1_C
470 
471  FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_6)
472  {
473  unsigned char src_str[10000];
474  unsigned char key_str[10000];
475  unsigned char hash_str[10000];
476  unsigned char output[41];
477  int key_len, src_len;
478 
479  memset(src_str, 0x00, 10000);
480  memset(key_str, 0x00, 10000);
481  memset(hash_str, 0x00, 10000);
482  memset(output, 0x00, 41);
483 
484  key_len = unhexify( key_str, "4a661bce6ed86d21" );
485  src_len = unhexify( src_str, "5ff6c744f1aab1bc29697d71f67541b8b3cec3c7079183b10a83fb98a9ee251d4bac3e1cb581ca972aaed8efd7c2875a6fb4c991132f67c9742d45e53bc7e8eaa94b35b37a907be61086b426cd11088ac118934e85d968c9667fd69fc6f6ea38c0fe34710b7ece91211b9b7ea00acd31f022aa6726368f9928a1352f122233f1" );
486 
487  sha1_hmac( key_str, key_len, src_str, src_len, output );
488  hexify( hash_str, output, 20 );
489 
490  fct_chk( strncmp( (char *) hash_str, "739df59353ac6694e55e", 10 * 2 ) == 0 );
491  }
492  FCT_TEST_END();
493 #endif /* POLARSSL_SHA1_C */
494 
495 #ifdef POLARSSL_SHA1_C
496 
497  FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_7)
498  {
499  unsigned char src_str[10000];
500  unsigned char key_str[10000];
501  unsigned char hash_str[10000];
502  unsigned char output[41];
503  int key_len, src_len;
504 
505  memset(src_str, 0x00, 10000);
506  memset(key_str, 0x00, 10000);
507  memset(hash_str, 0x00, 10000);
508  memset(output, 0x00, 41);
509 
510  key_len = unhexify( key_str, "1287e1565a57b547" );
511  src_len = unhexify( src_str, "390ffdccc6171c11568d85b8f913e019bf4cd982ca9cd21ea730d41bdf3fcc0bc88ff48ba13a8f23deb2d96ec1033e7b2a58ca72b0c1e17bf03330db25d1e360fa6918009c4294bd1215b5ccd159a8f58bc3dc3d490eb7c3b9f887e8c98dbbb274a75373dcb695a59abd0219529d88518a96f92abc0bbcbda985c388f1fbbcc9" );
512 
513  sha1_hmac( key_str, key_len, src_str, src_len, output );
514  hexify( hash_str, output, 20 );
515 
516  fct_chk( strncmp( (char *) hash_str, "d78ddf08077c7d9e2ba6", 10 * 2 ) == 0 );
517  }
518  FCT_TEST_END();
519 #endif /* POLARSSL_SHA1_C */
520 
521 #ifdef POLARSSL_SHA2_C
522 
523  FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_1)
524  {
525  unsigned char src_str[10000];
526  unsigned char key_str[10000];
527  unsigned char hash_str[10000];
528  unsigned char output[57];
529  int key_len, src_len;
530 
531  memset(src_str, 0x00, 10000);
532  memset(key_str, 0x00, 10000);
533  memset(hash_str, 0x00, 10000);
534  memset(output, 0x00, 57);
535 
536  key_len = unhexify( key_str, "e055eb756697ee573fd3214811a9f7fa" );
537  src_len = unhexify( src_str, "3875847012ee42fe54a0027bdf38cca7021b83a2ed0503af69ef6c37c637bc1114fba40096c5947d736e19b7af3c68d95a4e3b8b073adbbb80f47e9db8f2d4f0018ddd847fabfdf9dd9b52c93e40458977725f6b7ba15f0816bb895cdf50401268f5d702b7e6a5f9faef57b8768c8a3fc14f9a4b3182b41d940e337d219b29ff" );
538 
539  sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
540  hexify( hash_str, output, 28 );
541 
542  fct_chk( strncmp( (char *) hash_str, "40a453133361cc48da11baf616ee", 14 * 2 ) == 0 );
543  }
544  FCT_TEST_END();
545 #endif /* POLARSSL_SHA2_C */
546 
547 #ifdef POLARSSL_SHA2_C
548 
549  FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_2)
550  {
551  unsigned char src_str[10000];
552  unsigned char key_str[10000];
553  unsigned char hash_str[10000];
554  unsigned char output[57];
555  int key_len, src_len;
556 
557  memset(src_str, 0x00, 10000);
558  memset(key_str, 0x00, 10000);
559  memset(hash_str, 0x00, 10000);
560  memset(output, 0x00, 57);
561 
562  key_len = unhexify( key_str, "88e5258b55b1623385eb9632fa7c57d6" );
563  src_len = unhexify( src_str, "ada76bb604be14326551701cf30e48a65eee80b44f0b9d4a07b1844543b7844a621097fdc99de57387458ae9354899b620d0617eabcaefa9eef3d413a33628054335ce656c26fa2986e0f111a6351096b283101ec7868871d770b370973c7405983f9756b3005a3eab492cfd0e7eb42e5c2e15fa6be8718c0a50acc4e5717230" );
564 
565  sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
566  hexify( hash_str, output, 28 );
567 
568  fct_chk( strncmp( (char *) hash_str, "81c783af538015cef3c60095df53", 14 * 2 ) == 0 );
569  }
570  FCT_TEST_END();
571 #endif /* POLARSSL_SHA2_C */
572 
573 #ifdef POLARSSL_SHA2_C
574 
575  FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_3)
576  {
577  unsigned char src_str[10000];
578  unsigned char key_str[10000];
579  unsigned char hash_str[10000];
580  unsigned char output[57];
581  int key_len, src_len;
582 
583  memset(src_str, 0x00, 10000);
584  memset(key_str, 0x00, 10000);
585  memset(hash_str, 0x00, 10000);
586  memset(output, 0x00, 57);
587 
588  key_len = unhexify( key_str, "85d402d822114d31abf75526e2538705" );
589  src_len = unhexify( src_str, "8020d8d98cc2e2298b32879c51c751e1dd5558fe2eabb8f158604297d6d072ce2261a1d6830b7cfe2617b57c7126f99c9476211d6161acd75d266da217ec8174b80484c9dc6f0448a0a036a3fc82e8bf54bdb71549368258d5d41f57978a4c266b92e8783ef66350215573d99be4089144b383ad8f3222bae8f3bf80ffb1bb2b" );
590 
591  sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
592  hexify( hash_str, output, 28 );
593 
594  fct_chk( strncmp( (char *) hash_str, "2aa0340ac9deafe3be38129daca0", 14 * 2 ) == 0 );
595  }
596  FCT_TEST_END();
597 #endif /* POLARSSL_SHA2_C */
598 
599 #ifdef POLARSSL_SHA2_C
600 
601  FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_4)
602  {
603  unsigned char src_str[10000];
604  unsigned char key_str[10000];
605  unsigned char hash_str[10000];
606  unsigned char output[57];
607  int key_len, src_len;
608 
609  memset(src_str, 0x00, 10000);
610  memset(key_str, 0x00, 10000);
611  memset(hash_str, 0x00, 10000);
612  memset(output, 0x00, 57);
613 
614  key_len = unhexify( key_str, "545c6eecc5ee46fa17c59f91a94f81ae" );
615  src_len = unhexify( src_str, "8fb7f3565593170152ddb2021874784e951977cfdd22f8b72a72a61320a8f2a35697b5e913f717805559b1af1861ee3ed42fb788481e4fd276b17bdbefcae7b4501dc5d20de5b7626dd5efdcd65294db4bdf682c33d9a9255c6435383fa5f1c886326a3acbc6bd50a33ab5b2dbb034ce0112d4e226bbcd57e3731a519aa1d784" );
616 
617  sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
618  hexify( hash_str, output, 28 );
619 
620  fct_chk( strncmp( (char *) hash_str, "3eb566eac54c4a3a9ef092469f24", 14 * 2 ) == 0 );
621  }
622  FCT_TEST_END();
623 #endif /* POLARSSL_SHA2_C */
624 
625 #ifdef POLARSSL_SHA2_C
626 
627  FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_5)
628  {
629  unsigned char src_str[10000];
630  unsigned char key_str[10000];
631  unsigned char hash_str[10000];
632  unsigned char output[57];
633  int key_len, src_len;
634 
635  memset(src_str, 0x00, 10000);
636  memset(key_str, 0x00, 10000);
637  memset(hash_str, 0x00, 10000);
638  memset(output, 0x00, 57);
639 
640  key_len = unhexify( key_str, "4466ab4dc438841a9750c7f173dff02e" );
641  src_len = unhexify( src_str, "2534c11c78c99cffaec8f722f04adc7045c7324d58ce98e37cfa94b6ed21ed7f58ce55379ef24b72d6d640ee9154f96c614734be9c408e225d7ba4cecc1179cc9f6e1808e1067aa8f244a99bd0c3267594c1887a40d167f8b7cf78db0d19f97b01fc50b8c86def490dfa7a5135002c33e71d77a8cce8ea0f93e0580439a33733" );
642 
643  sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
644  hexify( hash_str, output, 28 );
645 
646  fct_chk( strncmp( (char *) hash_str, "59f44a9bbed4875b892d22d6b5ab", 14 * 2 ) == 0 );
647  }
648  FCT_TEST_END();
649 #endif /* POLARSSL_SHA2_C */
650 
651 #ifdef POLARSSL_SHA2_C
652 
653  FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_6)
654  {
655  unsigned char src_str[10000];
656  unsigned char key_str[10000];
657  unsigned char hash_str[10000];
658  unsigned char output[57];
659  int key_len, src_len;
660 
661  memset(src_str, 0x00, 10000);
662  memset(key_str, 0x00, 10000);
663  memset(hash_str, 0x00, 10000);
664  memset(output, 0x00, 57);
665 
666  key_len = unhexify( key_str, "0e3dd9bb5e4cf0f09a4c11600af56d8d" );
667  src_len = unhexify( src_str, "f4589fa76c328ea25cf8bae582026ba40a59d45a546ff31cf80eb826088f69bb954c452c74586836416dee90a5255bc5d56d3b405b3705a5197045688b32fa984c3a3dfbdc9c2460a0b5e6312a624048bb6f170306535e9b371a3ab134a2642a230ad03d2c688cca80baeaee9a20e1d4c548b1cede29c6a45bf4df2c8c476f1a" );
668 
669  sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
670  hexify( hash_str, output, 28 );
671 
672  fct_chk( strncmp( (char *) hash_str, "12175b93e3da4c58217145e4dc0a1cf142fab9319bb501e037b350ba", 28 * 2 ) == 0 );
673  }
674  FCT_TEST_END();
675 #endif /* POLARSSL_SHA2_C */
676 
677 #ifdef POLARSSL_SHA2_C
678 
679  FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_7)
680  {
681  unsigned char src_str[10000];
682  unsigned char key_str[10000];
683  unsigned char hash_str[10000];
684  unsigned char output[57];
685  int key_len, src_len;
686 
687  memset(src_str, 0x00, 10000);
688  memset(key_str, 0x00, 10000);
689  memset(hash_str, 0x00, 10000);
690  memset(output, 0x00, 57);
691 
692  key_len = unhexify( key_str, "cda5187b0c5dcb0f8e5a8beed2306584" );
693  src_len = unhexify( src_str, "9011ae29b44c49b347487ce972965f16ade3c15be0856ce9c853a9739dba07e4f20d594ddc1dfe21560a65a4e458cfa17745575b915a30c7a9412ff8d1d689db9680dd2428c27588bb0dc92d2cd9445fe8f44b840a197c52c3c4333fff45533945134398df6436513cfab06c924046b8c795a5bd92e8d5f2de85bf306f2eed67" );
694 
695  sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
696  hexify( hash_str, output, 28 );
697 
698  fct_chk( strncmp( (char *) hash_str, "4aaba92b40e2a600feab176eb9b292d814864195c03342aad6f67f08", 28 * 2 ) == 0 );
699  }
700  FCT_TEST_END();
701 #endif /* POLARSSL_SHA2_C */
702 
703 #ifdef POLARSSL_SHA2_C
704 
705  FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_1)
706  {
707  unsigned char src_str[10000];
708  unsigned char key_str[10000];
709  unsigned char hash_str[10000];
710  unsigned char output[65];
711  int key_len, src_len;
712 
713  memset(src_str, 0x00, 10000);
714  memset(key_str, 0x00, 10000);
715  memset(hash_str, 0x00, 10000);
716  memset(output, 0x00, 65);
717 
718  key_len = unhexify( key_str, "cdffd34e6b16fdc0" );
719  src_len = unhexify( src_str, "d83e78b99ab61709608972b36e76a575603db742269cc5dd4e7d5ca7816e26b65151c92632550cb4c5253c885d5fce53bc47459a1dbd5652786c4aac0145a532f12c05138af04cbb558101a7af5df478834c2146594dd73690d01a4fe72545894335f427ac70204798068cb86c5a600b40b414ede23590b41e1192373df84fe3" );
720 
721  sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
722  hexify( hash_str, output, 32 );
723 
724  fct_chk( strncmp( (char *) hash_str, "c6f0dde266cb4a26d41e8259d33499cc", 16 * 2 ) == 0 );
725  }
726  FCT_TEST_END();
727 #endif /* POLARSSL_SHA2_C */
728 
729 #ifdef POLARSSL_SHA2_C
730 
731  FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_2)
732  {
733  unsigned char src_str[10000];
734  unsigned char key_str[10000];
735  unsigned char hash_str[10000];
736  unsigned char output[65];
737  int key_len, src_len;
738 
739  memset(src_str, 0x00, 10000);
740  memset(key_str, 0x00, 10000);
741  memset(hash_str, 0x00, 10000);
742  memset(output, 0x00, 65);
743 
744  key_len = unhexify( key_str, "6d97bb5892245be2" );
745  src_len = unhexify( src_str, "13c2b391d59c0252ca5d2302beaaf88c4bcd779bb505ad9a122003dfae4cc123ad2bd036f225c4f040021a6b9fb8bd6f0281cf2e2631a732bdc71693cc42ef6d52b6c6912a9ef77b3274eb85ad7f965ae6ed44ac1721962a884ec7acfb4534b1488b1c0c45afa4dae8da1eb7b0a88a3240365d7e4e7d826abbde9f9203fd99d7" );
746 
747  sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
748  hexify( hash_str, output, 32 );
749 
750  fct_chk( strncmp( (char *) hash_str, "31588e241b015319a5ab8c4527296498", 16 * 2 ) == 0 );
751  }
752  FCT_TEST_END();
753 #endif /* POLARSSL_SHA2_C */
754 
755 #ifdef POLARSSL_SHA2_C
756 
757  FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_3)
758  {
759  unsigned char src_str[10000];
760  unsigned char key_str[10000];
761  unsigned char hash_str[10000];
762  unsigned char output[65];
763  int key_len, src_len;
764 
765  memset(src_str, 0x00, 10000);
766  memset(key_str, 0x00, 10000);
767  memset(hash_str, 0x00, 10000);
768  memset(output, 0x00, 65);
769 
770  key_len = unhexify( key_str, "3c7fc8a70b49007a" );
771  src_len = unhexify( src_str, "60024e428a39c8b8bb2e9591bad9dc2115dfbfd716b6eb7af30a6eb34560caccbbfa47b710fa8d523aca71e9e5ba10fc1feb1a43556d71f07ea4f33496f093044e8caf1d02b79e46eb1288d5964a7a7494f6b92574c35784eece054c6151281d80822f7d47b8231c35d07f5cb5cf4310ddc844845a01c6bfab514c048eccaf9f" );
772 
773  sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
774  hexify( hash_str, output, 32 );
775 
776  fct_chk( strncmp( (char *) hash_str, "1c98c94a32bec9f253c21070f82f8438", 16 * 2 ) == 0 );
777  }
778  FCT_TEST_END();
779 #endif /* POLARSSL_SHA2_C */
780 
781 #ifdef POLARSSL_SHA2_C
782 
783  FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_4)
784  {
785  unsigned char src_str[10000];
786  unsigned char key_str[10000];
787  unsigned char hash_str[10000];
788  unsigned char output[65];
789  int key_len, src_len;
790 
791  memset(src_str, 0x00, 10000);
792  memset(key_str, 0x00, 10000);
793  memset(hash_str, 0x00, 10000);
794  memset(output, 0x00, 65);
795 
796  key_len = unhexify( key_str, "369f33f85b927a07" );
797  src_len = unhexify( src_str, "ae8e2a94ca386d448cbacdb0e9040ae3cb297c296363052cc157455da29a0c95897315fc11e3f12b81e2418da1ec280bccbc00e847584ce9d14deeba7b3c9b8dba958b04bba37551f6c9ba9c060be1a4b8cf43aa62e5078b76c6512c5619b71a6a7cf5727180e1ff14f5a1a3c1691bf8b6ebad365c151e58d749d57adb3a4986" );
798 
799  sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
800  hexify( hash_str, output, 32 );
801 
802  fct_chk( strncmp( (char *) hash_str, "60b90383286533d309de46593e6ce39fc51fb00a8d88278c", 24 * 2 ) == 0 );
803  }
804  FCT_TEST_END();
805 #endif /* POLARSSL_SHA2_C */
806 
807 #ifdef POLARSSL_SHA2_C
808 
809  FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_5)
810  {
811  unsigned char src_str[10000];
812  unsigned char key_str[10000];
813  unsigned char hash_str[10000];
814  unsigned char output[65];
815  int key_len, src_len;
816 
817  memset(src_str, 0x00, 10000);
818  memset(key_str, 0x00, 10000);
819  memset(hash_str, 0x00, 10000);
820  memset(output, 0x00, 65);
821 
822  key_len = unhexify( key_str, "e5179687582b4dc4" );
823  src_len = unhexify( src_str, "ce103bdacdf32f614f6727bcb31ca1c2824a850d00f5585b016fb234fe1ef2cd687f302d3c6b738ed89a24060d65c36675d0d96307c72ef3e8a83bfa8402e226de9d5d1724ba75c4879bf41a4a465ce61887d9f49a34757849b48bae81c27ebed76faae2ad669bca04747d409148d40812776e0ae2c395b3cb9c89981ce72d5c" );
824 
825  sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
826  hexify( hash_str, output, 32 );
827 
828  fct_chk( strncmp( (char *) hash_str, "509581f6816df4b8cc9f2cf42b7cc6e6a5a1e375a16f2412", 24 * 2 ) == 0 );
829  }
830  FCT_TEST_END();
831 #endif /* POLARSSL_SHA2_C */
832 
833 #ifdef POLARSSL_SHA2_C
834 
835  FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_6)
836  {
837  unsigned char src_str[10000];
838  unsigned char key_str[10000];
839  unsigned char hash_str[10000];
840  unsigned char output[65];
841  int key_len, src_len;
842 
843  memset(src_str, 0x00, 10000);
844  memset(key_str, 0x00, 10000);
845  memset(hash_str, 0x00, 10000);
846  memset(output, 0x00, 65);
847 
848  key_len = unhexify( key_str, "63cec6246aeb1b61" );
849  src_len = unhexify( src_str, "c178db908a405fa88aa255b8cad22b4057016585f139ee930388b083d86062fa0b3ea1f23f8a43bd11bee8464bcbd19b5ab9f6a8038d5245516f8274d20c8ee3033a07b908da528fa00343bb595deed500cab9745c4cb6391c23300f0d3584b090b3326c4cfa342620b78f9f5b4f27f7307ed770643ec1764aeae3dcf1a3ec69" );
850 
851  sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
852  hexify( hash_str, output, 32 );
853 
854  fct_chk( strncmp( (char *) hash_str, "64f3dd861b7c7d29fce9ae0ce9ed954b5d7141806ee9eec7", 24 * 2 ) == 0 );
855  }
856  FCT_TEST_END();
857 #endif /* POLARSSL_SHA2_C */
858 
859 #ifdef POLARSSL_SHA4_C
860 
861  FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_1)
862  {
863  unsigned char src_str[10000];
864  unsigned char key_str[10000];
865  unsigned char hash_str[10000];
866  unsigned char output[97];
867  int key_len, src_len;
868 
869  memset(src_str, 0x00, 10000);
870  memset(key_str, 0x00, 10000);
871  memset(hash_str, 0x00, 10000);
872  memset(output, 0x00, 97);
873 
874  key_len = unhexify( key_str, "91a7401817386948ca952f9a20ee55dc" );
875  src_len = unhexify( src_str, "2fea5b91035d6d501f3a834fa178bff4e64b99a8450432dafd32e4466b0e1e7781166f8a73f7e036b3b0870920f559f47bd1400a1a906e85e0dcf00a6c26862e9148b23806680f285f1fe4f93cdaf924c181a965465739c14f2268c8be8b471847c74b222577a1310bcdc1a85ef1468aa1a3fd4031213c97324b7509c9050a3d" );
876 
877  sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
878  hexify( hash_str, output, 48 );
879 
880  fct_chk( strncmp( (char *) hash_str, "6d7be9490058cf413cc09fd043c224c2ec4fa7859b13783000a9a593c9f75838", 32 * 2 ) == 0 );
881  }
882  FCT_TEST_END();
883 #endif /* POLARSSL_SHA4_C */
884 
885 #ifdef POLARSSL_SHA4_C
886 
887  FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_2)
888  {
889  unsigned char src_str[10000];
890  unsigned char key_str[10000];
891  unsigned char hash_str[10000];
892  unsigned char output[97];
893  int key_len, src_len;
894 
895  memset(src_str, 0x00, 10000);
896  memset(key_str, 0x00, 10000);
897  memset(hash_str, 0x00, 10000);
898  memset(output, 0x00, 97);
899 
900  key_len = unhexify( key_str, "d6cac19657061aa90a6da11cd2e9ea47" );
901  src_len = unhexify( src_str, "9f482e4655173135dfaa22a11bbbe6af263db48716406c5aec162ba3c4b41cad4f5a91558377521191c7343118beee65982929802913d67b6de5c4bdc3d27299bd722219d5ad2efa5bdb9ff7b229fc4bbc3f60719320cf2e7a51cad1133d21bad2d80919b1836ef825308b7c51c6b7677ac782e2bc30007afba065681cbdd215" );
902 
903  sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
904  hexify( hash_str, output, 48 );
905 
906  fct_chk( strncmp( (char *) hash_str, "f3d5f3c008175321aa7b2ea379eaa4f8b9dcc60f895ec8940b8162f80a7dfe9f", 32 * 2 ) == 0 );
907  }
908  FCT_TEST_END();
909 #endif /* POLARSSL_SHA4_C */
910 
911 #ifdef POLARSSL_SHA4_C
912 
913  FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_3)
914  {
915  unsigned char src_str[10000];
916  unsigned char key_str[10000];
917  unsigned char hash_str[10000];
918  unsigned char output[97];
919  int key_len, src_len;
920 
921  memset(src_str, 0x00, 10000);
922  memset(key_str, 0x00, 10000);
923  memset(hash_str, 0x00, 10000);
924  memset(output, 0x00, 97);
925 
926  key_len = unhexify( key_str, "e06366ad149b8442cd4c1abdddd0afde" );
927  src_len = unhexify( src_str, "2d140a194c02a5598f69174834679b8371234a0d505491f1bd03e128dd91a8bca2fb812e9d5da71613b5b00952ea78bf450d5b7547dea79135925085c7d3e6f52009c51ca3d88c6c09e9d074b0ee110736e0ec9b478b93efb34d7bf1c41b54decec43eab077a3aa4998ede53f67b4ea36c266745f9643d5360bdc8337c70dabf" );
928 
929  sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
930  hexify( hash_str, output, 48 );
931 
932  fct_chk( strncmp( (char *) hash_str, "c19c67eda6fe29f3667bee1c897c333ce7683094ae77e84b4c16378d290895a1", 32 * 2 ) == 0 );
933  }
934  FCT_TEST_END();
935 #endif /* POLARSSL_SHA4_C */
936 
937 #ifdef POLARSSL_SHA4_C
938 
939  FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_4)
940  {
941  unsigned char src_str[10000];
942  unsigned char key_str[10000];
943  unsigned char hash_str[10000];
944  unsigned char output[97];
945  int key_len, src_len;
946 
947  memset(src_str, 0x00, 10000);
948  memset(key_str, 0x00, 10000);
949  memset(hash_str, 0x00, 10000);
950  memset(output, 0x00, 97);
951 
952  key_len = unhexify( key_str, "01ac59f42f8bb91d1bd10fe6990d7a87" );
953  src_len = unhexify( src_str, "3caf18c476edd5615f343ac7b7d3a9da9efade755672d5ba4b8ae8a7505539ea2c124ff755ec0457fbe49e43480b3c71e7f4742ec3693aad115d039f90222b030fdc9440313691716d5302005808c07627483b916fdf61983063c2eb1268f2deeef42fc790334456bc6bad256e31fc9066de7cc7e43d1321b1866db45e905622" );
954 
955  sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
956  hexify( hash_str, output, 48 );
957 
958  fct_chk( strncmp( (char *) hash_str, "1985fa2163a5943fc5d92f1fe8831215e7e91f0bff5332bc713a072bdb3a8f9e5c5157463a3bfeb36231416e65973e64", 48 * 2 ) == 0 );
959  }
960  FCT_TEST_END();
961 #endif /* POLARSSL_SHA4_C */
962 
963 #ifdef POLARSSL_SHA4_C
964 
965  FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_5)
966  {
967  unsigned char src_str[10000];
968  unsigned char key_str[10000];
969  unsigned char hash_str[10000];
970  unsigned char output[97];
971  int key_len, src_len;
972 
973  memset(src_str, 0x00, 10000);
974  memset(key_str, 0x00, 10000);
975  memset(hash_str, 0x00, 10000);
976  memset(output, 0x00, 97);
977 
978  key_len = unhexify( key_str, "fd74b9d9e102a3a80df1baf0cb35bace" );
979  src_len = unhexify( src_str, "1a068917584813d1689ccbd0370c2114d537cdc8cc52bf6db16d5535f8f7d1ad0c850a9fa0cf62373ffbf7642b1f1e8164010d350721d798d9f99e9724830399c2fce26377e83d38845675457865c03d4a07d741a505ef028343eb29fd46d0f761f3792886998c1e5c32ac3bc7e6f08faed194b34f06eff4d5d4a5b42c481e0e" );
980 
981  sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
982  hexify( hash_str, output, 48 );
983 
984  fct_chk( strncmp( (char *) hash_str, "a981eaf5de3d78b20ebd4414a4edd0657e3667cd808a0dbc430cf7252f73a5b24efa136039207bd59806897457d74e0c", 48 * 2 ) == 0 );
985  }
986  FCT_TEST_END();
987 #endif /* POLARSSL_SHA4_C */
988 
989 #ifdef POLARSSL_SHA4_C
990 
991  FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_5)
992  {
993  unsigned char src_str[10000];
994  unsigned char key_str[10000];
995  unsigned char hash_str[10000];
996  unsigned char output[97];
997  int key_len, src_len;
998 
999  memset(src_str, 0x00, 10000);
1000  memset(key_str, 0x00, 10000);
1001  memset(hash_str, 0x00, 10000);
1002  memset(output, 0x00, 97);
1003 
1004  key_len = unhexify( key_str, "9fe794f0e26b669fa5f6883149377c6c" );
1005  src_len = unhexify( src_str, "6010c9745e8f1d44cfdc99e7e0fd79bc4271944c2d1d84dba589073dfc4ca5eb98c59356f60cd87bef28aeb83a832bde339b2087daf942aa1f67876c5d5ed33924bed4143bc12a2be532ccaf64daa7e2bc3c8872b9823b0533b6f5159135effe8c61545536975d7c3a61ba7365ec35f165bc92b4d19eb9156ade17dfa1bb4161" );
1006 
1007  sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
1008  hexify( hash_str, output, 48 );
1009 
1010  fct_chk( strncmp( (char *) hash_str, "915ae61f8754698c2b6ef9629e93441f8541bd4258a5e05372d19136cfaefc0473b48d96119291b38eb1a3cb1982a986", 48 * 2 ) == 0 );
1011  }
1012  FCT_TEST_END();
1013 #endif /* POLARSSL_SHA4_C */
1014 
1015 #ifdef POLARSSL_SHA4_C
1016 
1017  FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_1)
1018  {
1019  unsigned char src_str[10000];
1020  unsigned char key_str[10000];
1021  unsigned char hash_str[10000];
1022  unsigned char output[129];
1023  int key_len, src_len;
1024 
1025  memset(src_str, 0x00, 10000);
1026  memset(key_str, 0x00, 10000);
1027  memset(hash_str, 0x00, 10000);
1028  memset(output, 0x00, 129);
1029 
1030  key_len = unhexify( key_str, "c95a17c09940a691ed2d621571b0eb844ede55a9" );
1031  src_len = unhexify( src_str, "99cd28262e81f34878cdcebf4128e05e2098a7009278a66f4c785784d0e5678f3f2b22f86e982d273b6273a222ec61750b4556d766f1550a7aedfe83faedbc4bdae83fa560d62df17eb914d05fdaa48940551bac81d700f5fca7147295e386e8120d66742ec65c6ee8d89a92217a0f6266d0ddc60bb20ef679ae8299c8502c2f" );
1032 
1033  sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
1034  hexify( hash_str, output, 64 );
1035 
1036  fct_chk( strncmp( (char *) hash_str, "6bc1379d156559ddee2ed420ea5d5c5ff3e454a1059b7ba72c350e77b6e9333c", 32 * 2 ) == 0 );
1037  }
1038  FCT_TEST_END();
1039 #endif /* POLARSSL_SHA4_C */
1040 
1041 #ifdef POLARSSL_SHA4_C
1042 
1043  FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_2)
1044  {
1045  unsigned char src_str[10000];
1046  unsigned char key_str[10000];
1047  unsigned char hash_str[10000];
1048  unsigned char output[129];
1049  int key_len, src_len;
1050 
1051  memset(src_str, 0x00, 10000);
1052  memset(key_str, 0x00, 10000);
1053  memset(hash_str, 0x00, 10000);
1054  memset(output, 0x00, 129);
1055 
1056  key_len = unhexify( key_str, "3b10b8fa718840d1dea8e9fc317476bcf55875fd" );
1057  src_len = unhexify( src_str, "f04f5b7073d7d0274e8354433b390306c5607632f5f589c12edb62d55673aff2366d2e6b24de731adf92e654baa30b1cfd4a069788f65ec1b99b015d904d8832110dbd74eae35a81562d14ce4136d820ad0a55ff5489ba678fbbc1c27663ec1349d70e740f0e0ec27cfbe8971819f4789e486b50a2d7271d77e2aaea50de62fd" );
1058 
1059  sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
1060  hexify( hash_str, output, 64 );
1061 
1062  fct_chk( strncmp( (char *) hash_str, "fc3c38c7a17e3ce06db033f1c172866f01a00045db55f2e234f71c82264f2ba2", 32 * 2 ) == 0 );
1063  }
1064  FCT_TEST_END();
1065 #endif /* POLARSSL_SHA4_C */
1066 
1067 #ifdef POLARSSL_SHA4_C
1068 
1069  FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_3)
1070  {
1071  unsigned char src_str[10000];
1072  unsigned char key_str[10000];
1073  unsigned char hash_str[10000];
1074  unsigned char output[129];
1075  int key_len, src_len;
1076 
1077  memset(src_str, 0x00, 10000);
1078  memset(key_str, 0x00, 10000);
1079  memset(hash_str, 0x00, 10000);
1080  memset(output, 0x00, 129);
1081 
1082  key_len = unhexify( key_str, "4803d311394600dc1e0d8fc8cedeb8bde3fe7c42" );
1083  src_len = unhexify( src_str, "a10c125dd702a97153ad923ba5e9889cfac1ba169de370debe51f233735aa6effcc9785c4b5c7e48c477dc5c411ae6a959118584e26adc94b42c2b29b046f3cf01c65b24a24bd2e620bdf650a23bb4a72655b1100d7ce9a4dab697c6379754b4396c825de4b9eb73f2e6a6c0d0353bbdeaf706612800e137b858fdb30f3311c6" );
1084 
1085  sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
1086  hexify( hash_str, output, 64 );
1087 
1088  fct_chk( strncmp( (char *) hash_str, "7cd8236c55102e6385f52279506df6fcc388ab75092da21395ce14a82b202ffa", 32 * 2 ) == 0 );
1089  }
1090  FCT_TEST_END();
1091 #endif /* POLARSSL_SHA4_C */
1092 
1093 #ifdef POLARSSL_SHA4_C
1094 
1095  FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_4)
1096  {
1097  unsigned char src_str[10000];
1098  unsigned char key_str[10000];
1099  unsigned char hash_str[10000];
1100  unsigned char output[129];
1101  int key_len, src_len;
1102 
1103  memset(src_str, 0x00, 10000);
1104  memset(key_str, 0x00, 10000);
1105  memset(hash_str, 0x00, 10000);
1106  memset(output, 0x00, 129);
1107 
1108  key_len = unhexify( key_str, "aeb2f3b977fa6c8e71e07c5a5c74ff58166de092" );
1109  src_len = unhexify( src_str, "22457355dc76095abd46846b41cfe49a06ce42ac8857b4702fc771508dfb3626e0bfe851df897a07b36811ec433766e4b4166c26301b3493e7440d4554b0ef6ac20f1a530e58fac8aeba4e9ff2d4898d8a28783b49cd269c2965fd7f8e4f2d60cf1e5284f2495145b72382aad90e153a90ecae125ad75336fb128825c23fb8b0" );
1110 
1111  sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
1112  hexify( hash_str, output, 64 );
1113 
1114  fct_chk( strncmp( (char *) hash_str, "fa39bd8fcc3bfa218f9dea5d3b2ce10a7619e31678a56d8a9d927b1fe703b125af445debe9a89a07db6194d27b44d85a", 48 * 2 ) == 0 );
1115  }
1116  FCT_TEST_END();
1117 #endif /* POLARSSL_SHA4_C */
1118 
1119 #ifdef POLARSSL_SHA4_C
1120 
1121  FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_5)
1122  {
1123  unsigned char src_str[10000];
1124  unsigned char key_str[10000];
1125  unsigned char hash_str[10000];
1126  unsigned char output[129];
1127  int key_len, src_len;
1128 
1129  memset(src_str, 0x00, 10000);
1130  memset(key_str, 0x00, 10000);
1131  memset(hash_str, 0x00, 10000);
1132  memset(output, 0x00, 129);
1133 
1134  key_len = unhexify( key_str, "4285d3d7744da52775bb44ca436a3154f7980309" );
1135  src_len = unhexify( src_str, "208f0b6f2de2e5aa5df11927ddc6df485edc1193181c484d0f0a434a95418803101d4de9fdb798f93516a6916fa38a8207de1666fe50fe3441c03b112eaaae6954ed063f7ac4e3c1e3f73b20d153fe9e4857f5e91430f0a70ee820529adac2467469fd18adf10e2af0fea27c0abc83c5a9af77c364a466cffce8bab4e2b70bc1" );
1136 
1137  sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
1138  hexify( hash_str, output, 64 );
1139 
1140  fct_chk( strncmp( (char *) hash_str, "fe7603f205b2774fe0f14ecfa3e338e90608a806d11ca459dff5ce36b1b264ecd3af5f0492a7521d8da3102ba20927a5", 48 * 2 ) == 0 );
1141  }
1142  FCT_TEST_END();
1143 #endif /* POLARSSL_SHA4_C */
1144 
1145 #ifdef POLARSSL_SHA4_C
1146 
1147  FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_6)
1148  {
1149  unsigned char src_str[10000];
1150  unsigned char key_str[10000];
1151  unsigned char hash_str[10000];
1152  unsigned char output[129];
1153  int key_len, src_len;
1154 
1155  memset(src_str, 0x00, 10000);
1156  memset(key_str, 0x00, 10000);
1157  memset(hash_str, 0x00, 10000);
1158  memset(output, 0x00, 129);
1159 
1160  key_len = unhexify( key_str, "8ab783d5acf32efa0d9c0a21abce955e96630d89" );
1161  src_len = unhexify( src_str, "17371e013dce839963d54418e97be4bd9fa3cb2a368a5220f5aa1b8aaddfa3bdefc91afe7c717244fd2fb640f5cb9d9bf3e25f7f0c8bc758883b89dcdce6d749d9672fed222277ece3e84b3ec01b96f70c125fcb3cbee6d19b8ef0873f915f173bdb05d81629ba187cc8ac1934b2f75952fb7616ae6bd812946df694bd2763af" );
1162 
1163  sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
1164  hexify( hash_str, output, 64 );
1165 
1166  fct_chk( strncmp( (char *) hash_str, "9ac7ca8d1aefc166b046e4cf7602ebe181a0e5055474bff5b342106731da0d7e48e4d87bc0a6f05871574289a1b099f8", 48 * 2 ) == 0 );
1167  }
1168  FCT_TEST_END();
1169 #endif /* POLARSSL_SHA4_C */
1170 
1171  }
1172  FCT_SUITE_END();
1173 
1174 
1175 }
1176 FCT_END();
1177