PolarSSL v1.1.4
|
00001 #include "fct.h" 00002 00003 #include <polarssl/sha1.h> 00004 #include <polarssl/sha2.h> 00005 #include <polarssl/sha4.h> 00006 00007 #include <polarssl/config.h> 00008 00009 #ifdef _MSC_VER 00010 #include <basetsd.h> 00011 typedef UINT32 uint32_t; 00012 #else 00013 #include <inttypes.h> 00014 #endif 00015 00016 /* 00017 * 32-bit integer manipulation macros (big endian) 00018 */ 00019 #ifndef GET_ULONG_BE 00020 #define GET_ULONG_BE(n,b,i) \ 00021 { \ 00022 (n) = ( (unsigned long) (b)[(i) ] << 24 ) \ 00023 | ( (unsigned long) (b)[(i) + 1] << 16 ) \ 00024 | ( (unsigned long) (b)[(i) + 2] << 8 ) \ 00025 | ( (unsigned long) (b)[(i) + 3] ); \ 00026 } 00027 #endif 00028 00029 #ifndef PUT_ULONG_BE 00030 #define PUT_ULONG_BE(n,b,i) \ 00031 { \ 00032 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ 00033 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ 00034 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ 00035 (b)[(i) + 3] = (unsigned char) ( (n) ); \ 00036 } 00037 #endif 00038 00039 int unhexify(unsigned char *obuf, const char *ibuf) 00040 { 00041 unsigned char c, c2; 00042 int len = strlen(ibuf) / 2; 00043 assert(!(strlen(ibuf) %1)); // must be even number of bytes 00044 00045 while (*ibuf != 0) 00046 { 00047 c = *ibuf++; 00048 if( c >= '0' && c <= '9' ) 00049 c -= '0'; 00050 else if( c >= 'a' && c <= 'f' ) 00051 c -= 'a' - 10; 00052 else if( c >= 'A' && c <= 'F' ) 00053 c -= 'A' - 10; 00054 else 00055 assert( 0 ); 00056 00057 c2 = *ibuf++; 00058 if( c2 >= '0' && c2 <= '9' ) 00059 c2 -= '0'; 00060 else if( c2 >= 'a' && c2 <= 'f' ) 00061 c2 -= 'a' - 10; 00062 else if( c2 >= 'A' && c2 <= 'F' ) 00063 c2 -= 'A' - 10; 00064 else 00065 assert( 0 ); 00066 00067 *obuf++ = ( c << 4 ) | c2; 00068 } 00069 00070 return len; 00071 } 00072 00073 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len) 00074 { 00075 unsigned char l, h; 00076 00077 while (len != 0) 00078 { 00079 h = (*ibuf) / 16; 00080 l = (*ibuf) % 16; 00081 00082 if( h < 10 ) 00083 *obuf++ = '0' + h; 00084 else 00085 *obuf++ = 'a' + h - 10; 00086 00087 if( l < 10 ) 00088 *obuf++ = '0' + l; 00089 else 00090 *obuf++ = 'a' + l - 10; 00091 00092 ++ibuf; 00093 len--; 00094 } 00095 } 00096 00106 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len ) 00107 { 00108 size_t i; 00109 00110 if( rng_state != NULL ) 00111 rng_state = NULL; 00112 00113 for( i = 0; i < len; ++i ) 00114 output[i] = rand(); 00115 00116 return( 0 ); 00117 } 00118 00124 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len ) 00125 { 00126 if( rng_state != NULL ) 00127 rng_state = NULL; 00128 00129 memset( output, 0, len ); 00130 00131 return( 0 ); 00132 } 00133 00134 typedef struct 00135 { 00136 unsigned char *buf; 00137 size_t length; 00138 } rnd_buf_info; 00139 00151 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len ) 00152 { 00153 rnd_buf_info *info = (rnd_buf_info *) rng_state; 00154 size_t use_len; 00155 00156 if( rng_state == NULL ) 00157 return( rnd_std_rand( NULL, output, len ) ); 00158 00159 use_len = len; 00160 if( len > info->length ) 00161 use_len = info->length; 00162 00163 if( use_len ) 00164 { 00165 memcpy( output, info->buf, use_len ); 00166 info->buf += use_len; 00167 info->length -= use_len; 00168 } 00169 00170 if( len - use_len > 0 ) 00171 return( rnd_std_rand( NULL, output + use_len, len - use_len ) ); 00172 00173 return( 0 ); 00174 } 00175 00183 typedef struct 00184 { 00185 uint32_t key[16]; 00186 uint32_t v0, v1; 00187 } rnd_pseudo_info; 00188 00197 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len ) 00198 { 00199 rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state; 00200 uint32_t i, *k, sum, delta=0x9E3779B9; 00201 unsigned char result[4]; 00202 00203 if( rng_state == NULL ) 00204 return( rnd_std_rand( NULL, output, len ) ); 00205 00206 k = info->key; 00207 00208 while( len > 0 ) 00209 { 00210 size_t use_len = ( len > 4 ) ? 4 : len; 00211 sum = 0; 00212 00213 for( i = 0; i < 32; i++ ) 00214 { 00215 info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]); 00216 sum += delta; 00217 info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]); 00218 } 00219 00220 PUT_ULONG_BE( info->v0, result, 0 ); 00221 memcpy( output, result, use_len ); 00222 len -= use_len; 00223 } 00224 00225 return( 0 ); 00226 } 00227 00228 00229 FCT_BGN() 00230 { 00231 00232 00233 FCT_SUITE_BGN(test_suite_shax) 00234 { 00235 #ifdef POLARSSL_SHA1_C 00236 00237 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_1) 00238 { 00239 unsigned char src_str[10000]; 00240 unsigned char hash_str[10000]; 00241 unsigned char output[41]; 00242 int src_len; 00243 00244 memset(src_str, 0x00, 10000); 00245 memset(hash_str, 0x00, 10000); 00246 memset(output, 0x00, 41); 00247 00248 src_len = unhexify( src_str, "" ); 00249 00250 sha1( src_str, src_len, output ); 00251 hexify( hash_str, output, 20 ); 00252 00253 fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 ); 00254 } 00255 FCT_TEST_END(); 00256 #endif /* POLARSSL_SHA1_C */ 00257 00258 #ifdef POLARSSL_SHA1_C 00259 00260 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_2) 00261 { 00262 unsigned char src_str[10000]; 00263 unsigned char hash_str[10000]; 00264 unsigned char output[41]; 00265 int src_len; 00266 00267 memset(src_str, 0x00, 10000); 00268 memset(hash_str, 0x00, 10000); 00269 memset(output, 0x00, 41); 00270 00271 src_len = unhexify( src_str, "a8" ); 00272 00273 sha1( src_str, src_len, output ); 00274 hexify( hash_str, output, 20 ); 00275 00276 fct_chk( strcmp( (char *) hash_str, "99f2aa95e36f95c2acb0eaf23998f030638f3f15" ) == 0 ); 00277 } 00278 FCT_TEST_END(); 00279 #endif /* POLARSSL_SHA1_C */ 00280 00281 #ifdef POLARSSL_SHA1_C 00282 00283 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_3) 00284 { 00285 unsigned char src_str[10000]; 00286 unsigned char hash_str[10000]; 00287 unsigned char output[41]; 00288 int src_len; 00289 00290 memset(src_str, 0x00, 10000); 00291 memset(hash_str, 0x00, 10000); 00292 memset(output, 0x00, 41); 00293 00294 src_len = unhexify( src_str, "3000" ); 00295 00296 sha1( src_str, src_len, output ); 00297 hexify( hash_str, output, 20 ); 00298 00299 fct_chk( strcmp( (char *) hash_str, "f944dcd635f9801f7ac90a407fbc479964dec024" ) == 0 ); 00300 } 00301 FCT_TEST_END(); 00302 #endif /* POLARSSL_SHA1_C */ 00303 00304 #ifdef POLARSSL_SHA1_C 00305 00306 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_4) 00307 { 00308 unsigned char src_str[10000]; 00309 unsigned char hash_str[10000]; 00310 unsigned char output[41]; 00311 int src_len; 00312 00313 memset(src_str, 0x00, 10000); 00314 memset(hash_str, 0x00, 10000); 00315 memset(output, 0x00, 41); 00316 00317 src_len = unhexify( src_str, "42749e" ); 00318 00319 sha1( src_str, src_len, output ); 00320 hexify( hash_str, output, 20 ); 00321 00322 fct_chk( strcmp( (char *) hash_str, "a444319e9b6cc1e8464c511ec0969c37d6bb2619" ) == 0 ); 00323 } 00324 FCT_TEST_END(); 00325 #endif /* POLARSSL_SHA1_C */ 00326 00327 #ifdef POLARSSL_SHA1_C 00328 00329 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_5) 00330 { 00331 unsigned char src_str[10000]; 00332 unsigned char hash_str[10000]; 00333 unsigned char output[41]; 00334 int src_len; 00335 00336 memset(src_str, 0x00, 10000); 00337 memset(hash_str, 0x00, 10000); 00338 memset(output, 0x00, 41); 00339 00340 src_len = unhexify( src_str, "9fc3fe08" ); 00341 00342 sha1( src_str, src_len, output ); 00343 hexify( hash_str, output, 20 ); 00344 00345 fct_chk( strcmp( (char *) hash_str, "16a0ff84fcc156fd5d3ca3a744f20a232d172253" ) == 0 ); 00346 } 00347 FCT_TEST_END(); 00348 #endif /* POLARSSL_SHA1_C */ 00349 00350 #ifdef POLARSSL_SHA1_C 00351 00352 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_6) 00353 { 00354 unsigned char src_str[10000]; 00355 unsigned char hash_str[10000]; 00356 unsigned char output[41]; 00357 int src_len; 00358 00359 memset(src_str, 0x00, 10000); 00360 memset(hash_str, 0x00, 10000); 00361 memset(output, 0x00, 41); 00362 00363 src_len = unhexify( src_str, "b5c1c6f1af" ); 00364 00365 sha1( src_str, src_len, output ); 00366 hexify( hash_str, output, 20 ); 00367 00368 fct_chk( strcmp( (char *) hash_str, "fec9deebfcdedaf66dda525e1be43597a73a1f93" ) == 0 ); 00369 } 00370 FCT_TEST_END(); 00371 #endif /* POLARSSL_SHA1_C */ 00372 00373 #ifdef POLARSSL_SHA1_C 00374 00375 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_7) 00376 { 00377 unsigned char src_str[10000]; 00378 unsigned char hash_str[10000]; 00379 unsigned char output[41]; 00380 int src_len; 00381 00382 memset(src_str, 0x00, 10000); 00383 memset(hash_str, 0x00, 10000); 00384 memset(output, 0x00, 41); 00385 00386 src_len = unhexify( src_str, "ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b2548035185813e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a5305da4b1b737fce7cd21c0eb7728d08235a9011" ); 00387 00388 sha1( src_str, src_len, output ); 00389 hexify( hash_str, output, 20 ); 00390 00391 fct_chk( strcmp( (char *) hash_str, "970111c4e77bcc88cc20459c02b69b4aa8f58217" ) == 0 ); 00392 } 00393 FCT_TEST_END(); 00394 #endif /* POLARSSL_SHA1_C */ 00395 00396 #ifdef POLARSSL_SHA1_C 00397 00398 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_8) 00399 { 00400 unsigned char src_str[10000]; 00401 unsigned char hash_str[10000]; 00402 unsigned char output[41]; 00403 int src_len; 00404 00405 memset(src_str, 0x00, 10000); 00406 memset(hash_str, 0x00, 10000); 00407 memset(output, 0x00, 41); 00408 00409 src_len = unhexify( src_str, "5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652afe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba553d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38ae485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77414197422be3d36a6080" ); 00410 00411 sha1( src_str, src_len, output ); 00412 hexify( hash_str, output, 20 ); 00413 00414 fct_chk( strcmp( (char *) hash_str, "0423dc76a8791107d14e13f5265b343f24cc0f19" ) == 0 ); 00415 } 00416 FCT_TEST_END(); 00417 #endif /* POLARSSL_SHA1_C */ 00418 00419 #ifdef POLARSSL_SHA1_C 00420 00421 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_9) 00422 { 00423 unsigned char src_str[10000]; 00424 unsigned char hash_str[10000]; 00425 unsigned char output[41]; 00426 int src_len; 00427 00428 memset(src_str, 0x00, 10000); 00429 memset(hash_str, 0x00, 10000); 00430 memset(output, 0x00, 41); 00431 00432 src_len = unhexify( src_str, "0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a007ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec428c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30baa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff57800e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee71366afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32beaea" ); 00433 00434 sha1( src_str, src_len, output ); 00435 hexify( hash_str, output, 20 ); 00436 00437 fct_chk( strcmp( (char *) hash_str, "6692a71d73e00f27df976bc56df4970650d90e45" ) == 0 ); 00438 } 00439 FCT_TEST_END(); 00440 #endif /* POLARSSL_SHA1_C */ 00441 00442 #ifdef POLARSSL_SHA1_C 00443 00444 FCT_TEST_BGN(sha_1_test_vector_nist_cavs_10) 00445 { 00446 unsigned char src_str[10000]; 00447 unsigned char hash_str[10000]; 00448 unsigned char output[41]; 00449 int src_len; 00450 00451 memset(src_str, 0x00, 10000); 00452 memset(hash_str, 0x00, 10000); 00453 memset(output, 0x00, 41); 00454 00455 src_len = unhexify( src_str, "8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff" ); 00456 00457 sha1( src_str, src_len, output ); 00458 hexify( hash_str, output, 20 ); 00459 00460 fct_chk( strcmp( (char *) hash_str, "11863b483809ef88413ca9b0084ac4a5390640af" ) == 0 ); 00461 } 00462 FCT_TEST_END(); 00463 #endif /* POLARSSL_SHA1_C */ 00464 00465 #ifdef POLARSSL_SHA2_C 00466 00467 FCT_TEST_BGN(sha_224_test_vector_nist_cavs_1) 00468 { 00469 unsigned char src_str[10000]; 00470 unsigned char hash_str[10000]; 00471 unsigned char output[57]; 00472 int src_len; 00473 00474 memset(src_str, 0x00, 10000); 00475 memset(hash_str, 0x00, 10000); 00476 memset(output, 0x00, 57); 00477 00478 src_len = unhexify( src_str, "" ); 00479 00480 sha2( src_str, src_len, output, 1 ); 00481 hexify( hash_str, output, 28 ); 00482 00483 fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 ); 00484 } 00485 FCT_TEST_END(); 00486 #endif /* POLARSSL_SHA2_C */ 00487 00488 #ifdef POLARSSL_SHA2_C 00489 00490 FCT_TEST_BGN(sha_224_test_vector_nist_cavs_2) 00491 { 00492 unsigned char src_str[10000]; 00493 unsigned char hash_str[10000]; 00494 unsigned char output[57]; 00495 int src_len; 00496 00497 memset(src_str, 0x00, 10000); 00498 memset(hash_str, 0x00, 10000); 00499 memset(output, 0x00, 57); 00500 00501 src_len = unhexify( src_str, "ff" ); 00502 00503 sha2( src_str, src_len, output, 1 ); 00504 hexify( hash_str, output, 28 ); 00505 00506 fct_chk( strcmp( (char *) hash_str, "e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5" ) == 0 ); 00507 } 00508 FCT_TEST_END(); 00509 #endif /* POLARSSL_SHA2_C */ 00510 00511 #ifdef POLARSSL_SHA2_C 00512 00513 FCT_TEST_BGN(sha_224_test_vector_nist_cavs_3) 00514 { 00515 unsigned char src_str[10000]; 00516 unsigned char hash_str[10000]; 00517 unsigned char output[57]; 00518 int src_len; 00519 00520 memset(src_str, 0x00, 10000); 00521 memset(hash_str, 0x00, 10000); 00522 memset(output, 0x00, 57); 00523 00524 src_len = unhexify( src_str, "984c" ); 00525 00526 sha2( src_str, src_len, output, 1 ); 00527 hexify( hash_str, output, 28 ); 00528 00529 fct_chk( strcmp( (char *) hash_str, "2fa9df9157d9e027cfbc4c6a9df32e1adc0cbe2328ec2a63c5ae934e" ) == 0 ); 00530 } 00531 FCT_TEST_END(); 00532 #endif /* POLARSSL_SHA2_C */ 00533 00534 #ifdef POLARSSL_SHA2_C 00535 00536 FCT_TEST_BGN(sha_224_test_vector_nist_cavs_4) 00537 { 00538 unsigned char src_str[10000]; 00539 unsigned char hash_str[10000]; 00540 unsigned char output[57]; 00541 int src_len; 00542 00543 memset(src_str, 0x00, 10000); 00544 memset(hash_str, 0x00, 10000); 00545 memset(output, 0x00, 57); 00546 00547 src_len = unhexify( src_str, "50efd0" ); 00548 00549 sha2( src_str, src_len, output, 1 ); 00550 hexify( hash_str, output, 28 ); 00551 00552 fct_chk( strcmp( (char *) hash_str, "b5a9820413c2bf8211fbbf5df1337043b32fa4eafaf61a0c8e9ccede" ) == 0 ); 00553 } 00554 FCT_TEST_END(); 00555 #endif /* POLARSSL_SHA2_C */ 00556 00557 #ifdef POLARSSL_SHA2_C 00558 00559 FCT_TEST_BGN(sha_224_test_vector_nist_cavs_5) 00560 { 00561 unsigned char src_str[10000]; 00562 unsigned char hash_str[10000]; 00563 unsigned char output[57]; 00564 int src_len; 00565 00566 memset(src_str, 0x00, 10000); 00567 memset(hash_str, 0x00, 10000); 00568 memset(output, 0x00, 57); 00569 00570 src_len = unhexify( src_str, "e5e09924" ); 00571 00572 sha2( src_str, src_len, output, 1 ); 00573 hexify( hash_str, output, 28 ); 00574 00575 fct_chk( strcmp( (char *) hash_str, "fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d" ) == 0 ); 00576 } 00577 FCT_TEST_END(); 00578 #endif /* POLARSSL_SHA2_C */ 00579 00580 #ifdef POLARSSL_SHA2_C 00581 00582 FCT_TEST_BGN(sha_224_test_vector_nist_cavs_6) 00583 { 00584 unsigned char src_str[10000]; 00585 unsigned char hash_str[10000]; 00586 unsigned char output[57]; 00587 int src_len; 00588 00589 memset(src_str, 0x00, 10000); 00590 memset(hash_str, 0x00, 10000); 00591 memset(output, 0x00, 57); 00592 00593 src_len = unhexify( src_str, "21ebecb914" ); 00594 00595 sha2( src_str, src_len, output, 1 ); 00596 hexify( hash_str, output, 28 ); 00597 00598 fct_chk( strcmp( (char *) hash_str, "78f4a71c21c694499ce1c7866611b14ace70d905012c356323c7c713" ) == 0 ); 00599 } 00600 FCT_TEST_END(); 00601 #endif /* POLARSSL_SHA2_C */ 00602 00603 #ifdef POLARSSL_SHA2_C 00604 00605 FCT_TEST_BGN(sha_224_test_vector_nist_cavs_7) 00606 { 00607 unsigned char src_str[10000]; 00608 unsigned char hash_str[10000]; 00609 unsigned char output[57]; 00610 int src_len; 00611 00612 memset(src_str, 0x00, 10000); 00613 memset(hash_str, 0x00, 10000); 00614 memset(output, 0x00, 57); 00615 00616 src_len = unhexify( src_str, "fc488947c1a7a589726b15436b4f3d9556262f98fc6422fc5cdf20f0fad7fe427a3491c86d101ffe6b7514f06268f65b2d269b0f69ad9a97847eff1c16a2438775eb7be6847ccf11cb8b2e8dcd6640b095b49c0693fe3cf4a66e2d9b7ad68bff14f3ad69abf49d0aba36cbe0535202deb6599a47225ef05beb351335cd7bc0f480d691198c7e71305ffd53b39d33242bb79cfd98bfd69e137b5d18b2b89ac9ace01c8dbdcf2533cce3682ecc52118de0c1062ec2126c2e657d6ea3d9e2398e705d4b0b1f1ceecb266dffc4f31bf42744fb1e938dc22a889919ee1e73f463f7871fed720519e32186264b7ef2a0e5d9a18e6c95c0781894f77967f048951dec3b4d892a38710b1e3436d3c29088eb8b3da1789c25db3d3bc6c26081206e7155d210a89b80ca6ea877c41ff9947c0f25625dcb118294a163501f6239c326661a958fd12da4cd15a899f8b88cc723589056eaec5aa04a4cf5dbb6f480f9660423ccf38c486e210707e0fb25e1f126ceb2616f63e147a647dab0af9ebe89d65458bf636154a46e4cab95f5ee62da2c7974cd14b90d3e4f99f81733e85b3c1d5da2b508d9b90f5eed7eff0d9c7649de62bee00375454fee4a39576a5bbfdae428e7f8097bdf7797f167686cb68407e49079e4611ff3402b6384ba7b7e522bd2bb11ce8fd02ea4c1604d163ac4f6dde50b8b1f593f7edaadeac0868ed97df690200680c25f0f5d85431a529e4f339089dcdeda105e4ee51dead704cdf5a605c55fb055c9b0e86b8ba1b564c0dea3eb790a595cb103cb292268b07c5e59371e1a7ef597cd4b22977a820694c9f9aeb55d9de3ef62b75d6e656e3336698d960a3787bf8cf5b926a7faeef52ae128bcb5dc9e66d94b016c7b8e034879171a2d91c381f57e6a815b63b5ee6a6d2ff435b49f14c963966960194430d78f8f87627a67757fb3532b289550894da6dce4817a4e07f4d56877a1102ffcc8befa5c9f8fca6a4574d93ff70376c8861e0f8108cf907fce77ecb49728f86f034f80224b9695682e0824462f76cdb1fd1af151337b0d85419047a7aa284791718a4860cd586f7824b95bc837b6fd4f9be5aade68456e20356aa4d943dac36bf8b67b9e8f9d01a00fcda74b798bafa746c661b010f75b59904b29d0c8041504811c4065f82cf2ead58d2f595cbd8bc3e7043f4d94577b373b7cfe16a36fe564f505c03b70cfeb5e5f411c79481338aa67e86b3f5a2e77c21e454c333ae3da943ab723ab5f4c940395319534a5575f64acba0d0ecc43f60221ed3badf7289c9b3a7b903a2d6c94e15fa4c310dc4fa7faa0c24f405160a1002dbef20e4105d481db982f7243f79400a6e4cd9753c4b9732a47575f504b20c328fe9add7f432a4f075829da07b53b695037dc51737d3cd731934df333cd1a53fcf65aa31baa450ca501a6fae26e322347e618c5a444d92e9fec5a8261ae38b98fee5be77c02cec09ddccd5b3de92036" ); 00617 00618 sha2( src_str, src_len, output, 1 ); 00619 hexify( hash_str, output, 28 ); 00620 00621 fct_chk( strcmp( (char *) hash_str, "1302149d1e197c41813b054c942329d420e366530f5517b470e964fe" ) == 0 ); 00622 } 00623 FCT_TEST_END(); 00624 #endif /* POLARSSL_SHA2_C */ 00625 00626 #ifdef POLARSSL_SHA2_C 00627 00628 FCT_TEST_BGN(sha_256_test_vector_nist_cavs_1) 00629 { 00630 unsigned char src_str[10000]; 00631 unsigned char hash_str[10000]; 00632 unsigned char output[65]; 00633 int src_len; 00634 00635 memset(src_str, 0x00, 10000); 00636 memset(hash_str, 0x00, 10000); 00637 memset(output, 0x00, 65); 00638 00639 src_len = unhexify( src_str, "" ); 00640 00641 sha2( src_str, src_len, output, 0 ); 00642 hexify( hash_str, output, 32 ); 00643 00644 fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 ); 00645 } 00646 FCT_TEST_END(); 00647 #endif /* POLARSSL_SHA2_C */ 00648 00649 #ifdef POLARSSL_SHA2_C 00650 00651 FCT_TEST_BGN(sha_256_test_vector_nist_cavs_2) 00652 { 00653 unsigned char src_str[10000]; 00654 unsigned char hash_str[10000]; 00655 unsigned char output[65]; 00656 int src_len; 00657 00658 memset(src_str, 0x00, 10000); 00659 memset(hash_str, 0x00, 10000); 00660 memset(output, 0x00, 65); 00661 00662 src_len = unhexify( src_str, "bd" ); 00663 00664 sha2( src_str, src_len, output, 0 ); 00665 hexify( hash_str, output, 32 ); 00666 00667 fct_chk( strcmp( (char *) hash_str, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b" ) == 0 ); 00668 } 00669 FCT_TEST_END(); 00670 #endif /* POLARSSL_SHA2_C */ 00671 00672 #ifdef POLARSSL_SHA2_C 00673 00674 FCT_TEST_BGN(sha_256_test_vector_nist_cavs_3) 00675 { 00676 unsigned char src_str[10000]; 00677 unsigned char hash_str[10000]; 00678 unsigned char output[65]; 00679 int src_len; 00680 00681 memset(src_str, 0x00, 10000); 00682 memset(hash_str, 0x00, 10000); 00683 memset(output, 0x00, 65); 00684 00685 src_len = unhexify( src_str, "5fd4" ); 00686 00687 sha2( src_str, src_len, output, 0 ); 00688 hexify( hash_str, output, 32 ); 00689 00690 fct_chk( strcmp( (char *) hash_str, "7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788" ) == 0 ); 00691 } 00692 FCT_TEST_END(); 00693 #endif /* POLARSSL_SHA2_C */ 00694 00695 #ifdef POLARSSL_SHA2_C 00696 00697 FCT_TEST_BGN(sha_256_test_vector_nist_cavs_4) 00698 { 00699 unsigned char src_str[10000]; 00700 unsigned char hash_str[10000]; 00701 unsigned char output[65]; 00702 int src_len; 00703 00704 memset(src_str, 0x00, 10000); 00705 memset(hash_str, 0x00, 10000); 00706 memset(output, 0x00, 65); 00707 00708 src_len = unhexify( src_str, "b0bd69" ); 00709 00710 sha2( src_str, src_len, output, 0 ); 00711 hexify( hash_str, output, 32 ); 00712 00713 fct_chk( strcmp( (char *) hash_str, "4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803" ) == 0 ); 00714 } 00715 FCT_TEST_END(); 00716 #endif /* POLARSSL_SHA2_C */ 00717 00718 #ifdef POLARSSL_SHA2_C 00719 00720 FCT_TEST_BGN(sha_256_test_vector_nist_cavs_5) 00721 { 00722 unsigned char src_str[10000]; 00723 unsigned char hash_str[10000]; 00724 unsigned char output[65]; 00725 int src_len; 00726 00727 memset(src_str, 0x00, 10000); 00728 memset(hash_str, 0x00, 10000); 00729 memset(output, 0x00, 65); 00730 00731 src_len = unhexify( src_str, "c98c8e55" ); 00732 00733 sha2( src_str, src_len, output, 0 ); 00734 hexify( hash_str, output, 32 ); 00735 00736 fct_chk( strcmp( (char *) hash_str, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504" ) == 0 ); 00737 } 00738 FCT_TEST_END(); 00739 #endif /* POLARSSL_SHA2_C */ 00740 00741 #ifdef POLARSSL_SHA2_C 00742 00743 FCT_TEST_BGN(sha_256_test_vector_nist_cavs_6) 00744 { 00745 unsigned char src_str[10000]; 00746 unsigned char hash_str[10000]; 00747 unsigned char output[65]; 00748 int src_len; 00749 00750 memset(src_str, 0x00, 10000); 00751 memset(hash_str, 0x00, 10000); 00752 memset(output, 0x00, 65); 00753 00754 src_len = unhexify( src_str, "81a723d966" ); 00755 00756 sha2( src_str, src_len, output, 0 ); 00757 hexify( hash_str, output, 32 ); 00758 00759 fct_chk( strcmp( (char *) hash_str, "7516fb8bb11350df2bf386bc3c33bd0f52cb4c67c6e4745e0488e62c2aea2605" ) == 0 ); 00760 } 00761 FCT_TEST_END(); 00762 #endif /* POLARSSL_SHA2_C */ 00763 00764 #ifdef POLARSSL_SHA2_C 00765 00766 FCT_TEST_BGN(sha_256_test_vector_nist_cavs_7) 00767 { 00768 unsigned char src_str[10000]; 00769 unsigned char hash_str[10000]; 00770 unsigned char output[65]; 00771 int src_len; 00772 00773 memset(src_str, 0x00, 10000); 00774 memset(hash_str, 0x00, 10000); 00775 memset(output, 0x00, 65); 00776 00777 src_len = unhexify( src_str, "8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e" ); 00778 00779 sha2( src_str, src_len, output, 0 ); 00780 hexify( hash_str, output, 32 ); 00781 00782 fct_chk( strcmp( (char *) hash_str, "4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e" ) == 0 ); 00783 } 00784 FCT_TEST_END(); 00785 #endif /* POLARSSL_SHA2_C */ 00786 00787 #ifdef POLARSSL_SHA4_C 00788 00789 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_1) 00790 { 00791 unsigned char src_str[10000]; 00792 unsigned char hash_str[10000]; 00793 unsigned char output[97]; 00794 int src_len; 00795 00796 memset(src_str, 0x00, 10000); 00797 memset(hash_str, 0x00, 10000); 00798 memset(output, 0x00, 97); 00799 00800 src_len = unhexify( src_str, "" ); 00801 00802 sha4( src_str, src_len, output, 1 ); 00803 hexify( hash_str, output, 48 ); 00804 00805 fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 ); 00806 } 00807 FCT_TEST_END(); 00808 #endif /* POLARSSL_SHA4_C */ 00809 00810 #ifdef POLARSSL_SHA4_C 00811 00812 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_2) 00813 { 00814 unsigned char src_str[10000]; 00815 unsigned char hash_str[10000]; 00816 unsigned char output[97]; 00817 int src_len; 00818 00819 memset(src_str, 0x00, 10000); 00820 memset(hash_str, 0x00, 10000); 00821 memset(output, 0x00, 97); 00822 00823 src_len = unhexify( src_str, "ab" ); 00824 00825 sha4( src_str, src_len, output, 1 ); 00826 hexify( hash_str, output, 48 ); 00827 00828 fct_chk( strcmp( (char *) hash_str, "fb94d5be118865f6fcbc978b825da82cff188faec2f66cb84b2537d74b4938469854b0ca89e66fa2e182834736629f3d" ) == 0 ); 00829 } 00830 FCT_TEST_END(); 00831 #endif /* POLARSSL_SHA4_C */ 00832 00833 #ifdef POLARSSL_SHA4_C 00834 00835 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_3) 00836 { 00837 unsigned char src_str[10000]; 00838 unsigned char hash_str[10000]; 00839 unsigned char output[97]; 00840 int src_len; 00841 00842 memset(src_str, 0x00, 10000); 00843 memset(hash_str, 0x00, 10000); 00844 memset(output, 0x00, 97); 00845 00846 src_len = unhexify( src_str, "7c27" ); 00847 00848 sha4( src_str, src_len, output, 1 ); 00849 hexify( hash_str, output, 48 ); 00850 00851 fct_chk( strcmp( (char *) hash_str, "3d80be467df86d63abb9ea1d3f9cb39cd19890e7f2c53a6200bedc5006842b35e820dc4e0ca90ca9b97ab23ef07080fc" ) == 0 ); 00852 } 00853 FCT_TEST_END(); 00854 #endif /* POLARSSL_SHA4_C */ 00855 00856 #ifdef POLARSSL_SHA4_C 00857 00858 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_4) 00859 { 00860 unsigned char src_str[10000]; 00861 unsigned char hash_str[10000]; 00862 unsigned char output[97]; 00863 int src_len; 00864 00865 memset(src_str, 0x00, 10000); 00866 memset(hash_str, 0x00, 10000); 00867 memset(output, 0x00, 97); 00868 00869 src_len = unhexify( src_str, "31f5ca" ); 00870 00871 sha4( src_str, src_len, output, 1 ); 00872 hexify( hash_str, output, 48 ); 00873 00874 fct_chk( strcmp( (char *) hash_str, "78d54b943421fdf7ba90a7fb9637c2073aa480454bd841d39ff72f4511fc21fb67797b652c0c823229342873d3bef955" ) == 0 ); 00875 } 00876 FCT_TEST_END(); 00877 #endif /* POLARSSL_SHA4_C */ 00878 00879 #ifdef POLARSSL_SHA4_C 00880 00881 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_5) 00882 { 00883 unsigned char src_str[10000]; 00884 unsigned char hash_str[10000]; 00885 unsigned char output[97]; 00886 int src_len; 00887 00888 memset(src_str, 0x00, 10000); 00889 memset(hash_str, 0x00, 10000); 00890 memset(output, 0x00, 97); 00891 00892 src_len = unhexify( src_str, "7bdee3f8" ); 00893 00894 sha4( src_str, src_len, output, 1 ); 00895 hexify( hash_str, output, 48 ); 00896 00897 fct_chk( strcmp( (char *) hash_str, "8bdafba0777ee446c3431c2d7b1fbb631089f71d2ca417abc1d230e1aba64ec2f1c187474a6f4077d372c14ad407f99a" ) == 0 ); 00898 } 00899 FCT_TEST_END(); 00900 #endif /* POLARSSL_SHA4_C */ 00901 00902 #ifdef POLARSSL_SHA4_C 00903 00904 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_6) 00905 { 00906 unsigned char src_str[10000]; 00907 unsigned char hash_str[10000]; 00908 unsigned char output[97]; 00909 int src_len; 00910 00911 memset(src_str, 0x00, 10000); 00912 memset(hash_str, 0x00, 10000); 00913 memset(output, 0x00, 97); 00914 00915 src_len = unhexify( src_str, "8f05604915" ); 00916 00917 sha4( src_str, src_len, output, 1 ); 00918 hexify( hash_str, output, 48 ); 00919 00920 fct_chk( strcmp( (char *) hash_str, "504e414bf1db1060f14c8c799e25b1e0c4dcf1504ebbd129998f0ae283e6de86e0d3c7e879c73ec3b1836c3ee89c2649" ) == 0 ); 00921 } 00922 FCT_TEST_END(); 00923 #endif /* POLARSSL_SHA4_C */ 00924 00925 #ifdef POLARSSL_SHA4_C 00926 00927 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_7) 00928 { 00929 unsigned char src_str[10000]; 00930 unsigned char hash_str[10000]; 00931 unsigned char output[97]; 00932 int src_len; 00933 00934 memset(src_str, 0x00, 10000); 00935 memset(hash_str, 0x00, 10000); 00936 memset(output, 0x00, 97); 00937 00938 src_len = unhexify( src_str, "665da6eda214" ); 00939 00940 sha4( src_str, src_len, output, 1 ); 00941 hexify( hash_str, output, 48 ); 00942 00943 fct_chk( strcmp( (char *) hash_str, "4c022f112010908848312f8b8f1072625fd5c105399d562ea1d56130619a7eac8dfc3748fd05ee37e4b690be9daa9980" ) == 0 ); 00944 } 00945 FCT_TEST_END(); 00946 #endif /* POLARSSL_SHA4_C */ 00947 00948 #ifdef POLARSSL_SHA4_C 00949 00950 FCT_TEST_BGN(sha_384_test_vector_nist_cavs_8) 00951 { 00952 unsigned char src_str[10000]; 00953 unsigned char hash_str[10000]; 00954 unsigned char output[97]; 00955 int src_len; 00956 00957 memset(src_str, 0x00, 10000); 00958 memset(hash_str, 0x00, 10000); 00959 memset(output, 0x00, 97); 00960 00961 src_len = unhexify( src_str, "7f46ce506d593c4ed53c82edeb602037e0485befbee03f7f930fe532d18ff2a3f5fd6076672c8145a1bf40dd94f7abab47c9ae71c234213d2ad1069c2dac0b0ba15257ae672b8245960ae55bd50315c0097daa3a318745788d70d14706910809ca6e396237fe4934fa46f9ce782d66606d8bd6b2d283b1160513ce9c24e9f084b97891f99d4cdefc169a029e431ca772ba1bba426fce6f01d8e286014e5acc66b799e4db62bd4783322f8a32ff78e0de3957df50ce10871f4e0680df4e8ca3960af9bc6f4efa8eb3962d18f474eb178c3265cc46b8f2ff5ab1a7449fea297dfcfabfa01f28abbb7289bb354b691b5664ec6d098af51be19947ec5ba7ebd66380d1141953ba78d4aa5401679fa7b0a44db1981f864d3535c45afe4c61183d5b0ad51fae71ca07e34240283959f7530a32c70d95a088e501c230059f333b0670825009e7e22103ef22935830df1fac8ef877f5f3426dd54f7d1128dd871ad9a7d088f94c0e8712013295b8d69ae7623b880978c2d3c6ad26dc478f8dc47f5c0adcc618665dc3dc205a9071b2f2191e16cac5bd89bb59148fc719633752303aa08e518dbc389f0a5482caaa4c507b8729a6f3edd061efb39026cecc6399f51971cf7381d605e144a5928c8c2d1ad7467b05da2f202f4f3234e1aff19a0198a28685721c3d2d52311c721e3fdcbaf30214cdc3acff8c433880e104fb63f2df7ce69a97857819ba7ac00ac8eae1969764fde8f68cf8e0916d7e0c151147d4944f99f42ae50f30e1c79a42d2b6c5188d133d3cbbf69094027b354b295ccd0f7dc5a87d73638bd98ebfb00383ca0fa69cb8dcb35a12510e5e07ad8789047d0b63841a1bb928737e8b0a0c33254f47aa8bfbe3341a09c2b76dbcefa67e30df300d34f7b8465c4f869e51b6bcfe6cf68b238359a645036bf7f63f02924e087ce7457e483b6025a859903cb484574aa3b12cf946f32127d537c33bee3141b5db96d10a148c50ae045f287210757710d6846e04b202f79e87dd9a56bc6da15f84a77a7f63935e1dee00309cd276a8e7176cb04da6bb0e9009534438732cb42d008008853d38d19beba46e61006e30f7efd1bc7c2906b024e4ff898a1b58c448d68b43c6ab63f34f85b3ac6aa4475867e51b583844cb23829f4b30f4bdd817d88e2ef3e7b4fc0a624395b05ec5e8686082b24d29fef2b0d3c29e031d5f94f504b1d3df9361eb5ffbadb242e66c39a8094cfe62f85f639f3fd65fc8ae0c74a8f4c6e1d070b9183a434c722caaa0225f8bcd68614d6f0738ed62f8484ec96077d155c08e26c46be262a73e3551698bd70d8d5610cf37c4c306eed04ba6a040a9c3e6d7e15e8acda17f477c2484cf5c56b813313927be8387b1024f995e98fc87f1029091c01424bdc2b296c2eadb7d25b3e762a2fd0c2dcd1727ddf91db97c5984305265f3695a7f5472f2d72c94d68c27914f14f82aa8dd5fe4e2348b0ca967a3f98626a091552f5d0ffa2bf10350d23c996256c01fdeffb2c2c612519869f877e4929c6e95ff15040f1485e22ed14119880232fef3b57b3848f15b1766a5552879df8f06" ); 00962 00963 sha4( src_str, src_len, output, 1 ); 00964 hexify( hash_str, output, 48 ); 00965 00966 fct_chk( strcmp( (char *) hash_str, "cba9e3eb12a6f83db11e8a6ff40d1049854ee094416bc527fea931d8585428a8ed6242ce81f6769b36e2123a5c23483e" ) == 0 ); 00967 } 00968 FCT_TEST_END(); 00969 #endif /* POLARSSL_SHA4_C */ 00970 00971 #ifdef POLARSSL_SHA4_C 00972 00973 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_1) 00974 { 00975 unsigned char src_str[10000]; 00976 unsigned char hash_str[10000]; 00977 unsigned char output[129]; 00978 int src_len; 00979 00980 memset(src_str, 0x00, 10000); 00981 memset(hash_str, 0x00, 10000); 00982 memset(output, 0x00, 129); 00983 00984 src_len = unhexify( src_str, "" ); 00985 00986 sha4( src_str, src_len, output, 0); 00987 hexify( hash_str, output, 64 ); 00988 00989 fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 ); 00990 } 00991 FCT_TEST_END(); 00992 #endif /* POLARSSL_SHA4_C */ 00993 00994 #ifdef POLARSSL_SHA4_C 00995 00996 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_2) 00997 { 00998 unsigned char src_str[10000]; 00999 unsigned char hash_str[10000]; 01000 unsigned char output[129]; 01001 int src_len; 01002 01003 memset(src_str, 0x00, 10000); 01004 memset(hash_str, 0x00, 10000); 01005 memset(output, 0x00, 129); 01006 01007 src_len = unhexify( src_str, "8f" ); 01008 01009 sha4( src_str, src_len, output, 0); 01010 hexify( hash_str, output, 64 ); 01011 01012 fct_chk( strcmp( (char *) hash_str, "e4cd2d19931b5aad9c920f45f56f6ce34e3d38c6d319a6e11d0588ab8b838576d6ce6d68eea7c830de66e2bd96458bfa7aafbcbec981d4ed040498c3dd95f22a" ) == 0 ); 01013 } 01014 FCT_TEST_END(); 01015 #endif /* POLARSSL_SHA4_C */ 01016 01017 #ifdef POLARSSL_SHA4_C 01018 01019 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_3) 01020 { 01021 unsigned char src_str[10000]; 01022 unsigned char hash_str[10000]; 01023 unsigned char output[129]; 01024 int src_len; 01025 01026 memset(src_str, 0x00, 10000); 01027 memset(hash_str, 0x00, 10000); 01028 memset(output, 0x00, 129); 01029 01030 src_len = unhexify( src_str, "e724" ); 01031 01032 sha4( src_str, src_len, output, 0); 01033 hexify( hash_str, output, 64 ); 01034 01035 fct_chk( strcmp( (char *) hash_str, "7dbb520221a70287b23dbcf62bfc1b73136d858e86266732a7fffa875ecaa2c1b8f673b5c065d360c563a7b9539349f5f59bef8c0c593f9587e3cd50bb26a231" ) == 0 ); 01036 } 01037 FCT_TEST_END(); 01038 #endif /* POLARSSL_SHA4_C */ 01039 01040 #ifdef POLARSSL_SHA4_C 01041 01042 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_4) 01043 { 01044 unsigned char src_str[10000]; 01045 unsigned char hash_str[10000]; 01046 unsigned char output[129]; 01047 int src_len; 01048 01049 memset(src_str, 0x00, 10000); 01050 memset(hash_str, 0x00, 10000); 01051 memset(output, 0x00, 129); 01052 01053 src_len = unhexify( src_str, "de4c90" ); 01054 01055 sha4( src_str, src_len, output, 0); 01056 hexify( hash_str, output, 64 ); 01057 01058 fct_chk( strcmp( (char *) hash_str, "33ce98281045a5c4c9df0363d8196f1d7dfcd5ee46ac89776fd8a4344c12f123a66788af5bd41ceff1941aa5637654b4064c88c14e00465ab79a2fc6c97e1014" ) == 0 ); 01059 } 01060 FCT_TEST_END(); 01061 #endif /* POLARSSL_SHA4_C */ 01062 01063 #ifdef POLARSSL_SHA4_C 01064 01065 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_5) 01066 { 01067 unsigned char src_str[10000]; 01068 unsigned char hash_str[10000]; 01069 unsigned char output[129]; 01070 int src_len; 01071 01072 memset(src_str, 0x00, 10000); 01073 memset(hash_str, 0x00, 10000); 01074 memset(output, 0x00, 129); 01075 01076 src_len = unhexify( src_str, "a801e94b" ); 01077 01078 sha4( src_str, src_len, output, 0); 01079 hexify( hash_str, output, 64 ); 01080 01081 fct_chk( strcmp( (char *) hash_str, "dadb1b5a27f9fece8d86adb2a51879beb1787ff28f4e8ce162cad7fee0f942efcabbf738bc6f797fc7cc79a3a75048cd4c82ca0757a324695bfb19a557e56e2f" ) == 0 ); 01082 } 01083 FCT_TEST_END(); 01084 #endif /* POLARSSL_SHA4_C */ 01085 01086 #ifdef POLARSSL_SHA4_C 01087 01088 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_6) 01089 { 01090 unsigned char src_str[10000]; 01091 unsigned char hash_str[10000]; 01092 unsigned char output[129]; 01093 int src_len; 01094 01095 memset(src_str, 0x00, 10000); 01096 memset(hash_str, 0x00, 10000); 01097 memset(output, 0x00, 129); 01098 01099 src_len = unhexify( src_str, "94390d3502" ); 01100 01101 sha4( src_str, src_len, output, 0); 01102 hexify( hash_str, output, 64 ); 01103 01104 fct_chk( strcmp( (char *) hash_str, "b6175c4c4cccf69e0ce5f0312010886ea6b34d43673f942ae42483f9cbb7da817de4e11b5d58e25a3d9bd721a22cdffe1c40411cc45df1911fa5506129b69297" ) == 0 ); 01105 } 01106 FCT_TEST_END(); 01107 #endif /* POLARSSL_SHA4_C */ 01108 01109 #ifdef POLARSSL_SHA4_C 01110 01111 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_7) 01112 { 01113 unsigned char src_str[10000]; 01114 unsigned char hash_str[10000]; 01115 unsigned char output[129]; 01116 int src_len; 01117 01118 memset(src_str, 0x00, 10000); 01119 memset(hash_str, 0x00, 10000); 01120 memset(output, 0x00, 129); 01121 01122 src_len = unhexify( src_str, "49297dd63e5f" ); 01123 01124 sha4( src_str, src_len, output, 0); 01125 hexify( hash_str, output, 64 ); 01126 01127 fct_chk( strcmp( (char *) hash_str, "1fcc1e6f6870859d11649f5e5336a9cd16329c029baf04d5a6edf257889a2e9522b497dd656bb402da461307c4ee382e2e89380c8e6e6e7697f1e439f650fa94" ) == 0 ); 01128 } 01129 FCT_TEST_END(); 01130 #endif /* POLARSSL_SHA4_C */ 01131 01132 #ifdef POLARSSL_SHA4_C 01133 01134 FCT_TEST_BGN(sha_512_test_vector_nist_cavs_8) 01135 { 01136 unsigned char src_str[10000]; 01137 unsigned char hash_str[10000]; 01138 unsigned char output[129]; 01139 int src_len; 01140 01141 memset(src_str, 0x00, 10000); 01142 memset(hash_str, 0x00, 10000); 01143 memset(output, 0x00, 129); 01144 01145 src_len = unhexify( src_str, "990d1ae71a62d7bda9bfdaa1762a68d296eee72a4cd946f287a898fbabc002ea941fd8d4d991030b4d27a637cce501a834bb95eab1b7889a3e784c7968e67cbf552006b206b68f76d9191327524fcc251aeb56af483d10b4e0c6c5e599ee8c0fe4faeca8293844a8547c6a9a90d093f2526873a19ad4a5e776794c68c742fb834793d2dfcb7fea46c63af4b70fd11cb6e41834e72ee40edb067b292a794990c288d5007e73f349fb383af6a756b8301ad6e5e0aa8cd614399bb3a452376b1575afa6bdaeaafc286cb064bb91edef97c632b6c1113d107fa93a0905098a105043c2f05397f702514439a08a9e5ddc196100721d45c8fc17d2ed659376f8a00bd5cb9a0860e26d8a29d8d6aaf52de97e9346033d6db501a35dbbaf97c20b830cd2d18c2532f3a59cc497ee64c0e57d8d060e5069b28d86edf1adcf59144b221ce3ddaef134b3124fbc7dd000240eff0f5f5f41e83cd7f5bb37c9ae21953fe302b0f6e8b68fa91c6ab99265c64b2fd9cd4942be04321bb5d6d71932376c6f2f88e02422ba6a5e2cb765df93fd5dd0728c6abdaf03bce22e0678a544e2c3636f741b6f4447ee58a8fc656b43ef817932176adbfc2e04b2c812c273cd6cbfa4098f0be036a34221fa02643f5ee2e0b38135f2a18ecd2f16ebc45f8eb31b8ab967a1567ee016904188910861ca1fa205c7adaa194b286893ffe2f4fbe0384c2aef72a4522aeafd3ebc71f9db71eeeef86c48394a1c86d5b36c352cc33a0a2c800bc99e62fd65b3a2fd69e0b53996ec13d8ce483ce9319efd9a85acefabdb5342226febb83fd1daf4b24265f50c61c6de74077ef89b6fecf9f29a1f871af1e9f89b2d345cda7499bd45c42fa5d195a1e1a6ba84851889e730da3b2b916e96152ae0c92154b49719841db7e7cc707ba8a5d7b101eb4ac7b629bb327817910fff61580b59aab78182d1a2e33473d05b00b170b29e331870826cfe45af206aa7d0246bbd8566ca7cfb2d3c10bfa1db7dd48dd786036469ce7282093d78b5e1a5b0fc81a54c8ed4ceac1e5305305e78284ac276f5d7862727aff246e17addde50c670028d572cbfc0be2e4f8b2eb28fa68ad7b4c6c2a239c460441bfb5ea049f23b08563b4e47729a59e5986a61a6093dbd54f8c36ebe87edae01f251cb060ad1364ce677d7e8d5a4a4ca966a7241cc360bc2acb280e5f9e9c1b032ad6a180a35e0c5180b9d16d026c865b252098cc1d99ba7375ca31c7702c0d943d5e3dd2f6861fa55bd46d94b67ed3e52eccd8dd06d968e01897d6de97ed3058d91dd" ); 01146 01147 sha4( src_str, src_len, output, 0); 01148 hexify( hash_str, output, 64 ); 01149 01150 fct_chk( strcmp( (char *) hash_str, "8e4bc6f8b8c60fe4d68c61d9b159c8693c3151c46749af58da228442d927f23359bd6ccd6c2ec8fa3f00a86cecbfa728e1ad60b821ed22fcd309ba91a4138bc9" ) == 0 ); 01151 } 01152 FCT_TEST_END(); 01153 #endif /* POLARSSL_SHA4_C */ 01154 01155 #ifdef POLARSSL_FS_IO 01156 #ifdef POLARSSL_SHA1_C 01157 01158 FCT_TEST_BGN(sha1_hash_file_1) 01159 { 01160 unsigned char hash_str[41]; 01161 unsigned char output[21]; 01162 01163 memset(hash_str, 0x00, 41); 01164 memset(output, 0x00, 21); 01165 01166 sha1_file( "data_files/hash_file_1", output); 01167 hexify( hash_str, output, 20 ); 01168 01169 fct_chk( strcmp( (char *) hash_str, "d21c965b1e768bd7a6aa6869f5f821901d255f9f" ) == 0 ); 01170 } 01171 FCT_TEST_END(); 01172 #endif /* POLARSSL_FS_IO */ 01173 #endif /* POLARSSL_SHA1_C */ 01174 01175 #ifdef POLARSSL_FS_IO 01176 #ifdef POLARSSL_SHA1_C 01177 01178 FCT_TEST_BGN(sha1_hash_file_2) 01179 { 01180 unsigned char hash_str[41]; 01181 unsigned char output[21]; 01182 01183 memset(hash_str, 0x00, 41); 01184 memset(output, 0x00, 21); 01185 01186 sha1_file( "data_files/hash_file_2", output); 01187 hexify( hash_str, output, 20 ); 01188 01189 fct_chk( strcmp( (char *) hash_str, "353f34271f2aef49d23a8913d4a6bd82b2cecdc6" ) == 0 ); 01190 } 01191 FCT_TEST_END(); 01192 #endif /* POLARSSL_FS_IO */ 01193 #endif /* POLARSSL_SHA1_C */ 01194 01195 #ifdef POLARSSL_FS_IO 01196 #ifdef POLARSSL_SHA1_C 01197 01198 FCT_TEST_BGN(sha1_hash_file_3) 01199 { 01200 unsigned char hash_str[41]; 01201 unsigned char output[21]; 01202 01203 memset(hash_str, 0x00, 41); 01204 memset(output, 0x00, 21); 01205 01206 sha1_file( "data_files/hash_file_3", output); 01207 hexify( hash_str, output, 20 ); 01208 01209 fct_chk( strcmp( (char *) hash_str, "93640ed592076328096270c756db2fba9c486b35" ) == 0 ); 01210 } 01211 FCT_TEST_END(); 01212 #endif /* POLARSSL_FS_IO */ 01213 #endif /* POLARSSL_SHA1_C */ 01214 01215 #ifdef POLARSSL_FS_IO 01216 #ifdef POLARSSL_SHA1_C 01217 01218 FCT_TEST_BGN(sha1_hash_file_4) 01219 { 01220 unsigned char hash_str[41]; 01221 unsigned char output[21]; 01222 01223 memset(hash_str, 0x00, 41); 01224 memset(output, 0x00, 21); 01225 01226 sha1_file( "data_files/hash_file_4", output); 01227 hexify( hash_str, output, 20 ); 01228 01229 fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 ); 01230 } 01231 FCT_TEST_END(); 01232 #endif /* POLARSSL_FS_IO */ 01233 #endif /* POLARSSL_SHA1_C */ 01234 01235 #ifdef POLARSSL_FS_IO 01236 #ifdef POLARSSL_SHA2_C 01237 01238 FCT_TEST_BGN(sha_224_hash_file_1) 01239 { 01240 unsigned char hash_str[57]; 01241 unsigned char output[29]; 01242 01243 memset(hash_str, 0x00, 57); 01244 memset(output, 0x00, 29); 01245 01246 sha2_file( "data_files/hash_file_1", output, 1); 01247 hexify( hash_str, output, 28 ); 01248 01249 fct_chk( strcmp( (char *) hash_str, "8606da018870f0c16834a21bc3385704cb1683b9dbab04c5ddb90a48" ) == 0 ); 01250 } 01251 FCT_TEST_END(); 01252 #endif /* POLARSSL_FS_IO */ 01253 #endif /* POLARSSL_SHA2_C */ 01254 01255 #ifdef POLARSSL_FS_IO 01256 #ifdef POLARSSL_SHA2_C 01257 01258 FCT_TEST_BGN(sha_224_hash_file_2) 01259 { 01260 unsigned char hash_str[57]; 01261 unsigned char output[29]; 01262 01263 memset(hash_str, 0x00, 57); 01264 memset(output, 0x00, 29); 01265 01266 sha2_file( "data_files/hash_file_2", output, 1); 01267 hexify( hash_str, output, 28 ); 01268 01269 fct_chk( strcmp( (char *) hash_str, "733b2ab97b6f63f2e29b9a2089756d81e14c93fe4cc9615c0d5e8a03" ) == 0 ); 01270 } 01271 FCT_TEST_END(); 01272 #endif /* POLARSSL_FS_IO */ 01273 #endif /* POLARSSL_SHA2_C */ 01274 01275 #ifdef POLARSSL_FS_IO 01276 #ifdef POLARSSL_SHA2_C 01277 01278 FCT_TEST_BGN(sha_224_hash_file_3) 01279 { 01280 unsigned char hash_str[57]; 01281 unsigned char output[29]; 01282 01283 memset(hash_str, 0x00, 57); 01284 memset(output, 0x00, 29); 01285 01286 sha2_file( "data_files/hash_file_3", output, 1); 01287 hexify( hash_str, output, 28 ); 01288 01289 fct_chk( strcmp( (char *) hash_str, "e1df95867580e2cc2100e9565bf9c2e42c24fe5250c19efe33d1c4fe" ) == 0 ); 01290 } 01291 FCT_TEST_END(); 01292 #endif /* POLARSSL_FS_IO */ 01293 #endif /* POLARSSL_SHA2_C */ 01294 01295 #ifdef POLARSSL_FS_IO 01296 #ifdef POLARSSL_SHA2_C 01297 01298 FCT_TEST_BGN(sha_224_hash_file_4) 01299 { 01300 unsigned char hash_str[57]; 01301 unsigned char output[29]; 01302 01303 memset(hash_str, 0x00, 57); 01304 memset(output, 0x00, 29); 01305 01306 sha2_file( "data_files/hash_file_4", output, 1); 01307 hexify( hash_str, output, 28 ); 01308 01309 fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 ); 01310 } 01311 FCT_TEST_END(); 01312 #endif /* POLARSSL_FS_IO */ 01313 #endif /* POLARSSL_SHA2_C */ 01314 01315 #ifdef POLARSSL_FS_IO 01316 #ifdef POLARSSL_SHA2_C 01317 01318 FCT_TEST_BGN(sha_256_hash_file_1) 01319 { 01320 unsigned char hash_str[65]; 01321 unsigned char output[33]; 01322 01323 memset(hash_str, 0x00, 65); 01324 memset(output, 0x00, 33); 01325 01326 sha2_file( "data_files/hash_file_1", output, 0); 01327 hexify( hash_str, output, 32 ); 01328 01329 fct_chk( strcmp( (char *) hash_str, "975d0c620d3936886f8a3665e585a3e84aa0501f4225bf53029710242823e391" ) == 0 ); 01330 } 01331 FCT_TEST_END(); 01332 #endif /* POLARSSL_FS_IO */ 01333 #endif /* POLARSSL_SHA2_C */ 01334 01335 #ifdef POLARSSL_FS_IO 01336 #ifdef POLARSSL_SHA2_C 01337 01338 FCT_TEST_BGN(sha_256_hash_file_2) 01339 { 01340 unsigned char hash_str[65]; 01341 unsigned char output[33]; 01342 01343 memset(hash_str, 0x00, 65); 01344 memset(output, 0x00, 33); 01345 01346 sha2_file( "data_files/hash_file_2", output, 0); 01347 hexify( hash_str, output, 32 ); 01348 01349 fct_chk( strcmp( (char *) hash_str, "11fcbf1baa36ca45745f10cc5467aee86f066f80ba2c46806d876bf783022ad2" ) == 0 ); 01350 } 01351 FCT_TEST_END(); 01352 #endif /* POLARSSL_FS_IO */ 01353 #endif /* POLARSSL_SHA2_C */ 01354 01355 #ifdef POLARSSL_FS_IO 01356 #ifdef POLARSSL_SHA2_C 01357 01358 FCT_TEST_BGN(sha_256_hash_file_3) 01359 { 01360 unsigned char hash_str[65]; 01361 unsigned char output[33]; 01362 01363 memset(hash_str, 0x00, 65); 01364 memset(output, 0x00, 33); 01365 01366 sha2_file( "data_files/hash_file_3", output, 0); 01367 hexify( hash_str, output, 32 ); 01368 01369 fct_chk( strcmp( (char *) hash_str, "9ae4b369f9f4f03b86505b46a5469542e00aaff7cf7417a71af6d6d0aba3b70c" ) == 0 ); 01370 } 01371 FCT_TEST_END(); 01372 #endif /* POLARSSL_FS_IO */ 01373 #endif /* POLARSSL_SHA2_C */ 01374 01375 #ifdef POLARSSL_FS_IO 01376 #ifdef POLARSSL_SHA2_C 01377 01378 FCT_TEST_BGN(sha_256_hash_file_4) 01379 { 01380 unsigned char hash_str[65]; 01381 unsigned char output[33]; 01382 01383 memset(hash_str, 0x00, 65); 01384 memset(output, 0x00, 33); 01385 01386 sha2_file( "data_files/hash_file_4", output, 0); 01387 hexify( hash_str, output, 32 ); 01388 01389 fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 ); 01390 } 01391 FCT_TEST_END(); 01392 #endif /* POLARSSL_FS_IO */ 01393 #endif /* POLARSSL_SHA2_C */ 01394 01395 #ifdef POLARSSL_FS_IO 01396 #ifdef POLARSSL_SHA4_C 01397 01398 FCT_TEST_BGN(sha_384_hash_file_1) 01399 { 01400 unsigned char hash_str[97]; 01401 unsigned char output[49]; 01402 01403 memset(hash_str, 0x00, 97); 01404 memset(output, 0x00, 49); 01405 01406 sha4_file( "data_files/hash_file_1", output, 1); 01407 hexify( hash_str, output, 48 ); 01408 01409 fct_chk( strcmp( (char *) hash_str, "e0a3e6259d6378001b54ef82f5dd087009c5fad86d8db226a9fe1d14ecbe33a6fc916e3a4b16f5f286424de15d5a8e0e" ) == 0 ); 01410 } 01411 FCT_TEST_END(); 01412 #endif /* POLARSSL_FS_IO */ 01413 #endif /* POLARSSL_SHA4_C */ 01414 01415 #ifdef POLARSSL_FS_IO 01416 #ifdef POLARSSL_SHA4_C 01417 01418 FCT_TEST_BGN(sha_384_hash_file_2) 01419 { 01420 unsigned char hash_str[97]; 01421 unsigned char output[49]; 01422 01423 memset(hash_str, 0x00, 97); 01424 memset(output, 0x00, 49); 01425 01426 sha4_file( "data_files/hash_file_2", output, 1); 01427 hexify( hash_str, output, 48 ); 01428 01429 fct_chk( strcmp( (char *) hash_str, "eff727afc8495c92e2f370f97a317f93c3350324b0646b0f0e264708b3c97d3d332d3c5390e1e47130f5c92f1ef4b9cf" ) == 0 ); 01430 } 01431 FCT_TEST_END(); 01432 #endif /* POLARSSL_FS_IO */ 01433 #endif /* POLARSSL_SHA4_C */ 01434 01435 #ifdef POLARSSL_FS_IO 01436 #ifdef POLARSSL_SHA4_C 01437 01438 FCT_TEST_BGN(sha_384_hash_file_3) 01439 { 01440 unsigned char hash_str[97]; 01441 unsigned char output[49]; 01442 01443 memset(hash_str, 0x00, 97); 01444 memset(output, 0x00, 49); 01445 01446 sha4_file( "data_files/hash_file_3", output, 1); 01447 hexify( hash_str, output, 48 ); 01448 01449 fct_chk( strcmp( (char *) hash_str, "6fc10ebda96a1ccf61777cac72f6034f92533d42052a4bf9f9d929c672973c71e5aeb1213268043c21527ac0f7f349c4" ) == 0 ); 01450 } 01451 FCT_TEST_END(); 01452 #endif /* POLARSSL_FS_IO */ 01453 #endif /* POLARSSL_SHA4_C */ 01454 01455 #ifdef POLARSSL_FS_IO 01456 #ifdef POLARSSL_SHA4_C 01457 01458 FCT_TEST_BGN(sha_384_hash_file_4) 01459 { 01460 unsigned char hash_str[97]; 01461 unsigned char output[49]; 01462 01463 memset(hash_str, 0x00, 97); 01464 memset(output, 0x00, 49); 01465 01466 sha4_file( "data_files/hash_file_4", output, 1); 01467 hexify( hash_str, output, 48 ); 01468 01469 fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 ); 01470 } 01471 FCT_TEST_END(); 01472 #endif /* POLARSSL_FS_IO */ 01473 #endif /* POLARSSL_SHA4_C */ 01474 01475 #ifdef POLARSSL_FS_IO 01476 #ifdef POLARSSL_SHA4_C 01477 01478 FCT_TEST_BGN(sha_512_hash_file_1) 01479 { 01480 unsigned char hash_str[129]; 01481 unsigned char output[65]; 01482 01483 memset(hash_str, 0x00, 129); 01484 memset(output, 0x00, 65); 01485 01486 sha4_file( "data_files/hash_file_1", output, 0); 01487 hexify( hash_str, output, 64 ); 01488 01489 fct_chk( strcmp( (char *) hash_str, "d8207a2e1ff2b424f2c4163fe1b723c9bd42e464061eb411e8df730bcd24a7ab3956a6f3ff044a52eb2d262f9e4ca6b524092b544ab78f14d6f9c4cc8ddf335a" ) == 0 ); 01490 } 01491 FCT_TEST_END(); 01492 #endif /* POLARSSL_FS_IO */ 01493 #endif /* POLARSSL_SHA4_C */ 01494 01495 #ifdef POLARSSL_FS_IO 01496 #ifdef POLARSSL_SHA4_C 01497 01498 FCT_TEST_BGN(sha_512_hash_file_2) 01499 { 01500 unsigned char hash_str[129]; 01501 unsigned char output[65]; 01502 01503 memset(hash_str, 0x00, 129); 01504 memset(output, 0x00, 65); 01505 01506 sha4_file( "data_files/hash_file_2", output, 0); 01507 hexify( hash_str, output, 64 ); 01508 01509 fct_chk( strcmp( (char *) hash_str, "ecbb7f0ed8a702b49f16ad3088bcc06ea93451912a7187db15f64d93517b09630b039293aed418d4a00695777b758b1f381548c2fd7b92ce5ed996b32c8734e7" ) == 0 ); 01510 } 01511 FCT_TEST_END(); 01512 #endif /* POLARSSL_FS_IO */ 01513 #endif /* POLARSSL_SHA4_C */ 01514 01515 #ifdef POLARSSL_FS_IO 01516 #ifdef POLARSSL_SHA4_C 01517 01518 FCT_TEST_BGN(sha_512_hash_file_3) 01519 { 01520 unsigned char hash_str[129]; 01521 unsigned char output[65]; 01522 01523 memset(hash_str, 0x00, 129); 01524 memset(output, 0x00, 65); 01525 01526 sha4_file( "data_files/hash_file_3", output, 0); 01527 hexify( hash_str, output, 64 ); 01528 01529 fct_chk( strcmp( (char *) hash_str, "7ccc9b2da71ffde9966c3ce44d7f20945fccf33b1fade4da152b021f1afcc7293382944aa6c09eac67af25f22026758e2bf6bed86ae2a43592677ee50f8eea41" ) == 0 ); 01530 } 01531 FCT_TEST_END(); 01532 #endif /* POLARSSL_FS_IO */ 01533 #endif /* POLARSSL_SHA4_C */ 01534 01535 #ifdef POLARSSL_FS_IO 01536 #ifdef POLARSSL_SHA4_C 01537 01538 FCT_TEST_BGN(sha_512_hash_file_4) 01539 { 01540 unsigned char hash_str[129]; 01541 unsigned char output[65]; 01542 01543 memset(hash_str, 0x00, 129); 01544 memset(output, 0x00, 65); 01545 01546 sha4_file( "data_files/hash_file_4", output, 0); 01547 hexify( hash_str, output, 64 ); 01548 01549 fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 ); 01550 } 01551 FCT_TEST_END(); 01552 #endif /* POLARSSL_FS_IO */ 01553 #endif /* POLARSSL_SHA4_C */ 01554 01555 #ifdef POLARSSL_SELF_TEST 01556 #ifdef POLARSSL_SHA1_C 01557 01558 FCT_TEST_BGN(sha_1_selftest) 01559 { 01560 fct_chk( sha1_self_test( 0 ) == 0 ); 01561 } 01562 FCT_TEST_END(); 01563 #endif /* POLARSSL_SELF_TEST */ 01564 #endif /* POLARSSL_SHA1_C */ 01565 01566 #ifdef POLARSSL_SELF_TEST 01567 #ifdef POLARSSL_SHA2_C 01568 01569 FCT_TEST_BGN(sha_2_selftest) 01570 { 01571 fct_chk( sha2_self_test( 0 ) == 0 ); 01572 } 01573 FCT_TEST_END(); 01574 #endif /* POLARSSL_SELF_TEST */ 01575 #endif /* POLARSSL_SHA2_C */ 01576 01577 #ifdef POLARSSL_SELF_TEST 01578 #ifdef POLARSSL_SHA4_C 01579 01580 FCT_TEST_BGN(sha_4_selftest) 01581 { 01582 fct_chk( sha4_self_test( 0 ) == 0 ); 01583 } 01584 FCT_TEST_END(); 01585 #endif /* POLARSSL_SELF_TEST */ 01586 #endif /* POLARSSL_SHA4_C */ 01587 01588 } 01589 FCT_SUITE_END(); 01590 01591 01592 } 01593 FCT_END(); 01594