PolarSSL v1.1.4
test_suite_hmac_shax.c
Go to the documentation of this file.
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_hmac_shax)
00234     {
00235 #ifdef POLARSSL_SHA1_C
00236 
00237         FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_1)
00238         {
00239             unsigned char src_str[10000];
00240             unsigned char key_str[10000];
00241             unsigned char hash_str[10000];
00242             unsigned char output[41];
00243             int key_len, src_len;
00244         
00245             memset(src_str, 0x00, 10000);
00246             memset(key_str, 0x00, 10000);
00247             memset(hash_str, 0x00, 10000);
00248             memset(output, 0x00, 41);
00249         
00250             key_len = unhexify( key_str, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" );
00251             src_len = unhexify( src_str, "53616d706c65202331" );
00252         
00253             sha1_hmac( key_str, key_len, src_str, src_len, output );
00254             hexify( hash_str, output, 20 );
00255         
00256             fct_chk( strncmp( (char *) hash_str, "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", 20 * 2 ) == 0 );
00257         }
00258         FCT_TEST_END();
00259 #endif /* POLARSSL_SHA1_C */
00260 
00261 #ifdef POLARSSL_SHA1_C
00262 
00263         FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_2)
00264         {
00265             unsigned char src_str[10000];
00266             unsigned char key_str[10000];
00267             unsigned char hash_str[10000];
00268             unsigned char output[41];
00269             int key_len, src_len;
00270         
00271             memset(src_str, 0x00, 10000);
00272             memset(key_str, 0x00, 10000);
00273             memset(hash_str, 0x00, 10000);
00274             memset(output, 0x00, 41);
00275         
00276             key_len = unhexify( key_str, "303132333435363738393a3b3c3d3e3f40414243" );
00277             src_len = unhexify( src_str, "53616d706c65202332" );
00278         
00279             sha1_hmac( key_str, key_len, src_str, src_len, output );
00280             hexify( hash_str, output, 20 );
00281         
00282             fct_chk( strncmp( (char *) hash_str, "0922d3405faa3d194f82a45830737d5cc6c75d24", 20 * 2 ) == 0 );
00283         }
00284         FCT_TEST_END();
00285 #endif /* POLARSSL_SHA1_C */
00286 
00287 #ifdef POLARSSL_SHA1_C
00288 
00289         FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_3)
00290         {
00291             unsigned char src_str[10000];
00292             unsigned char key_str[10000];
00293             unsigned char hash_str[10000];
00294             unsigned char output[41];
00295             int key_len, src_len;
00296         
00297             memset(src_str, 0x00, 10000);
00298             memset(key_str, 0x00, 10000);
00299             memset(hash_str, 0x00, 10000);
00300             memset(output, 0x00, 41);
00301         
00302             key_len = unhexify( key_str, "505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" );
00303             src_len = unhexify( src_str, "53616d706c65202333" );
00304         
00305             sha1_hmac( key_str, key_len, src_str, src_len, output );
00306             hexify( hash_str, output, 20 );
00307         
00308             fct_chk( strncmp( (char *) hash_str, "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", 20 * 2 ) == 0 );
00309         }
00310         FCT_TEST_END();
00311 #endif /* POLARSSL_SHA1_C */
00312 
00313 #ifdef POLARSSL_SHA1_C
00314 
00315         FCT_TEST_BGN(hmac_sha_1_test_vector_fips_198a_4)
00316         {
00317             unsigned char src_str[10000];
00318             unsigned char key_str[10000];
00319             unsigned char hash_str[10000];
00320             unsigned char output[41];
00321             int key_len, src_len;
00322         
00323             memset(src_str, 0x00, 10000);
00324             memset(key_str, 0x00, 10000);
00325             memset(hash_str, 0x00, 10000);
00326             memset(output, 0x00, 41);
00327         
00328             key_len = unhexify( key_str, "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0" );
00329             src_len = unhexify( src_str, "53616d706c65202334" );
00330         
00331             sha1_hmac( key_str, key_len, src_str, src_len, output );
00332             hexify( hash_str, output, 20 );
00333         
00334             fct_chk( strncmp( (char *) hash_str, "9ea886efe268dbecce420c75", 12 * 2 ) == 0 );
00335         }
00336         FCT_TEST_END();
00337 #endif /* POLARSSL_SHA1_C */
00338 
00339 #ifdef POLARSSL_SHA1_C
00340 
00341         FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_1)
00342         {
00343             unsigned char src_str[10000];
00344             unsigned char key_str[10000];
00345             unsigned char hash_str[10000];
00346             unsigned char output[41];
00347             int key_len, src_len;
00348         
00349             memset(src_str, 0x00, 10000);
00350             memset(key_str, 0x00, 10000);
00351             memset(hash_str, 0x00, 10000);
00352             memset(output, 0x00, 41);
00353         
00354             key_len = unhexify( key_str, "7b10f4124b15c82e" );
00355             src_len = unhexify( src_str, "27dcb5b1daf60cfd3e2f73d4d64ca9c684f8bf71fc682a46793b1790afa4feb100ca7aaff26f58f0e1d0ed42f1cdad1f474afa2e79d53a0c42892c4d7b327cbe46b295ed8da3b6ecab3d4851687a6f812b79df2f6b20f11f6706f5301790ca99625aad7391d84f78043d2a0a239b1477984c157bbc9276064e7a1a406b0612ca" );
00356         
00357             sha1_hmac( key_str, key_len, src_str, src_len, output );
00358             hexify( hash_str, output, 20 );
00359         
00360             fct_chk( strncmp( (char *) hash_str, "4ead12c2fe3d6ea43acb", 10 * 2 ) == 0 );
00361         }
00362         FCT_TEST_END();
00363 #endif /* POLARSSL_SHA1_C */
00364 
00365 #ifdef POLARSSL_SHA1_C
00366 
00367         FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_2)
00368         {
00369             unsigned char src_str[10000];
00370             unsigned char key_str[10000];
00371             unsigned char hash_str[10000];
00372             unsigned char output[41];
00373             int key_len, src_len;
00374         
00375             memset(src_str, 0x00, 10000);
00376             memset(key_str, 0x00, 10000);
00377             memset(hash_str, 0x00, 10000);
00378             memset(output, 0x00, 41);
00379         
00380             key_len = unhexify( key_str, "4fe9fb902172a21b" );
00381             src_len = unhexify( src_str, "4ceb3a7c13659c22fe51134f03dce4c239d181b63c6b0b59d367157fd05cab98384f92dfa482d2d5e78e72eef1b1838af4696026c54233d484ecbbe87f904df5546419f8567eafd232e6c2fcd3ee2b7682c63000524b078dbb2096f585007deae752562df1fe3b01278089e16f3be46e2d0f7cabac2d8e6cc02a2d0ca953425f" );
00382         
00383             sha1_hmac( key_str, key_len, src_str, src_len, output );
00384             hexify( hash_str, output, 20 );
00385         
00386             fct_chk( strncmp( (char *) hash_str, "564428a67be1924b5793", 10 * 2 ) == 0 );
00387         }
00388         FCT_TEST_END();
00389 #endif /* POLARSSL_SHA1_C */
00390 
00391 #ifdef POLARSSL_SHA1_C
00392 
00393         FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_3)
00394         {
00395             unsigned char src_str[10000];
00396             unsigned char key_str[10000];
00397             unsigned char hash_str[10000];
00398             unsigned char output[41];
00399             int key_len, src_len;
00400         
00401             memset(src_str, 0x00, 10000);
00402             memset(key_str, 0x00, 10000);
00403             memset(hash_str, 0x00, 10000);
00404             memset(output, 0x00, 41);
00405         
00406             key_len = unhexify( key_str, "d1f01455f78c4fb4" );
00407             src_len = unhexify( src_str, "00d40f67b57914bec456a3e3201ef1464be319a8d188c02e157af4b54f9b5a66d67f898a9bdbb19ff63a80aba6f246d013575721d52eb1b47a65def884011c49b257bcc2817fc853f106e8138ce386d7a5ac3103de0a3fa0ed6bb7af9ff66ebd1cc46fb86e4da0013d20a3c2dcd8fb828a4b70f7f104b41bf3f44682a66497ea" );
00408         
00409             sha1_hmac( key_str, key_len, src_str, src_len, output );
00410             hexify( hash_str, output, 20 );
00411         
00412             fct_chk( strncmp( (char *) hash_str, "56a665a7cdfe610f9fc5", 10 * 2 ) == 0 );
00413         }
00414         FCT_TEST_END();
00415 #endif /* POLARSSL_SHA1_C */
00416 
00417 #ifdef POLARSSL_SHA1_C
00418 
00419         FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_4)
00420         {
00421             unsigned char src_str[10000];
00422             unsigned char key_str[10000];
00423             unsigned char hash_str[10000];
00424             unsigned char output[41];
00425             int key_len, src_len;
00426         
00427             memset(src_str, 0x00, 10000);
00428             memset(key_str, 0x00, 10000);
00429             memset(hash_str, 0x00, 10000);
00430             memset(output, 0x00, 41);
00431         
00432             key_len = unhexify( key_str, "4e5ef77fdf033a5b" );
00433             src_len = unhexify( src_str, "e59326464e3201d195e29f2a3446ec1b1c9ff31154e2a4d0e40ed466f1bc855d29f76835624fa0127d29c9b1915939a046f385af7e5d47a23ba91f28bd22f811ea258dbbf3332bcd3543b8285d5df41bd064ffd64a341c22c4edb44f9c8d9e6df0c59dbf4a052a6c83da7478e179a6f3839c6870ff8ca8b9497f9ac1d725fdda" );
00434         
00435             sha1_hmac( key_str, key_len, src_str, src_len, output );
00436             hexify( hash_str, output, 20 );
00437         
00438             fct_chk( strncmp( (char *) hash_str, "981c0a7a8423b63a8fa6", 10 * 2 ) == 0 );
00439         }
00440         FCT_TEST_END();
00441 #endif /* POLARSSL_SHA1_C */
00442 
00443 #ifdef POLARSSL_SHA1_C
00444 
00445         FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_5)
00446         {
00447             unsigned char src_str[10000];
00448             unsigned char key_str[10000];
00449             unsigned char hash_str[10000];
00450             unsigned char output[41];
00451             int key_len, src_len;
00452         
00453             memset(src_str, 0x00, 10000);
00454             memset(key_str, 0x00, 10000);
00455             memset(hash_str, 0x00, 10000);
00456             memset(output, 0x00, 41);
00457         
00458             key_len = unhexify( key_str, "bcd9ff8aa60be2be" );
00459             src_len = unhexify( src_str, "51be4d0eb37bab714f92e19e9d70390655b363e8cd346a748245e731f437759cb8206412c8dab2ef1d4f36f880f41ff69d949da4594fdecb65e23cac1329b59e69e29bf875b38c31df6fa546c595f35cc2192aa750679a8a51a65e00e839d73a8d8c598a610d237fbe78955213589d80efcb73b95b8586f96d17b6f51a71c3b8" );
00460         
00461             sha1_hmac( key_str, key_len, src_str, src_len, output );
00462             hexify( hash_str, output, 20 );
00463         
00464             fct_chk( strncmp( (char *) hash_str, "84633f9f5040c8971478", 10 * 2 ) == 0 );
00465         }
00466         FCT_TEST_END();
00467 #endif /* POLARSSL_SHA1_C */
00468 
00469 #ifdef POLARSSL_SHA1_C
00470 
00471         FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_6)
00472         {
00473             unsigned char src_str[10000];
00474             unsigned char key_str[10000];
00475             unsigned char hash_str[10000];
00476             unsigned char output[41];
00477             int key_len, src_len;
00478         
00479             memset(src_str, 0x00, 10000);
00480             memset(key_str, 0x00, 10000);
00481             memset(hash_str, 0x00, 10000);
00482             memset(output, 0x00, 41);
00483         
00484             key_len = unhexify( key_str, "4a661bce6ed86d21" );
00485             src_len = unhexify( src_str, "5ff6c744f1aab1bc29697d71f67541b8b3cec3c7079183b10a83fb98a9ee251d4bac3e1cb581ca972aaed8efd7c2875a6fb4c991132f67c9742d45e53bc7e8eaa94b35b37a907be61086b426cd11088ac118934e85d968c9667fd69fc6f6ea38c0fe34710b7ece91211b9b7ea00acd31f022aa6726368f9928a1352f122233f1" );
00486         
00487             sha1_hmac( key_str, key_len, src_str, src_len, output );
00488             hexify( hash_str, output, 20 );
00489         
00490             fct_chk( strncmp( (char *) hash_str, "739df59353ac6694e55e", 10 * 2 ) == 0 );
00491         }
00492         FCT_TEST_END();
00493 #endif /* POLARSSL_SHA1_C */
00494 
00495 #ifdef POLARSSL_SHA1_C
00496 
00497         FCT_TEST_BGN(hmac_sha_1_test_vector_nist_cavs_7)
00498         {
00499             unsigned char src_str[10000];
00500             unsigned char key_str[10000];
00501             unsigned char hash_str[10000];
00502             unsigned char output[41];
00503             int key_len, src_len;
00504         
00505             memset(src_str, 0x00, 10000);
00506             memset(key_str, 0x00, 10000);
00507             memset(hash_str, 0x00, 10000);
00508             memset(output, 0x00, 41);
00509         
00510             key_len = unhexify( key_str, "1287e1565a57b547" );
00511             src_len = unhexify( src_str, "390ffdccc6171c11568d85b8f913e019bf4cd982ca9cd21ea730d41bdf3fcc0bc88ff48ba13a8f23deb2d96ec1033e7b2a58ca72b0c1e17bf03330db25d1e360fa6918009c4294bd1215b5ccd159a8f58bc3dc3d490eb7c3b9f887e8c98dbbb274a75373dcb695a59abd0219529d88518a96f92abc0bbcbda985c388f1fbbcc9" );
00512         
00513             sha1_hmac( key_str, key_len, src_str, src_len, output );
00514             hexify( hash_str, output, 20 );
00515         
00516             fct_chk( strncmp( (char *) hash_str, "d78ddf08077c7d9e2ba6", 10 * 2 ) == 0 );
00517         }
00518         FCT_TEST_END();
00519 #endif /* POLARSSL_SHA1_C */
00520 
00521 #ifdef POLARSSL_SHA2_C
00522 
00523         FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_1)
00524         {
00525             unsigned char src_str[10000];
00526             unsigned char key_str[10000];
00527             unsigned char hash_str[10000];
00528             unsigned char output[57];
00529             int key_len, src_len;
00530         
00531             memset(src_str, 0x00, 10000);
00532             memset(key_str, 0x00, 10000);
00533             memset(hash_str, 0x00, 10000);
00534             memset(output, 0x00, 57);
00535         
00536             key_len = unhexify( key_str, "e055eb756697ee573fd3214811a9f7fa" );
00537             src_len = unhexify( src_str, "3875847012ee42fe54a0027bdf38cca7021b83a2ed0503af69ef6c37c637bc1114fba40096c5947d736e19b7af3c68d95a4e3b8b073adbbb80f47e9db8f2d4f0018ddd847fabfdf9dd9b52c93e40458977725f6b7ba15f0816bb895cdf50401268f5d702b7e6a5f9faef57b8768c8a3fc14f9a4b3182b41d940e337d219b29ff" );
00538         
00539             sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
00540             hexify( hash_str, output, 28 );
00541         
00542             fct_chk( strncmp( (char *) hash_str, "40a453133361cc48da11baf616ee", 14 * 2 ) == 0 );
00543         }
00544         FCT_TEST_END();
00545 #endif /* POLARSSL_SHA2_C */
00546 
00547 #ifdef POLARSSL_SHA2_C
00548 
00549         FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_2)
00550         {
00551             unsigned char src_str[10000];
00552             unsigned char key_str[10000];
00553             unsigned char hash_str[10000];
00554             unsigned char output[57];
00555             int key_len, src_len;
00556         
00557             memset(src_str, 0x00, 10000);
00558             memset(key_str, 0x00, 10000);
00559             memset(hash_str, 0x00, 10000);
00560             memset(output, 0x00, 57);
00561         
00562             key_len = unhexify( key_str, "88e5258b55b1623385eb9632fa7c57d6" );
00563             src_len = unhexify( src_str, "ada76bb604be14326551701cf30e48a65eee80b44f0b9d4a07b1844543b7844a621097fdc99de57387458ae9354899b620d0617eabcaefa9eef3d413a33628054335ce656c26fa2986e0f111a6351096b283101ec7868871d770b370973c7405983f9756b3005a3eab492cfd0e7eb42e5c2e15fa6be8718c0a50acc4e5717230" );
00564         
00565             sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
00566             hexify( hash_str, output, 28 );
00567         
00568             fct_chk( strncmp( (char *) hash_str, "81c783af538015cef3c60095df53", 14 * 2 ) == 0 );
00569         }
00570         FCT_TEST_END();
00571 #endif /* POLARSSL_SHA2_C */
00572 
00573 #ifdef POLARSSL_SHA2_C
00574 
00575         FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_3)
00576         {
00577             unsigned char src_str[10000];
00578             unsigned char key_str[10000];
00579             unsigned char hash_str[10000];
00580             unsigned char output[57];
00581             int key_len, src_len;
00582         
00583             memset(src_str, 0x00, 10000);
00584             memset(key_str, 0x00, 10000);
00585             memset(hash_str, 0x00, 10000);
00586             memset(output, 0x00, 57);
00587         
00588             key_len = unhexify( key_str, "85d402d822114d31abf75526e2538705" );
00589             src_len = unhexify( src_str, "8020d8d98cc2e2298b32879c51c751e1dd5558fe2eabb8f158604297d6d072ce2261a1d6830b7cfe2617b57c7126f99c9476211d6161acd75d266da217ec8174b80484c9dc6f0448a0a036a3fc82e8bf54bdb71549368258d5d41f57978a4c266b92e8783ef66350215573d99be4089144b383ad8f3222bae8f3bf80ffb1bb2b" );
00590         
00591             sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
00592             hexify( hash_str, output, 28 );
00593         
00594             fct_chk( strncmp( (char *) hash_str, "2aa0340ac9deafe3be38129daca0", 14 * 2 ) == 0 );
00595         }
00596         FCT_TEST_END();
00597 #endif /* POLARSSL_SHA2_C */
00598 
00599 #ifdef POLARSSL_SHA2_C
00600 
00601         FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_4)
00602         {
00603             unsigned char src_str[10000];
00604             unsigned char key_str[10000];
00605             unsigned char hash_str[10000];
00606             unsigned char output[57];
00607             int key_len, src_len;
00608         
00609             memset(src_str, 0x00, 10000);
00610             memset(key_str, 0x00, 10000);
00611             memset(hash_str, 0x00, 10000);
00612             memset(output, 0x00, 57);
00613         
00614             key_len = unhexify( key_str, "545c6eecc5ee46fa17c59f91a94f81ae" );
00615             src_len = unhexify( src_str, "8fb7f3565593170152ddb2021874784e951977cfdd22f8b72a72a61320a8f2a35697b5e913f717805559b1af1861ee3ed42fb788481e4fd276b17bdbefcae7b4501dc5d20de5b7626dd5efdcd65294db4bdf682c33d9a9255c6435383fa5f1c886326a3acbc6bd50a33ab5b2dbb034ce0112d4e226bbcd57e3731a519aa1d784" );
00616         
00617             sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
00618             hexify( hash_str, output, 28 );
00619         
00620             fct_chk( strncmp( (char *) hash_str, "3eb566eac54c4a3a9ef092469f24", 14 * 2 ) == 0 );
00621         }
00622         FCT_TEST_END();
00623 #endif /* POLARSSL_SHA2_C */
00624 
00625 #ifdef POLARSSL_SHA2_C
00626 
00627         FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_5)
00628         {
00629             unsigned char src_str[10000];
00630             unsigned char key_str[10000];
00631             unsigned char hash_str[10000];
00632             unsigned char output[57];
00633             int key_len, src_len;
00634         
00635             memset(src_str, 0x00, 10000);
00636             memset(key_str, 0x00, 10000);
00637             memset(hash_str, 0x00, 10000);
00638             memset(output, 0x00, 57);
00639         
00640             key_len = unhexify( key_str, "4466ab4dc438841a9750c7f173dff02e" );
00641             src_len = unhexify( src_str, "2534c11c78c99cffaec8f722f04adc7045c7324d58ce98e37cfa94b6ed21ed7f58ce55379ef24b72d6d640ee9154f96c614734be9c408e225d7ba4cecc1179cc9f6e1808e1067aa8f244a99bd0c3267594c1887a40d167f8b7cf78db0d19f97b01fc50b8c86def490dfa7a5135002c33e71d77a8cce8ea0f93e0580439a33733" );
00642         
00643             sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
00644             hexify( hash_str, output, 28 );
00645         
00646             fct_chk( strncmp( (char *) hash_str, "59f44a9bbed4875b892d22d6b5ab", 14 * 2 ) == 0 );
00647         }
00648         FCT_TEST_END();
00649 #endif /* POLARSSL_SHA2_C */
00650 
00651 #ifdef POLARSSL_SHA2_C
00652 
00653         FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_6)
00654         {
00655             unsigned char src_str[10000];
00656             unsigned char key_str[10000];
00657             unsigned char hash_str[10000];
00658             unsigned char output[57];
00659             int key_len, src_len;
00660         
00661             memset(src_str, 0x00, 10000);
00662             memset(key_str, 0x00, 10000);
00663             memset(hash_str, 0x00, 10000);
00664             memset(output, 0x00, 57);
00665         
00666             key_len = unhexify( key_str, "0e3dd9bb5e4cf0f09a4c11600af56d8d" );
00667             src_len = unhexify( src_str, "f4589fa76c328ea25cf8bae582026ba40a59d45a546ff31cf80eb826088f69bb954c452c74586836416dee90a5255bc5d56d3b405b3705a5197045688b32fa984c3a3dfbdc9c2460a0b5e6312a624048bb6f170306535e9b371a3ab134a2642a230ad03d2c688cca80baeaee9a20e1d4c548b1cede29c6a45bf4df2c8c476f1a" );
00668         
00669             sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
00670             hexify( hash_str, output, 28 );
00671         
00672             fct_chk( strncmp( (char *) hash_str, "12175b93e3da4c58217145e4dc0a1cf142fab9319bb501e037b350ba", 28 * 2 ) == 0 );
00673         }
00674         FCT_TEST_END();
00675 #endif /* POLARSSL_SHA2_C */
00676 
00677 #ifdef POLARSSL_SHA2_C
00678 
00679         FCT_TEST_BGN(hmac_sha_224_test_vector_nist_cavs_7)
00680         {
00681             unsigned char src_str[10000];
00682             unsigned char key_str[10000];
00683             unsigned char hash_str[10000];
00684             unsigned char output[57];
00685             int key_len, src_len;
00686         
00687             memset(src_str, 0x00, 10000);
00688             memset(key_str, 0x00, 10000);
00689             memset(hash_str, 0x00, 10000);
00690             memset(output, 0x00, 57);
00691         
00692             key_len = unhexify( key_str, "cda5187b0c5dcb0f8e5a8beed2306584" );
00693             src_len = unhexify( src_str, "9011ae29b44c49b347487ce972965f16ade3c15be0856ce9c853a9739dba07e4f20d594ddc1dfe21560a65a4e458cfa17745575b915a30c7a9412ff8d1d689db9680dd2428c27588bb0dc92d2cd9445fe8f44b840a197c52c3c4333fff45533945134398df6436513cfab06c924046b8c795a5bd92e8d5f2de85bf306f2eed67" );
00694         
00695             sha2_hmac( key_str, key_len, src_str, src_len, output, 1 );
00696             hexify( hash_str, output, 28 );
00697         
00698             fct_chk( strncmp( (char *) hash_str, "4aaba92b40e2a600feab176eb9b292d814864195c03342aad6f67f08", 28 * 2 ) == 0 );
00699         }
00700         FCT_TEST_END();
00701 #endif /* POLARSSL_SHA2_C */
00702 
00703 #ifdef POLARSSL_SHA2_C
00704 
00705         FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_1)
00706         {
00707             unsigned char src_str[10000];
00708             unsigned char key_str[10000];
00709             unsigned char hash_str[10000];
00710             unsigned char output[65];
00711             int key_len, src_len;
00712         
00713             memset(src_str, 0x00, 10000);
00714             memset(key_str, 0x00, 10000);
00715             memset(hash_str, 0x00, 10000);
00716             memset(output, 0x00, 65);
00717         
00718             key_len = unhexify( key_str, "cdffd34e6b16fdc0" );
00719             src_len = unhexify( src_str, "d83e78b99ab61709608972b36e76a575603db742269cc5dd4e7d5ca7816e26b65151c92632550cb4c5253c885d5fce53bc47459a1dbd5652786c4aac0145a532f12c05138af04cbb558101a7af5df478834c2146594dd73690d01a4fe72545894335f427ac70204798068cb86c5a600b40b414ede23590b41e1192373df84fe3" );
00720         
00721             sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
00722             hexify( hash_str, output, 32 );
00723         
00724             fct_chk( strncmp( (char *) hash_str, "c6f0dde266cb4a26d41e8259d33499cc", 16 * 2 ) == 0 );
00725         }
00726         FCT_TEST_END();
00727 #endif /* POLARSSL_SHA2_C */
00728 
00729 #ifdef POLARSSL_SHA2_C
00730 
00731         FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_2)
00732         {
00733             unsigned char src_str[10000];
00734             unsigned char key_str[10000];
00735             unsigned char hash_str[10000];
00736             unsigned char output[65];
00737             int key_len, src_len;
00738         
00739             memset(src_str, 0x00, 10000);
00740             memset(key_str, 0x00, 10000);
00741             memset(hash_str, 0x00, 10000);
00742             memset(output, 0x00, 65);
00743         
00744             key_len = unhexify( key_str, "6d97bb5892245be2" );
00745             src_len = unhexify( src_str, "13c2b391d59c0252ca5d2302beaaf88c4bcd779bb505ad9a122003dfae4cc123ad2bd036f225c4f040021a6b9fb8bd6f0281cf2e2631a732bdc71693cc42ef6d52b6c6912a9ef77b3274eb85ad7f965ae6ed44ac1721962a884ec7acfb4534b1488b1c0c45afa4dae8da1eb7b0a88a3240365d7e4e7d826abbde9f9203fd99d7" );
00746         
00747             sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
00748             hexify( hash_str, output, 32 );
00749         
00750             fct_chk( strncmp( (char *) hash_str, "31588e241b015319a5ab8c4527296498", 16 * 2 ) == 0 );
00751         }
00752         FCT_TEST_END();
00753 #endif /* POLARSSL_SHA2_C */
00754 
00755 #ifdef POLARSSL_SHA2_C
00756 
00757         FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_3)
00758         {
00759             unsigned char src_str[10000];
00760             unsigned char key_str[10000];
00761             unsigned char hash_str[10000];
00762             unsigned char output[65];
00763             int key_len, src_len;
00764         
00765             memset(src_str, 0x00, 10000);
00766             memset(key_str, 0x00, 10000);
00767             memset(hash_str, 0x00, 10000);
00768             memset(output, 0x00, 65);
00769         
00770             key_len = unhexify( key_str, "3c7fc8a70b49007a" );
00771             src_len = unhexify( src_str, "60024e428a39c8b8bb2e9591bad9dc2115dfbfd716b6eb7af30a6eb34560caccbbfa47b710fa8d523aca71e9e5ba10fc1feb1a43556d71f07ea4f33496f093044e8caf1d02b79e46eb1288d5964a7a7494f6b92574c35784eece054c6151281d80822f7d47b8231c35d07f5cb5cf4310ddc844845a01c6bfab514c048eccaf9f" );
00772         
00773             sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
00774             hexify( hash_str, output, 32 );
00775         
00776             fct_chk( strncmp( (char *) hash_str, "1c98c94a32bec9f253c21070f82f8438", 16 * 2 ) == 0 );
00777         }
00778         FCT_TEST_END();
00779 #endif /* POLARSSL_SHA2_C */
00780 
00781 #ifdef POLARSSL_SHA2_C
00782 
00783         FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_4)
00784         {
00785             unsigned char src_str[10000];
00786             unsigned char key_str[10000];
00787             unsigned char hash_str[10000];
00788             unsigned char output[65];
00789             int key_len, src_len;
00790         
00791             memset(src_str, 0x00, 10000);
00792             memset(key_str, 0x00, 10000);
00793             memset(hash_str, 0x00, 10000);
00794             memset(output, 0x00, 65);
00795         
00796             key_len = unhexify( key_str, "369f33f85b927a07" );
00797             src_len = unhexify( src_str, "ae8e2a94ca386d448cbacdb0e9040ae3cb297c296363052cc157455da29a0c95897315fc11e3f12b81e2418da1ec280bccbc00e847584ce9d14deeba7b3c9b8dba958b04bba37551f6c9ba9c060be1a4b8cf43aa62e5078b76c6512c5619b71a6a7cf5727180e1ff14f5a1a3c1691bf8b6ebad365c151e58d749d57adb3a4986" );
00798         
00799             sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
00800             hexify( hash_str, output, 32 );
00801         
00802             fct_chk( strncmp( (char *) hash_str, "60b90383286533d309de46593e6ce39fc51fb00a8d88278c", 24 * 2 ) == 0 );
00803         }
00804         FCT_TEST_END();
00805 #endif /* POLARSSL_SHA2_C */
00806 
00807 #ifdef POLARSSL_SHA2_C
00808 
00809         FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_5)
00810         {
00811             unsigned char src_str[10000];
00812             unsigned char key_str[10000];
00813             unsigned char hash_str[10000];
00814             unsigned char output[65];
00815             int key_len, src_len;
00816         
00817             memset(src_str, 0x00, 10000);
00818             memset(key_str, 0x00, 10000);
00819             memset(hash_str, 0x00, 10000);
00820             memset(output, 0x00, 65);
00821         
00822             key_len = unhexify( key_str, "e5179687582b4dc4" );
00823             src_len = unhexify( src_str, "ce103bdacdf32f614f6727bcb31ca1c2824a850d00f5585b016fb234fe1ef2cd687f302d3c6b738ed89a24060d65c36675d0d96307c72ef3e8a83bfa8402e226de9d5d1724ba75c4879bf41a4a465ce61887d9f49a34757849b48bae81c27ebed76faae2ad669bca04747d409148d40812776e0ae2c395b3cb9c89981ce72d5c" );
00824         
00825             sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
00826             hexify( hash_str, output, 32 );
00827         
00828             fct_chk( strncmp( (char *) hash_str, "509581f6816df4b8cc9f2cf42b7cc6e6a5a1e375a16f2412", 24 * 2 ) == 0 );
00829         }
00830         FCT_TEST_END();
00831 #endif /* POLARSSL_SHA2_C */
00832 
00833 #ifdef POLARSSL_SHA2_C
00834 
00835         FCT_TEST_BGN(hmac_sha_256_test_vector_nist_cavs_6)
00836         {
00837             unsigned char src_str[10000];
00838             unsigned char key_str[10000];
00839             unsigned char hash_str[10000];
00840             unsigned char output[65];
00841             int key_len, src_len;
00842         
00843             memset(src_str, 0x00, 10000);
00844             memset(key_str, 0x00, 10000);
00845             memset(hash_str, 0x00, 10000);
00846             memset(output, 0x00, 65);
00847         
00848             key_len = unhexify( key_str, "63cec6246aeb1b61" );
00849             src_len = unhexify( src_str, "c178db908a405fa88aa255b8cad22b4057016585f139ee930388b083d86062fa0b3ea1f23f8a43bd11bee8464bcbd19b5ab9f6a8038d5245516f8274d20c8ee3033a07b908da528fa00343bb595deed500cab9745c4cb6391c23300f0d3584b090b3326c4cfa342620b78f9f5b4f27f7307ed770643ec1764aeae3dcf1a3ec69" );
00850         
00851             sha2_hmac( key_str, key_len, src_str, src_len, output, 0 );
00852             hexify( hash_str, output, 32 );
00853         
00854             fct_chk( strncmp( (char *) hash_str, "64f3dd861b7c7d29fce9ae0ce9ed954b5d7141806ee9eec7", 24 * 2 ) == 0 );
00855         }
00856         FCT_TEST_END();
00857 #endif /* POLARSSL_SHA2_C */
00858 
00859 #ifdef POLARSSL_SHA4_C
00860 
00861         FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_1)
00862         {
00863             unsigned char src_str[10000];
00864             unsigned char key_str[10000];
00865             unsigned char hash_str[10000];
00866             unsigned char output[97];
00867             int key_len, src_len;
00868         
00869             memset(src_str, 0x00, 10000);
00870             memset(key_str, 0x00, 10000);
00871             memset(hash_str, 0x00, 10000);
00872             memset(output, 0x00, 97);
00873         
00874             key_len = unhexify( key_str, "91a7401817386948ca952f9a20ee55dc" );
00875             src_len = unhexify( src_str, "2fea5b91035d6d501f3a834fa178bff4e64b99a8450432dafd32e4466b0e1e7781166f8a73f7e036b3b0870920f559f47bd1400a1a906e85e0dcf00a6c26862e9148b23806680f285f1fe4f93cdaf924c181a965465739c14f2268c8be8b471847c74b222577a1310bcdc1a85ef1468aa1a3fd4031213c97324b7509c9050a3d" );
00876         
00877             sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
00878             hexify( hash_str, output, 48 );
00879         
00880             fct_chk( strncmp( (char *) hash_str, "6d7be9490058cf413cc09fd043c224c2ec4fa7859b13783000a9a593c9f75838", 32 * 2 ) == 0 );
00881         }
00882         FCT_TEST_END();
00883 #endif /* POLARSSL_SHA4_C */
00884 
00885 #ifdef POLARSSL_SHA4_C
00886 
00887         FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_2)
00888         {
00889             unsigned char src_str[10000];
00890             unsigned char key_str[10000];
00891             unsigned char hash_str[10000];
00892             unsigned char output[97];
00893             int key_len, src_len;
00894         
00895             memset(src_str, 0x00, 10000);
00896             memset(key_str, 0x00, 10000);
00897             memset(hash_str, 0x00, 10000);
00898             memset(output, 0x00, 97);
00899         
00900             key_len = unhexify( key_str, "d6cac19657061aa90a6da11cd2e9ea47" );
00901             src_len = unhexify( src_str, "9f482e4655173135dfaa22a11bbbe6af263db48716406c5aec162ba3c4b41cad4f5a91558377521191c7343118beee65982929802913d67b6de5c4bdc3d27299bd722219d5ad2efa5bdb9ff7b229fc4bbc3f60719320cf2e7a51cad1133d21bad2d80919b1836ef825308b7c51c6b7677ac782e2bc30007afba065681cbdd215" );
00902         
00903             sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
00904             hexify( hash_str, output, 48 );
00905         
00906             fct_chk( strncmp( (char *) hash_str, "f3d5f3c008175321aa7b2ea379eaa4f8b9dcc60f895ec8940b8162f80a7dfe9f", 32 * 2 ) == 0 );
00907         }
00908         FCT_TEST_END();
00909 #endif /* POLARSSL_SHA4_C */
00910 
00911 #ifdef POLARSSL_SHA4_C
00912 
00913         FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_3)
00914         {
00915             unsigned char src_str[10000];
00916             unsigned char key_str[10000];
00917             unsigned char hash_str[10000];
00918             unsigned char output[97];
00919             int key_len, src_len;
00920         
00921             memset(src_str, 0x00, 10000);
00922             memset(key_str, 0x00, 10000);
00923             memset(hash_str, 0x00, 10000);
00924             memset(output, 0x00, 97);
00925         
00926             key_len = unhexify( key_str, "e06366ad149b8442cd4c1abdddd0afde" );
00927             src_len = unhexify( src_str, "2d140a194c02a5598f69174834679b8371234a0d505491f1bd03e128dd91a8bca2fb812e9d5da71613b5b00952ea78bf450d5b7547dea79135925085c7d3e6f52009c51ca3d88c6c09e9d074b0ee110736e0ec9b478b93efb34d7bf1c41b54decec43eab077a3aa4998ede53f67b4ea36c266745f9643d5360bdc8337c70dabf" );
00928         
00929             sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
00930             hexify( hash_str, output, 48 );
00931         
00932             fct_chk( strncmp( (char *) hash_str, "c19c67eda6fe29f3667bee1c897c333ce7683094ae77e84b4c16378d290895a1", 32 * 2 ) == 0 );
00933         }
00934         FCT_TEST_END();
00935 #endif /* POLARSSL_SHA4_C */
00936 
00937 #ifdef POLARSSL_SHA4_C
00938 
00939         FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_4)
00940         {
00941             unsigned char src_str[10000];
00942             unsigned char key_str[10000];
00943             unsigned char hash_str[10000];
00944             unsigned char output[97];
00945             int key_len, src_len;
00946         
00947             memset(src_str, 0x00, 10000);
00948             memset(key_str, 0x00, 10000);
00949             memset(hash_str, 0x00, 10000);
00950             memset(output, 0x00, 97);
00951         
00952             key_len = unhexify( key_str, "01ac59f42f8bb91d1bd10fe6990d7a87" );
00953             src_len = unhexify( src_str, "3caf18c476edd5615f343ac7b7d3a9da9efade755672d5ba4b8ae8a7505539ea2c124ff755ec0457fbe49e43480b3c71e7f4742ec3693aad115d039f90222b030fdc9440313691716d5302005808c07627483b916fdf61983063c2eb1268f2deeef42fc790334456bc6bad256e31fc9066de7cc7e43d1321b1866db45e905622" );
00954         
00955             sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
00956             hexify( hash_str, output, 48 );
00957         
00958             fct_chk( strncmp( (char *) hash_str, "1985fa2163a5943fc5d92f1fe8831215e7e91f0bff5332bc713a072bdb3a8f9e5c5157463a3bfeb36231416e65973e64", 48 * 2 ) == 0 );
00959         }
00960         FCT_TEST_END();
00961 #endif /* POLARSSL_SHA4_C */
00962 
00963 #ifdef POLARSSL_SHA4_C
00964 
00965         FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_5)
00966         {
00967             unsigned char src_str[10000];
00968             unsigned char key_str[10000];
00969             unsigned char hash_str[10000];
00970             unsigned char output[97];
00971             int key_len, src_len;
00972         
00973             memset(src_str, 0x00, 10000);
00974             memset(key_str, 0x00, 10000);
00975             memset(hash_str, 0x00, 10000);
00976             memset(output, 0x00, 97);
00977         
00978             key_len = unhexify( key_str, "fd74b9d9e102a3a80df1baf0cb35bace" );
00979             src_len = unhexify( src_str, "1a068917584813d1689ccbd0370c2114d537cdc8cc52bf6db16d5535f8f7d1ad0c850a9fa0cf62373ffbf7642b1f1e8164010d350721d798d9f99e9724830399c2fce26377e83d38845675457865c03d4a07d741a505ef028343eb29fd46d0f761f3792886998c1e5c32ac3bc7e6f08faed194b34f06eff4d5d4a5b42c481e0e" );
00980         
00981             sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
00982             hexify( hash_str, output, 48 );
00983         
00984             fct_chk( strncmp( (char *) hash_str, "a981eaf5de3d78b20ebd4414a4edd0657e3667cd808a0dbc430cf7252f73a5b24efa136039207bd59806897457d74e0c", 48 * 2 ) == 0 );
00985         }
00986         FCT_TEST_END();
00987 #endif /* POLARSSL_SHA4_C */
00988 
00989 #ifdef POLARSSL_SHA4_C
00990 
00991         FCT_TEST_BGN(hmac_sha_384_test_vector_nist_cavs_5)
00992         {
00993             unsigned char src_str[10000];
00994             unsigned char key_str[10000];
00995             unsigned char hash_str[10000];
00996             unsigned char output[97];
00997             int key_len, src_len;
00998         
00999             memset(src_str, 0x00, 10000);
01000             memset(key_str, 0x00, 10000);
01001             memset(hash_str, 0x00, 10000);
01002             memset(output, 0x00, 97);
01003         
01004             key_len = unhexify( key_str, "9fe794f0e26b669fa5f6883149377c6c" );
01005             src_len = unhexify( src_str, "6010c9745e8f1d44cfdc99e7e0fd79bc4271944c2d1d84dba589073dfc4ca5eb98c59356f60cd87bef28aeb83a832bde339b2087daf942aa1f67876c5d5ed33924bed4143bc12a2be532ccaf64daa7e2bc3c8872b9823b0533b6f5159135effe8c61545536975d7c3a61ba7365ec35f165bc92b4d19eb9156ade17dfa1bb4161" );
01006         
01007             sha4_hmac( key_str, key_len, src_str, src_len, output, 1 );
01008             hexify( hash_str, output, 48 );
01009         
01010             fct_chk( strncmp( (char *) hash_str, "915ae61f8754698c2b6ef9629e93441f8541bd4258a5e05372d19136cfaefc0473b48d96119291b38eb1a3cb1982a986", 48 * 2 ) == 0 );
01011         }
01012         FCT_TEST_END();
01013 #endif /* POLARSSL_SHA4_C */
01014 
01015 #ifdef POLARSSL_SHA4_C
01016 
01017         FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_1)
01018         {
01019             unsigned char src_str[10000];
01020             unsigned char key_str[10000];
01021             unsigned char hash_str[10000];
01022             unsigned char output[129];
01023             int key_len, src_len;
01024         
01025             memset(src_str, 0x00, 10000);
01026             memset(key_str, 0x00, 10000);
01027             memset(hash_str, 0x00, 10000);
01028             memset(output, 0x00, 129);
01029         
01030             key_len = unhexify( key_str, "c95a17c09940a691ed2d621571b0eb844ede55a9" );
01031             src_len = unhexify( src_str, "99cd28262e81f34878cdcebf4128e05e2098a7009278a66f4c785784d0e5678f3f2b22f86e982d273b6273a222ec61750b4556d766f1550a7aedfe83faedbc4bdae83fa560d62df17eb914d05fdaa48940551bac81d700f5fca7147295e386e8120d66742ec65c6ee8d89a92217a0f6266d0ddc60bb20ef679ae8299c8502c2f" );
01032         
01033             sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
01034             hexify( hash_str, output, 64 );
01035         
01036             fct_chk( strncmp( (char *) hash_str, "6bc1379d156559ddee2ed420ea5d5c5ff3e454a1059b7ba72c350e77b6e9333c", 32 * 2 ) == 0 );
01037         }
01038         FCT_TEST_END();
01039 #endif /* POLARSSL_SHA4_C */
01040 
01041 #ifdef POLARSSL_SHA4_C
01042 
01043         FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_2)
01044         {
01045             unsigned char src_str[10000];
01046             unsigned char key_str[10000];
01047             unsigned char hash_str[10000];
01048             unsigned char output[129];
01049             int key_len, src_len;
01050         
01051             memset(src_str, 0x00, 10000);
01052             memset(key_str, 0x00, 10000);
01053             memset(hash_str, 0x00, 10000);
01054             memset(output, 0x00, 129);
01055         
01056             key_len = unhexify( key_str, "3b10b8fa718840d1dea8e9fc317476bcf55875fd" );
01057             src_len = unhexify( src_str, "f04f5b7073d7d0274e8354433b390306c5607632f5f589c12edb62d55673aff2366d2e6b24de731adf92e654baa30b1cfd4a069788f65ec1b99b015d904d8832110dbd74eae35a81562d14ce4136d820ad0a55ff5489ba678fbbc1c27663ec1349d70e740f0e0ec27cfbe8971819f4789e486b50a2d7271d77e2aaea50de62fd" );
01058         
01059             sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
01060             hexify( hash_str, output, 64 );
01061         
01062             fct_chk( strncmp( (char *) hash_str, "fc3c38c7a17e3ce06db033f1c172866f01a00045db55f2e234f71c82264f2ba2", 32 * 2 ) == 0 );
01063         }
01064         FCT_TEST_END();
01065 #endif /* POLARSSL_SHA4_C */
01066 
01067 #ifdef POLARSSL_SHA4_C
01068 
01069         FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_3)
01070         {
01071             unsigned char src_str[10000];
01072             unsigned char key_str[10000];
01073             unsigned char hash_str[10000];
01074             unsigned char output[129];
01075             int key_len, src_len;
01076         
01077             memset(src_str, 0x00, 10000);
01078             memset(key_str, 0x00, 10000);
01079             memset(hash_str, 0x00, 10000);
01080             memset(output, 0x00, 129);
01081         
01082             key_len = unhexify( key_str, "4803d311394600dc1e0d8fc8cedeb8bde3fe7c42" );
01083             src_len = unhexify( src_str, "a10c125dd702a97153ad923ba5e9889cfac1ba169de370debe51f233735aa6effcc9785c4b5c7e48c477dc5c411ae6a959118584e26adc94b42c2b29b046f3cf01c65b24a24bd2e620bdf650a23bb4a72655b1100d7ce9a4dab697c6379754b4396c825de4b9eb73f2e6a6c0d0353bbdeaf706612800e137b858fdb30f3311c6" );
01084         
01085             sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
01086             hexify( hash_str, output, 64 );
01087         
01088             fct_chk( strncmp( (char *) hash_str, "7cd8236c55102e6385f52279506df6fcc388ab75092da21395ce14a82b202ffa", 32 * 2 ) == 0 );
01089         }
01090         FCT_TEST_END();
01091 #endif /* POLARSSL_SHA4_C */
01092 
01093 #ifdef POLARSSL_SHA4_C
01094 
01095         FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_4)
01096         {
01097             unsigned char src_str[10000];
01098             unsigned char key_str[10000];
01099             unsigned char hash_str[10000];
01100             unsigned char output[129];
01101             int key_len, src_len;
01102         
01103             memset(src_str, 0x00, 10000);
01104             memset(key_str, 0x00, 10000);
01105             memset(hash_str, 0x00, 10000);
01106             memset(output, 0x00, 129);
01107         
01108             key_len = unhexify( key_str, "aeb2f3b977fa6c8e71e07c5a5c74ff58166de092" );
01109             src_len = unhexify( src_str, "22457355dc76095abd46846b41cfe49a06ce42ac8857b4702fc771508dfb3626e0bfe851df897a07b36811ec433766e4b4166c26301b3493e7440d4554b0ef6ac20f1a530e58fac8aeba4e9ff2d4898d8a28783b49cd269c2965fd7f8e4f2d60cf1e5284f2495145b72382aad90e153a90ecae125ad75336fb128825c23fb8b0" );
01110         
01111             sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
01112             hexify( hash_str, output, 64 );
01113         
01114             fct_chk( strncmp( (char *) hash_str, "fa39bd8fcc3bfa218f9dea5d3b2ce10a7619e31678a56d8a9d927b1fe703b125af445debe9a89a07db6194d27b44d85a", 48 * 2 ) == 0 );
01115         }
01116         FCT_TEST_END();
01117 #endif /* POLARSSL_SHA4_C */
01118 
01119 #ifdef POLARSSL_SHA4_C
01120 
01121         FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_5)
01122         {
01123             unsigned char src_str[10000];
01124             unsigned char key_str[10000];
01125             unsigned char hash_str[10000];
01126             unsigned char output[129];
01127             int key_len, src_len;
01128         
01129             memset(src_str, 0x00, 10000);
01130             memset(key_str, 0x00, 10000);
01131             memset(hash_str, 0x00, 10000);
01132             memset(output, 0x00, 129);
01133         
01134             key_len = unhexify( key_str, "4285d3d7744da52775bb44ca436a3154f7980309" );
01135             src_len = unhexify( src_str, "208f0b6f2de2e5aa5df11927ddc6df485edc1193181c484d0f0a434a95418803101d4de9fdb798f93516a6916fa38a8207de1666fe50fe3441c03b112eaaae6954ed063f7ac4e3c1e3f73b20d153fe9e4857f5e91430f0a70ee820529adac2467469fd18adf10e2af0fea27c0abc83c5a9af77c364a466cffce8bab4e2b70bc1" );
01136         
01137             sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
01138             hexify( hash_str, output, 64 );
01139         
01140             fct_chk( strncmp( (char *) hash_str, "fe7603f205b2774fe0f14ecfa3e338e90608a806d11ca459dff5ce36b1b264ecd3af5f0492a7521d8da3102ba20927a5", 48 * 2 ) == 0 );
01141         }
01142         FCT_TEST_END();
01143 #endif /* POLARSSL_SHA4_C */
01144 
01145 #ifdef POLARSSL_SHA4_C
01146 
01147         FCT_TEST_BGN(hmac_sha_512_test_vector_nist_cavs_6)
01148         {
01149             unsigned char src_str[10000];
01150             unsigned char key_str[10000];
01151             unsigned char hash_str[10000];
01152             unsigned char output[129];
01153             int key_len, src_len;
01154         
01155             memset(src_str, 0x00, 10000);
01156             memset(key_str, 0x00, 10000);
01157             memset(hash_str, 0x00, 10000);
01158             memset(output, 0x00, 129);
01159         
01160             key_len = unhexify( key_str, "8ab783d5acf32efa0d9c0a21abce955e96630d89" );
01161             src_len = unhexify( src_str, "17371e013dce839963d54418e97be4bd9fa3cb2a368a5220f5aa1b8aaddfa3bdefc91afe7c717244fd2fb640f5cb9d9bf3e25f7f0c8bc758883b89dcdce6d749d9672fed222277ece3e84b3ec01b96f70c125fcb3cbee6d19b8ef0873f915f173bdb05d81629ba187cc8ac1934b2f75952fb7616ae6bd812946df694bd2763af" );
01162         
01163             sha4_hmac( key_str, key_len, src_str, src_len, output, 0 );
01164             hexify( hash_str, output, 64 );
01165         
01166             fct_chk( strncmp( (char *) hash_str, "9ac7ca8d1aefc166b046e4cf7602ebe181a0e5055474bff5b342106731da0d7e48e4d87bc0a6f05871574289a1b099f8", 48 * 2 ) == 0 );
01167         }
01168         FCT_TEST_END();
01169 #endif /* POLARSSL_SHA4_C */
01170 
01171     }
01172     FCT_SUITE_END();
01173 
01174 
01175 }
01176 FCT_END();
01177