PolarSSL v1.1.4
test_suite_md.c
Go to the documentation of this file.
00001 #include "fct.h"
00002 
00003 #include <polarssl/md.h>
00004 #include <polarssl/md2.h>
00005 #include <polarssl/md4.h>
00006 #include <polarssl/md5.h>
00007 #include <polarssl/sha1.h>
00008 #include <polarssl/sha2.h>
00009 #include <polarssl/sha4.h>
00010 
00011 #include <polarssl/config.h>
00012 
00013 #ifdef _MSC_VER
00014 #include <basetsd.h>
00015 typedef UINT32 uint32_t;
00016 #else
00017 #include <inttypes.h>
00018 #endif
00019 
00020 /*
00021  * 32-bit integer manipulation macros (big endian)
00022  */
00023 #ifndef GET_ULONG_BE
00024 #define GET_ULONG_BE(n,b,i)                             \
00025 {                                                       \
00026     (n) = ( (unsigned long) (b)[(i)    ] << 24 )        \
00027         | ( (unsigned long) (b)[(i) + 1] << 16 )        \
00028         | ( (unsigned long) (b)[(i) + 2] <<  8 )        \
00029         | ( (unsigned long) (b)[(i) + 3]       );       \
00030 }
00031 #endif
00032 
00033 #ifndef PUT_ULONG_BE
00034 #define PUT_ULONG_BE(n,b,i)                             \
00035 {                                                       \
00036     (b)[(i)    ] = (unsigned char) ( (n) >> 24 );       \
00037     (b)[(i) + 1] = (unsigned char) ( (n) >> 16 );       \
00038     (b)[(i) + 2] = (unsigned char) ( (n) >>  8 );       \
00039     (b)[(i) + 3] = (unsigned char) ( (n)       );       \
00040 }
00041 #endif
00042 
00043 int unhexify(unsigned char *obuf, const char *ibuf)
00044 {
00045     unsigned char c, c2;
00046     int len = strlen(ibuf) / 2;
00047     assert(!(strlen(ibuf) %1)); // must be even number of bytes
00048 
00049     while (*ibuf != 0)
00050     {
00051         c = *ibuf++;
00052         if( c >= '0' && c <= '9' )
00053             c -= '0';
00054         else if( c >= 'a' && c <= 'f' )
00055             c -= 'a' - 10;
00056         else if( c >= 'A' && c <= 'F' )
00057             c -= 'A' - 10;
00058         else
00059             assert( 0 );
00060 
00061         c2 = *ibuf++;
00062         if( c2 >= '0' && c2 <= '9' )
00063             c2 -= '0';
00064         else if( c2 >= 'a' && c2 <= 'f' )
00065             c2 -= 'a' - 10;
00066         else if( c2 >= 'A' && c2 <= 'F' )
00067             c2 -= 'A' - 10;
00068         else
00069             assert( 0 );
00070 
00071         *obuf++ = ( c << 4 ) | c2;
00072     }
00073 
00074     return len;
00075 }
00076 
00077 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
00078 {
00079     unsigned char l, h;
00080 
00081     while (len != 0)
00082     {
00083         h = (*ibuf) / 16;
00084         l = (*ibuf) % 16;
00085 
00086         if( h < 10 )
00087             *obuf++ = '0' + h;
00088         else
00089             *obuf++ = 'a' + h - 10;
00090 
00091         if( l < 10 )
00092             *obuf++ = '0' + l;
00093         else
00094             *obuf++ = 'a' + l - 10;
00095 
00096         ++ibuf;
00097         len--;
00098     }
00099 }
00100 
00110 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
00111 {
00112     size_t i;
00113 
00114     if( rng_state != NULL )
00115         rng_state  = NULL;
00116 
00117     for( i = 0; i < len; ++i )
00118         output[i] = rand();
00119 
00120     return( 0 );
00121 }
00122 
00128 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
00129 {
00130     if( rng_state != NULL )
00131         rng_state  = NULL;
00132 
00133     memset( output, 0, len );
00134 
00135     return( 0 );
00136 }
00137 
00138 typedef struct
00139 {
00140     unsigned char *buf;
00141     size_t length;
00142 } rnd_buf_info;
00143 
00155 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
00156 {
00157     rnd_buf_info *info = (rnd_buf_info *) rng_state;
00158     size_t use_len;
00159 
00160     if( rng_state == NULL )
00161         return( rnd_std_rand( NULL, output, len ) );
00162 
00163     use_len = len;
00164     if( len > info->length )
00165         use_len = info->length;
00166 
00167     if( use_len )
00168     {
00169         memcpy( output, info->buf, use_len );
00170         info->buf += use_len;
00171         info->length -= use_len;
00172     }
00173 
00174     if( len - use_len > 0 )
00175         return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
00176 
00177     return( 0 );
00178 }
00179 
00187 typedef struct
00188 {
00189     uint32_t key[16];
00190     uint32_t v0, v1;
00191 } rnd_pseudo_info;
00192 
00201 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
00202 {
00203     rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
00204     uint32_t i, *k, sum, delta=0x9E3779B9;
00205     unsigned char result[4];
00206 
00207     if( rng_state == NULL )
00208         return( rnd_std_rand( NULL, output, len ) );
00209 
00210     k = info->key;
00211 
00212     while( len > 0 )
00213     {
00214         size_t use_len = ( len > 4 ) ? 4 : len;
00215         sum = 0;
00216 
00217         for( i = 0; i < 32; i++ )
00218         {
00219             info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
00220             sum += delta;
00221             info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
00222         }
00223 
00224         PUT_ULONG_BE( info->v0, result, 0 );
00225         memcpy( output, result, use_len );
00226         len -= use_len;
00227     }
00228 
00229     return( 0 );
00230 }
00231 
00232 
00233 FCT_BGN()
00234 {
00235 #ifdef POLARSSL_MD_C
00236 
00237 
00238     FCT_SUITE_BGN(test_suite_md)
00239     {
00240 #ifdef POLARSSL_MD2_C
00241 
00242         FCT_TEST_BGN(generic_md2_test_vector_rfc1319_1)
00243         {
00244             char md_name[100];
00245             unsigned char src_str[1000];
00246             unsigned char hash_str[1000];
00247             unsigned char output[100];
00248             const md_info_t *md_info = NULL;
00249         
00250             memset(md_name, 0x00, 100);
00251             memset(src_str, 0x00, 1000);
00252             memset(hash_str, 0x00, 1000);
00253             memset(output, 0x00, 100);
00254         
00255             strcpy( (char *) src_str, "" );
00256             
00257             strncpy( (char *) md_name, "md2", 100 );
00258             md_info = md_info_from_string(md_name);
00259             fct_chk( md_info != NULL );
00260         
00261             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00262             hexify( hash_str, output, md_get_size(md_info) );
00263         
00264             fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
00265         }
00266         FCT_TEST_END();
00267 #endif /* POLARSSL_MD2_C */
00268 
00269 #ifdef POLARSSL_MD2_C
00270 
00271         FCT_TEST_BGN(generic_md2_test_vector_rfc1319_2)
00272         {
00273             char md_name[100];
00274             unsigned char src_str[1000];
00275             unsigned char hash_str[1000];
00276             unsigned char output[100];
00277             const md_info_t *md_info = NULL;
00278         
00279             memset(md_name, 0x00, 100);
00280             memset(src_str, 0x00, 1000);
00281             memset(hash_str, 0x00, 1000);
00282             memset(output, 0x00, 100);
00283         
00284             strcpy( (char *) src_str, "a" );
00285             
00286             strncpy( (char *) md_name, "md2", 100 );
00287             md_info = md_info_from_string(md_name);
00288             fct_chk( md_info != NULL );
00289         
00290             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00291             hexify( hash_str, output, md_get_size(md_info) );
00292         
00293             fct_chk( strcmp( (char *) hash_str, "32ec01ec4a6dac72c0ab96fb34c0b5d1" ) == 0 );
00294         }
00295         FCT_TEST_END();
00296 #endif /* POLARSSL_MD2_C */
00297 
00298 #ifdef POLARSSL_MD2_C
00299 
00300         FCT_TEST_BGN(generic_md2_test_vector_rfc1319_3)
00301         {
00302             char md_name[100];
00303             unsigned char src_str[1000];
00304             unsigned char hash_str[1000];
00305             unsigned char output[100];
00306             const md_info_t *md_info = NULL;
00307         
00308             memset(md_name, 0x00, 100);
00309             memset(src_str, 0x00, 1000);
00310             memset(hash_str, 0x00, 1000);
00311             memset(output, 0x00, 100);
00312         
00313             strcpy( (char *) src_str, "abc" );
00314             
00315             strncpy( (char *) md_name, "md2", 100 );
00316             md_info = md_info_from_string(md_name);
00317             fct_chk( md_info != NULL );
00318         
00319             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00320             hexify( hash_str, output, md_get_size(md_info) );
00321         
00322             fct_chk( strcmp( (char *) hash_str, "da853b0d3f88d99b30283a69e6ded6bb" ) == 0 );
00323         }
00324         FCT_TEST_END();
00325 #endif /* POLARSSL_MD2_C */
00326 
00327 #ifdef POLARSSL_MD2_C
00328 
00329         FCT_TEST_BGN(generic_md2_test_vector_rfc1319_4)
00330         {
00331             char md_name[100];
00332             unsigned char src_str[1000];
00333             unsigned char hash_str[1000];
00334             unsigned char output[100];
00335             const md_info_t *md_info = NULL;
00336         
00337             memset(md_name, 0x00, 100);
00338             memset(src_str, 0x00, 1000);
00339             memset(hash_str, 0x00, 1000);
00340             memset(output, 0x00, 100);
00341         
00342             strcpy( (char *) src_str, "message digest" );
00343             
00344             strncpy( (char *) md_name, "md2", 100 );
00345             md_info = md_info_from_string(md_name);
00346             fct_chk( md_info != NULL );
00347         
00348             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00349             hexify( hash_str, output, md_get_size(md_info) );
00350         
00351             fct_chk( strcmp( (char *) hash_str, "ab4f496bfb2a530b219ff33031fe06b0" ) == 0 );
00352         }
00353         FCT_TEST_END();
00354 #endif /* POLARSSL_MD2_C */
00355 
00356 #ifdef POLARSSL_MD2_C
00357 
00358         FCT_TEST_BGN(generic_md2_test_vector_rfc1319_5)
00359         {
00360             char md_name[100];
00361             unsigned char src_str[1000];
00362             unsigned char hash_str[1000];
00363             unsigned char output[100];
00364             const md_info_t *md_info = NULL;
00365         
00366             memset(md_name, 0x00, 100);
00367             memset(src_str, 0x00, 1000);
00368             memset(hash_str, 0x00, 1000);
00369             memset(output, 0x00, 100);
00370         
00371             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
00372             
00373             strncpy( (char *) md_name, "md2", 100 );
00374             md_info = md_info_from_string(md_name);
00375             fct_chk( md_info != NULL );
00376         
00377             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00378             hexify( hash_str, output, md_get_size(md_info) );
00379         
00380             fct_chk( strcmp( (char *) hash_str, "4e8ddff3650292ab5a4108c3aa47940b" ) == 0 );
00381         }
00382         FCT_TEST_END();
00383 #endif /* POLARSSL_MD2_C */
00384 
00385 #ifdef POLARSSL_MD2_C
00386 
00387         FCT_TEST_BGN(generic_md2_test_vector_rfc1319_6)
00388         {
00389             char md_name[100];
00390             unsigned char src_str[1000];
00391             unsigned char hash_str[1000];
00392             unsigned char output[100];
00393             const md_info_t *md_info = NULL;
00394         
00395             memset(md_name, 0x00, 100);
00396             memset(src_str, 0x00, 1000);
00397             memset(hash_str, 0x00, 1000);
00398             memset(output, 0x00, 100);
00399         
00400             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
00401             
00402             strncpy( (char *) md_name, "md2", 100 );
00403             md_info = md_info_from_string(md_name);
00404             fct_chk( md_info != NULL );
00405         
00406             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00407             hexify( hash_str, output, md_get_size(md_info) );
00408         
00409             fct_chk( strcmp( (char *) hash_str, "da33def2a42df13975352846c30338cd" ) == 0 );
00410         }
00411         FCT_TEST_END();
00412 #endif /* POLARSSL_MD2_C */
00413 
00414 #ifdef POLARSSL_MD2_C
00415 
00416         FCT_TEST_BGN(generic_md2_test_vector_rfc1319_7)
00417         {
00418             char md_name[100];
00419             unsigned char src_str[1000];
00420             unsigned char hash_str[1000];
00421             unsigned char output[100];
00422             const md_info_t *md_info = NULL;
00423         
00424             memset(md_name, 0x00, 100);
00425             memset(src_str, 0x00, 1000);
00426             memset(hash_str, 0x00, 1000);
00427             memset(output, 0x00, 100);
00428         
00429             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
00430             
00431             strncpy( (char *) md_name, "md2", 100 );
00432             md_info = md_info_from_string(md_name);
00433             fct_chk( md_info != NULL );
00434         
00435             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00436             hexify( hash_str, output, md_get_size(md_info) );
00437         
00438             fct_chk( strcmp( (char *) hash_str, "d5976f79d83d3a0dc9806c3c66f3efd8" ) == 0 );
00439         }
00440         FCT_TEST_END();
00441 #endif /* POLARSSL_MD2_C */
00442 
00443 #ifdef POLARSSL_MD4_C
00444 
00445         FCT_TEST_BGN(generic_md4_test_vector_rfc1320_1)
00446         {
00447             char md_name[100];
00448             unsigned char src_str[1000];
00449             unsigned char hash_str[1000];
00450             unsigned char output[100];
00451             const md_info_t *md_info = NULL;
00452         
00453             memset(md_name, 0x00, 100);
00454             memset(src_str, 0x00, 1000);
00455             memset(hash_str, 0x00, 1000);
00456             memset(output, 0x00, 100);
00457         
00458             strcpy( (char *) src_str, "" );
00459             
00460             strncpy( (char *) md_name, "md4", 100 );
00461             md_info = md_info_from_string(md_name);
00462             fct_chk( md_info != NULL );
00463         
00464             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00465             hexify( hash_str, output, md_get_size(md_info) );
00466         
00467             fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
00468         }
00469         FCT_TEST_END();
00470 #endif /* POLARSSL_MD4_C */
00471 
00472 #ifdef POLARSSL_MD4_C
00473 
00474         FCT_TEST_BGN(generic_md4_test_vector_rfc1320_2)
00475         {
00476             char md_name[100];
00477             unsigned char src_str[1000];
00478             unsigned char hash_str[1000];
00479             unsigned char output[100];
00480             const md_info_t *md_info = NULL;
00481         
00482             memset(md_name, 0x00, 100);
00483             memset(src_str, 0x00, 1000);
00484             memset(hash_str, 0x00, 1000);
00485             memset(output, 0x00, 100);
00486         
00487             strcpy( (char *) src_str, "a" );
00488             
00489             strncpy( (char *) md_name, "md4", 100 );
00490             md_info = md_info_from_string(md_name);
00491             fct_chk( md_info != NULL );
00492         
00493             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00494             hexify( hash_str, output, md_get_size(md_info) );
00495         
00496             fct_chk( strcmp( (char *) hash_str, "bde52cb31de33e46245e05fbdbd6fb24" ) == 0 );
00497         }
00498         FCT_TEST_END();
00499 #endif /* POLARSSL_MD4_C */
00500 
00501 #ifdef POLARSSL_MD4_C
00502 
00503         FCT_TEST_BGN(generic_md4_test_vector_rfc1320_3)
00504         {
00505             char md_name[100];
00506             unsigned char src_str[1000];
00507             unsigned char hash_str[1000];
00508             unsigned char output[100];
00509             const md_info_t *md_info = NULL;
00510         
00511             memset(md_name, 0x00, 100);
00512             memset(src_str, 0x00, 1000);
00513             memset(hash_str, 0x00, 1000);
00514             memset(output, 0x00, 100);
00515         
00516             strcpy( (char *) src_str, "abc" );
00517             
00518             strncpy( (char *) md_name, "md4", 100 );
00519             md_info = md_info_from_string(md_name);
00520             fct_chk( md_info != NULL );
00521         
00522             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00523             hexify( hash_str, output, md_get_size(md_info) );
00524         
00525             fct_chk( strcmp( (char *) hash_str, "a448017aaf21d8525fc10ae87aa6729d" ) == 0 );
00526         }
00527         FCT_TEST_END();
00528 #endif /* POLARSSL_MD4_C */
00529 
00530 #ifdef POLARSSL_MD4_C
00531 
00532         FCT_TEST_BGN(generic_md4_test_vector_rfc1320_4)
00533         {
00534             char md_name[100];
00535             unsigned char src_str[1000];
00536             unsigned char hash_str[1000];
00537             unsigned char output[100];
00538             const md_info_t *md_info = NULL;
00539         
00540             memset(md_name, 0x00, 100);
00541             memset(src_str, 0x00, 1000);
00542             memset(hash_str, 0x00, 1000);
00543             memset(output, 0x00, 100);
00544         
00545             strcpy( (char *) src_str, "message digest" );
00546             
00547             strncpy( (char *) md_name, "md4", 100 );
00548             md_info = md_info_from_string(md_name);
00549             fct_chk( md_info != NULL );
00550         
00551             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00552             hexify( hash_str, output, md_get_size(md_info) );
00553         
00554             fct_chk( strcmp( (char *) hash_str, "d9130a8164549fe818874806e1c7014b" ) == 0 );
00555         }
00556         FCT_TEST_END();
00557 #endif /* POLARSSL_MD4_C */
00558 
00559 #ifdef POLARSSL_MD4_C
00560 
00561         FCT_TEST_BGN(generic_md4_test_vector_rfc1320_5)
00562         {
00563             char md_name[100];
00564             unsigned char src_str[1000];
00565             unsigned char hash_str[1000];
00566             unsigned char output[100];
00567             const md_info_t *md_info = NULL;
00568         
00569             memset(md_name, 0x00, 100);
00570             memset(src_str, 0x00, 1000);
00571             memset(hash_str, 0x00, 1000);
00572             memset(output, 0x00, 100);
00573         
00574             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
00575             
00576             strncpy( (char *) md_name, "md4", 100 );
00577             md_info = md_info_from_string(md_name);
00578             fct_chk( md_info != NULL );
00579         
00580             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00581             hexify( hash_str, output, md_get_size(md_info) );
00582         
00583             fct_chk( strcmp( (char *) hash_str, "d79e1c308aa5bbcdeea8ed63df412da9" ) == 0 );
00584         }
00585         FCT_TEST_END();
00586 #endif /* POLARSSL_MD4_C */
00587 
00588 #ifdef POLARSSL_MD4_C
00589 
00590         FCT_TEST_BGN(generic_md4_test_vector_rfc1320_6)
00591         {
00592             char md_name[100];
00593             unsigned char src_str[1000];
00594             unsigned char hash_str[1000];
00595             unsigned char output[100];
00596             const md_info_t *md_info = NULL;
00597         
00598             memset(md_name, 0x00, 100);
00599             memset(src_str, 0x00, 1000);
00600             memset(hash_str, 0x00, 1000);
00601             memset(output, 0x00, 100);
00602         
00603             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
00604             
00605             strncpy( (char *) md_name, "md4", 100 );
00606             md_info = md_info_from_string(md_name);
00607             fct_chk( md_info != NULL );
00608         
00609             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00610             hexify( hash_str, output, md_get_size(md_info) );
00611         
00612             fct_chk( strcmp( (char *) hash_str, "043f8582f241db351ce627e153e7f0e4" ) == 0 );
00613         }
00614         FCT_TEST_END();
00615 #endif /* POLARSSL_MD4_C */
00616 
00617 #ifdef POLARSSL_MD4_C
00618 
00619         FCT_TEST_BGN(generic_md4_test_vector_rfc1320_7)
00620         {
00621             char md_name[100];
00622             unsigned char src_str[1000];
00623             unsigned char hash_str[1000];
00624             unsigned char output[100];
00625             const md_info_t *md_info = NULL;
00626         
00627             memset(md_name, 0x00, 100);
00628             memset(src_str, 0x00, 1000);
00629             memset(hash_str, 0x00, 1000);
00630             memset(output, 0x00, 100);
00631         
00632             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
00633             
00634             strncpy( (char *) md_name, "md4", 100 );
00635             md_info = md_info_from_string(md_name);
00636             fct_chk( md_info != NULL );
00637         
00638             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00639             hexify( hash_str, output, md_get_size(md_info) );
00640         
00641             fct_chk( strcmp( (char *) hash_str, "e33b4ddc9c38f2199c3e7b164fcc0536" ) == 0 );
00642         }
00643         FCT_TEST_END();
00644 #endif /* POLARSSL_MD4_C */
00645 
00646 #ifdef POLARSSL_MD5_C
00647 
00648         FCT_TEST_BGN(generic_md5_test_vector_rfc1321_1)
00649         {
00650             char md_name[100];
00651             unsigned char src_str[1000];
00652             unsigned char hash_str[1000];
00653             unsigned char output[100];
00654             const md_info_t *md_info = NULL;
00655         
00656             memset(md_name, 0x00, 100);
00657             memset(src_str, 0x00, 1000);
00658             memset(hash_str, 0x00, 1000);
00659             memset(output, 0x00, 100);
00660         
00661             strcpy( (char *) src_str, "" );
00662             
00663             strncpy( (char *) md_name, "md5", 100 );
00664             md_info = md_info_from_string(md_name);
00665             fct_chk( md_info != NULL );
00666         
00667             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00668             hexify( hash_str, output, md_get_size(md_info) );
00669         
00670             fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
00671         }
00672         FCT_TEST_END();
00673 #endif /* POLARSSL_MD5_C */
00674 
00675 #ifdef POLARSSL_MD5_C
00676 
00677         FCT_TEST_BGN(generic_md5_test_vector_rfc1321_2)
00678         {
00679             char md_name[100];
00680             unsigned char src_str[1000];
00681             unsigned char hash_str[1000];
00682             unsigned char output[100];
00683             const md_info_t *md_info = NULL;
00684         
00685             memset(md_name, 0x00, 100);
00686             memset(src_str, 0x00, 1000);
00687             memset(hash_str, 0x00, 1000);
00688             memset(output, 0x00, 100);
00689         
00690             strcpy( (char *) src_str, "a" );
00691             
00692             strncpy( (char *) md_name, "md5", 100 );
00693             md_info = md_info_from_string(md_name);
00694             fct_chk( md_info != NULL );
00695         
00696             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00697             hexify( hash_str, output, md_get_size(md_info) );
00698         
00699             fct_chk( strcmp( (char *) hash_str, "0cc175b9c0f1b6a831c399e269772661" ) == 0 );
00700         }
00701         FCT_TEST_END();
00702 #endif /* POLARSSL_MD5_C */
00703 
00704 #ifdef POLARSSL_MD5_C
00705 
00706         FCT_TEST_BGN(generic_md5_test_vector_rfc1321_3)
00707         {
00708             char md_name[100];
00709             unsigned char src_str[1000];
00710             unsigned char hash_str[1000];
00711             unsigned char output[100];
00712             const md_info_t *md_info = NULL;
00713         
00714             memset(md_name, 0x00, 100);
00715             memset(src_str, 0x00, 1000);
00716             memset(hash_str, 0x00, 1000);
00717             memset(output, 0x00, 100);
00718         
00719             strcpy( (char *) src_str, "abc" );
00720             
00721             strncpy( (char *) md_name, "md5", 100 );
00722             md_info = md_info_from_string(md_name);
00723             fct_chk( md_info != NULL );
00724         
00725             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00726             hexify( hash_str, output, md_get_size(md_info) );
00727         
00728             fct_chk( strcmp( (char *) hash_str, "900150983cd24fb0d6963f7d28e17f72" ) == 0 );
00729         }
00730         FCT_TEST_END();
00731 #endif /* POLARSSL_MD5_C */
00732 
00733 #ifdef POLARSSL_MD5_C
00734 
00735         FCT_TEST_BGN(generic_md5_test_vector_rfc1321_4)
00736         {
00737             char md_name[100];
00738             unsigned char src_str[1000];
00739             unsigned char hash_str[1000];
00740             unsigned char output[100];
00741             const md_info_t *md_info = NULL;
00742         
00743             memset(md_name, 0x00, 100);
00744             memset(src_str, 0x00, 1000);
00745             memset(hash_str, 0x00, 1000);
00746             memset(output, 0x00, 100);
00747         
00748             strcpy( (char *) src_str, "message digest" );
00749             
00750             strncpy( (char *) md_name, "md5", 100 );
00751             md_info = md_info_from_string(md_name);
00752             fct_chk( md_info != NULL );
00753         
00754             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00755             hexify( hash_str, output, md_get_size(md_info) );
00756         
00757             fct_chk( strcmp( (char *) hash_str, "f96b697d7cb7938d525a2f31aaf161d0" ) == 0 );
00758         }
00759         FCT_TEST_END();
00760 #endif /* POLARSSL_MD5_C */
00761 
00762 #ifdef POLARSSL_MD5_C
00763 
00764         FCT_TEST_BGN(generic_md5_test_vector_rfc1321_5)
00765         {
00766             char md_name[100];
00767             unsigned char src_str[1000];
00768             unsigned char hash_str[1000];
00769             unsigned char output[100];
00770             const md_info_t *md_info = NULL;
00771         
00772             memset(md_name, 0x00, 100);
00773             memset(src_str, 0x00, 1000);
00774             memset(hash_str, 0x00, 1000);
00775             memset(output, 0x00, 100);
00776         
00777             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
00778             
00779             strncpy( (char *) md_name, "md5", 100 );
00780             md_info = md_info_from_string(md_name);
00781             fct_chk( md_info != NULL );
00782         
00783             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00784             hexify( hash_str, output, md_get_size(md_info) );
00785         
00786             fct_chk( strcmp( (char *) hash_str, "c3fcd3d76192e4007dfb496cca67e13b" ) == 0 );
00787         }
00788         FCT_TEST_END();
00789 #endif /* POLARSSL_MD5_C */
00790 
00791 #ifdef POLARSSL_MD5_C
00792 
00793         FCT_TEST_BGN(generic_md5_test_vector_rfc1321_6)
00794         {
00795             char md_name[100];
00796             unsigned char src_str[1000];
00797             unsigned char hash_str[1000];
00798             unsigned char output[100];
00799             const md_info_t *md_info = NULL;
00800         
00801             memset(md_name, 0x00, 100);
00802             memset(src_str, 0x00, 1000);
00803             memset(hash_str, 0x00, 1000);
00804             memset(output, 0x00, 100);
00805         
00806             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
00807             
00808             strncpy( (char *) md_name, "md5", 100 );
00809             md_info = md_info_from_string(md_name);
00810             fct_chk( md_info != NULL );
00811         
00812             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00813             hexify( hash_str, output, md_get_size(md_info) );
00814         
00815             fct_chk( strcmp( (char *) hash_str, "d174ab98d277d9f5a5611c2c9f419d9f" ) == 0 );
00816         }
00817         FCT_TEST_END();
00818 #endif /* POLARSSL_MD5_C */
00819 
00820 #ifdef POLARSSL_MD5_C
00821 
00822         FCT_TEST_BGN(generic_md5_test_vector_rfc1321_7)
00823         {
00824             char md_name[100];
00825             unsigned char src_str[1000];
00826             unsigned char hash_str[1000];
00827             unsigned char output[100];
00828             const md_info_t *md_info = NULL;
00829         
00830             memset(md_name, 0x00, 100);
00831             memset(src_str, 0x00, 1000);
00832             memset(hash_str, 0x00, 1000);
00833             memset(output, 0x00, 100);
00834         
00835             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
00836             
00837             strncpy( (char *) md_name, "md5", 100 );
00838             md_info = md_info_from_string(md_name);
00839             fct_chk( md_info != NULL );
00840         
00841             fct_chk ( 0 == md( md_info, src_str, strlen( (char *) src_str ), output ) );
00842             hexify( hash_str, output, md_get_size(md_info) );
00843         
00844             fct_chk( strcmp( (char *) hash_str, "57edf4a22be3c955ac49da2e2107b67a" ) == 0 );
00845         }
00846         FCT_TEST_END();
00847 #endif /* POLARSSL_MD5_C */
00848 
00849 #ifdef POLARSSL_MD2_C
00850 
00851         FCT_TEST_BGN(generic_hmac_md2_hash_file_openssl_test_1)
00852         {
00853             char md_name[100];
00854             unsigned char src_str[10000];
00855             unsigned char key_str[10000];
00856             unsigned char hash_str[10000];
00857             unsigned char output[100];
00858             int key_len, src_len;
00859             const md_info_t *md_info = NULL;
00860         
00861             memset(md_name, 0x00, 100);
00862             memset(src_str, 0x00, 10000);
00863             memset(key_str, 0x00, 10000);
00864             memset(hash_str, 0x00, 10000);
00865             memset(output, 0x00, 100);
00866         
00867             strncpy( (char *) md_name, "md2", 100 );
00868             md_info = md_info_from_string( md_name );
00869             fct_chk( md_info != NULL );
00870         
00871             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00872             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00873         
00874             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
00875             hexify( hash_str, output, md_get_size(md_info) );
00876         
00877             fct_chk( strncmp( (char *) hash_str, "d5732582f494f5ddf35efd166c85af9c", 16 * 2 ) == 0 );
00878         }
00879         FCT_TEST_END();
00880 #endif /* POLARSSL_MD2_C */
00881 
00882 #ifdef POLARSSL_MD2_C
00883 
00884         FCT_TEST_BGN(generic_hmac_md2_hash_file_openssl_test_2)
00885         {
00886             char md_name[100];
00887             unsigned char src_str[10000];
00888             unsigned char key_str[10000];
00889             unsigned char hash_str[10000];
00890             unsigned char output[100];
00891             int key_len, src_len;
00892             const md_info_t *md_info = NULL;
00893         
00894             memset(md_name, 0x00, 100);
00895             memset(src_str, 0x00, 10000);
00896             memset(key_str, 0x00, 10000);
00897             memset(hash_str, 0x00, 10000);
00898             memset(output, 0x00, 100);
00899         
00900             strncpy( (char *) md_name, "md2", 100 );
00901             md_info = md_info_from_string( md_name );
00902             fct_chk( md_info != NULL );
00903         
00904             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00905             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
00906         
00907             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
00908             hexify( hash_str, output, md_get_size(md_info) );
00909         
00910             fct_chk( strncmp( (char *) hash_str, "54ab68503f7d1b5c7741340dff2722a9", 16 * 2 ) == 0 );
00911         }
00912         FCT_TEST_END();
00913 #endif /* POLARSSL_MD2_C */
00914 
00915 #ifdef POLARSSL_MD2_C
00916 
00917         FCT_TEST_BGN(generic_hmac_md2_hash_file_openssl_test_3)
00918         {
00919             char md_name[100];
00920             unsigned char src_str[10000];
00921             unsigned char key_str[10000];
00922             unsigned char hash_str[10000];
00923             unsigned char output[100];
00924             int key_len, src_len;
00925             const md_info_t *md_info = NULL;
00926         
00927             memset(md_name, 0x00, 100);
00928             memset(src_str, 0x00, 10000);
00929             memset(key_str, 0x00, 10000);
00930             memset(hash_str, 0x00, 10000);
00931             memset(output, 0x00, 100);
00932         
00933             strncpy( (char *) md_name, "md2", 100 );
00934             md_info = md_info_from_string( md_name );
00935             fct_chk( md_info != NULL );
00936         
00937             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
00938             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00939         
00940             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
00941             hexify( hash_str, output, md_get_size(md_info) );
00942         
00943             fct_chk( strncmp( (char *) hash_str, "d850e5f554558cf0fe79a0612e1d0365", 16 * 2 ) == 0 );
00944         }
00945         FCT_TEST_END();
00946 #endif /* POLARSSL_MD2_C */
00947 
00948 #ifdef POLARSSL_MD4_C
00949 
00950         FCT_TEST_BGN(generic_hmac_md4_hash_file_openssl_test_1)
00951         {
00952             char md_name[100];
00953             unsigned char src_str[10000];
00954             unsigned char key_str[10000];
00955             unsigned char hash_str[10000];
00956             unsigned char output[100];
00957             int key_len, src_len;
00958             const md_info_t *md_info = NULL;
00959         
00960             memset(md_name, 0x00, 100);
00961             memset(src_str, 0x00, 10000);
00962             memset(key_str, 0x00, 10000);
00963             memset(hash_str, 0x00, 10000);
00964             memset(output, 0x00, 100);
00965         
00966             strncpy( (char *) md_name, "md4", 100 );
00967             md_info = md_info_from_string( md_name );
00968             fct_chk( md_info != NULL );
00969         
00970             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00971             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00972         
00973             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
00974             hexify( hash_str, output, md_get_size(md_info) );
00975         
00976             fct_chk( strncmp( (char *) hash_str, "eabd0fbefb82fb0063a25a6d7b8bdc0f", 16 * 2 ) == 0 );
00977         }
00978         FCT_TEST_END();
00979 #endif /* POLARSSL_MD4_C */
00980 
00981 #ifdef POLARSSL_MD4_C
00982 
00983         FCT_TEST_BGN(generic_hmac_md4_hash_file_openssl_test_2)
00984         {
00985             char md_name[100];
00986             unsigned char src_str[10000];
00987             unsigned char key_str[10000];
00988             unsigned char hash_str[10000];
00989             unsigned char output[100];
00990             int key_len, src_len;
00991             const md_info_t *md_info = NULL;
00992         
00993             memset(md_name, 0x00, 100);
00994             memset(src_str, 0x00, 10000);
00995             memset(key_str, 0x00, 10000);
00996             memset(hash_str, 0x00, 10000);
00997             memset(output, 0x00, 100);
00998         
00999             strncpy( (char *) md_name, "md4", 100 );
01000             md_info = md_info_from_string( md_name );
01001             fct_chk( md_info != NULL );
01002         
01003             key_len = unhexify( key_str, "61616161616161616161616161616161" );
01004             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
01005         
01006             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01007             hexify( hash_str, output, md_get_size(md_info) );
01008         
01009             fct_chk( strncmp( (char *) hash_str, "cec3c5e421a7b783aa89cacf78daf6dc", 16 * 2 ) == 0 );
01010         }
01011         FCT_TEST_END();
01012 #endif /* POLARSSL_MD4_C */
01013 
01014 #ifdef POLARSSL_MD4_C
01015 
01016         FCT_TEST_BGN(generic_hmac_md4_hash_file_openssl_test_3)
01017         {
01018             char md_name[100];
01019             unsigned char src_str[10000];
01020             unsigned char key_str[10000];
01021             unsigned char hash_str[10000];
01022             unsigned char output[100];
01023             int key_len, src_len;
01024             const md_info_t *md_info = NULL;
01025         
01026             memset(md_name, 0x00, 100);
01027             memset(src_str, 0x00, 10000);
01028             memset(key_str, 0x00, 10000);
01029             memset(hash_str, 0x00, 10000);
01030             memset(output, 0x00, 100);
01031         
01032             strncpy( (char *) md_name, "md4", 100 );
01033             md_info = md_info_from_string( md_name );
01034             fct_chk( md_info != NULL );
01035         
01036             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
01037             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
01038         
01039             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01040             hexify( hash_str, output, md_get_size(md_info) );
01041         
01042             fct_chk( strncmp( (char *) hash_str, "ad5f0a04116109b397b57f9cc9b6df4b", 16 * 2 ) == 0 );
01043         }
01044         FCT_TEST_END();
01045 #endif /* POLARSSL_MD4_C */
01046 
01047 #ifdef POLARSSL_MD5_C
01048 
01049         FCT_TEST_BGN(generic_hmac_md5_hash_file_openssl_test_1)
01050         {
01051             char md_name[100];
01052             unsigned char src_str[10000];
01053             unsigned char key_str[10000];
01054             unsigned char hash_str[10000];
01055             unsigned char output[100];
01056             int key_len, src_len;
01057             const md_info_t *md_info = NULL;
01058         
01059             memset(md_name, 0x00, 100);
01060             memset(src_str, 0x00, 10000);
01061             memset(key_str, 0x00, 10000);
01062             memset(hash_str, 0x00, 10000);
01063             memset(output, 0x00, 100);
01064         
01065             strncpy( (char *) md_name, "md5", 100 );
01066             md_info = md_info_from_string( md_name );
01067             fct_chk( md_info != NULL );
01068         
01069             key_len = unhexify( key_str, "61616161616161616161616161616161" );
01070             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
01071         
01072             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01073             hexify( hash_str, output, md_get_size(md_info) );
01074         
01075             fct_chk( strncmp( (char *) hash_str, "42552882f00bd4633ea81135a184b284", 16 * 2 ) == 0 );
01076         }
01077         FCT_TEST_END();
01078 #endif /* POLARSSL_MD5_C */
01079 
01080 #ifdef POLARSSL_MD5_C
01081 
01082         FCT_TEST_BGN(generic_hmac_md5_hash_file_openssl_test_2)
01083         {
01084             char md_name[100];
01085             unsigned char src_str[10000];
01086             unsigned char key_str[10000];
01087             unsigned char hash_str[10000];
01088             unsigned char output[100];
01089             int key_len, src_len;
01090             const md_info_t *md_info = NULL;
01091         
01092             memset(md_name, 0x00, 100);
01093             memset(src_str, 0x00, 10000);
01094             memset(key_str, 0x00, 10000);
01095             memset(hash_str, 0x00, 10000);
01096             memset(output, 0x00, 100);
01097         
01098             strncpy( (char *) md_name, "md5", 100 );
01099             md_info = md_info_from_string( md_name );
01100             fct_chk( md_info != NULL );
01101         
01102             key_len = unhexify( key_str, "61616161616161616161616161616161" );
01103             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
01104         
01105             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01106             hexify( hash_str, output, md_get_size(md_info) );
01107         
01108             fct_chk( strncmp( (char *) hash_str, "a16a842891786d01fe50ba7731db7464", 16 * 2 ) == 0 );
01109         }
01110         FCT_TEST_END();
01111 #endif /* POLARSSL_MD5_C */
01112 
01113 #ifdef POLARSSL_MD5_C
01114 
01115         FCT_TEST_BGN(generic_hmac_md5_hash_file_openssl_test_3)
01116         {
01117             char md_name[100];
01118             unsigned char src_str[10000];
01119             unsigned char key_str[10000];
01120             unsigned char hash_str[10000];
01121             unsigned char output[100];
01122             int key_len, src_len;
01123             const md_info_t *md_info = NULL;
01124         
01125             memset(md_name, 0x00, 100);
01126             memset(src_str, 0x00, 10000);
01127             memset(key_str, 0x00, 10000);
01128             memset(hash_str, 0x00, 10000);
01129             memset(output, 0x00, 100);
01130         
01131             strncpy( (char *) md_name, "md5", 100 );
01132             md_info = md_info_from_string( md_name );
01133             fct_chk( md_info != NULL );
01134         
01135             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
01136             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
01137         
01138             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01139             hexify( hash_str, output, md_get_size(md_info) );
01140         
01141             fct_chk( strncmp( (char *) hash_str, "e97f623936f98a7f741c4bd0612fecc2", 16 * 2 ) == 0 );
01142         }
01143         FCT_TEST_END();
01144 #endif /* POLARSSL_MD5_C */
01145 
01146 #ifdef POLARSSL_MD5_C
01147 
01148         FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_1)
01149         {
01150             char md_name[100];
01151             unsigned char src_str[10000];
01152             unsigned char key_str[10000];
01153             unsigned char hash_str[10000];
01154             unsigned char output[100];
01155             int key_len, src_len;
01156             const md_info_t *md_info = NULL;
01157         
01158             memset(md_name, 0x00, 100);
01159             memset(src_str, 0x00, 10000);
01160             memset(key_str, 0x00, 10000);
01161             memset(hash_str, 0x00, 10000);
01162             memset(output, 0x00, 100);
01163         
01164             strncpy( (char *) md_name, "md5", 100 );
01165             md_info = md_info_from_string( md_name );
01166             fct_chk( md_info != NULL );
01167         
01168             key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
01169             src_len = unhexify( src_str, "4869205468657265" );
01170         
01171             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01172             hexify( hash_str, output, md_get_size(md_info) );
01173         
01174             fct_chk( strncmp( (char *) hash_str, "9294727a3638bb1c13f48ef8158bfc9d", 16 * 2 ) == 0 );
01175         }
01176         FCT_TEST_END();
01177 #endif /* POLARSSL_MD5_C */
01178 
01179 #ifdef POLARSSL_MD5_C
01180 
01181         FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_2)
01182         {
01183             char md_name[100];
01184             unsigned char src_str[10000];
01185             unsigned char key_str[10000];
01186             unsigned char hash_str[10000];
01187             unsigned char output[100];
01188             int key_len, src_len;
01189             const md_info_t *md_info = NULL;
01190         
01191             memset(md_name, 0x00, 100);
01192             memset(src_str, 0x00, 10000);
01193             memset(key_str, 0x00, 10000);
01194             memset(hash_str, 0x00, 10000);
01195             memset(output, 0x00, 100);
01196         
01197             strncpy( (char *) md_name, "md5", 100 );
01198             md_info = md_info_from_string( md_name );
01199             fct_chk( md_info != NULL );
01200         
01201             key_len = unhexify( key_str, "4a656665" );
01202             src_len = unhexify( src_str, "7768617420646f2079612077616e7420666f72206e6f7468696e673f" );
01203         
01204             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01205             hexify( hash_str, output, md_get_size(md_info) );
01206         
01207             fct_chk( strncmp( (char *) hash_str, "750c783e6ab0b503eaa86e310a5db738", 16 * 2 ) == 0 );
01208         }
01209         FCT_TEST_END();
01210 #endif /* POLARSSL_MD5_C */
01211 
01212 #ifdef POLARSSL_MD5_C
01213 
01214         FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_3)
01215         {
01216             char md_name[100];
01217             unsigned char src_str[10000];
01218             unsigned char key_str[10000];
01219             unsigned char hash_str[10000];
01220             unsigned char output[100];
01221             int key_len, src_len;
01222             const md_info_t *md_info = NULL;
01223         
01224             memset(md_name, 0x00, 100);
01225             memset(src_str, 0x00, 10000);
01226             memset(key_str, 0x00, 10000);
01227             memset(hash_str, 0x00, 10000);
01228             memset(output, 0x00, 100);
01229         
01230             strncpy( (char *) md_name, "md5", 100 );
01231             md_info = md_info_from_string( md_name );
01232             fct_chk( md_info != NULL );
01233         
01234             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
01235             src_len = unhexify( src_str, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" );
01236         
01237             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01238             hexify( hash_str, output, md_get_size(md_info) );
01239         
01240             fct_chk( strncmp( (char *) hash_str, "56be34521d144c88dbb8c733f0e8b3f6", 16 * 2 ) == 0 );
01241         }
01242         FCT_TEST_END();
01243 #endif /* POLARSSL_MD5_C */
01244 
01245 #ifdef POLARSSL_MD5_C
01246 
01247         FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_4)
01248         {
01249             char md_name[100];
01250             unsigned char src_str[10000];
01251             unsigned char key_str[10000];
01252             unsigned char hash_str[10000];
01253             unsigned char output[100];
01254             int key_len, src_len;
01255             const md_info_t *md_info = NULL;
01256         
01257             memset(md_name, 0x00, 100);
01258             memset(src_str, 0x00, 10000);
01259             memset(key_str, 0x00, 10000);
01260             memset(hash_str, 0x00, 10000);
01261             memset(output, 0x00, 100);
01262         
01263             strncpy( (char *) md_name, "md5", 100 );
01264             md_info = md_info_from_string( md_name );
01265             fct_chk( md_info != NULL );
01266         
01267             key_len = unhexify( key_str, "0102030405060708090a0b0c0d0e0f10111213141516171819" );
01268             src_len = unhexify( src_str, "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
01269         
01270             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01271             hexify( hash_str, output, md_get_size(md_info) );
01272         
01273             fct_chk( strncmp( (char *) hash_str, "697eaf0aca3a3aea3a75164746ffaa79", 16 * 2 ) == 0 );
01274         }
01275         FCT_TEST_END();
01276 #endif /* POLARSSL_MD5_C */
01277 
01278 #ifdef POLARSSL_MD5_C
01279 
01280         FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_5)
01281         {
01282             char md_name[100];
01283             unsigned char src_str[10000];
01284             unsigned char key_str[10000];
01285             unsigned char hash_str[10000];
01286             unsigned char output[100];
01287             int key_len, src_len;
01288             const md_info_t *md_info = NULL;
01289         
01290             memset(md_name, 0x00, 100);
01291             memset(src_str, 0x00, 10000);
01292             memset(key_str, 0x00, 10000);
01293             memset(hash_str, 0x00, 10000);
01294             memset(output, 0x00, 100);
01295         
01296             strncpy( (char *) md_name, "md5", 100 );
01297             md_info = md_info_from_string( md_name );
01298             fct_chk( md_info != NULL );
01299         
01300             key_len = unhexify( key_str, "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" );
01301             src_len = unhexify( src_str, "546573742057697468205472756e636174696f6e" );
01302         
01303             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01304             hexify( hash_str, output, md_get_size(md_info) );
01305         
01306             fct_chk( strncmp( (char *) hash_str, "56461ef2342edc00f9bab995", 12 * 2 ) == 0 );
01307         }
01308         FCT_TEST_END();
01309 #endif /* POLARSSL_MD5_C */
01310 
01311 #ifdef POLARSSL_MD5_C
01312 
01313         FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_6)
01314         {
01315             char md_name[100];
01316             unsigned char src_str[10000];
01317             unsigned char key_str[10000];
01318             unsigned char hash_str[10000];
01319             unsigned char output[100];
01320             int key_len, src_len;
01321             const md_info_t *md_info = NULL;
01322         
01323             memset(md_name, 0x00, 100);
01324             memset(src_str, 0x00, 10000);
01325             memset(key_str, 0x00, 10000);
01326             memset(hash_str, 0x00, 10000);
01327             memset(output, 0x00, 100);
01328         
01329             strncpy( (char *) md_name, "md5", 100 );
01330             md_info = md_info_from_string( md_name );
01331             fct_chk( md_info != NULL );
01332         
01333             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
01334             src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374" );
01335         
01336             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01337             hexify( hash_str, output, md_get_size(md_info) );
01338         
01339             fct_chk( strncmp( (char *) hash_str, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", 16 * 2 ) == 0 );
01340         }
01341         FCT_TEST_END();
01342 #endif /* POLARSSL_MD5_C */
01343 
01344 #ifdef POLARSSL_MD5_C
01345 
01346         FCT_TEST_BGN(generic_hmac_md5_test_vector_rfc2202_7)
01347         {
01348             char md_name[100];
01349             unsigned char src_str[10000];
01350             unsigned char key_str[10000];
01351             unsigned char hash_str[10000];
01352             unsigned char output[100];
01353             int key_len, src_len;
01354             const md_info_t *md_info = NULL;
01355         
01356             memset(md_name, 0x00, 100);
01357             memset(src_str, 0x00, 10000);
01358             memset(key_str, 0x00, 10000);
01359             memset(hash_str, 0x00, 10000);
01360             memset(output, 0x00, 100);
01361         
01362             strncpy( (char *) md_name, "md5", 100 );
01363             md_info = md_info_from_string( md_name );
01364             fct_chk( md_info != NULL );
01365         
01366             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
01367             src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461" );
01368         
01369             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
01370             hexify( hash_str, output, md_get_size(md_info) );
01371         
01372             fct_chk( strncmp( (char *) hash_str, "6f630fad67cda0ee1fb1f562db3aa53e", 16 * 2 ) == 0 );
01373         }
01374         FCT_TEST_END();
01375 #endif /* POLARSSL_MD5_C */
01376 
01377 #ifdef POLARSSL_MD_C
01378 #ifdef POLARSSL_MD2_C
01379 
01380         FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_1)
01381         {
01382             char md_name[100];
01383             unsigned char src_str[1000];
01384             unsigned char hash_str[1000];
01385             unsigned char output[100];
01386             
01387             const md_info_t *md_info = NULL;
01388             md_context_t ctx = MD_CONTEXT_T_INIT;
01389         
01390             memset(md_name, 0x00, 100);
01391             memset(src_str, 0x00, 1000);
01392             memset(hash_str, 0x00, 1000);
01393             memset(output, 0x00, 100);
01394         
01395             strcpy( (char *) src_str, "" );
01396             
01397             strncpy( (char *) md_name, "md2", 100 );
01398             md_info = md_info_from_string(md_name);
01399             fct_chk( md_info != NULL );
01400             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01401         
01402             fct_chk ( 0 == md_starts( &ctx ) );
01403             fct_chk ( ctx.md_ctx != NULL );
01404             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01405             fct_chk ( 0 == md_finish( &ctx, output ) );
01406             fct_chk ( 0 == md_free_ctx( &ctx ) );
01407             
01408             hexify( hash_str, output, md_get_size(md_info) );
01409         
01410             fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
01411         }
01412         FCT_TEST_END();
01413 #endif /* POLARSSL_MD_C */
01414 #endif /* POLARSSL_MD2_C */
01415 
01416 #ifdef POLARSSL_MD2_C
01417 
01418         FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_2)
01419         {
01420             char md_name[100];
01421             unsigned char src_str[1000];
01422             unsigned char hash_str[1000];
01423             unsigned char output[100];
01424             
01425             const md_info_t *md_info = NULL;
01426             md_context_t ctx = MD_CONTEXT_T_INIT;
01427         
01428             memset(md_name, 0x00, 100);
01429             memset(src_str, 0x00, 1000);
01430             memset(hash_str, 0x00, 1000);
01431             memset(output, 0x00, 100);
01432         
01433             strcpy( (char *) src_str, "a" );
01434             
01435             strncpy( (char *) md_name, "md2", 100 );
01436             md_info = md_info_from_string(md_name);
01437             fct_chk( md_info != NULL );
01438             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01439         
01440             fct_chk ( 0 == md_starts( &ctx ) );
01441             fct_chk ( ctx.md_ctx != NULL );
01442             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01443             fct_chk ( 0 == md_finish( &ctx, output ) );
01444             fct_chk ( 0 == md_free_ctx( &ctx ) );
01445             
01446             hexify( hash_str, output, md_get_size(md_info) );
01447         
01448             fct_chk( strcmp( (char *) hash_str, "32ec01ec4a6dac72c0ab96fb34c0b5d1" ) == 0 );
01449         }
01450         FCT_TEST_END();
01451 #endif /* POLARSSL_MD2_C */
01452 
01453 #ifdef POLARSSL_MD2_C
01454 
01455         FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_3)
01456         {
01457             char md_name[100];
01458             unsigned char src_str[1000];
01459             unsigned char hash_str[1000];
01460             unsigned char output[100];
01461             
01462             const md_info_t *md_info = NULL;
01463             md_context_t ctx = MD_CONTEXT_T_INIT;
01464         
01465             memset(md_name, 0x00, 100);
01466             memset(src_str, 0x00, 1000);
01467             memset(hash_str, 0x00, 1000);
01468             memset(output, 0x00, 100);
01469         
01470             strcpy( (char *) src_str, "abc" );
01471             
01472             strncpy( (char *) md_name, "md2", 100 );
01473             md_info = md_info_from_string(md_name);
01474             fct_chk( md_info != NULL );
01475             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01476         
01477             fct_chk ( 0 == md_starts( &ctx ) );
01478             fct_chk ( ctx.md_ctx != NULL );
01479             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01480             fct_chk ( 0 == md_finish( &ctx, output ) );
01481             fct_chk ( 0 == md_free_ctx( &ctx ) );
01482             
01483             hexify( hash_str, output, md_get_size(md_info) );
01484         
01485             fct_chk( strcmp( (char *) hash_str, "da853b0d3f88d99b30283a69e6ded6bb" ) == 0 );
01486         }
01487         FCT_TEST_END();
01488 #endif /* POLARSSL_MD2_C */
01489 
01490 #ifdef POLARSSL_MD2_C
01491 
01492         FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_4)
01493         {
01494             char md_name[100];
01495             unsigned char src_str[1000];
01496             unsigned char hash_str[1000];
01497             unsigned char output[100];
01498             
01499             const md_info_t *md_info = NULL;
01500             md_context_t ctx = MD_CONTEXT_T_INIT;
01501         
01502             memset(md_name, 0x00, 100);
01503             memset(src_str, 0x00, 1000);
01504             memset(hash_str, 0x00, 1000);
01505             memset(output, 0x00, 100);
01506         
01507             strcpy( (char *) src_str, "message digest" );
01508             
01509             strncpy( (char *) md_name, "md2", 100 );
01510             md_info = md_info_from_string(md_name);
01511             fct_chk( md_info != NULL );
01512             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01513         
01514             fct_chk ( 0 == md_starts( &ctx ) );
01515             fct_chk ( ctx.md_ctx != NULL );
01516             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01517             fct_chk ( 0 == md_finish( &ctx, output ) );
01518             fct_chk ( 0 == md_free_ctx( &ctx ) );
01519             
01520             hexify( hash_str, output, md_get_size(md_info) );
01521         
01522             fct_chk( strcmp( (char *) hash_str, "ab4f496bfb2a530b219ff33031fe06b0" ) == 0 );
01523         }
01524         FCT_TEST_END();
01525 #endif /* POLARSSL_MD2_C */
01526 
01527 #ifdef POLARSSL_MD2_C
01528 
01529         FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_5)
01530         {
01531             char md_name[100];
01532             unsigned char src_str[1000];
01533             unsigned char hash_str[1000];
01534             unsigned char output[100];
01535             
01536             const md_info_t *md_info = NULL;
01537             md_context_t ctx = MD_CONTEXT_T_INIT;
01538         
01539             memset(md_name, 0x00, 100);
01540             memset(src_str, 0x00, 1000);
01541             memset(hash_str, 0x00, 1000);
01542             memset(output, 0x00, 100);
01543         
01544             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
01545             
01546             strncpy( (char *) md_name, "md2", 100 );
01547             md_info = md_info_from_string(md_name);
01548             fct_chk( md_info != NULL );
01549             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01550         
01551             fct_chk ( 0 == md_starts( &ctx ) );
01552             fct_chk ( ctx.md_ctx != NULL );
01553             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01554             fct_chk ( 0 == md_finish( &ctx, output ) );
01555             fct_chk ( 0 == md_free_ctx( &ctx ) );
01556             
01557             hexify( hash_str, output, md_get_size(md_info) );
01558         
01559             fct_chk( strcmp( (char *) hash_str, "4e8ddff3650292ab5a4108c3aa47940b" ) == 0 );
01560         }
01561         FCT_TEST_END();
01562 #endif /* POLARSSL_MD2_C */
01563 
01564 #ifdef POLARSSL_MD2_C
01565 
01566         FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_6)
01567         {
01568             char md_name[100];
01569             unsigned char src_str[1000];
01570             unsigned char hash_str[1000];
01571             unsigned char output[100];
01572             
01573             const md_info_t *md_info = NULL;
01574             md_context_t ctx = MD_CONTEXT_T_INIT;
01575         
01576             memset(md_name, 0x00, 100);
01577             memset(src_str, 0x00, 1000);
01578             memset(hash_str, 0x00, 1000);
01579             memset(output, 0x00, 100);
01580         
01581             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
01582             
01583             strncpy( (char *) md_name, "md2", 100 );
01584             md_info = md_info_from_string(md_name);
01585             fct_chk( md_info != NULL );
01586             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01587         
01588             fct_chk ( 0 == md_starts( &ctx ) );
01589             fct_chk ( ctx.md_ctx != NULL );
01590             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01591             fct_chk ( 0 == md_finish( &ctx, output ) );
01592             fct_chk ( 0 == md_free_ctx( &ctx ) );
01593             
01594             hexify( hash_str, output, md_get_size(md_info) );
01595         
01596             fct_chk( strcmp( (char *) hash_str, "da33def2a42df13975352846c30338cd" ) == 0 );
01597         }
01598         FCT_TEST_END();
01599 #endif /* POLARSSL_MD2_C */
01600 
01601 #ifdef POLARSSL_MD2_C
01602 
01603         FCT_TEST_BGN(generic_multi_step_md2_test_vector_rfc1319_7)
01604         {
01605             char md_name[100];
01606             unsigned char src_str[1000];
01607             unsigned char hash_str[1000];
01608             unsigned char output[100];
01609             
01610             const md_info_t *md_info = NULL;
01611             md_context_t ctx = MD_CONTEXT_T_INIT;
01612         
01613             memset(md_name, 0x00, 100);
01614             memset(src_str, 0x00, 1000);
01615             memset(hash_str, 0x00, 1000);
01616             memset(output, 0x00, 100);
01617         
01618             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
01619             
01620             strncpy( (char *) md_name, "md2", 100 );
01621             md_info = md_info_from_string(md_name);
01622             fct_chk( md_info != NULL );
01623             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01624         
01625             fct_chk ( 0 == md_starts( &ctx ) );
01626             fct_chk ( ctx.md_ctx != NULL );
01627             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01628             fct_chk ( 0 == md_finish( &ctx, output ) );
01629             fct_chk ( 0 == md_free_ctx( &ctx ) );
01630             
01631             hexify( hash_str, output, md_get_size(md_info) );
01632         
01633             fct_chk( strcmp( (char *) hash_str, "d5976f79d83d3a0dc9806c3c66f3efd8" ) == 0 );
01634         }
01635         FCT_TEST_END();
01636 #endif /* POLARSSL_MD2_C */
01637 
01638 #ifdef POLARSSL_MD4_C
01639 
01640         FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_1)
01641         {
01642             char md_name[100];
01643             unsigned char src_str[1000];
01644             unsigned char hash_str[1000];
01645             unsigned char output[100];
01646             
01647             const md_info_t *md_info = NULL;
01648             md_context_t ctx = MD_CONTEXT_T_INIT;
01649         
01650             memset(md_name, 0x00, 100);
01651             memset(src_str, 0x00, 1000);
01652             memset(hash_str, 0x00, 1000);
01653             memset(output, 0x00, 100);
01654         
01655             strcpy( (char *) src_str, "" );
01656             
01657             strncpy( (char *) md_name, "md4", 100 );
01658             md_info = md_info_from_string(md_name);
01659             fct_chk( md_info != NULL );
01660             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01661         
01662             fct_chk ( 0 == md_starts( &ctx ) );
01663             fct_chk ( ctx.md_ctx != NULL );
01664             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01665             fct_chk ( 0 == md_finish( &ctx, output ) );
01666             fct_chk ( 0 == md_free_ctx( &ctx ) );
01667             
01668             hexify( hash_str, output, md_get_size(md_info) );
01669         
01670             fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
01671         }
01672         FCT_TEST_END();
01673 #endif /* POLARSSL_MD4_C */
01674 
01675 #ifdef POLARSSL_MD4_C
01676 
01677         FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_2)
01678         {
01679             char md_name[100];
01680             unsigned char src_str[1000];
01681             unsigned char hash_str[1000];
01682             unsigned char output[100];
01683             
01684             const md_info_t *md_info = NULL;
01685             md_context_t ctx = MD_CONTEXT_T_INIT;
01686         
01687             memset(md_name, 0x00, 100);
01688             memset(src_str, 0x00, 1000);
01689             memset(hash_str, 0x00, 1000);
01690             memset(output, 0x00, 100);
01691         
01692             strcpy( (char *) src_str, "a" );
01693             
01694             strncpy( (char *) md_name, "md4", 100 );
01695             md_info = md_info_from_string(md_name);
01696             fct_chk( md_info != NULL );
01697             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01698         
01699             fct_chk ( 0 == md_starts( &ctx ) );
01700             fct_chk ( ctx.md_ctx != NULL );
01701             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01702             fct_chk ( 0 == md_finish( &ctx, output ) );
01703             fct_chk ( 0 == md_free_ctx( &ctx ) );
01704             
01705             hexify( hash_str, output, md_get_size(md_info) );
01706         
01707             fct_chk( strcmp( (char *) hash_str, "bde52cb31de33e46245e05fbdbd6fb24" ) == 0 );
01708         }
01709         FCT_TEST_END();
01710 #endif /* POLARSSL_MD4_C */
01711 
01712 #ifdef POLARSSL_MD4_C
01713 
01714         FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_3)
01715         {
01716             char md_name[100];
01717             unsigned char src_str[1000];
01718             unsigned char hash_str[1000];
01719             unsigned char output[100];
01720             
01721             const md_info_t *md_info = NULL;
01722             md_context_t ctx = MD_CONTEXT_T_INIT;
01723         
01724             memset(md_name, 0x00, 100);
01725             memset(src_str, 0x00, 1000);
01726             memset(hash_str, 0x00, 1000);
01727             memset(output, 0x00, 100);
01728         
01729             strcpy( (char *) src_str, "abc" );
01730             
01731             strncpy( (char *) md_name, "md4", 100 );
01732             md_info = md_info_from_string(md_name);
01733             fct_chk( md_info != NULL );
01734             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01735         
01736             fct_chk ( 0 == md_starts( &ctx ) );
01737             fct_chk ( ctx.md_ctx != NULL );
01738             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01739             fct_chk ( 0 == md_finish( &ctx, output ) );
01740             fct_chk ( 0 == md_free_ctx( &ctx ) );
01741             
01742             hexify( hash_str, output, md_get_size(md_info) );
01743         
01744             fct_chk( strcmp( (char *) hash_str, "a448017aaf21d8525fc10ae87aa6729d" ) == 0 );
01745         }
01746         FCT_TEST_END();
01747 #endif /* POLARSSL_MD4_C */
01748 
01749 #ifdef POLARSSL_MD4_C
01750 
01751         FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_4)
01752         {
01753             char md_name[100];
01754             unsigned char src_str[1000];
01755             unsigned char hash_str[1000];
01756             unsigned char output[100];
01757             
01758             const md_info_t *md_info = NULL;
01759             md_context_t ctx = MD_CONTEXT_T_INIT;
01760         
01761             memset(md_name, 0x00, 100);
01762             memset(src_str, 0x00, 1000);
01763             memset(hash_str, 0x00, 1000);
01764             memset(output, 0x00, 100);
01765         
01766             strcpy( (char *) src_str, "message digest" );
01767             
01768             strncpy( (char *) md_name, "md4", 100 );
01769             md_info = md_info_from_string(md_name);
01770             fct_chk( md_info != NULL );
01771             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01772         
01773             fct_chk ( 0 == md_starts( &ctx ) );
01774             fct_chk ( ctx.md_ctx != NULL );
01775             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01776             fct_chk ( 0 == md_finish( &ctx, output ) );
01777             fct_chk ( 0 == md_free_ctx( &ctx ) );
01778             
01779             hexify( hash_str, output, md_get_size(md_info) );
01780         
01781             fct_chk( strcmp( (char *) hash_str, "d9130a8164549fe818874806e1c7014b" ) == 0 );
01782         }
01783         FCT_TEST_END();
01784 #endif /* POLARSSL_MD4_C */
01785 
01786 #ifdef POLARSSL_MD4_C
01787 
01788         FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_5)
01789         {
01790             char md_name[100];
01791             unsigned char src_str[1000];
01792             unsigned char hash_str[1000];
01793             unsigned char output[100];
01794             
01795             const md_info_t *md_info = NULL;
01796             md_context_t ctx = MD_CONTEXT_T_INIT;
01797         
01798             memset(md_name, 0x00, 100);
01799             memset(src_str, 0x00, 1000);
01800             memset(hash_str, 0x00, 1000);
01801             memset(output, 0x00, 100);
01802         
01803             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
01804             
01805             strncpy( (char *) md_name, "md4", 100 );
01806             md_info = md_info_from_string(md_name);
01807             fct_chk( md_info != NULL );
01808             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01809         
01810             fct_chk ( 0 == md_starts( &ctx ) );
01811             fct_chk ( ctx.md_ctx != NULL );
01812             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01813             fct_chk ( 0 == md_finish( &ctx, output ) );
01814             fct_chk ( 0 == md_free_ctx( &ctx ) );
01815             
01816             hexify( hash_str, output, md_get_size(md_info) );
01817         
01818             fct_chk( strcmp( (char *) hash_str, "d79e1c308aa5bbcdeea8ed63df412da9" ) == 0 );
01819         }
01820         FCT_TEST_END();
01821 #endif /* POLARSSL_MD4_C */
01822 
01823 #ifdef POLARSSL_MD4_C
01824 
01825         FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_6)
01826         {
01827             char md_name[100];
01828             unsigned char src_str[1000];
01829             unsigned char hash_str[1000];
01830             unsigned char output[100];
01831             
01832             const md_info_t *md_info = NULL;
01833             md_context_t ctx = MD_CONTEXT_T_INIT;
01834         
01835             memset(md_name, 0x00, 100);
01836             memset(src_str, 0x00, 1000);
01837             memset(hash_str, 0x00, 1000);
01838             memset(output, 0x00, 100);
01839         
01840             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
01841             
01842             strncpy( (char *) md_name, "md4", 100 );
01843             md_info = md_info_from_string(md_name);
01844             fct_chk( md_info != NULL );
01845             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01846         
01847             fct_chk ( 0 == md_starts( &ctx ) );
01848             fct_chk ( ctx.md_ctx != NULL );
01849             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01850             fct_chk ( 0 == md_finish( &ctx, output ) );
01851             fct_chk ( 0 == md_free_ctx( &ctx ) );
01852             
01853             hexify( hash_str, output, md_get_size(md_info) );
01854         
01855             fct_chk( strcmp( (char *) hash_str, "043f8582f241db351ce627e153e7f0e4" ) == 0 );
01856         }
01857         FCT_TEST_END();
01858 #endif /* POLARSSL_MD4_C */
01859 
01860 #ifdef POLARSSL_MD4_C
01861 
01862         FCT_TEST_BGN(generic_multi_step_md4_test_vector_rfc1320_7)
01863         {
01864             char md_name[100];
01865             unsigned char src_str[1000];
01866             unsigned char hash_str[1000];
01867             unsigned char output[100];
01868             
01869             const md_info_t *md_info = NULL;
01870             md_context_t ctx = MD_CONTEXT_T_INIT;
01871         
01872             memset(md_name, 0x00, 100);
01873             memset(src_str, 0x00, 1000);
01874             memset(hash_str, 0x00, 1000);
01875             memset(output, 0x00, 100);
01876         
01877             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
01878             
01879             strncpy( (char *) md_name, "md4", 100 );
01880             md_info = md_info_from_string(md_name);
01881             fct_chk( md_info != NULL );
01882             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01883         
01884             fct_chk ( 0 == md_starts( &ctx ) );
01885             fct_chk ( ctx.md_ctx != NULL );
01886             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01887             fct_chk ( 0 == md_finish( &ctx, output ) );
01888             fct_chk ( 0 == md_free_ctx( &ctx ) );
01889             
01890             hexify( hash_str, output, md_get_size(md_info) );
01891         
01892             fct_chk( strcmp( (char *) hash_str, "e33b4ddc9c38f2199c3e7b164fcc0536" ) == 0 );
01893         }
01894         FCT_TEST_END();
01895 #endif /* POLARSSL_MD4_C */
01896 
01897 #ifdef POLARSSL_MD5_C
01898 
01899         FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_1)
01900         {
01901             char md_name[100];
01902             unsigned char src_str[1000];
01903             unsigned char hash_str[1000];
01904             unsigned char output[100];
01905             
01906             const md_info_t *md_info = NULL;
01907             md_context_t ctx = MD_CONTEXT_T_INIT;
01908         
01909             memset(md_name, 0x00, 100);
01910             memset(src_str, 0x00, 1000);
01911             memset(hash_str, 0x00, 1000);
01912             memset(output, 0x00, 100);
01913         
01914             strcpy( (char *) src_str, "" );
01915             
01916             strncpy( (char *) md_name, "md5", 100 );
01917             md_info = md_info_from_string(md_name);
01918             fct_chk( md_info != NULL );
01919             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01920         
01921             fct_chk ( 0 == md_starts( &ctx ) );
01922             fct_chk ( ctx.md_ctx != NULL );
01923             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01924             fct_chk ( 0 == md_finish( &ctx, output ) );
01925             fct_chk ( 0 == md_free_ctx( &ctx ) );
01926             
01927             hexify( hash_str, output, md_get_size(md_info) );
01928         
01929             fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
01930         }
01931         FCT_TEST_END();
01932 #endif /* POLARSSL_MD5_C */
01933 
01934 #ifdef POLARSSL_MD5_C
01935 
01936         FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_2)
01937         {
01938             char md_name[100];
01939             unsigned char src_str[1000];
01940             unsigned char hash_str[1000];
01941             unsigned char output[100];
01942             
01943             const md_info_t *md_info = NULL;
01944             md_context_t ctx = MD_CONTEXT_T_INIT;
01945         
01946             memset(md_name, 0x00, 100);
01947             memset(src_str, 0x00, 1000);
01948             memset(hash_str, 0x00, 1000);
01949             memset(output, 0x00, 100);
01950         
01951             strcpy( (char *) src_str, "a" );
01952             
01953             strncpy( (char *) md_name, "md5", 100 );
01954             md_info = md_info_from_string(md_name);
01955             fct_chk( md_info != NULL );
01956             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01957         
01958             fct_chk ( 0 == md_starts( &ctx ) );
01959             fct_chk ( ctx.md_ctx != NULL );
01960             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01961             fct_chk ( 0 == md_finish( &ctx, output ) );
01962             fct_chk ( 0 == md_free_ctx( &ctx ) );
01963             
01964             hexify( hash_str, output, md_get_size(md_info) );
01965         
01966             fct_chk( strcmp( (char *) hash_str, "0cc175b9c0f1b6a831c399e269772661" ) == 0 );
01967         }
01968         FCT_TEST_END();
01969 #endif /* POLARSSL_MD5_C */
01970 
01971 #ifdef POLARSSL_MD5_C
01972 
01973         FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_3)
01974         {
01975             char md_name[100];
01976             unsigned char src_str[1000];
01977             unsigned char hash_str[1000];
01978             unsigned char output[100];
01979             
01980             const md_info_t *md_info = NULL;
01981             md_context_t ctx = MD_CONTEXT_T_INIT;
01982         
01983             memset(md_name, 0x00, 100);
01984             memset(src_str, 0x00, 1000);
01985             memset(hash_str, 0x00, 1000);
01986             memset(output, 0x00, 100);
01987         
01988             strcpy( (char *) src_str, "abc" );
01989             
01990             strncpy( (char *) md_name, "md5", 100 );
01991             md_info = md_info_from_string(md_name);
01992             fct_chk( md_info != NULL );
01993             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
01994         
01995             fct_chk ( 0 == md_starts( &ctx ) );
01996             fct_chk ( ctx.md_ctx != NULL );
01997             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
01998             fct_chk ( 0 == md_finish( &ctx, output ) );
01999             fct_chk ( 0 == md_free_ctx( &ctx ) );
02000             
02001             hexify( hash_str, output, md_get_size(md_info) );
02002         
02003             fct_chk( strcmp( (char *) hash_str, "900150983cd24fb0d6963f7d28e17f72" ) == 0 );
02004         }
02005         FCT_TEST_END();
02006 #endif /* POLARSSL_MD5_C */
02007 
02008 #ifdef POLARSSL_MD5_C
02009 
02010         FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_4)
02011         {
02012             char md_name[100];
02013             unsigned char src_str[1000];
02014             unsigned char hash_str[1000];
02015             unsigned char output[100];
02016             
02017             const md_info_t *md_info = NULL;
02018             md_context_t ctx = MD_CONTEXT_T_INIT;
02019         
02020             memset(md_name, 0x00, 100);
02021             memset(src_str, 0x00, 1000);
02022             memset(hash_str, 0x00, 1000);
02023             memset(output, 0x00, 100);
02024         
02025             strcpy( (char *) src_str, "message digest" );
02026             
02027             strncpy( (char *) md_name, "md5", 100 );
02028             md_info = md_info_from_string(md_name);
02029             fct_chk( md_info != NULL );
02030             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02031         
02032             fct_chk ( 0 == md_starts( &ctx ) );
02033             fct_chk ( ctx.md_ctx != NULL );
02034             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
02035             fct_chk ( 0 == md_finish( &ctx, output ) );
02036             fct_chk ( 0 == md_free_ctx( &ctx ) );
02037             
02038             hexify( hash_str, output, md_get_size(md_info) );
02039         
02040             fct_chk( strcmp( (char *) hash_str, "f96b697d7cb7938d525a2f31aaf161d0" ) == 0 );
02041         }
02042         FCT_TEST_END();
02043 #endif /* POLARSSL_MD5_C */
02044 
02045 #ifdef POLARSSL_MD5_C
02046 
02047         FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_5)
02048         {
02049             char md_name[100];
02050             unsigned char src_str[1000];
02051             unsigned char hash_str[1000];
02052             unsigned char output[100];
02053             
02054             const md_info_t *md_info = NULL;
02055             md_context_t ctx = MD_CONTEXT_T_INIT;
02056         
02057             memset(md_name, 0x00, 100);
02058             memset(src_str, 0x00, 1000);
02059             memset(hash_str, 0x00, 1000);
02060             memset(output, 0x00, 100);
02061         
02062             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
02063             
02064             strncpy( (char *) md_name, "md5", 100 );
02065             md_info = md_info_from_string(md_name);
02066             fct_chk( md_info != NULL );
02067             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02068         
02069             fct_chk ( 0 == md_starts( &ctx ) );
02070             fct_chk ( ctx.md_ctx != NULL );
02071             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
02072             fct_chk ( 0 == md_finish( &ctx, output ) );
02073             fct_chk ( 0 == md_free_ctx( &ctx ) );
02074             
02075             hexify( hash_str, output, md_get_size(md_info) );
02076         
02077             fct_chk( strcmp( (char *) hash_str, "c3fcd3d76192e4007dfb496cca67e13b" ) == 0 );
02078         }
02079         FCT_TEST_END();
02080 #endif /* POLARSSL_MD5_C */
02081 
02082 #ifdef POLARSSL_MD5_C
02083 
02084         FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_6)
02085         {
02086             char md_name[100];
02087             unsigned char src_str[1000];
02088             unsigned char hash_str[1000];
02089             unsigned char output[100];
02090             
02091             const md_info_t *md_info = NULL;
02092             md_context_t ctx = MD_CONTEXT_T_INIT;
02093         
02094             memset(md_name, 0x00, 100);
02095             memset(src_str, 0x00, 1000);
02096             memset(hash_str, 0x00, 1000);
02097             memset(output, 0x00, 100);
02098         
02099             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
02100             
02101             strncpy( (char *) md_name, "md5", 100 );
02102             md_info = md_info_from_string(md_name);
02103             fct_chk( md_info != NULL );
02104             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02105         
02106             fct_chk ( 0 == md_starts( &ctx ) );
02107             fct_chk ( ctx.md_ctx != NULL );
02108             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
02109             fct_chk ( 0 == md_finish( &ctx, output ) );
02110             fct_chk ( 0 == md_free_ctx( &ctx ) );
02111             
02112             hexify( hash_str, output, md_get_size(md_info) );
02113         
02114             fct_chk( strcmp( (char *) hash_str, "d174ab98d277d9f5a5611c2c9f419d9f" ) == 0 );
02115         }
02116         FCT_TEST_END();
02117 #endif /* POLARSSL_MD5_C */
02118 
02119 #ifdef POLARSSL_MD5_C
02120 
02121         FCT_TEST_BGN(generic_multi_step_md5_test_vector_rfc1321_7)
02122         {
02123             char md_name[100];
02124             unsigned char src_str[1000];
02125             unsigned char hash_str[1000];
02126             unsigned char output[100];
02127             
02128             const md_info_t *md_info = NULL;
02129             md_context_t ctx = MD_CONTEXT_T_INIT;
02130         
02131             memset(md_name, 0x00, 100);
02132             memset(src_str, 0x00, 1000);
02133             memset(hash_str, 0x00, 1000);
02134             memset(output, 0x00, 100);
02135         
02136             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
02137             
02138             strncpy( (char *) md_name, "md5", 100 );
02139             md_info = md_info_from_string(md_name);
02140             fct_chk( md_info != NULL );
02141             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02142         
02143             fct_chk ( 0 == md_starts( &ctx ) );
02144             fct_chk ( ctx.md_ctx != NULL );
02145             fct_chk ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
02146             fct_chk ( 0 == md_finish( &ctx, output ) );
02147             fct_chk ( 0 == md_free_ctx( &ctx ) );
02148             
02149             hexify( hash_str, output, md_get_size(md_info) );
02150         
02151             fct_chk( strcmp( (char *) hash_str, "57edf4a22be3c955ac49da2e2107b67a" ) == 0 );
02152         }
02153         FCT_TEST_END();
02154 #endif /* POLARSSL_MD5_C */
02155 
02156 #ifdef POLARSSL_MD2_C
02157 
02158         FCT_TEST_BGN(generic_multi_step_hmac_md2_hash_file_openssl_test_1)
02159         {
02160             char md_name[100];
02161             unsigned char src_str[10000];
02162             unsigned char key_str[10000];
02163             unsigned char hash_str[10000];
02164             unsigned char output[100];
02165             int key_len, src_len;
02166             const md_info_t *md_info = NULL;
02167             md_context_t ctx = MD_CONTEXT_T_INIT;
02168         
02169             memset(md_name, 0x00, 100);
02170             memset(src_str, 0x00, 10000);
02171             memset(key_str, 0x00, 10000);
02172             memset(hash_str, 0x00, 10000);
02173             memset(output, 0x00, 100);
02174         
02175             strncpy( (char *) md_name, "md2", 100 );
02176             md_info = md_info_from_string( md_name );
02177             fct_chk( md_info != NULL );
02178             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02179         
02180             key_len = unhexify( key_str, "61616161616161616161616161616161" );
02181             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
02182         
02183             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02184             fct_chk ( ctx.md_ctx != NULL );
02185             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02186             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02187             fct_chk ( 0 == md_free_ctx( &ctx ) );
02188             
02189             hexify( hash_str, output, md_get_size(md_info) );
02190         
02191             fct_chk( strncmp( (char *) hash_str, "d5732582f494f5ddf35efd166c85af9c", 16 * 2 ) == 0 );
02192         }
02193         FCT_TEST_END();
02194 #endif /* POLARSSL_MD2_C */
02195 
02196 #ifdef POLARSSL_MD2_C
02197 
02198         FCT_TEST_BGN(generic_multi_step_hmac_md2_hash_file_openssl_test_2)
02199         {
02200             char md_name[100];
02201             unsigned char src_str[10000];
02202             unsigned char key_str[10000];
02203             unsigned char hash_str[10000];
02204             unsigned char output[100];
02205             int key_len, src_len;
02206             const md_info_t *md_info = NULL;
02207             md_context_t ctx = MD_CONTEXT_T_INIT;
02208         
02209             memset(md_name, 0x00, 100);
02210             memset(src_str, 0x00, 10000);
02211             memset(key_str, 0x00, 10000);
02212             memset(hash_str, 0x00, 10000);
02213             memset(output, 0x00, 100);
02214         
02215             strncpy( (char *) md_name, "md2", 100 );
02216             md_info = md_info_from_string( md_name );
02217             fct_chk( md_info != NULL );
02218             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02219         
02220             key_len = unhexify( key_str, "61616161616161616161616161616161" );
02221             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
02222         
02223             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02224             fct_chk ( ctx.md_ctx != NULL );
02225             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02226             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02227             fct_chk ( 0 == md_free_ctx( &ctx ) );
02228             
02229             hexify( hash_str, output, md_get_size(md_info) );
02230         
02231             fct_chk( strncmp( (char *) hash_str, "54ab68503f7d1b5c7741340dff2722a9", 16 * 2 ) == 0 );
02232         }
02233         FCT_TEST_END();
02234 #endif /* POLARSSL_MD2_C */
02235 
02236 #ifdef POLARSSL_MD2_C
02237 
02238         FCT_TEST_BGN(generic_multi_step_hmac_md2_hash_file_openssl_test_3)
02239         {
02240             char md_name[100];
02241             unsigned char src_str[10000];
02242             unsigned char key_str[10000];
02243             unsigned char hash_str[10000];
02244             unsigned char output[100];
02245             int key_len, src_len;
02246             const md_info_t *md_info = NULL;
02247             md_context_t ctx = MD_CONTEXT_T_INIT;
02248         
02249             memset(md_name, 0x00, 100);
02250             memset(src_str, 0x00, 10000);
02251             memset(key_str, 0x00, 10000);
02252             memset(hash_str, 0x00, 10000);
02253             memset(output, 0x00, 100);
02254         
02255             strncpy( (char *) md_name, "md2", 100 );
02256             md_info = md_info_from_string( md_name );
02257             fct_chk( md_info != NULL );
02258             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02259         
02260             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
02261             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
02262         
02263             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02264             fct_chk ( ctx.md_ctx != NULL );
02265             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02266             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02267             fct_chk ( 0 == md_free_ctx( &ctx ) );
02268             
02269             hexify( hash_str, output, md_get_size(md_info) );
02270         
02271             fct_chk( strncmp( (char *) hash_str, "d850e5f554558cf0fe79a0612e1d0365", 16 * 2 ) == 0 );
02272         }
02273         FCT_TEST_END();
02274 #endif /* POLARSSL_MD2_C */
02275 
02276 #ifdef POLARSSL_MD4_C
02277 
02278         FCT_TEST_BGN(generic_multi_step_hmac_md4_hash_file_openssl_test_1)
02279         {
02280             char md_name[100];
02281             unsigned char src_str[10000];
02282             unsigned char key_str[10000];
02283             unsigned char hash_str[10000];
02284             unsigned char output[100];
02285             int key_len, src_len;
02286             const md_info_t *md_info = NULL;
02287             md_context_t ctx = MD_CONTEXT_T_INIT;
02288         
02289             memset(md_name, 0x00, 100);
02290             memset(src_str, 0x00, 10000);
02291             memset(key_str, 0x00, 10000);
02292             memset(hash_str, 0x00, 10000);
02293             memset(output, 0x00, 100);
02294         
02295             strncpy( (char *) md_name, "md4", 100 );
02296             md_info = md_info_from_string( md_name );
02297             fct_chk( md_info != NULL );
02298             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02299         
02300             key_len = unhexify( key_str, "61616161616161616161616161616161" );
02301             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
02302         
02303             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02304             fct_chk ( ctx.md_ctx != NULL );
02305             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02306             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02307             fct_chk ( 0 == md_free_ctx( &ctx ) );
02308             
02309             hexify( hash_str, output, md_get_size(md_info) );
02310         
02311             fct_chk( strncmp( (char *) hash_str, "eabd0fbefb82fb0063a25a6d7b8bdc0f", 16 * 2 ) == 0 );
02312         }
02313         FCT_TEST_END();
02314 #endif /* POLARSSL_MD4_C */
02315 
02316 #ifdef POLARSSL_MD4_C
02317 
02318         FCT_TEST_BGN(generic_multi_step_hmac_md4_hash_file_openssl_test_2)
02319         {
02320             char md_name[100];
02321             unsigned char src_str[10000];
02322             unsigned char key_str[10000];
02323             unsigned char hash_str[10000];
02324             unsigned char output[100];
02325             int key_len, src_len;
02326             const md_info_t *md_info = NULL;
02327             md_context_t ctx = MD_CONTEXT_T_INIT;
02328         
02329             memset(md_name, 0x00, 100);
02330             memset(src_str, 0x00, 10000);
02331             memset(key_str, 0x00, 10000);
02332             memset(hash_str, 0x00, 10000);
02333             memset(output, 0x00, 100);
02334         
02335             strncpy( (char *) md_name, "md4", 100 );
02336             md_info = md_info_from_string( md_name );
02337             fct_chk( md_info != NULL );
02338             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02339         
02340             key_len = unhexify( key_str, "61616161616161616161616161616161" );
02341             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
02342         
02343             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02344             fct_chk ( ctx.md_ctx != NULL );
02345             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02346             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02347             fct_chk ( 0 == md_free_ctx( &ctx ) );
02348             
02349             hexify( hash_str, output, md_get_size(md_info) );
02350         
02351             fct_chk( strncmp( (char *) hash_str, "cec3c5e421a7b783aa89cacf78daf6dc", 16 * 2 ) == 0 );
02352         }
02353         FCT_TEST_END();
02354 #endif /* POLARSSL_MD4_C */
02355 
02356 #ifdef POLARSSL_MD4_C
02357 
02358         FCT_TEST_BGN(generic_multi_step_hmac_md4_hash_file_openssl_test_3)
02359         {
02360             char md_name[100];
02361             unsigned char src_str[10000];
02362             unsigned char key_str[10000];
02363             unsigned char hash_str[10000];
02364             unsigned char output[100];
02365             int key_len, src_len;
02366             const md_info_t *md_info = NULL;
02367             md_context_t ctx = MD_CONTEXT_T_INIT;
02368         
02369             memset(md_name, 0x00, 100);
02370             memset(src_str, 0x00, 10000);
02371             memset(key_str, 0x00, 10000);
02372             memset(hash_str, 0x00, 10000);
02373             memset(output, 0x00, 100);
02374         
02375             strncpy( (char *) md_name, "md4", 100 );
02376             md_info = md_info_from_string( md_name );
02377             fct_chk( md_info != NULL );
02378             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02379         
02380             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
02381             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
02382         
02383             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02384             fct_chk ( ctx.md_ctx != NULL );
02385             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02386             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02387             fct_chk ( 0 == md_free_ctx( &ctx ) );
02388             
02389             hexify( hash_str, output, md_get_size(md_info) );
02390         
02391             fct_chk( strncmp( (char *) hash_str, "ad5f0a04116109b397b57f9cc9b6df4b", 16 * 2 ) == 0 );
02392         }
02393         FCT_TEST_END();
02394 #endif /* POLARSSL_MD4_C */
02395 
02396 #ifdef POLARSSL_MD5_C
02397 
02398         FCT_TEST_BGN(generic_multi_step_hmac_md5_hash_file_openssl_test_1)
02399         {
02400             char md_name[100];
02401             unsigned char src_str[10000];
02402             unsigned char key_str[10000];
02403             unsigned char hash_str[10000];
02404             unsigned char output[100];
02405             int key_len, src_len;
02406             const md_info_t *md_info = NULL;
02407             md_context_t ctx = MD_CONTEXT_T_INIT;
02408         
02409             memset(md_name, 0x00, 100);
02410             memset(src_str, 0x00, 10000);
02411             memset(key_str, 0x00, 10000);
02412             memset(hash_str, 0x00, 10000);
02413             memset(output, 0x00, 100);
02414         
02415             strncpy( (char *) md_name, "md5", 100 );
02416             md_info = md_info_from_string( md_name );
02417             fct_chk( md_info != NULL );
02418             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02419         
02420             key_len = unhexify( key_str, "61616161616161616161616161616161" );
02421             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
02422         
02423             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02424             fct_chk ( ctx.md_ctx != NULL );
02425             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02426             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02427             fct_chk ( 0 == md_free_ctx( &ctx ) );
02428             
02429             hexify( hash_str, output, md_get_size(md_info) );
02430         
02431             fct_chk( strncmp( (char *) hash_str, "42552882f00bd4633ea81135a184b284", 16 * 2 ) == 0 );
02432         }
02433         FCT_TEST_END();
02434 #endif /* POLARSSL_MD5_C */
02435 
02436 #ifdef POLARSSL_MD5_C
02437 
02438         FCT_TEST_BGN(generic_multi_step_hmac_md5_hash_file_openssl_test_2)
02439         {
02440             char md_name[100];
02441             unsigned char src_str[10000];
02442             unsigned char key_str[10000];
02443             unsigned char hash_str[10000];
02444             unsigned char output[100];
02445             int key_len, src_len;
02446             const md_info_t *md_info = NULL;
02447             md_context_t ctx = MD_CONTEXT_T_INIT;
02448         
02449             memset(md_name, 0x00, 100);
02450             memset(src_str, 0x00, 10000);
02451             memset(key_str, 0x00, 10000);
02452             memset(hash_str, 0x00, 10000);
02453             memset(output, 0x00, 100);
02454         
02455             strncpy( (char *) md_name, "md5", 100 );
02456             md_info = md_info_from_string( md_name );
02457             fct_chk( md_info != NULL );
02458             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02459         
02460             key_len = unhexify( key_str, "61616161616161616161616161616161" );
02461             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
02462         
02463             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02464             fct_chk ( ctx.md_ctx != NULL );
02465             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02466             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02467             fct_chk ( 0 == md_free_ctx( &ctx ) );
02468             
02469             hexify( hash_str, output, md_get_size(md_info) );
02470         
02471             fct_chk( strncmp( (char *) hash_str, "a16a842891786d01fe50ba7731db7464", 16 * 2 ) == 0 );
02472         }
02473         FCT_TEST_END();
02474 #endif /* POLARSSL_MD5_C */
02475 
02476 #ifdef POLARSSL_MD5_C
02477 
02478         FCT_TEST_BGN(generic_multi_step_hmac_md5_hash_file_openssl_test_3)
02479         {
02480             char md_name[100];
02481             unsigned char src_str[10000];
02482             unsigned char key_str[10000];
02483             unsigned char hash_str[10000];
02484             unsigned char output[100];
02485             int key_len, src_len;
02486             const md_info_t *md_info = NULL;
02487             md_context_t ctx = MD_CONTEXT_T_INIT;
02488         
02489             memset(md_name, 0x00, 100);
02490             memset(src_str, 0x00, 10000);
02491             memset(key_str, 0x00, 10000);
02492             memset(hash_str, 0x00, 10000);
02493             memset(output, 0x00, 100);
02494         
02495             strncpy( (char *) md_name, "md5", 100 );
02496             md_info = md_info_from_string( md_name );
02497             fct_chk( md_info != NULL );
02498             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02499         
02500             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
02501             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
02502         
02503             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02504             fct_chk ( ctx.md_ctx != NULL );
02505             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02506             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02507             fct_chk ( 0 == md_free_ctx( &ctx ) );
02508             
02509             hexify( hash_str, output, md_get_size(md_info) );
02510         
02511             fct_chk( strncmp( (char *) hash_str, "e97f623936f98a7f741c4bd0612fecc2", 16 * 2 ) == 0 );
02512         }
02513         FCT_TEST_END();
02514 #endif /* POLARSSL_MD5_C */
02515 
02516 #ifdef POLARSSL_MD5_C
02517 
02518         FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_1)
02519         {
02520             char md_name[100];
02521             unsigned char src_str[10000];
02522             unsigned char key_str[10000];
02523             unsigned char hash_str[10000];
02524             unsigned char output[100];
02525             int key_len, src_len;
02526             const md_info_t *md_info = NULL;
02527             md_context_t ctx = MD_CONTEXT_T_INIT;
02528         
02529             memset(md_name, 0x00, 100);
02530             memset(src_str, 0x00, 10000);
02531             memset(key_str, 0x00, 10000);
02532             memset(hash_str, 0x00, 10000);
02533             memset(output, 0x00, 100);
02534         
02535             strncpy( (char *) md_name, "md5", 100 );
02536             md_info = md_info_from_string( md_name );
02537             fct_chk( md_info != NULL );
02538             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02539         
02540             key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
02541             src_len = unhexify( src_str, "4869205468657265" );
02542         
02543             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02544             fct_chk ( ctx.md_ctx != NULL );
02545             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02546             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02547             fct_chk ( 0 == md_free_ctx( &ctx ) );
02548             
02549             hexify( hash_str, output, md_get_size(md_info) );
02550         
02551             fct_chk( strncmp( (char *) hash_str, "9294727a3638bb1c13f48ef8158bfc9d", 16 * 2 ) == 0 );
02552         }
02553         FCT_TEST_END();
02554 #endif /* POLARSSL_MD5_C */
02555 
02556 #ifdef POLARSSL_MD5_C
02557 
02558         FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_2)
02559         {
02560             char md_name[100];
02561             unsigned char src_str[10000];
02562             unsigned char key_str[10000];
02563             unsigned char hash_str[10000];
02564             unsigned char output[100];
02565             int key_len, src_len;
02566             const md_info_t *md_info = NULL;
02567             md_context_t ctx = MD_CONTEXT_T_INIT;
02568         
02569             memset(md_name, 0x00, 100);
02570             memset(src_str, 0x00, 10000);
02571             memset(key_str, 0x00, 10000);
02572             memset(hash_str, 0x00, 10000);
02573             memset(output, 0x00, 100);
02574         
02575             strncpy( (char *) md_name, "md5", 100 );
02576             md_info = md_info_from_string( md_name );
02577             fct_chk( md_info != NULL );
02578             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02579         
02580             key_len = unhexify( key_str, "4a656665" );
02581             src_len = unhexify( src_str, "7768617420646f2079612077616e7420666f72206e6f7468696e673f" );
02582         
02583             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02584             fct_chk ( ctx.md_ctx != NULL );
02585             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02586             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02587             fct_chk ( 0 == md_free_ctx( &ctx ) );
02588             
02589             hexify( hash_str, output, md_get_size(md_info) );
02590         
02591             fct_chk( strncmp( (char *) hash_str, "750c783e6ab0b503eaa86e310a5db738", 16 * 2 ) == 0 );
02592         }
02593         FCT_TEST_END();
02594 #endif /* POLARSSL_MD5_C */
02595 
02596 #ifdef POLARSSL_MD5_C
02597 
02598         FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_3)
02599         {
02600             char md_name[100];
02601             unsigned char src_str[10000];
02602             unsigned char key_str[10000];
02603             unsigned char hash_str[10000];
02604             unsigned char output[100];
02605             int key_len, src_len;
02606             const md_info_t *md_info = NULL;
02607             md_context_t ctx = MD_CONTEXT_T_INIT;
02608         
02609             memset(md_name, 0x00, 100);
02610             memset(src_str, 0x00, 10000);
02611             memset(key_str, 0x00, 10000);
02612             memset(hash_str, 0x00, 10000);
02613             memset(output, 0x00, 100);
02614         
02615             strncpy( (char *) md_name, "md5", 100 );
02616             md_info = md_info_from_string( md_name );
02617             fct_chk( md_info != NULL );
02618             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02619         
02620             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
02621             src_len = unhexify( src_str, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" );
02622         
02623             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02624             fct_chk ( ctx.md_ctx != NULL );
02625             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02626             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02627             fct_chk ( 0 == md_free_ctx( &ctx ) );
02628             
02629             hexify( hash_str, output, md_get_size(md_info) );
02630         
02631             fct_chk( strncmp( (char *) hash_str, "56be34521d144c88dbb8c733f0e8b3f6", 16 * 2 ) == 0 );
02632         }
02633         FCT_TEST_END();
02634 #endif /* POLARSSL_MD5_C */
02635 
02636 #ifdef POLARSSL_MD5_C
02637 
02638         FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_4)
02639         {
02640             char md_name[100];
02641             unsigned char src_str[10000];
02642             unsigned char key_str[10000];
02643             unsigned char hash_str[10000];
02644             unsigned char output[100];
02645             int key_len, src_len;
02646             const md_info_t *md_info = NULL;
02647             md_context_t ctx = MD_CONTEXT_T_INIT;
02648         
02649             memset(md_name, 0x00, 100);
02650             memset(src_str, 0x00, 10000);
02651             memset(key_str, 0x00, 10000);
02652             memset(hash_str, 0x00, 10000);
02653             memset(output, 0x00, 100);
02654         
02655             strncpy( (char *) md_name, "md5", 100 );
02656             md_info = md_info_from_string( md_name );
02657             fct_chk( md_info != NULL );
02658             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02659         
02660             key_len = unhexify( key_str, "0102030405060708090a0b0c0d0e0f10111213141516171819" );
02661             src_len = unhexify( src_str, "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
02662         
02663             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02664             fct_chk ( ctx.md_ctx != NULL );
02665             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02666             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02667             fct_chk ( 0 == md_free_ctx( &ctx ) );
02668             
02669             hexify( hash_str, output, md_get_size(md_info) );
02670         
02671             fct_chk( strncmp( (char *) hash_str, "697eaf0aca3a3aea3a75164746ffaa79", 16 * 2 ) == 0 );
02672         }
02673         FCT_TEST_END();
02674 #endif /* POLARSSL_MD5_C */
02675 
02676 #ifdef POLARSSL_MD5_C
02677 
02678         FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_5)
02679         {
02680             char md_name[100];
02681             unsigned char src_str[10000];
02682             unsigned char key_str[10000];
02683             unsigned char hash_str[10000];
02684             unsigned char output[100];
02685             int key_len, src_len;
02686             const md_info_t *md_info = NULL;
02687             md_context_t ctx = MD_CONTEXT_T_INIT;
02688         
02689             memset(md_name, 0x00, 100);
02690             memset(src_str, 0x00, 10000);
02691             memset(key_str, 0x00, 10000);
02692             memset(hash_str, 0x00, 10000);
02693             memset(output, 0x00, 100);
02694         
02695             strncpy( (char *) md_name, "md5", 100 );
02696             md_info = md_info_from_string( md_name );
02697             fct_chk( md_info != NULL );
02698             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02699         
02700             key_len = unhexify( key_str, "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" );
02701             src_len = unhexify( src_str, "546573742057697468205472756e636174696f6e" );
02702         
02703             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02704             fct_chk ( ctx.md_ctx != NULL );
02705             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02706             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02707             fct_chk ( 0 == md_free_ctx( &ctx ) );
02708             
02709             hexify( hash_str, output, md_get_size(md_info) );
02710         
02711             fct_chk( strncmp( (char *) hash_str, "56461ef2342edc00f9bab995", 12 * 2 ) == 0 );
02712         }
02713         FCT_TEST_END();
02714 #endif /* POLARSSL_MD5_C */
02715 
02716 #ifdef POLARSSL_MD5_C
02717 
02718         FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_6)
02719         {
02720             char md_name[100];
02721             unsigned char src_str[10000];
02722             unsigned char key_str[10000];
02723             unsigned char hash_str[10000];
02724             unsigned char output[100];
02725             int key_len, src_len;
02726             const md_info_t *md_info = NULL;
02727             md_context_t ctx = MD_CONTEXT_T_INIT;
02728         
02729             memset(md_name, 0x00, 100);
02730             memset(src_str, 0x00, 10000);
02731             memset(key_str, 0x00, 10000);
02732             memset(hash_str, 0x00, 10000);
02733             memset(output, 0x00, 100);
02734         
02735             strncpy( (char *) md_name, "md5", 100 );
02736             md_info = md_info_from_string( md_name );
02737             fct_chk( md_info != NULL );
02738             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02739         
02740             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
02741             src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374" );
02742         
02743             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02744             fct_chk ( ctx.md_ctx != NULL );
02745             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02746             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02747             fct_chk ( 0 == md_free_ctx( &ctx ) );
02748             
02749             hexify( hash_str, output, md_get_size(md_info) );
02750         
02751             fct_chk( strncmp( (char *) hash_str, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", 16 * 2 ) == 0 );
02752         }
02753         FCT_TEST_END();
02754 #endif /* POLARSSL_MD5_C */
02755 
02756 #ifdef POLARSSL_MD5_C
02757 
02758         FCT_TEST_BGN(generic_multi_step_hmac_md5_test_vector_rfc2202_7)
02759         {
02760             char md_name[100];
02761             unsigned char src_str[10000];
02762             unsigned char key_str[10000];
02763             unsigned char hash_str[10000];
02764             unsigned char output[100];
02765             int key_len, src_len;
02766             const md_info_t *md_info = NULL;
02767             md_context_t ctx = MD_CONTEXT_T_INIT;
02768         
02769             memset(md_name, 0x00, 100);
02770             memset(src_str, 0x00, 10000);
02771             memset(key_str, 0x00, 10000);
02772             memset(hash_str, 0x00, 10000);
02773             memset(output, 0x00, 100);
02774         
02775             strncpy( (char *) md_name, "md5", 100 );
02776             md_info = md_info_from_string( md_name );
02777             fct_chk( md_info != NULL );
02778             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
02779         
02780             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
02781             src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461" );
02782         
02783             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
02784             fct_chk ( ctx.md_ctx != NULL );
02785             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
02786             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
02787             fct_chk ( 0 == md_free_ctx( &ctx ) );
02788             
02789             hexify( hash_str, output, md_get_size(md_info) );
02790         
02791             fct_chk( strncmp( (char *) hash_str, "6f630fad67cda0ee1fb1f562db3aa53e", 16 * 2 ) == 0 );
02792         }
02793         FCT_TEST_END();
02794 #endif /* POLARSSL_MD5_C */
02795 
02796 #ifdef POLARSSL_MD2_C
02797 #ifdef POLARSSL_FS_IO
02798 
02799         FCT_TEST_BGN(generic_md2_hash_file_1)
02800         {
02801             char md_name[100];
02802             unsigned char hash_str[1000];
02803             unsigned char output[100];
02804             const md_info_t *md_info = NULL;
02805         
02806             memset(md_name, 0x00, 100);
02807             memset(hash_str, 0x00, 1000);
02808             memset(output, 0x00, 100);
02809         
02810             strncpy( (char *) md_name, "md2", 100 );
02811             md_info = md_info_from_string( md_name );
02812             fct_chk( md_info != NULL );
02813         
02814             md_file( md_info, "data_files/hash_file_1", output);
02815             hexify( hash_str, output, md_get_size(md_info) );
02816         
02817             fct_chk( strcmp( (char *) hash_str, "b593c098712d2e21628c8986695451a8" ) == 0 );
02818         }
02819         FCT_TEST_END();
02820 #endif /* POLARSSL_MD2_C */
02821 #endif /* POLARSSL_FS_IO */
02822 
02823 #ifdef POLARSSL_MD2_C
02824 #ifdef POLARSSL_FS_IO
02825 
02826         FCT_TEST_BGN(generic_md2_hash_file_2)
02827         {
02828             char md_name[100];
02829             unsigned char hash_str[1000];
02830             unsigned char output[100];
02831             const md_info_t *md_info = NULL;
02832         
02833             memset(md_name, 0x00, 100);
02834             memset(hash_str, 0x00, 1000);
02835             memset(output, 0x00, 100);
02836         
02837             strncpy( (char *) md_name, "md2", 100 );
02838             md_info = md_info_from_string( md_name );
02839             fct_chk( md_info != NULL );
02840         
02841             md_file( md_info, "data_files/hash_file_2", output);
02842             hexify( hash_str, output, md_get_size(md_info) );
02843         
02844             fct_chk( strcmp( (char *) hash_str, "3c027b7409909a4c4b26bbab69ad9f4f" ) == 0 );
02845         }
02846         FCT_TEST_END();
02847 #endif /* POLARSSL_MD2_C */
02848 #endif /* POLARSSL_FS_IO */
02849 
02850 #ifdef POLARSSL_MD2_C
02851 #ifdef POLARSSL_FS_IO
02852 
02853         FCT_TEST_BGN(generic_md2_hash_file_3)
02854         {
02855             char md_name[100];
02856             unsigned char hash_str[1000];
02857             unsigned char output[100];
02858             const md_info_t *md_info = NULL;
02859         
02860             memset(md_name, 0x00, 100);
02861             memset(hash_str, 0x00, 1000);
02862             memset(output, 0x00, 100);
02863         
02864             strncpy( (char *) md_name, "md2", 100 );
02865             md_info = md_info_from_string( md_name );
02866             fct_chk( md_info != NULL );
02867         
02868             md_file( md_info, "data_files/hash_file_3", output);
02869             hexify( hash_str, output, md_get_size(md_info) );
02870         
02871             fct_chk( strcmp( (char *) hash_str, "6bb43eb285e81f414083a94cdbe2989d" ) == 0 );
02872         }
02873         FCT_TEST_END();
02874 #endif /* POLARSSL_MD2_C */
02875 #endif /* POLARSSL_FS_IO */
02876 
02877 #ifdef POLARSSL_MD2_C
02878 #ifdef POLARSSL_FS_IO
02879 
02880         FCT_TEST_BGN(generic_md2_hash_file_4)
02881         {
02882             char md_name[100];
02883             unsigned char hash_str[1000];
02884             unsigned char output[100];
02885             const md_info_t *md_info = NULL;
02886         
02887             memset(md_name, 0x00, 100);
02888             memset(hash_str, 0x00, 1000);
02889             memset(output, 0x00, 100);
02890         
02891             strncpy( (char *) md_name, "md2", 100 );
02892             md_info = md_info_from_string( md_name );
02893             fct_chk( md_info != NULL );
02894         
02895             md_file( md_info, "data_files/hash_file_4", output);
02896             hexify( hash_str, output, md_get_size(md_info) );
02897         
02898             fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
02899         }
02900         FCT_TEST_END();
02901 #endif /* POLARSSL_MD2_C */
02902 #endif /* POLARSSL_FS_IO */
02903 
02904 #ifdef POLARSSL_MD4_C
02905 #ifdef POLARSSL_FS_IO
02906 
02907         FCT_TEST_BGN(generic_md4_hash_file_1)
02908         {
02909             char md_name[100];
02910             unsigned char hash_str[1000];
02911             unsigned char output[100];
02912             const md_info_t *md_info = NULL;
02913         
02914             memset(md_name, 0x00, 100);
02915             memset(hash_str, 0x00, 1000);
02916             memset(output, 0x00, 100);
02917         
02918             strncpy( (char *) md_name, "md4", 100 );
02919             md_info = md_info_from_string( md_name );
02920             fct_chk( md_info != NULL );
02921         
02922             md_file( md_info, "data_files/hash_file_1", output);
02923             hexify( hash_str, output, md_get_size(md_info) );
02924         
02925             fct_chk( strcmp( (char *) hash_str, "8d19772c176bd27153b9486715e2c0b9" ) == 0 );
02926         }
02927         FCT_TEST_END();
02928 #endif /* POLARSSL_MD4_C */
02929 #endif /* POLARSSL_FS_IO */
02930 
02931 #ifdef POLARSSL_MD4_C
02932 #ifdef POLARSSL_FS_IO
02933 
02934         FCT_TEST_BGN(generic_md4_hash_file_2)
02935         {
02936             char md_name[100];
02937             unsigned char hash_str[1000];
02938             unsigned char output[100];
02939             const md_info_t *md_info = NULL;
02940         
02941             memset(md_name, 0x00, 100);
02942             memset(hash_str, 0x00, 1000);
02943             memset(output, 0x00, 100);
02944         
02945             strncpy( (char *) md_name, "md4", 100 );
02946             md_info = md_info_from_string( md_name );
02947             fct_chk( md_info != NULL );
02948         
02949             md_file( md_info, "data_files/hash_file_2", output);
02950             hexify( hash_str, output, md_get_size(md_info) );
02951         
02952             fct_chk( strcmp( (char *) hash_str, "f2ac53b8542882a5a0007c6f84b4d9fd" ) == 0 );
02953         }
02954         FCT_TEST_END();
02955 #endif /* POLARSSL_MD4_C */
02956 #endif /* POLARSSL_FS_IO */
02957 
02958 #ifdef POLARSSL_MD4_C
02959 #ifdef POLARSSL_FS_IO
02960 
02961         FCT_TEST_BGN(generic_md4_hash_file_3)
02962         {
02963             char md_name[100];
02964             unsigned char hash_str[1000];
02965             unsigned char output[100];
02966             const md_info_t *md_info = NULL;
02967         
02968             memset(md_name, 0x00, 100);
02969             memset(hash_str, 0x00, 1000);
02970             memset(output, 0x00, 100);
02971         
02972             strncpy( (char *) md_name, "md4", 100 );
02973             md_info = md_info_from_string( md_name );
02974             fct_chk( md_info != NULL );
02975         
02976             md_file( md_info, "data_files/hash_file_3", output);
02977             hexify( hash_str, output, md_get_size(md_info) );
02978         
02979             fct_chk( strcmp( (char *) hash_str, "195c15158e2d07881d9a654095ce4a42" ) == 0 );
02980         }
02981         FCT_TEST_END();
02982 #endif /* POLARSSL_MD4_C */
02983 #endif /* POLARSSL_FS_IO */
02984 
02985 #ifdef POLARSSL_MD4_C
02986 #ifdef POLARSSL_FS_IO
02987 
02988         FCT_TEST_BGN(generic_md4_hash_file_4)
02989         {
02990             char md_name[100];
02991             unsigned char hash_str[1000];
02992             unsigned char output[100];
02993             const md_info_t *md_info = NULL;
02994         
02995             memset(md_name, 0x00, 100);
02996             memset(hash_str, 0x00, 1000);
02997             memset(output, 0x00, 100);
02998         
02999             strncpy( (char *) md_name, "md4", 100 );
03000             md_info = md_info_from_string( md_name );
03001             fct_chk( md_info != NULL );
03002         
03003             md_file( md_info, "data_files/hash_file_4", output);
03004             hexify( hash_str, output, md_get_size(md_info) );
03005         
03006             fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
03007         }
03008         FCT_TEST_END();
03009 #endif /* POLARSSL_MD4_C */
03010 #endif /* POLARSSL_FS_IO */
03011 
03012 #ifdef POLARSSL_MD5_C
03013 #ifdef POLARSSL_FS_IO
03014 
03015         FCT_TEST_BGN(generic_md5_hash_file_1)
03016         {
03017             char md_name[100];
03018             unsigned char hash_str[1000];
03019             unsigned char output[100];
03020             const md_info_t *md_info = NULL;
03021         
03022             memset(md_name, 0x00, 100);
03023             memset(hash_str, 0x00, 1000);
03024             memset(output, 0x00, 100);
03025         
03026             strncpy( (char *) md_name, "md5", 100 );
03027             md_info = md_info_from_string( md_name );
03028             fct_chk( md_info != NULL );
03029         
03030             md_file( md_info, "data_files/hash_file_1", output);
03031             hexify( hash_str, output, md_get_size(md_info) );
03032         
03033             fct_chk( strcmp( (char *) hash_str, "52bcdc983c9ed64fc148a759b3c7a415" ) == 0 );
03034         }
03035         FCT_TEST_END();
03036 #endif /* POLARSSL_MD5_C */
03037 #endif /* POLARSSL_FS_IO */
03038 
03039 #ifdef POLARSSL_MD5_C
03040 #ifdef POLARSSL_FS_IO
03041 
03042         FCT_TEST_BGN(generic_md5_hash_file_2)
03043         {
03044             char md_name[100];
03045             unsigned char hash_str[1000];
03046             unsigned char output[100];
03047             const md_info_t *md_info = NULL;
03048         
03049             memset(md_name, 0x00, 100);
03050             memset(hash_str, 0x00, 1000);
03051             memset(output, 0x00, 100);
03052         
03053             strncpy( (char *) md_name, "md5", 100 );
03054             md_info = md_info_from_string( md_name );
03055             fct_chk( md_info != NULL );
03056         
03057             md_file( md_info, "data_files/hash_file_2", output);
03058             hexify( hash_str, output, md_get_size(md_info) );
03059         
03060             fct_chk( strcmp( (char *) hash_str, "d17d466f15891df10542207ae78277f0" ) == 0 );
03061         }
03062         FCT_TEST_END();
03063 #endif /* POLARSSL_MD5_C */
03064 #endif /* POLARSSL_FS_IO */
03065 
03066 #ifdef POLARSSL_MD5_C
03067 #ifdef POLARSSL_FS_IO
03068 
03069         FCT_TEST_BGN(generic_md5_hash_file_3)
03070         {
03071             char md_name[100];
03072             unsigned char hash_str[1000];
03073             unsigned char output[100];
03074             const md_info_t *md_info = NULL;
03075         
03076             memset(md_name, 0x00, 100);
03077             memset(hash_str, 0x00, 1000);
03078             memset(output, 0x00, 100);
03079         
03080             strncpy( (char *) md_name, "md5", 100 );
03081             md_info = md_info_from_string( md_name );
03082             fct_chk( md_info != NULL );
03083         
03084             md_file( md_info, "data_files/hash_file_3", output);
03085             hexify( hash_str, output, md_get_size(md_info) );
03086         
03087             fct_chk( strcmp( (char *) hash_str, "d945bcc6200ea95d061a2a818167d920" ) == 0 );
03088         }
03089         FCT_TEST_END();
03090 #endif /* POLARSSL_MD5_C */
03091 #endif /* POLARSSL_FS_IO */
03092 
03093 #ifdef POLARSSL_MD5_C
03094 #ifdef POLARSSL_FS_IO
03095 
03096         FCT_TEST_BGN(generic_md5_hash_file_4)
03097         {
03098             char md_name[100];
03099             unsigned char hash_str[1000];
03100             unsigned char output[100];
03101             const md_info_t *md_info = NULL;
03102         
03103             memset(md_name, 0x00, 100);
03104             memset(hash_str, 0x00, 1000);
03105             memset(output, 0x00, 100);
03106         
03107             strncpy( (char *) md_name, "md5", 100 );
03108             md_info = md_info_from_string( md_name );
03109             fct_chk( md_info != NULL );
03110         
03111             md_file( md_info, "data_files/hash_file_4", output);
03112             hexify( hash_str, output, md_get_size(md_info) );
03113         
03114             fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
03115         }
03116         FCT_TEST_END();
03117 #endif /* POLARSSL_MD5_C */
03118 #endif /* POLARSSL_FS_IO */
03119 
03120 #ifdef POLARSSL_SHA1_C
03121 
03122         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_1)
03123         {
03124             char md_name[100];
03125             unsigned char src_str[10000];
03126             unsigned char key_str[10000];
03127             unsigned char hash_str[10000];
03128             unsigned char output[100];
03129             int key_len, src_len;
03130             const md_info_t *md_info = NULL;
03131         
03132             memset(md_name, 0x00, 100);
03133             memset(src_str, 0x00, 10000);
03134             memset(key_str, 0x00, 10000);
03135             memset(hash_str, 0x00, 10000);
03136             memset(output, 0x00, 100);
03137         
03138             strncpy( (char *) md_name, "sha1", 100 );
03139             md_info = md_info_from_string( md_name );
03140             fct_chk( md_info != NULL );
03141         
03142             key_len = unhexify( key_str, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" );
03143             src_len = unhexify( src_str, "53616d706c65202331" );
03144         
03145             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03146             hexify( hash_str, output, md_get_size(md_info) );
03147         
03148             fct_chk( strncmp( (char *) hash_str, "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", 20 * 2 ) == 0 );
03149         }
03150         FCT_TEST_END();
03151 #endif /* POLARSSL_SHA1_C */
03152 
03153 #ifdef POLARSSL_SHA1_C
03154 
03155         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_2)
03156         {
03157             char md_name[100];
03158             unsigned char src_str[10000];
03159             unsigned char key_str[10000];
03160             unsigned char hash_str[10000];
03161             unsigned char output[100];
03162             int key_len, src_len;
03163             const md_info_t *md_info = NULL;
03164         
03165             memset(md_name, 0x00, 100);
03166             memset(src_str, 0x00, 10000);
03167             memset(key_str, 0x00, 10000);
03168             memset(hash_str, 0x00, 10000);
03169             memset(output, 0x00, 100);
03170         
03171             strncpy( (char *) md_name, "sha1", 100 );
03172             md_info = md_info_from_string( md_name );
03173             fct_chk( md_info != NULL );
03174         
03175             key_len = unhexify( key_str, "303132333435363738393a3b3c3d3e3f40414243" );
03176             src_len = unhexify( src_str, "53616d706c65202332" );
03177         
03178             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03179             hexify( hash_str, output, md_get_size(md_info) );
03180         
03181             fct_chk( strncmp( (char *) hash_str, "0922d3405faa3d194f82a45830737d5cc6c75d24", 20 * 2 ) == 0 );
03182         }
03183         FCT_TEST_END();
03184 #endif /* POLARSSL_SHA1_C */
03185 
03186 #ifdef POLARSSL_SHA1_C
03187 
03188         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_3)
03189         {
03190             char md_name[100];
03191             unsigned char src_str[10000];
03192             unsigned char key_str[10000];
03193             unsigned char hash_str[10000];
03194             unsigned char output[100];
03195             int key_len, src_len;
03196             const md_info_t *md_info = NULL;
03197         
03198             memset(md_name, 0x00, 100);
03199             memset(src_str, 0x00, 10000);
03200             memset(key_str, 0x00, 10000);
03201             memset(hash_str, 0x00, 10000);
03202             memset(output, 0x00, 100);
03203         
03204             strncpy( (char *) md_name, "sha1", 100 );
03205             md_info = md_info_from_string( md_name );
03206             fct_chk( md_info != NULL );
03207         
03208             key_len = unhexify( key_str, "505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" );
03209             src_len = unhexify( src_str, "53616d706c65202333" );
03210         
03211             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03212             hexify( hash_str, output, md_get_size(md_info) );
03213         
03214             fct_chk( strncmp( (char *) hash_str, "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", 20 * 2 ) == 0 );
03215         }
03216         FCT_TEST_END();
03217 #endif /* POLARSSL_SHA1_C */
03218 
03219 #ifdef POLARSSL_SHA1_C
03220 
03221         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_fips_198a_4)
03222         {
03223             char md_name[100];
03224             unsigned char src_str[10000];
03225             unsigned char key_str[10000];
03226             unsigned char hash_str[10000];
03227             unsigned char output[100];
03228             int key_len, src_len;
03229             const md_info_t *md_info = NULL;
03230         
03231             memset(md_name, 0x00, 100);
03232             memset(src_str, 0x00, 10000);
03233             memset(key_str, 0x00, 10000);
03234             memset(hash_str, 0x00, 10000);
03235             memset(output, 0x00, 100);
03236         
03237             strncpy( (char *) md_name, "sha1", 100 );
03238             md_info = md_info_from_string( md_name );
03239             fct_chk( md_info != NULL );
03240         
03241             key_len = unhexify( key_str, "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0" );
03242             src_len = unhexify( src_str, "53616d706c65202334" );
03243         
03244             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03245             hexify( hash_str, output, md_get_size(md_info) );
03246         
03247             fct_chk( strncmp( (char *) hash_str, "9ea886efe268dbecce420c75", 12 * 2 ) == 0 );
03248         }
03249         FCT_TEST_END();
03250 #endif /* POLARSSL_SHA1_C */
03251 
03252 #ifdef POLARSSL_SHA1_C
03253 
03254         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_1)
03255         {
03256             char md_name[100];
03257             unsigned char src_str[10000];
03258             unsigned char key_str[10000];
03259             unsigned char hash_str[10000];
03260             unsigned char output[100];
03261             int key_len, src_len;
03262             const md_info_t *md_info = NULL;
03263         
03264             memset(md_name, 0x00, 100);
03265             memset(src_str, 0x00, 10000);
03266             memset(key_str, 0x00, 10000);
03267             memset(hash_str, 0x00, 10000);
03268             memset(output, 0x00, 100);
03269         
03270             strncpy( (char *) md_name, "sha1", 100 );
03271             md_info = md_info_from_string( md_name );
03272             fct_chk( md_info != NULL );
03273         
03274             key_len = unhexify( key_str, "7b10f4124b15c82e" );
03275             src_len = unhexify( src_str, "27dcb5b1daf60cfd3e2f73d4d64ca9c684f8bf71fc682a46793b1790afa4feb100ca7aaff26f58f0e1d0ed42f1cdad1f474afa2e79d53a0c42892c4d7b327cbe46b295ed8da3b6ecab3d4851687a6f812b79df2f6b20f11f6706f5301790ca99625aad7391d84f78043d2a0a239b1477984c157bbc9276064e7a1a406b0612ca" );
03276         
03277             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03278             hexify( hash_str, output, md_get_size(md_info) );
03279         
03280             fct_chk( strncmp( (char *) hash_str, "4ead12c2fe3d6ea43acb", 10 * 2 ) == 0 );
03281         }
03282         FCT_TEST_END();
03283 #endif /* POLARSSL_SHA1_C */
03284 
03285 #ifdef POLARSSL_SHA1_C
03286 
03287         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_2)
03288         {
03289             char md_name[100];
03290             unsigned char src_str[10000];
03291             unsigned char key_str[10000];
03292             unsigned char hash_str[10000];
03293             unsigned char output[100];
03294             int key_len, src_len;
03295             const md_info_t *md_info = NULL;
03296         
03297             memset(md_name, 0x00, 100);
03298             memset(src_str, 0x00, 10000);
03299             memset(key_str, 0x00, 10000);
03300             memset(hash_str, 0x00, 10000);
03301             memset(output, 0x00, 100);
03302         
03303             strncpy( (char *) md_name, "sha1", 100 );
03304             md_info = md_info_from_string( md_name );
03305             fct_chk( md_info != NULL );
03306         
03307             key_len = unhexify( key_str, "4fe9fb902172a21b" );
03308             src_len = unhexify( src_str, "4ceb3a7c13659c22fe51134f03dce4c239d181b63c6b0b59d367157fd05cab98384f92dfa482d2d5e78e72eef1b1838af4696026c54233d484ecbbe87f904df5546419f8567eafd232e6c2fcd3ee2b7682c63000524b078dbb2096f585007deae752562df1fe3b01278089e16f3be46e2d0f7cabac2d8e6cc02a2d0ca953425f" );
03309         
03310             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03311             hexify( hash_str, output, md_get_size(md_info) );
03312         
03313             fct_chk( strncmp( (char *) hash_str, "564428a67be1924b5793", 10 * 2 ) == 0 );
03314         }
03315         FCT_TEST_END();
03316 #endif /* POLARSSL_SHA1_C */
03317 
03318 #ifdef POLARSSL_SHA1_C
03319 
03320         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_3)
03321         {
03322             char md_name[100];
03323             unsigned char src_str[10000];
03324             unsigned char key_str[10000];
03325             unsigned char hash_str[10000];
03326             unsigned char output[100];
03327             int key_len, src_len;
03328             const md_info_t *md_info = NULL;
03329         
03330             memset(md_name, 0x00, 100);
03331             memset(src_str, 0x00, 10000);
03332             memset(key_str, 0x00, 10000);
03333             memset(hash_str, 0x00, 10000);
03334             memset(output, 0x00, 100);
03335         
03336             strncpy( (char *) md_name, "sha1", 100 );
03337             md_info = md_info_from_string( md_name );
03338             fct_chk( md_info != NULL );
03339         
03340             key_len = unhexify( key_str, "d1f01455f78c4fb4" );
03341             src_len = unhexify( src_str, "00d40f67b57914bec456a3e3201ef1464be319a8d188c02e157af4b54f9b5a66d67f898a9bdbb19ff63a80aba6f246d013575721d52eb1b47a65def884011c49b257bcc2817fc853f106e8138ce386d7a5ac3103de0a3fa0ed6bb7af9ff66ebd1cc46fb86e4da0013d20a3c2dcd8fb828a4b70f7f104b41bf3f44682a66497ea" );
03342         
03343             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03344             hexify( hash_str, output, md_get_size(md_info) );
03345         
03346             fct_chk( strncmp( (char *) hash_str, "56a665a7cdfe610f9fc5", 10 * 2 ) == 0 );
03347         }
03348         FCT_TEST_END();
03349 #endif /* POLARSSL_SHA1_C */
03350 
03351 #ifdef POLARSSL_SHA1_C
03352 
03353         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_4)
03354         {
03355             char md_name[100];
03356             unsigned char src_str[10000];
03357             unsigned char key_str[10000];
03358             unsigned char hash_str[10000];
03359             unsigned char output[100];
03360             int key_len, src_len;
03361             const md_info_t *md_info = NULL;
03362         
03363             memset(md_name, 0x00, 100);
03364             memset(src_str, 0x00, 10000);
03365             memset(key_str, 0x00, 10000);
03366             memset(hash_str, 0x00, 10000);
03367             memset(output, 0x00, 100);
03368         
03369             strncpy( (char *) md_name, "sha1", 100 );
03370             md_info = md_info_from_string( md_name );
03371             fct_chk( md_info != NULL );
03372         
03373             key_len = unhexify( key_str, "4e5ef77fdf033a5b" );
03374             src_len = unhexify( src_str, "e59326464e3201d195e29f2a3446ec1b1c9ff31154e2a4d0e40ed466f1bc855d29f76835624fa0127d29c9b1915939a046f385af7e5d47a23ba91f28bd22f811ea258dbbf3332bcd3543b8285d5df41bd064ffd64a341c22c4edb44f9c8d9e6df0c59dbf4a052a6c83da7478e179a6f3839c6870ff8ca8b9497f9ac1d725fdda" );
03375         
03376             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03377             hexify( hash_str, output, md_get_size(md_info) );
03378         
03379             fct_chk( strncmp( (char *) hash_str, "981c0a7a8423b63a8fa6", 10 * 2 ) == 0 );
03380         }
03381         FCT_TEST_END();
03382 #endif /* POLARSSL_SHA1_C */
03383 
03384 #ifdef POLARSSL_SHA1_C
03385 
03386         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_5)
03387         {
03388             char md_name[100];
03389             unsigned char src_str[10000];
03390             unsigned char key_str[10000];
03391             unsigned char hash_str[10000];
03392             unsigned char output[100];
03393             int key_len, src_len;
03394             const md_info_t *md_info = NULL;
03395         
03396             memset(md_name, 0x00, 100);
03397             memset(src_str, 0x00, 10000);
03398             memset(key_str, 0x00, 10000);
03399             memset(hash_str, 0x00, 10000);
03400             memset(output, 0x00, 100);
03401         
03402             strncpy( (char *) md_name, "sha1", 100 );
03403             md_info = md_info_from_string( md_name );
03404             fct_chk( md_info != NULL );
03405         
03406             key_len = unhexify( key_str, "bcd9ff8aa60be2be" );
03407             src_len = unhexify( src_str, "51be4d0eb37bab714f92e19e9d70390655b363e8cd346a748245e731f437759cb8206412c8dab2ef1d4f36f880f41ff69d949da4594fdecb65e23cac1329b59e69e29bf875b38c31df6fa546c595f35cc2192aa750679a8a51a65e00e839d73a8d8c598a610d237fbe78955213589d80efcb73b95b8586f96d17b6f51a71c3b8" );
03408         
03409             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03410             hexify( hash_str, output, md_get_size(md_info) );
03411         
03412             fct_chk( strncmp( (char *) hash_str, "84633f9f5040c8971478", 10 * 2 ) == 0 );
03413         }
03414         FCT_TEST_END();
03415 #endif /* POLARSSL_SHA1_C */
03416 
03417 #ifdef POLARSSL_SHA1_C
03418 
03419         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_6)
03420         {
03421             char md_name[100];
03422             unsigned char src_str[10000];
03423             unsigned char key_str[10000];
03424             unsigned char hash_str[10000];
03425             unsigned char output[100];
03426             int key_len, src_len;
03427             const md_info_t *md_info = NULL;
03428         
03429             memset(md_name, 0x00, 100);
03430             memset(src_str, 0x00, 10000);
03431             memset(key_str, 0x00, 10000);
03432             memset(hash_str, 0x00, 10000);
03433             memset(output, 0x00, 100);
03434         
03435             strncpy( (char *) md_name, "sha1", 100 );
03436             md_info = md_info_from_string( md_name );
03437             fct_chk( md_info != NULL );
03438         
03439             key_len = unhexify( key_str, "4a661bce6ed86d21" );
03440             src_len = unhexify( src_str, "5ff6c744f1aab1bc29697d71f67541b8b3cec3c7079183b10a83fb98a9ee251d4bac3e1cb581ca972aaed8efd7c2875a6fb4c991132f67c9742d45e53bc7e8eaa94b35b37a907be61086b426cd11088ac118934e85d968c9667fd69fc6f6ea38c0fe34710b7ece91211b9b7ea00acd31f022aa6726368f9928a1352f122233f1" );
03441         
03442             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03443             hexify( hash_str, output, md_get_size(md_info) );
03444         
03445             fct_chk( strncmp( (char *) hash_str, "739df59353ac6694e55e", 10 * 2 ) == 0 );
03446         }
03447         FCT_TEST_END();
03448 #endif /* POLARSSL_SHA1_C */
03449 
03450 #ifdef POLARSSL_SHA1_C
03451 
03452         FCT_TEST_BGN(generic_hmac_sha_1_test_vector_nist_cavs_7)
03453         {
03454             char md_name[100];
03455             unsigned char src_str[10000];
03456             unsigned char key_str[10000];
03457             unsigned char hash_str[10000];
03458             unsigned char output[100];
03459             int key_len, src_len;
03460             const md_info_t *md_info = NULL;
03461         
03462             memset(md_name, 0x00, 100);
03463             memset(src_str, 0x00, 10000);
03464             memset(key_str, 0x00, 10000);
03465             memset(hash_str, 0x00, 10000);
03466             memset(output, 0x00, 100);
03467         
03468             strncpy( (char *) md_name, "sha1", 100 );
03469             md_info = md_info_from_string( md_name );
03470             fct_chk( md_info != NULL );
03471         
03472             key_len = unhexify( key_str, "1287e1565a57b547" );
03473             src_len = unhexify( src_str, "390ffdccc6171c11568d85b8f913e019bf4cd982ca9cd21ea730d41bdf3fcc0bc88ff48ba13a8f23deb2d96ec1033e7b2a58ca72b0c1e17bf03330db25d1e360fa6918009c4294bd1215b5ccd159a8f58bc3dc3d490eb7c3b9f887e8c98dbbb274a75373dcb695a59abd0219529d88518a96f92abc0bbcbda985c388f1fbbcc9" );
03474         
03475             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03476             hexify( hash_str, output, md_get_size(md_info) );
03477         
03478             fct_chk( strncmp( (char *) hash_str, "d78ddf08077c7d9e2ba6", 10 * 2 ) == 0 );
03479         }
03480         FCT_TEST_END();
03481 #endif /* POLARSSL_SHA1_C */
03482 
03483 #ifdef POLARSSL_SHA2_C
03484 
03485         FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_1)
03486         {
03487             char md_name[100];
03488             unsigned char src_str[10000];
03489             unsigned char key_str[10000];
03490             unsigned char hash_str[10000];
03491             unsigned char output[100];
03492             int key_len, src_len;
03493             const md_info_t *md_info = NULL;
03494         
03495             memset(md_name, 0x00, 100);
03496             memset(src_str, 0x00, 10000);
03497             memset(key_str, 0x00, 10000);
03498             memset(hash_str, 0x00, 10000);
03499             memset(output, 0x00, 100);
03500         
03501             strncpy( (char *) md_name, "sha224", 100 );
03502             md_info = md_info_from_string( md_name );
03503             fct_chk( md_info != NULL );
03504         
03505             key_len = unhexify( key_str, "e055eb756697ee573fd3214811a9f7fa" );
03506             src_len = unhexify( src_str, "3875847012ee42fe54a0027bdf38cca7021b83a2ed0503af69ef6c37c637bc1114fba40096c5947d736e19b7af3c68d95a4e3b8b073adbbb80f47e9db8f2d4f0018ddd847fabfdf9dd9b52c93e40458977725f6b7ba15f0816bb895cdf50401268f5d702b7e6a5f9faef57b8768c8a3fc14f9a4b3182b41d940e337d219b29ff" );
03507         
03508             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03509             hexify( hash_str, output, md_get_size(md_info) );
03510         
03511             fct_chk( strncmp( (char *) hash_str, "40a453133361cc48da11baf616ee", 14 * 2 ) == 0 );
03512         }
03513         FCT_TEST_END();
03514 #endif /* POLARSSL_SHA2_C */
03515 
03516 #ifdef POLARSSL_SHA2_C
03517 
03518         FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_2)
03519         {
03520             char md_name[100];
03521             unsigned char src_str[10000];
03522             unsigned char key_str[10000];
03523             unsigned char hash_str[10000];
03524             unsigned char output[100];
03525             int key_len, src_len;
03526             const md_info_t *md_info = NULL;
03527         
03528             memset(md_name, 0x00, 100);
03529             memset(src_str, 0x00, 10000);
03530             memset(key_str, 0x00, 10000);
03531             memset(hash_str, 0x00, 10000);
03532             memset(output, 0x00, 100);
03533         
03534             strncpy( (char *) md_name, "sha224", 100 );
03535             md_info = md_info_from_string( md_name );
03536             fct_chk( md_info != NULL );
03537         
03538             key_len = unhexify( key_str, "88e5258b55b1623385eb9632fa7c57d6" );
03539             src_len = unhexify( src_str, "ada76bb604be14326551701cf30e48a65eee80b44f0b9d4a07b1844543b7844a621097fdc99de57387458ae9354899b620d0617eabcaefa9eef3d413a33628054335ce656c26fa2986e0f111a6351096b283101ec7868871d770b370973c7405983f9756b3005a3eab492cfd0e7eb42e5c2e15fa6be8718c0a50acc4e5717230" );
03540         
03541             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03542             hexify( hash_str, output, md_get_size(md_info) );
03543         
03544             fct_chk( strncmp( (char *) hash_str, "81c783af538015cef3c60095df53", 14 * 2 ) == 0 );
03545         }
03546         FCT_TEST_END();
03547 #endif /* POLARSSL_SHA2_C */
03548 
03549 #ifdef POLARSSL_SHA2_C
03550 
03551         FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_3)
03552         {
03553             char md_name[100];
03554             unsigned char src_str[10000];
03555             unsigned char key_str[10000];
03556             unsigned char hash_str[10000];
03557             unsigned char output[100];
03558             int key_len, src_len;
03559             const md_info_t *md_info = NULL;
03560         
03561             memset(md_name, 0x00, 100);
03562             memset(src_str, 0x00, 10000);
03563             memset(key_str, 0x00, 10000);
03564             memset(hash_str, 0x00, 10000);
03565             memset(output, 0x00, 100);
03566         
03567             strncpy( (char *) md_name, "sha224", 100 );
03568             md_info = md_info_from_string( md_name );
03569             fct_chk( md_info != NULL );
03570         
03571             key_len = unhexify( key_str, "85d402d822114d31abf75526e2538705" );
03572             src_len = unhexify( src_str, "8020d8d98cc2e2298b32879c51c751e1dd5558fe2eabb8f158604297d6d072ce2261a1d6830b7cfe2617b57c7126f99c9476211d6161acd75d266da217ec8174b80484c9dc6f0448a0a036a3fc82e8bf54bdb71549368258d5d41f57978a4c266b92e8783ef66350215573d99be4089144b383ad8f3222bae8f3bf80ffb1bb2b" );
03573         
03574             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03575             hexify( hash_str, output, md_get_size(md_info) );
03576         
03577             fct_chk( strncmp( (char *) hash_str, "2aa0340ac9deafe3be38129daca0", 14 * 2 ) == 0 );
03578         }
03579         FCT_TEST_END();
03580 #endif /* POLARSSL_SHA2_C */
03581 
03582 #ifdef POLARSSL_SHA2_C
03583 
03584         FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_4)
03585         {
03586             char md_name[100];
03587             unsigned char src_str[10000];
03588             unsigned char key_str[10000];
03589             unsigned char hash_str[10000];
03590             unsigned char output[100];
03591             int key_len, src_len;
03592             const md_info_t *md_info = NULL;
03593         
03594             memset(md_name, 0x00, 100);
03595             memset(src_str, 0x00, 10000);
03596             memset(key_str, 0x00, 10000);
03597             memset(hash_str, 0x00, 10000);
03598             memset(output, 0x00, 100);
03599         
03600             strncpy( (char *) md_name, "sha224", 100 );
03601             md_info = md_info_from_string( md_name );
03602             fct_chk( md_info != NULL );
03603         
03604             key_len = unhexify( key_str, "545c6eecc5ee46fa17c59f91a94f81ae" );
03605             src_len = unhexify( src_str, "8fb7f3565593170152ddb2021874784e951977cfdd22f8b72a72a61320a8f2a35697b5e913f717805559b1af1861ee3ed42fb788481e4fd276b17bdbefcae7b4501dc5d20de5b7626dd5efdcd65294db4bdf682c33d9a9255c6435383fa5f1c886326a3acbc6bd50a33ab5b2dbb034ce0112d4e226bbcd57e3731a519aa1d784" );
03606         
03607             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03608             hexify( hash_str, output, md_get_size(md_info) );
03609         
03610             fct_chk( strncmp( (char *) hash_str, "3eb566eac54c4a3a9ef092469f24", 14 * 2 ) == 0 );
03611         }
03612         FCT_TEST_END();
03613 #endif /* POLARSSL_SHA2_C */
03614 
03615 #ifdef POLARSSL_SHA2_C
03616 
03617         FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_5)
03618         {
03619             char md_name[100];
03620             unsigned char src_str[10000];
03621             unsigned char key_str[10000];
03622             unsigned char hash_str[10000];
03623             unsigned char output[100];
03624             int key_len, src_len;
03625             const md_info_t *md_info = NULL;
03626         
03627             memset(md_name, 0x00, 100);
03628             memset(src_str, 0x00, 10000);
03629             memset(key_str, 0x00, 10000);
03630             memset(hash_str, 0x00, 10000);
03631             memset(output, 0x00, 100);
03632         
03633             strncpy( (char *) md_name, "sha224", 100 );
03634             md_info = md_info_from_string( md_name );
03635             fct_chk( md_info != NULL );
03636         
03637             key_len = unhexify( key_str, "4466ab4dc438841a9750c7f173dff02e" );
03638             src_len = unhexify( src_str, "2534c11c78c99cffaec8f722f04adc7045c7324d58ce98e37cfa94b6ed21ed7f58ce55379ef24b72d6d640ee9154f96c614734be9c408e225d7ba4cecc1179cc9f6e1808e1067aa8f244a99bd0c3267594c1887a40d167f8b7cf78db0d19f97b01fc50b8c86def490dfa7a5135002c33e71d77a8cce8ea0f93e0580439a33733" );
03639         
03640             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03641             hexify( hash_str, output, md_get_size(md_info) );
03642         
03643             fct_chk( strncmp( (char *) hash_str, "59f44a9bbed4875b892d22d6b5ab", 14 * 2 ) == 0 );
03644         }
03645         FCT_TEST_END();
03646 #endif /* POLARSSL_SHA2_C */
03647 
03648 #ifdef POLARSSL_SHA2_C
03649 
03650         FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_6)
03651         {
03652             char md_name[100];
03653             unsigned char src_str[10000];
03654             unsigned char key_str[10000];
03655             unsigned char hash_str[10000];
03656             unsigned char output[100];
03657             int key_len, src_len;
03658             const md_info_t *md_info = NULL;
03659         
03660             memset(md_name, 0x00, 100);
03661             memset(src_str, 0x00, 10000);
03662             memset(key_str, 0x00, 10000);
03663             memset(hash_str, 0x00, 10000);
03664             memset(output, 0x00, 100);
03665         
03666             strncpy( (char *) md_name, "sha224", 100 );
03667             md_info = md_info_from_string( md_name );
03668             fct_chk( md_info != NULL );
03669         
03670             key_len = unhexify( key_str, "0e3dd9bb5e4cf0f09a4c11600af56d8d" );
03671             src_len = unhexify( src_str, "f4589fa76c328ea25cf8bae582026ba40a59d45a546ff31cf80eb826088f69bb954c452c74586836416dee90a5255bc5d56d3b405b3705a5197045688b32fa984c3a3dfbdc9c2460a0b5e6312a624048bb6f170306535e9b371a3ab134a2642a230ad03d2c688cca80baeaee9a20e1d4c548b1cede29c6a45bf4df2c8c476f1a" );
03672         
03673             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03674             hexify( hash_str, output, md_get_size(md_info) );
03675         
03676             fct_chk( strncmp( (char *) hash_str, "12175b93e3da4c58217145e4dc0a1cf142fab9319bb501e037b350ba", 28 * 2 ) == 0 );
03677         }
03678         FCT_TEST_END();
03679 #endif /* POLARSSL_SHA2_C */
03680 
03681 #ifdef POLARSSL_SHA2_C
03682 
03683         FCT_TEST_BGN(generic_hmac_sha_224_test_vector_nist_cavs_7)
03684         {
03685             char md_name[100];
03686             unsigned char src_str[10000];
03687             unsigned char key_str[10000];
03688             unsigned char hash_str[10000];
03689             unsigned char output[100];
03690             int key_len, src_len;
03691             const md_info_t *md_info = NULL;
03692         
03693             memset(md_name, 0x00, 100);
03694             memset(src_str, 0x00, 10000);
03695             memset(key_str, 0x00, 10000);
03696             memset(hash_str, 0x00, 10000);
03697             memset(output, 0x00, 100);
03698         
03699             strncpy( (char *) md_name, "sha224", 100 );
03700             md_info = md_info_from_string( md_name );
03701             fct_chk( md_info != NULL );
03702         
03703             key_len = unhexify( key_str, "cda5187b0c5dcb0f8e5a8beed2306584" );
03704             src_len = unhexify( src_str, "9011ae29b44c49b347487ce972965f16ade3c15be0856ce9c853a9739dba07e4f20d594ddc1dfe21560a65a4e458cfa17745575b915a30c7a9412ff8d1d689db9680dd2428c27588bb0dc92d2cd9445fe8f44b840a197c52c3c4333fff45533945134398df6436513cfab06c924046b8c795a5bd92e8d5f2de85bf306f2eed67" );
03705         
03706             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03707             hexify( hash_str, output, md_get_size(md_info) );
03708         
03709             fct_chk( strncmp( (char *) hash_str, "4aaba92b40e2a600feab176eb9b292d814864195c03342aad6f67f08", 28 * 2 ) == 0 );
03710         }
03711         FCT_TEST_END();
03712 #endif /* POLARSSL_SHA2_C */
03713 
03714 #ifdef POLARSSL_SHA2_C
03715 
03716         FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_1)
03717         {
03718             char md_name[100];
03719             unsigned char src_str[10000];
03720             unsigned char key_str[10000];
03721             unsigned char hash_str[10000];
03722             unsigned char output[100];
03723             int key_len, src_len;
03724             const md_info_t *md_info = NULL;
03725         
03726             memset(md_name, 0x00, 100);
03727             memset(src_str, 0x00, 10000);
03728             memset(key_str, 0x00, 10000);
03729             memset(hash_str, 0x00, 10000);
03730             memset(output, 0x00, 100);
03731         
03732             strncpy( (char *) md_name, "sha256", 100 );
03733             md_info = md_info_from_string( md_name );
03734             fct_chk( md_info != NULL );
03735         
03736             key_len = unhexify( key_str, "cdffd34e6b16fdc0" );
03737             src_len = unhexify( src_str, "d83e78b99ab61709608972b36e76a575603db742269cc5dd4e7d5ca7816e26b65151c92632550cb4c5253c885d5fce53bc47459a1dbd5652786c4aac0145a532f12c05138af04cbb558101a7af5df478834c2146594dd73690d01a4fe72545894335f427ac70204798068cb86c5a600b40b414ede23590b41e1192373df84fe3" );
03738         
03739             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03740             hexify( hash_str, output, md_get_size(md_info) );
03741         
03742             fct_chk( strncmp( (char *) hash_str, "c6f0dde266cb4a26d41e8259d33499cc", 16 * 2 ) == 0 );
03743         }
03744         FCT_TEST_END();
03745 #endif /* POLARSSL_SHA2_C */
03746 
03747 #ifdef POLARSSL_SHA2_C
03748 
03749         FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_2)
03750         {
03751             char md_name[100];
03752             unsigned char src_str[10000];
03753             unsigned char key_str[10000];
03754             unsigned char hash_str[10000];
03755             unsigned char output[100];
03756             int key_len, src_len;
03757             const md_info_t *md_info = NULL;
03758         
03759             memset(md_name, 0x00, 100);
03760             memset(src_str, 0x00, 10000);
03761             memset(key_str, 0x00, 10000);
03762             memset(hash_str, 0x00, 10000);
03763             memset(output, 0x00, 100);
03764         
03765             strncpy( (char *) md_name, "sha256", 100 );
03766             md_info = md_info_from_string( md_name );
03767             fct_chk( md_info != NULL );
03768         
03769             key_len = unhexify( key_str, "6d97bb5892245be2" );
03770             src_len = unhexify( src_str, "13c2b391d59c0252ca5d2302beaaf88c4bcd779bb505ad9a122003dfae4cc123ad2bd036f225c4f040021a6b9fb8bd6f0281cf2e2631a732bdc71693cc42ef6d52b6c6912a9ef77b3274eb85ad7f965ae6ed44ac1721962a884ec7acfb4534b1488b1c0c45afa4dae8da1eb7b0a88a3240365d7e4e7d826abbde9f9203fd99d7" );
03771         
03772             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03773             hexify( hash_str, output, md_get_size(md_info) );
03774         
03775             fct_chk( strncmp( (char *) hash_str, "31588e241b015319a5ab8c4527296498", 16 * 2 ) == 0 );
03776         }
03777         FCT_TEST_END();
03778 #endif /* POLARSSL_SHA2_C */
03779 
03780 #ifdef POLARSSL_SHA2_C
03781 
03782         FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_3)
03783         {
03784             char md_name[100];
03785             unsigned char src_str[10000];
03786             unsigned char key_str[10000];
03787             unsigned char hash_str[10000];
03788             unsigned char output[100];
03789             int key_len, src_len;
03790             const md_info_t *md_info = NULL;
03791         
03792             memset(md_name, 0x00, 100);
03793             memset(src_str, 0x00, 10000);
03794             memset(key_str, 0x00, 10000);
03795             memset(hash_str, 0x00, 10000);
03796             memset(output, 0x00, 100);
03797         
03798             strncpy( (char *) md_name, "sha256", 100 );
03799             md_info = md_info_from_string( md_name );
03800             fct_chk( md_info != NULL );
03801         
03802             key_len = unhexify( key_str, "3c7fc8a70b49007a" );
03803             src_len = unhexify( src_str, "60024e428a39c8b8bb2e9591bad9dc2115dfbfd716b6eb7af30a6eb34560caccbbfa47b710fa8d523aca71e9e5ba10fc1feb1a43556d71f07ea4f33496f093044e8caf1d02b79e46eb1288d5964a7a7494f6b92574c35784eece054c6151281d80822f7d47b8231c35d07f5cb5cf4310ddc844845a01c6bfab514c048eccaf9f" );
03804         
03805             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03806             hexify( hash_str, output, md_get_size(md_info) );
03807         
03808             fct_chk( strncmp( (char *) hash_str, "1c98c94a32bec9f253c21070f82f8438", 16 * 2 ) == 0 );
03809         }
03810         FCT_TEST_END();
03811 #endif /* POLARSSL_SHA2_C */
03812 
03813 #ifdef POLARSSL_SHA2_C
03814 
03815         FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_4)
03816         {
03817             char md_name[100];
03818             unsigned char src_str[10000];
03819             unsigned char key_str[10000];
03820             unsigned char hash_str[10000];
03821             unsigned char output[100];
03822             int key_len, src_len;
03823             const md_info_t *md_info = NULL;
03824         
03825             memset(md_name, 0x00, 100);
03826             memset(src_str, 0x00, 10000);
03827             memset(key_str, 0x00, 10000);
03828             memset(hash_str, 0x00, 10000);
03829             memset(output, 0x00, 100);
03830         
03831             strncpy( (char *) md_name, "sha256", 100 );
03832             md_info = md_info_from_string( md_name );
03833             fct_chk( md_info != NULL );
03834         
03835             key_len = unhexify( key_str, "369f33f85b927a07" );
03836             src_len = unhexify( src_str, "ae8e2a94ca386d448cbacdb0e9040ae3cb297c296363052cc157455da29a0c95897315fc11e3f12b81e2418da1ec280bccbc00e847584ce9d14deeba7b3c9b8dba958b04bba37551f6c9ba9c060be1a4b8cf43aa62e5078b76c6512c5619b71a6a7cf5727180e1ff14f5a1a3c1691bf8b6ebad365c151e58d749d57adb3a4986" );
03837         
03838             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03839             hexify( hash_str, output, md_get_size(md_info) );
03840         
03841             fct_chk( strncmp( (char *) hash_str, "60b90383286533d309de46593e6ce39fc51fb00a8d88278c", 24 * 2 ) == 0 );
03842         }
03843         FCT_TEST_END();
03844 #endif /* POLARSSL_SHA2_C */
03845 
03846 #ifdef POLARSSL_SHA2_C
03847 
03848         FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_5)
03849         {
03850             char md_name[100];
03851             unsigned char src_str[10000];
03852             unsigned char key_str[10000];
03853             unsigned char hash_str[10000];
03854             unsigned char output[100];
03855             int key_len, src_len;
03856             const md_info_t *md_info = NULL;
03857         
03858             memset(md_name, 0x00, 100);
03859             memset(src_str, 0x00, 10000);
03860             memset(key_str, 0x00, 10000);
03861             memset(hash_str, 0x00, 10000);
03862             memset(output, 0x00, 100);
03863         
03864             strncpy( (char *) md_name, "sha256", 100 );
03865             md_info = md_info_from_string( md_name );
03866             fct_chk( md_info != NULL );
03867         
03868             key_len = unhexify( key_str, "e5179687582b4dc4" );
03869             src_len = unhexify( src_str, "ce103bdacdf32f614f6727bcb31ca1c2824a850d00f5585b016fb234fe1ef2cd687f302d3c6b738ed89a24060d65c36675d0d96307c72ef3e8a83bfa8402e226de9d5d1724ba75c4879bf41a4a465ce61887d9f49a34757849b48bae81c27ebed76faae2ad669bca04747d409148d40812776e0ae2c395b3cb9c89981ce72d5c" );
03870         
03871             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03872             hexify( hash_str, output, md_get_size(md_info) );
03873         
03874             fct_chk( strncmp( (char *) hash_str, "509581f6816df4b8cc9f2cf42b7cc6e6a5a1e375a16f2412", 24 * 2 ) == 0 );
03875         }
03876         FCT_TEST_END();
03877 #endif /* POLARSSL_SHA2_C */
03878 
03879 #ifdef POLARSSL_SHA2_C
03880 
03881         FCT_TEST_BGN(generic_hmac_sha_256_test_vector_nist_cavs_6)
03882         {
03883             char md_name[100];
03884             unsigned char src_str[10000];
03885             unsigned char key_str[10000];
03886             unsigned char hash_str[10000];
03887             unsigned char output[100];
03888             int key_len, src_len;
03889             const md_info_t *md_info = NULL;
03890         
03891             memset(md_name, 0x00, 100);
03892             memset(src_str, 0x00, 10000);
03893             memset(key_str, 0x00, 10000);
03894             memset(hash_str, 0x00, 10000);
03895             memset(output, 0x00, 100);
03896         
03897             strncpy( (char *) md_name, "sha256", 100 );
03898             md_info = md_info_from_string( md_name );
03899             fct_chk( md_info != NULL );
03900         
03901             key_len = unhexify( key_str, "63cec6246aeb1b61" );
03902             src_len = unhexify( src_str, "c178db908a405fa88aa255b8cad22b4057016585f139ee930388b083d86062fa0b3ea1f23f8a43bd11bee8464bcbd19b5ab9f6a8038d5245516f8274d20c8ee3033a07b908da528fa00343bb595deed500cab9745c4cb6391c23300f0d3584b090b3326c4cfa342620b78f9f5b4f27f7307ed770643ec1764aeae3dcf1a3ec69" );
03903         
03904             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03905             hexify( hash_str, output, md_get_size(md_info) );
03906         
03907             fct_chk( strncmp( (char *) hash_str, "64f3dd861b7c7d29fce9ae0ce9ed954b5d7141806ee9eec7", 24 * 2 ) == 0 );
03908         }
03909         FCT_TEST_END();
03910 #endif /* POLARSSL_SHA2_C */
03911 
03912 #ifdef POLARSSL_SHA4_C
03913 
03914         FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_1)
03915         {
03916             char md_name[100];
03917             unsigned char src_str[10000];
03918             unsigned char key_str[10000];
03919             unsigned char hash_str[10000];
03920             unsigned char output[100];
03921             int key_len, src_len;
03922             const md_info_t *md_info = NULL;
03923         
03924             memset(md_name, 0x00, 100);
03925             memset(src_str, 0x00, 10000);
03926             memset(key_str, 0x00, 10000);
03927             memset(hash_str, 0x00, 10000);
03928             memset(output, 0x00, 100);
03929         
03930             strncpy( (char *) md_name, "sha384", 100 );
03931             md_info = md_info_from_string( md_name );
03932             fct_chk( md_info != NULL );
03933         
03934             key_len = unhexify( key_str, "91a7401817386948ca952f9a20ee55dc" );
03935             src_len = unhexify( src_str, "2fea5b91035d6d501f3a834fa178bff4e64b99a8450432dafd32e4466b0e1e7781166f8a73f7e036b3b0870920f559f47bd1400a1a906e85e0dcf00a6c26862e9148b23806680f285f1fe4f93cdaf924c181a965465739c14f2268c8be8b471847c74b222577a1310bcdc1a85ef1468aa1a3fd4031213c97324b7509c9050a3d" );
03936         
03937             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03938             hexify( hash_str, output, md_get_size(md_info) );
03939         
03940             fct_chk( strncmp( (char *) hash_str, "6d7be9490058cf413cc09fd043c224c2ec4fa7859b13783000a9a593c9f75838", 32 * 2 ) == 0 );
03941         }
03942         FCT_TEST_END();
03943 #endif /* POLARSSL_SHA4_C */
03944 
03945 #ifdef POLARSSL_SHA4_C
03946 
03947         FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_2)
03948         {
03949             char md_name[100];
03950             unsigned char src_str[10000];
03951             unsigned char key_str[10000];
03952             unsigned char hash_str[10000];
03953             unsigned char output[100];
03954             int key_len, src_len;
03955             const md_info_t *md_info = NULL;
03956         
03957             memset(md_name, 0x00, 100);
03958             memset(src_str, 0x00, 10000);
03959             memset(key_str, 0x00, 10000);
03960             memset(hash_str, 0x00, 10000);
03961             memset(output, 0x00, 100);
03962         
03963             strncpy( (char *) md_name, "sha384", 100 );
03964             md_info = md_info_from_string( md_name );
03965             fct_chk( md_info != NULL );
03966         
03967             key_len = unhexify( key_str, "d6cac19657061aa90a6da11cd2e9ea47" );
03968             src_len = unhexify( src_str, "9f482e4655173135dfaa22a11bbbe6af263db48716406c5aec162ba3c4b41cad4f5a91558377521191c7343118beee65982929802913d67b6de5c4bdc3d27299bd722219d5ad2efa5bdb9ff7b229fc4bbc3f60719320cf2e7a51cad1133d21bad2d80919b1836ef825308b7c51c6b7677ac782e2bc30007afba065681cbdd215" );
03969         
03970             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
03971             hexify( hash_str, output, md_get_size(md_info) );
03972         
03973             fct_chk( strncmp( (char *) hash_str, "f3d5f3c008175321aa7b2ea379eaa4f8b9dcc60f895ec8940b8162f80a7dfe9f", 32 * 2 ) == 0 );
03974         }
03975         FCT_TEST_END();
03976 #endif /* POLARSSL_SHA4_C */
03977 
03978 #ifdef POLARSSL_SHA4_C
03979 
03980         FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_3)
03981         {
03982             char md_name[100];
03983             unsigned char src_str[10000];
03984             unsigned char key_str[10000];
03985             unsigned char hash_str[10000];
03986             unsigned char output[100];
03987             int key_len, src_len;
03988             const md_info_t *md_info = NULL;
03989         
03990             memset(md_name, 0x00, 100);
03991             memset(src_str, 0x00, 10000);
03992             memset(key_str, 0x00, 10000);
03993             memset(hash_str, 0x00, 10000);
03994             memset(output, 0x00, 100);
03995         
03996             strncpy( (char *) md_name, "sha384", 100 );
03997             md_info = md_info_from_string( md_name );
03998             fct_chk( md_info != NULL );
03999         
04000             key_len = unhexify( key_str, "e06366ad149b8442cd4c1abdddd0afde" );
04001             src_len = unhexify( src_str, "2d140a194c02a5598f69174834679b8371234a0d505491f1bd03e128dd91a8bca2fb812e9d5da71613b5b00952ea78bf450d5b7547dea79135925085c7d3e6f52009c51ca3d88c6c09e9d074b0ee110736e0ec9b478b93efb34d7bf1c41b54decec43eab077a3aa4998ede53f67b4ea36c266745f9643d5360bdc8337c70dabf" );
04002         
04003             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04004             hexify( hash_str, output, md_get_size(md_info) );
04005         
04006             fct_chk( strncmp( (char *) hash_str, "c19c67eda6fe29f3667bee1c897c333ce7683094ae77e84b4c16378d290895a1", 32 * 2 ) == 0 );
04007         }
04008         FCT_TEST_END();
04009 #endif /* POLARSSL_SHA4_C */
04010 
04011 #ifdef POLARSSL_SHA4_C
04012 
04013         FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_4)
04014         {
04015             char md_name[100];
04016             unsigned char src_str[10000];
04017             unsigned char key_str[10000];
04018             unsigned char hash_str[10000];
04019             unsigned char output[100];
04020             int key_len, src_len;
04021             const md_info_t *md_info = NULL;
04022         
04023             memset(md_name, 0x00, 100);
04024             memset(src_str, 0x00, 10000);
04025             memset(key_str, 0x00, 10000);
04026             memset(hash_str, 0x00, 10000);
04027             memset(output, 0x00, 100);
04028         
04029             strncpy( (char *) md_name, "sha384", 100 );
04030             md_info = md_info_from_string( md_name );
04031             fct_chk( md_info != NULL );
04032         
04033             key_len = unhexify( key_str, "01ac59f42f8bb91d1bd10fe6990d7a87" );
04034             src_len = unhexify( src_str, "3caf18c476edd5615f343ac7b7d3a9da9efade755672d5ba4b8ae8a7505539ea2c124ff755ec0457fbe49e43480b3c71e7f4742ec3693aad115d039f90222b030fdc9440313691716d5302005808c07627483b916fdf61983063c2eb1268f2deeef42fc790334456bc6bad256e31fc9066de7cc7e43d1321b1866db45e905622" );
04035         
04036             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04037             hexify( hash_str, output, md_get_size(md_info) );
04038         
04039             fct_chk( strncmp( (char *) hash_str, "1985fa2163a5943fc5d92f1fe8831215e7e91f0bff5332bc713a072bdb3a8f9e5c5157463a3bfeb36231416e65973e64", 48 * 2 ) == 0 );
04040         }
04041         FCT_TEST_END();
04042 #endif /* POLARSSL_SHA4_C */
04043 
04044 #ifdef POLARSSL_SHA4_C
04045 
04046         FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_5)
04047         {
04048             char md_name[100];
04049             unsigned char src_str[10000];
04050             unsigned char key_str[10000];
04051             unsigned char hash_str[10000];
04052             unsigned char output[100];
04053             int key_len, src_len;
04054             const md_info_t *md_info = NULL;
04055         
04056             memset(md_name, 0x00, 100);
04057             memset(src_str, 0x00, 10000);
04058             memset(key_str, 0x00, 10000);
04059             memset(hash_str, 0x00, 10000);
04060             memset(output, 0x00, 100);
04061         
04062             strncpy( (char *) md_name, "sha384", 100 );
04063             md_info = md_info_from_string( md_name );
04064             fct_chk( md_info != NULL );
04065         
04066             key_len = unhexify( key_str, "fd74b9d9e102a3a80df1baf0cb35bace" );
04067             src_len = unhexify( src_str, "1a068917584813d1689ccbd0370c2114d537cdc8cc52bf6db16d5535f8f7d1ad0c850a9fa0cf62373ffbf7642b1f1e8164010d350721d798d9f99e9724830399c2fce26377e83d38845675457865c03d4a07d741a505ef028343eb29fd46d0f761f3792886998c1e5c32ac3bc7e6f08faed194b34f06eff4d5d4a5b42c481e0e" );
04068         
04069             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04070             hexify( hash_str, output, md_get_size(md_info) );
04071         
04072             fct_chk( strncmp( (char *) hash_str, "a981eaf5de3d78b20ebd4414a4edd0657e3667cd808a0dbc430cf7252f73a5b24efa136039207bd59806897457d74e0c", 48 * 2 ) == 0 );
04073         }
04074         FCT_TEST_END();
04075 #endif /* POLARSSL_SHA4_C */
04076 
04077 #ifdef POLARSSL_SHA4_C
04078 
04079         FCT_TEST_BGN(generic_hmac_sha_384_test_vector_nist_cavs_5)
04080         {
04081             char md_name[100];
04082             unsigned char src_str[10000];
04083             unsigned char key_str[10000];
04084             unsigned char hash_str[10000];
04085             unsigned char output[100];
04086             int key_len, src_len;
04087             const md_info_t *md_info = NULL;
04088         
04089             memset(md_name, 0x00, 100);
04090             memset(src_str, 0x00, 10000);
04091             memset(key_str, 0x00, 10000);
04092             memset(hash_str, 0x00, 10000);
04093             memset(output, 0x00, 100);
04094         
04095             strncpy( (char *) md_name, "sha384", 100 );
04096             md_info = md_info_from_string( md_name );
04097             fct_chk( md_info != NULL );
04098         
04099             key_len = unhexify( key_str, "9fe794f0e26b669fa5f6883149377c6c" );
04100             src_len = unhexify( src_str, "6010c9745e8f1d44cfdc99e7e0fd79bc4271944c2d1d84dba589073dfc4ca5eb98c59356f60cd87bef28aeb83a832bde339b2087daf942aa1f67876c5d5ed33924bed4143bc12a2be532ccaf64daa7e2bc3c8872b9823b0533b6f5159135effe8c61545536975d7c3a61ba7365ec35f165bc92b4d19eb9156ade17dfa1bb4161" );
04101         
04102             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04103             hexify( hash_str, output, md_get_size(md_info) );
04104         
04105             fct_chk( strncmp( (char *) hash_str, "915ae61f8754698c2b6ef9629e93441f8541bd4258a5e05372d19136cfaefc0473b48d96119291b38eb1a3cb1982a986", 48 * 2 ) == 0 );
04106         }
04107         FCT_TEST_END();
04108 #endif /* POLARSSL_SHA4_C */
04109 
04110 #ifdef POLARSSL_SHA4_C
04111 
04112         FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_1)
04113         {
04114             char md_name[100];
04115             unsigned char src_str[10000];
04116             unsigned char key_str[10000];
04117             unsigned char hash_str[10000];
04118             unsigned char output[100];
04119             int key_len, src_len;
04120             const md_info_t *md_info = NULL;
04121         
04122             memset(md_name, 0x00, 100);
04123             memset(src_str, 0x00, 10000);
04124             memset(key_str, 0x00, 10000);
04125             memset(hash_str, 0x00, 10000);
04126             memset(output, 0x00, 100);
04127         
04128             strncpy( (char *) md_name, "sha512", 100 );
04129             md_info = md_info_from_string( md_name );
04130             fct_chk( md_info != NULL );
04131         
04132             key_len = unhexify( key_str, "c95a17c09940a691ed2d621571b0eb844ede55a9" );
04133             src_len = unhexify( src_str, "99cd28262e81f34878cdcebf4128e05e2098a7009278a66f4c785784d0e5678f3f2b22f86e982d273b6273a222ec61750b4556d766f1550a7aedfe83faedbc4bdae83fa560d62df17eb914d05fdaa48940551bac81d700f5fca7147295e386e8120d66742ec65c6ee8d89a92217a0f6266d0ddc60bb20ef679ae8299c8502c2f" );
04134         
04135             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04136             hexify( hash_str, output, md_get_size(md_info) );
04137         
04138             fct_chk( strncmp( (char *) hash_str, "6bc1379d156559ddee2ed420ea5d5c5ff3e454a1059b7ba72c350e77b6e9333c", 32 * 2 ) == 0 );
04139         }
04140         FCT_TEST_END();
04141 #endif /* POLARSSL_SHA4_C */
04142 
04143 #ifdef POLARSSL_SHA4_C
04144 
04145         FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_2)
04146         {
04147             char md_name[100];
04148             unsigned char src_str[10000];
04149             unsigned char key_str[10000];
04150             unsigned char hash_str[10000];
04151             unsigned char output[100];
04152             int key_len, src_len;
04153             const md_info_t *md_info = NULL;
04154         
04155             memset(md_name, 0x00, 100);
04156             memset(src_str, 0x00, 10000);
04157             memset(key_str, 0x00, 10000);
04158             memset(hash_str, 0x00, 10000);
04159             memset(output, 0x00, 100);
04160         
04161             strncpy( (char *) md_name, "sha512", 100 );
04162             md_info = md_info_from_string( md_name );
04163             fct_chk( md_info != NULL );
04164         
04165             key_len = unhexify( key_str, "3b10b8fa718840d1dea8e9fc317476bcf55875fd" );
04166             src_len = unhexify( src_str, "f04f5b7073d7d0274e8354433b390306c5607632f5f589c12edb62d55673aff2366d2e6b24de731adf92e654baa30b1cfd4a069788f65ec1b99b015d904d8832110dbd74eae35a81562d14ce4136d820ad0a55ff5489ba678fbbc1c27663ec1349d70e740f0e0ec27cfbe8971819f4789e486b50a2d7271d77e2aaea50de62fd" );
04167         
04168             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04169             hexify( hash_str, output, md_get_size(md_info) );
04170         
04171             fct_chk( strncmp( (char *) hash_str, "fc3c38c7a17e3ce06db033f1c172866f01a00045db55f2e234f71c82264f2ba2", 32 * 2 ) == 0 );
04172         }
04173         FCT_TEST_END();
04174 #endif /* POLARSSL_SHA4_C */
04175 
04176 #ifdef POLARSSL_SHA4_C
04177 
04178         FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_3)
04179         {
04180             char md_name[100];
04181             unsigned char src_str[10000];
04182             unsigned char key_str[10000];
04183             unsigned char hash_str[10000];
04184             unsigned char output[100];
04185             int key_len, src_len;
04186             const md_info_t *md_info = NULL;
04187         
04188             memset(md_name, 0x00, 100);
04189             memset(src_str, 0x00, 10000);
04190             memset(key_str, 0x00, 10000);
04191             memset(hash_str, 0x00, 10000);
04192             memset(output, 0x00, 100);
04193         
04194             strncpy( (char *) md_name, "sha512", 100 );
04195             md_info = md_info_from_string( md_name );
04196             fct_chk( md_info != NULL );
04197         
04198             key_len = unhexify( key_str, "4803d311394600dc1e0d8fc8cedeb8bde3fe7c42" );
04199             src_len = unhexify( src_str, "a10c125dd702a97153ad923ba5e9889cfac1ba169de370debe51f233735aa6effcc9785c4b5c7e48c477dc5c411ae6a959118584e26adc94b42c2b29b046f3cf01c65b24a24bd2e620bdf650a23bb4a72655b1100d7ce9a4dab697c6379754b4396c825de4b9eb73f2e6a6c0d0353bbdeaf706612800e137b858fdb30f3311c6" );
04200         
04201             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04202             hexify( hash_str, output, md_get_size(md_info) );
04203         
04204             fct_chk( strncmp( (char *) hash_str, "7cd8236c55102e6385f52279506df6fcc388ab75092da21395ce14a82b202ffa", 32 * 2 ) == 0 );
04205         }
04206         FCT_TEST_END();
04207 #endif /* POLARSSL_SHA4_C */
04208 
04209 #ifdef POLARSSL_SHA4_C
04210 
04211         FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_4)
04212         {
04213             char md_name[100];
04214             unsigned char src_str[10000];
04215             unsigned char key_str[10000];
04216             unsigned char hash_str[10000];
04217             unsigned char output[100];
04218             int key_len, src_len;
04219             const md_info_t *md_info = NULL;
04220         
04221             memset(md_name, 0x00, 100);
04222             memset(src_str, 0x00, 10000);
04223             memset(key_str, 0x00, 10000);
04224             memset(hash_str, 0x00, 10000);
04225             memset(output, 0x00, 100);
04226         
04227             strncpy( (char *) md_name, "sha512", 100 );
04228             md_info = md_info_from_string( md_name );
04229             fct_chk( md_info != NULL );
04230         
04231             key_len = unhexify( key_str, "aeb2f3b977fa6c8e71e07c5a5c74ff58166de092" );
04232             src_len = unhexify( src_str, "22457355dc76095abd46846b41cfe49a06ce42ac8857b4702fc771508dfb3626e0bfe851df897a07b36811ec433766e4b4166c26301b3493e7440d4554b0ef6ac20f1a530e58fac8aeba4e9ff2d4898d8a28783b49cd269c2965fd7f8e4f2d60cf1e5284f2495145b72382aad90e153a90ecae125ad75336fb128825c23fb8b0" );
04233         
04234             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04235             hexify( hash_str, output, md_get_size(md_info) );
04236         
04237             fct_chk( strncmp( (char *) hash_str, "fa39bd8fcc3bfa218f9dea5d3b2ce10a7619e31678a56d8a9d927b1fe703b125af445debe9a89a07db6194d27b44d85a", 48 * 2 ) == 0 );
04238         }
04239         FCT_TEST_END();
04240 #endif /* POLARSSL_SHA4_C */
04241 
04242 #ifdef POLARSSL_SHA4_C
04243 
04244         FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_5)
04245         {
04246             char md_name[100];
04247             unsigned char src_str[10000];
04248             unsigned char key_str[10000];
04249             unsigned char hash_str[10000];
04250             unsigned char output[100];
04251             int key_len, src_len;
04252             const md_info_t *md_info = NULL;
04253         
04254             memset(md_name, 0x00, 100);
04255             memset(src_str, 0x00, 10000);
04256             memset(key_str, 0x00, 10000);
04257             memset(hash_str, 0x00, 10000);
04258             memset(output, 0x00, 100);
04259         
04260             strncpy( (char *) md_name, "sha512", 100 );
04261             md_info = md_info_from_string( md_name );
04262             fct_chk( md_info != NULL );
04263         
04264             key_len = unhexify( key_str, "4285d3d7744da52775bb44ca436a3154f7980309" );
04265             src_len = unhexify( src_str, "208f0b6f2de2e5aa5df11927ddc6df485edc1193181c484d0f0a434a95418803101d4de9fdb798f93516a6916fa38a8207de1666fe50fe3441c03b112eaaae6954ed063f7ac4e3c1e3f73b20d153fe9e4857f5e91430f0a70ee820529adac2467469fd18adf10e2af0fea27c0abc83c5a9af77c364a466cffce8bab4e2b70bc1" );
04266         
04267             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04268             hexify( hash_str, output, md_get_size(md_info) );
04269         
04270             fct_chk( strncmp( (char *) hash_str, "fe7603f205b2774fe0f14ecfa3e338e90608a806d11ca459dff5ce36b1b264ecd3af5f0492a7521d8da3102ba20927a5", 48 * 2 ) == 0 );
04271         }
04272         FCT_TEST_END();
04273 #endif /* POLARSSL_SHA4_C */
04274 
04275 #ifdef POLARSSL_SHA4_C
04276 
04277         FCT_TEST_BGN(generic_hmac_sha_512_test_vector_nist_cavs_6)
04278         {
04279             char md_name[100];
04280             unsigned char src_str[10000];
04281             unsigned char key_str[10000];
04282             unsigned char hash_str[10000];
04283             unsigned char output[100];
04284             int key_len, src_len;
04285             const md_info_t *md_info = NULL;
04286         
04287             memset(md_name, 0x00, 100);
04288             memset(src_str, 0x00, 10000);
04289             memset(key_str, 0x00, 10000);
04290             memset(hash_str, 0x00, 10000);
04291             memset(output, 0x00, 100);
04292         
04293             strncpy( (char *) md_name, "sha512", 100 );
04294             md_info = md_info_from_string( md_name );
04295             fct_chk( md_info != NULL );
04296         
04297             key_len = unhexify( key_str, "8ab783d5acf32efa0d9c0a21abce955e96630d89" );
04298             src_len = unhexify( src_str, "17371e013dce839963d54418e97be4bd9fa3cb2a368a5220f5aa1b8aaddfa3bdefc91afe7c717244fd2fb640f5cb9d9bf3e25f7f0c8bc758883b89dcdce6d749d9672fed222277ece3e84b3ec01b96f70c125fcb3cbee6d19b8ef0873f915f173bdb05d81629ba187cc8ac1934b2f75952fb7616ae6bd812946df694bd2763af" );
04299         
04300             fct_chk ( md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 );
04301             hexify( hash_str, output, md_get_size(md_info) );
04302         
04303             fct_chk( strncmp( (char *) hash_str, "9ac7ca8d1aefc166b046e4cf7602ebe181a0e5055474bff5b342106731da0d7e48e4d87bc0a6f05871574289a1b099f8", 48 * 2 ) == 0 );
04304         }
04305         FCT_TEST_END();
04306 #endif /* POLARSSL_SHA4_C */
04307 
04308 #ifdef POLARSSL_SHA1_C
04309 
04310         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_1)
04311         {
04312             char md_name[100];
04313             unsigned char src_str[10000];
04314             unsigned char key_str[10000];
04315             unsigned char hash_str[10000];
04316             unsigned char output[100];
04317             int key_len, src_len;
04318             const md_info_t *md_info = NULL;
04319             md_context_t ctx = MD_CONTEXT_T_INIT;
04320         
04321             memset(md_name, 0x00, 100);
04322             memset(src_str, 0x00, 10000);
04323             memset(key_str, 0x00, 10000);
04324             memset(hash_str, 0x00, 10000);
04325             memset(output, 0x00, 100);
04326         
04327             strncpy( (char *) md_name, "sha1", 100 );
04328             md_info = md_info_from_string( md_name );
04329             fct_chk( md_info != NULL );
04330             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04331         
04332             key_len = unhexify( key_str, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f" );
04333             src_len = unhexify( src_str, "53616d706c65202331" );
04334         
04335             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04336             fct_chk ( ctx.md_ctx != NULL );
04337             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04338             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04339             fct_chk ( 0 == md_free_ctx( &ctx ) );
04340             
04341             hexify( hash_str, output, md_get_size(md_info) );
04342         
04343             fct_chk( strncmp( (char *) hash_str, "4f4ca3d5d68ba7cc0a1208c9c61e9c5da0403c0a", 20 * 2 ) == 0 );
04344         }
04345         FCT_TEST_END();
04346 #endif /* POLARSSL_SHA1_C */
04347 
04348 #ifdef POLARSSL_SHA1_C
04349 
04350         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_2)
04351         {
04352             char md_name[100];
04353             unsigned char src_str[10000];
04354             unsigned char key_str[10000];
04355             unsigned char hash_str[10000];
04356             unsigned char output[100];
04357             int key_len, src_len;
04358             const md_info_t *md_info = NULL;
04359             md_context_t ctx = MD_CONTEXT_T_INIT;
04360         
04361             memset(md_name, 0x00, 100);
04362             memset(src_str, 0x00, 10000);
04363             memset(key_str, 0x00, 10000);
04364             memset(hash_str, 0x00, 10000);
04365             memset(output, 0x00, 100);
04366         
04367             strncpy( (char *) md_name, "sha1", 100 );
04368             md_info = md_info_from_string( md_name );
04369             fct_chk( md_info != NULL );
04370             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04371         
04372             key_len = unhexify( key_str, "303132333435363738393a3b3c3d3e3f40414243" );
04373             src_len = unhexify( src_str, "53616d706c65202332" );
04374         
04375             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04376             fct_chk ( ctx.md_ctx != NULL );
04377             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04378             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04379             fct_chk ( 0 == md_free_ctx( &ctx ) );
04380             
04381             hexify( hash_str, output, md_get_size(md_info) );
04382         
04383             fct_chk( strncmp( (char *) hash_str, "0922d3405faa3d194f82a45830737d5cc6c75d24", 20 * 2 ) == 0 );
04384         }
04385         FCT_TEST_END();
04386 #endif /* POLARSSL_SHA1_C */
04387 
04388 #ifdef POLARSSL_SHA1_C
04389 
04390         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_3)
04391         {
04392             char md_name[100];
04393             unsigned char src_str[10000];
04394             unsigned char key_str[10000];
04395             unsigned char hash_str[10000];
04396             unsigned char output[100];
04397             int key_len, src_len;
04398             const md_info_t *md_info = NULL;
04399             md_context_t ctx = MD_CONTEXT_T_INIT;
04400         
04401             memset(md_name, 0x00, 100);
04402             memset(src_str, 0x00, 10000);
04403             memset(key_str, 0x00, 10000);
04404             memset(hash_str, 0x00, 10000);
04405             memset(output, 0x00, 100);
04406         
04407             strncpy( (char *) md_name, "sha1", 100 );
04408             md_info = md_info_from_string( md_name );
04409             fct_chk( md_info != NULL );
04410             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04411         
04412             key_len = unhexify( key_str, "505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3" );
04413             src_len = unhexify( src_str, "53616d706c65202333" );
04414         
04415             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04416             fct_chk ( ctx.md_ctx != NULL );
04417             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04418             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04419             fct_chk ( 0 == md_free_ctx( &ctx ) );
04420             
04421             hexify( hash_str, output, md_get_size(md_info) );
04422         
04423             fct_chk( strncmp( (char *) hash_str, "bcf41eab8bb2d802f3d05caf7cb092ecf8d1a3aa", 20 * 2 ) == 0 );
04424         }
04425         FCT_TEST_END();
04426 #endif /* POLARSSL_SHA1_C */
04427 
04428 #ifdef POLARSSL_SHA1_C
04429 
04430         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_fips_198a_4)
04431         {
04432             char md_name[100];
04433             unsigned char src_str[10000];
04434             unsigned char key_str[10000];
04435             unsigned char hash_str[10000];
04436             unsigned char output[100];
04437             int key_len, src_len;
04438             const md_info_t *md_info = NULL;
04439             md_context_t ctx = MD_CONTEXT_T_INIT;
04440         
04441             memset(md_name, 0x00, 100);
04442             memset(src_str, 0x00, 10000);
04443             memset(key_str, 0x00, 10000);
04444             memset(hash_str, 0x00, 10000);
04445             memset(output, 0x00, 100);
04446         
04447             strncpy( (char *) md_name, "sha1", 100 );
04448             md_info = md_info_from_string( md_name );
04449             fct_chk( md_info != NULL );
04450             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04451         
04452             key_len = unhexify( key_str, "707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0" );
04453             src_len = unhexify( src_str, "53616d706c65202334" );
04454         
04455             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04456             fct_chk ( ctx.md_ctx != NULL );
04457             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04458             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04459             fct_chk ( 0 == md_free_ctx( &ctx ) );
04460             
04461             hexify( hash_str, output, md_get_size(md_info) );
04462         
04463             fct_chk( strncmp( (char *) hash_str, "9ea886efe268dbecce420c75", 12 * 2 ) == 0 );
04464         }
04465         FCT_TEST_END();
04466 #endif /* POLARSSL_SHA1_C */
04467 
04468 #ifdef POLARSSL_SHA1_C
04469 
04470         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_1)
04471         {
04472             char md_name[100];
04473             unsigned char src_str[10000];
04474             unsigned char key_str[10000];
04475             unsigned char hash_str[10000];
04476             unsigned char output[100];
04477             int key_len, src_len;
04478             const md_info_t *md_info = NULL;
04479             md_context_t ctx = MD_CONTEXT_T_INIT;
04480         
04481             memset(md_name, 0x00, 100);
04482             memset(src_str, 0x00, 10000);
04483             memset(key_str, 0x00, 10000);
04484             memset(hash_str, 0x00, 10000);
04485             memset(output, 0x00, 100);
04486         
04487             strncpy( (char *) md_name, "sha1", 100 );
04488             md_info = md_info_from_string( md_name );
04489             fct_chk( md_info != NULL );
04490             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04491         
04492             key_len = unhexify( key_str, "7b10f4124b15c82e" );
04493             src_len = unhexify( src_str, "27dcb5b1daf60cfd3e2f73d4d64ca9c684f8bf71fc682a46793b1790afa4feb100ca7aaff26f58f0e1d0ed42f1cdad1f474afa2e79d53a0c42892c4d7b327cbe46b295ed8da3b6ecab3d4851687a6f812b79df2f6b20f11f6706f5301790ca99625aad7391d84f78043d2a0a239b1477984c157bbc9276064e7a1a406b0612ca" );
04494         
04495             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04496             fct_chk ( ctx.md_ctx != NULL );
04497             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04498             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04499             fct_chk ( 0 == md_free_ctx( &ctx ) );
04500             
04501             hexify( hash_str, output, md_get_size(md_info) );
04502         
04503             fct_chk( strncmp( (char *) hash_str, "4ead12c2fe3d6ea43acb", 10 * 2 ) == 0 );
04504         }
04505         FCT_TEST_END();
04506 #endif /* POLARSSL_SHA1_C */
04507 
04508 #ifdef POLARSSL_SHA1_C
04509 
04510         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_2)
04511         {
04512             char md_name[100];
04513             unsigned char src_str[10000];
04514             unsigned char key_str[10000];
04515             unsigned char hash_str[10000];
04516             unsigned char output[100];
04517             int key_len, src_len;
04518             const md_info_t *md_info = NULL;
04519             md_context_t ctx = MD_CONTEXT_T_INIT;
04520         
04521             memset(md_name, 0x00, 100);
04522             memset(src_str, 0x00, 10000);
04523             memset(key_str, 0x00, 10000);
04524             memset(hash_str, 0x00, 10000);
04525             memset(output, 0x00, 100);
04526         
04527             strncpy( (char *) md_name, "sha1", 100 );
04528             md_info = md_info_from_string( md_name );
04529             fct_chk( md_info != NULL );
04530             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04531         
04532             key_len = unhexify( key_str, "4fe9fb902172a21b" );
04533             src_len = unhexify( src_str, "4ceb3a7c13659c22fe51134f03dce4c239d181b63c6b0b59d367157fd05cab98384f92dfa482d2d5e78e72eef1b1838af4696026c54233d484ecbbe87f904df5546419f8567eafd232e6c2fcd3ee2b7682c63000524b078dbb2096f585007deae752562df1fe3b01278089e16f3be46e2d0f7cabac2d8e6cc02a2d0ca953425f" );
04534         
04535             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04536             fct_chk ( ctx.md_ctx != NULL );
04537             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04538             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04539             fct_chk ( 0 == md_free_ctx( &ctx ) );
04540             
04541             hexify( hash_str, output, md_get_size(md_info) );
04542         
04543             fct_chk( strncmp( (char *) hash_str, "564428a67be1924b5793", 10 * 2 ) == 0 );
04544         }
04545         FCT_TEST_END();
04546 #endif /* POLARSSL_SHA1_C */
04547 
04548 #ifdef POLARSSL_SHA1_C
04549 
04550         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_3)
04551         {
04552             char md_name[100];
04553             unsigned char src_str[10000];
04554             unsigned char key_str[10000];
04555             unsigned char hash_str[10000];
04556             unsigned char output[100];
04557             int key_len, src_len;
04558             const md_info_t *md_info = NULL;
04559             md_context_t ctx = MD_CONTEXT_T_INIT;
04560         
04561             memset(md_name, 0x00, 100);
04562             memset(src_str, 0x00, 10000);
04563             memset(key_str, 0x00, 10000);
04564             memset(hash_str, 0x00, 10000);
04565             memset(output, 0x00, 100);
04566         
04567             strncpy( (char *) md_name, "sha1", 100 );
04568             md_info = md_info_from_string( md_name );
04569             fct_chk( md_info != NULL );
04570             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04571         
04572             key_len = unhexify( key_str, "d1f01455f78c4fb4" );
04573             src_len = unhexify( src_str, "00d40f67b57914bec456a3e3201ef1464be319a8d188c02e157af4b54f9b5a66d67f898a9bdbb19ff63a80aba6f246d013575721d52eb1b47a65def884011c49b257bcc2817fc853f106e8138ce386d7a5ac3103de0a3fa0ed6bb7af9ff66ebd1cc46fb86e4da0013d20a3c2dcd8fb828a4b70f7f104b41bf3f44682a66497ea" );
04574         
04575             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04576             fct_chk ( ctx.md_ctx != NULL );
04577             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04578             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04579             fct_chk ( 0 == md_free_ctx( &ctx ) );
04580             
04581             hexify( hash_str, output, md_get_size(md_info) );
04582         
04583             fct_chk( strncmp( (char *) hash_str, "56a665a7cdfe610f9fc5", 10 * 2 ) == 0 );
04584         }
04585         FCT_TEST_END();
04586 #endif /* POLARSSL_SHA1_C */
04587 
04588 #ifdef POLARSSL_SHA1_C
04589 
04590         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_4)
04591         {
04592             char md_name[100];
04593             unsigned char src_str[10000];
04594             unsigned char key_str[10000];
04595             unsigned char hash_str[10000];
04596             unsigned char output[100];
04597             int key_len, src_len;
04598             const md_info_t *md_info = NULL;
04599             md_context_t ctx = MD_CONTEXT_T_INIT;
04600         
04601             memset(md_name, 0x00, 100);
04602             memset(src_str, 0x00, 10000);
04603             memset(key_str, 0x00, 10000);
04604             memset(hash_str, 0x00, 10000);
04605             memset(output, 0x00, 100);
04606         
04607             strncpy( (char *) md_name, "sha1", 100 );
04608             md_info = md_info_from_string( md_name );
04609             fct_chk( md_info != NULL );
04610             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04611         
04612             key_len = unhexify( key_str, "4e5ef77fdf033a5b" );
04613             src_len = unhexify( src_str, "e59326464e3201d195e29f2a3446ec1b1c9ff31154e2a4d0e40ed466f1bc855d29f76835624fa0127d29c9b1915939a046f385af7e5d47a23ba91f28bd22f811ea258dbbf3332bcd3543b8285d5df41bd064ffd64a341c22c4edb44f9c8d9e6df0c59dbf4a052a6c83da7478e179a6f3839c6870ff8ca8b9497f9ac1d725fdda" );
04614         
04615             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04616             fct_chk ( ctx.md_ctx != NULL );
04617             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04618             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04619             fct_chk ( 0 == md_free_ctx( &ctx ) );
04620             
04621             hexify( hash_str, output, md_get_size(md_info) );
04622         
04623             fct_chk( strncmp( (char *) hash_str, "981c0a7a8423b63a8fa6", 10 * 2 ) == 0 );
04624         }
04625         FCT_TEST_END();
04626 #endif /* POLARSSL_SHA1_C */
04627 
04628 #ifdef POLARSSL_SHA1_C
04629 
04630         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_5)
04631         {
04632             char md_name[100];
04633             unsigned char src_str[10000];
04634             unsigned char key_str[10000];
04635             unsigned char hash_str[10000];
04636             unsigned char output[100];
04637             int key_len, src_len;
04638             const md_info_t *md_info = NULL;
04639             md_context_t ctx = MD_CONTEXT_T_INIT;
04640         
04641             memset(md_name, 0x00, 100);
04642             memset(src_str, 0x00, 10000);
04643             memset(key_str, 0x00, 10000);
04644             memset(hash_str, 0x00, 10000);
04645             memset(output, 0x00, 100);
04646         
04647             strncpy( (char *) md_name, "sha1", 100 );
04648             md_info = md_info_from_string( md_name );
04649             fct_chk( md_info != NULL );
04650             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04651         
04652             key_len = unhexify( key_str, "bcd9ff8aa60be2be" );
04653             src_len = unhexify( src_str, "51be4d0eb37bab714f92e19e9d70390655b363e8cd346a748245e731f437759cb8206412c8dab2ef1d4f36f880f41ff69d949da4594fdecb65e23cac1329b59e69e29bf875b38c31df6fa546c595f35cc2192aa750679a8a51a65e00e839d73a8d8c598a610d237fbe78955213589d80efcb73b95b8586f96d17b6f51a71c3b8" );
04654         
04655             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04656             fct_chk ( ctx.md_ctx != NULL );
04657             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04658             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04659             fct_chk ( 0 == md_free_ctx( &ctx ) );
04660             
04661             hexify( hash_str, output, md_get_size(md_info) );
04662         
04663             fct_chk( strncmp( (char *) hash_str, "84633f9f5040c8971478", 10 * 2 ) == 0 );
04664         }
04665         FCT_TEST_END();
04666 #endif /* POLARSSL_SHA1_C */
04667 
04668 #ifdef POLARSSL_SHA1_C
04669 
04670         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_6)
04671         {
04672             char md_name[100];
04673             unsigned char src_str[10000];
04674             unsigned char key_str[10000];
04675             unsigned char hash_str[10000];
04676             unsigned char output[100];
04677             int key_len, src_len;
04678             const md_info_t *md_info = NULL;
04679             md_context_t ctx = MD_CONTEXT_T_INIT;
04680         
04681             memset(md_name, 0x00, 100);
04682             memset(src_str, 0x00, 10000);
04683             memset(key_str, 0x00, 10000);
04684             memset(hash_str, 0x00, 10000);
04685             memset(output, 0x00, 100);
04686         
04687             strncpy( (char *) md_name, "sha1", 100 );
04688             md_info = md_info_from_string( md_name );
04689             fct_chk( md_info != NULL );
04690             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04691         
04692             key_len = unhexify( key_str, "4a661bce6ed86d21" );
04693             src_len = unhexify( src_str, "5ff6c744f1aab1bc29697d71f67541b8b3cec3c7079183b10a83fb98a9ee251d4bac3e1cb581ca972aaed8efd7c2875a6fb4c991132f67c9742d45e53bc7e8eaa94b35b37a907be61086b426cd11088ac118934e85d968c9667fd69fc6f6ea38c0fe34710b7ece91211b9b7ea00acd31f022aa6726368f9928a1352f122233f1" );
04694         
04695             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04696             fct_chk ( ctx.md_ctx != NULL );
04697             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04698             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04699             fct_chk ( 0 == md_free_ctx( &ctx ) );
04700             
04701             hexify( hash_str, output, md_get_size(md_info) );
04702         
04703             fct_chk( strncmp( (char *) hash_str, "739df59353ac6694e55e", 10 * 2 ) == 0 );
04704         }
04705         FCT_TEST_END();
04706 #endif /* POLARSSL_SHA1_C */
04707 
04708 #ifdef POLARSSL_SHA1_C
04709 
04710         FCT_TEST_BGN(generic_multi_step_hmac_sha_1_test_vector_nist_cavs_7)
04711         {
04712             char md_name[100];
04713             unsigned char src_str[10000];
04714             unsigned char key_str[10000];
04715             unsigned char hash_str[10000];
04716             unsigned char output[100];
04717             int key_len, src_len;
04718             const md_info_t *md_info = NULL;
04719             md_context_t ctx = MD_CONTEXT_T_INIT;
04720         
04721             memset(md_name, 0x00, 100);
04722             memset(src_str, 0x00, 10000);
04723             memset(key_str, 0x00, 10000);
04724             memset(hash_str, 0x00, 10000);
04725             memset(output, 0x00, 100);
04726         
04727             strncpy( (char *) md_name, "sha1", 100 );
04728             md_info = md_info_from_string( md_name );
04729             fct_chk( md_info != NULL );
04730             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04731         
04732             key_len = unhexify( key_str, "1287e1565a57b547" );
04733             src_len = unhexify( src_str, "390ffdccc6171c11568d85b8f913e019bf4cd982ca9cd21ea730d41bdf3fcc0bc88ff48ba13a8f23deb2d96ec1033e7b2a58ca72b0c1e17bf03330db25d1e360fa6918009c4294bd1215b5ccd159a8f58bc3dc3d490eb7c3b9f887e8c98dbbb274a75373dcb695a59abd0219529d88518a96f92abc0bbcbda985c388f1fbbcc9" );
04734         
04735             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04736             fct_chk ( ctx.md_ctx != NULL );
04737             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04738             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04739             fct_chk ( 0 == md_free_ctx( &ctx ) );
04740             
04741             hexify( hash_str, output, md_get_size(md_info) );
04742         
04743             fct_chk( strncmp( (char *) hash_str, "d78ddf08077c7d9e2ba6", 10 * 2 ) == 0 );
04744         }
04745         FCT_TEST_END();
04746 #endif /* POLARSSL_SHA1_C */
04747 
04748 #ifdef POLARSSL_SHA2_C
04749 
04750         FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_1)
04751         {
04752             char md_name[100];
04753             unsigned char src_str[10000];
04754             unsigned char key_str[10000];
04755             unsigned char hash_str[10000];
04756             unsigned char output[100];
04757             int key_len, src_len;
04758             const md_info_t *md_info = NULL;
04759             md_context_t ctx = MD_CONTEXT_T_INIT;
04760         
04761             memset(md_name, 0x00, 100);
04762             memset(src_str, 0x00, 10000);
04763             memset(key_str, 0x00, 10000);
04764             memset(hash_str, 0x00, 10000);
04765             memset(output, 0x00, 100);
04766         
04767             strncpy( (char *) md_name, "sha224", 100 );
04768             md_info = md_info_from_string( md_name );
04769             fct_chk( md_info != NULL );
04770             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04771         
04772             key_len = unhexify( key_str, "e055eb756697ee573fd3214811a9f7fa" );
04773             src_len = unhexify( src_str, "3875847012ee42fe54a0027bdf38cca7021b83a2ed0503af69ef6c37c637bc1114fba40096c5947d736e19b7af3c68d95a4e3b8b073adbbb80f47e9db8f2d4f0018ddd847fabfdf9dd9b52c93e40458977725f6b7ba15f0816bb895cdf50401268f5d702b7e6a5f9faef57b8768c8a3fc14f9a4b3182b41d940e337d219b29ff" );
04774         
04775             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04776             fct_chk ( ctx.md_ctx != NULL );
04777             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04778             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04779             fct_chk ( 0 == md_free_ctx( &ctx ) );
04780             
04781             hexify( hash_str, output, md_get_size(md_info) );
04782         
04783             fct_chk( strncmp( (char *) hash_str, "40a453133361cc48da11baf616ee", 14 * 2 ) == 0 );
04784         }
04785         FCT_TEST_END();
04786 #endif /* POLARSSL_SHA2_C */
04787 
04788 #ifdef POLARSSL_SHA2_C
04789 
04790         FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_2)
04791         {
04792             char md_name[100];
04793             unsigned char src_str[10000];
04794             unsigned char key_str[10000];
04795             unsigned char hash_str[10000];
04796             unsigned char output[100];
04797             int key_len, src_len;
04798             const md_info_t *md_info = NULL;
04799             md_context_t ctx = MD_CONTEXT_T_INIT;
04800         
04801             memset(md_name, 0x00, 100);
04802             memset(src_str, 0x00, 10000);
04803             memset(key_str, 0x00, 10000);
04804             memset(hash_str, 0x00, 10000);
04805             memset(output, 0x00, 100);
04806         
04807             strncpy( (char *) md_name, "sha224", 100 );
04808             md_info = md_info_from_string( md_name );
04809             fct_chk( md_info != NULL );
04810             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04811         
04812             key_len = unhexify( key_str, "88e5258b55b1623385eb9632fa7c57d6" );
04813             src_len = unhexify( src_str, "ada76bb604be14326551701cf30e48a65eee80b44f0b9d4a07b1844543b7844a621097fdc99de57387458ae9354899b620d0617eabcaefa9eef3d413a33628054335ce656c26fa2986e0f111a6351096b283101ec7868871d770b370973c7405983f9756b3005a3eab492cfd0e7eb42e5c2e15fa6be8718c0a50acc4e5717230" );
04814         
04815             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04816             fct_chk ( ctx.md_ctx != NULL );
04817             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04818             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04819             fct_chk ( 0 == md_free_ctx( &ctx ) );
04820             
04821             hexify( hash_str, output, md_get_size(md_info) );
04822         
04823             fct_chk( strncmp( (char *) hash_str, "81c783af538015cef3c60095df53", 14 * 2 ) == 0 );
04824         }
04825         FCT_TEST_END();
04826 #endif /* POLARSSL_SHA2_C */
04827 
04828 #ifdef POLARSSL_SHA2_C
04829 
04830         FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_3)
04831         {
04832             char md_name[100];
04833             unsigned char src_str[10000];
04834             unsigned char key_str[10000];
04835             unsigned char hash_str[10000];
04836             unsigned char output[100];
04837             int key_len, src_len;
04838             const md_info_t *md_info = NULL;
04839             md_context_t ctx = MD_CONTEXT_T_INIT;
04840         
04841             memset(md_name, 0x00, 100);
04842             memset(src_str, 0x00, 10000);
04843             memset(key_str, 0x00, 10000);
04844             memset(hash_str, 0x00, 10000);
04845             memset(output, 0x00, 100);
04846         
04847             strncpy( (char *) md_name, "sha224", 100 );
04848             md_info = md_info_from_string( md_name );
04849             fct_chk( md_info != NULL );
04850             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04851         
04852             key_len = unhexify( key_str, "85d402d822114d31abf75526e2538705" );
04853             src_len = unhexify( src_str, "8020d8d98cc2e2298b32879c51c751e1dd5558fe2eabb8f158604297d6d072ce2261a1d6830b7cfe2617b57c7126f99c9476211d6161acd75d266da217ec8174b80484c9dc6f0448a0a036a3fc82e8bf54bdb71549368258d5d41f57978a4c266b92e8783ef66350215573d99be4089144b383ad8f3222bae8f3bf80ffb1bb2b" );
04854         
04855             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04856             fct_chk ( ctx.md_ctx != NULL );
04857             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04858             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04859             fct_chk ( 0 == md_free_ctx( &ctx ) );
04860             
04861             hexify( hash_str, output, md_get_size(md_info) );
04862         
04863             fct_chk( strncmp( (char *) hash_str, "2aa0340ac9deafe3be38129daca0", 14 * 2 ) == 0 );
04864         }
04865         FCT_TEST_END();
04866 #endif /* POLARSSL_SHA2_C */
04867 
04868 #ifdef POLARSSL_SHA2_C
04869 
04870         FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_4)
04871         {
04872             char md_name[100];
04873             unsigned char src_str[10000];
04874             unsigned char key_str[10000];
04875             unsigned char hash_str[10000];
04876             unsigned char output[100];
04877             int key_len, src_len;
04878             const md_info_t *md_info = NULL;
04879             md_context_t ctx = MD_CONTEXT_T_INIT;
04880         
04881             memset(md_name, 0x00, 100);
04882             memset(src_str, 0x00, 10000);
04883             memset(key_str, 0x00, 10000);
04884             memset(hash_str, 0x00, 10000);
04885             memset(output, 0x00, 100);
04886         
04887             strncpy( (char *) md_name, "sha224", 100 );
04888             md_info = md_info_from_string( md_name );
04889             fct_chk( md_info != NULL );
04890             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04891         
04892             key_len = unhexify( key_str, "545c6eecc5ee46fa17c59f91a94f81ae" );
04893             src_len = unhexify( src_str, "8fb7f3565593170152ddb2021874784e951977cfdd22f8b72a72a61320a8f2a35697b5e913f717805559b1af1861ee3ed42fb788481e4fd276b17bdbefcae7b4501dc5d20de5b7626dd5efdcd65294db4bdf682c33d9a9255c6435383fa5f1c886326a3acbc6bd50a33ab5b2dbb034ce0112d4e226bbcd57e3731a519aa1d784" );
04894         
04895             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04896             fct_chk ( ctx.md_ctx != NULL );
04897             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04898             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04899             fct_chk ( 0 == md_free_ctx( &ctx ) );
04900             
04901             hexify( hash_str, output, md_get_size(md_info) );
04902         
04903             fct_chk( strncmp( (char *) hash_str, "3eb566eac54c4a3a9ef092469f24", 14 * 2 ) == 0 );
04904         }
04905         FCT_TEST_END();
04906 #endif /* POLARSSL_SHA2_C */
04907 
04908 #ifdef POLARSSL_SHA2_C
04909 
04910         FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_5)
04911         {
04912             char md_name[100];
04913             unsigned char src_str[10000];
04914             unsigned char key_str[10000];
04915             unsigned char hash_str[10000];
04916             unsigned char output[100];
04917             int key_len, src_len;
04918             const md_info_t *md_info = NULL;
04919             md_context_t ctx = MD_CONTEXT_T_INIT;
04920         
04921             memset(md_name, 0x00, 100);
04922             memset(src_str, 0x00, 10000);
04923             memset(key_str, 0x00, 10000);
04924             memset(hash_str, 0x00, 10000);
04925             memset(output, 0x00, 100);
04926         
04927             strncpy( (char *) md_name, "sha224", 100 );
04928             md_info = md_info_from_string( md_name );
04929             fct_chk( md_info != NULL );
04930             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04931         
04932             key_len = unhexify( key_str, "4466ab4dc438841a9750c7f173dff02e" );
04933             src_len = unhexify( src_str, "2534c11c78c99cffaec8f722f04adc7045c7324d58ce98e37cfa94b6ed21ed7f58ce55379ef24b72d6d640ee9154f96c614734be9c408e225d7ba4cecc1179cc9f6e1808e1067aa8f244a99bd0c3267594c1887a40d167f8b7cf78db0d19f97b01fc50b8c86def490dfa7a5135002c33e71d77a8cce8ea0f93e0580439a33733" );
04934         
04935             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04936             fct_chk ( ctx.md_ctx != NULL );
04937             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04938             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04939             fct_chk ( 0 == md_free_ctx( &ctx ) );
04940             
04941             hexify( hash_str, output, md_get_size(md_info) );
04942         
04943             fct_chk( strncmp( (char *) hash_str, "59f44a9bbed4875b892d22d6b5ab", 14 * 2 ) == 0 );
04944         }
04945         FCT_TEST_END();
04946 #endif /* POLARSSL_SHA2_C */
04947 
04948 #ifdef POLARSSL_SHA2_C
04949 
04950         FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_6)
04951         {
04952             char md_name[100];
04953             unsigned char src_str[10000];
04954             unsigned char key_str[10000];
04955             unsigned char hash_str[10000];
04956             unsigned char output[100];
04957             int key_len, src_len;
04958             const md_info_t *md_info = NULL;
04959             md_context_t ctx = MD_CONTEXT_T_INIT;
04960         
04961             memset(md_name, 0x00, 100);
04962             memset(src_str, 0x00, 10000);
04963             memset(key_str, 0x00, 10000);
04964             memset(hash_str, 0x00, 10000);
04965             memset(output, 0x00, 100);
04966         
04967             strncpy( (char *) md_name, "sha224", 100 );
04968             md_info = md_info_from_string( md_name );
04969             fct_chk( md_info != NULL );
04970             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
04971         
04972             key_len = unhexify( key_str, "0e3dd9bb5e4cf0f09a4c11600af56d8d" );
04973             src_len = unhexify( src_str, "f4589fa76c328ea25cf8bae582026ba40a59d45a546ff31cf80eb826088f69bb954c452c74586836416dee90a5255bc5d56d3b405b3705a5197045688b32fa984c3a3dfbdc9c2460a0b5e6312a624048bb6f170306535e9b371a3ab134a2642a230ad03d2c688cca80baeaee9a20e1d4c548b1cede29c6a45bf4df2c8c476f1a" );
04974         
04975             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
04976             fct_chk ( ctx.md_ctx != NULL );
04977             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
04978             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
04979             fct_chk ( 0 == md_free_ctx( &ctx ) );
04980             
04981             hexify( hash_str, output, md_get_size(md_info) );
04982         
04983             fct_chk( strncmp( (char *) hash_str, "12175b93e3da4c58217145e4dc0a1cf142fab9319bb501e037b350ba", 28 * 2 ) == 0 );
04984         }
04985         FCT_TEST_END();
04986 #endif /* POLARSSL_SHA2_C */
04987 
04988 #ifdef POLARSSL_SHA2_C
04989 
04990         FCT_TEST_BGN(generic_multi_step_hmac_sha_224_test_vector_nist_cavs_7)
04991         {
04992             char md_name[100];
04993             unsigned char src_str[10000];
04994             unsigned char key_str[10000];
04995             unsigned char hash_str[10000];
04996             unsigned char output[100];
04997             int key_len, src_len;
04998             const md_info_t *md_info = NULL;
04999             md_context_t ctx = MD_CONTEXT_T_INIT;
05000         
05001             memset(md_name, 0x00, 100);
05002             memset(src_str, 0x00, 10000);
05003             memset(key_str, 0x00, 10000);
05004             memset(hash_str, 0x00, 10000);
05005             memset(output, 0x00, 100);
05006         
05007             strncpy( (char *) md_name, "sha224", 100 );
05008             md_info = md_info_from_string( md_name );
05009             fct_chk( md_info != NULL );
05010             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05011         
05012             key_len = unhexify( key_str, "cda5187b0c5dcb0f8e5a8beed2306584" );
05013             src_len = unhexify( src_str, "9011ae29b44c49b347487ce972965f16ade3c15be0856ce9c853a9739dba07e4f20d594ddc1dfe21560a65a4e458cfa17745575b915a30c7a9412ff8d1d689db9680dd2428c27588bb0dc92d2cd9445fe8f44b840a197c52c3c4333fff45533945134398df6436513cfab06c924046b8c795a5bd92e8d5f2de85bf306f2eed67" );
05014         
05015             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05016             fct_chk ( ctx.md_ctx != NULL );
05017             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05018             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05019             fct_chk ( 0 == md_free_ctx( &ctx ) );
05020             
05021             hexify( hash_str, output, md_get_size(md_info) );
05022         
05023             fct_chk( strncmp( (char *) hash_str, "4aaba92b40e2a600feab176eb9b292d814864195c03342aad6f67f08", 28 * 2 ) == 0 );
05024         }
05025         FCT_TEST_END();
05026 #endif /* POLARSSL_SHA2_C */
05027 
05028 #ifdef POLARSSL_SHA2_C
05029 
05030         FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_1)
05031         {
05032             char md_name[100];
05033             unsigned char src_str[10000];
05034             unsigned char key_str[10000];
05035             unsigned char hash_str[10000];
05036             unsigned char output[100];
05037             int key_len, src_len;
05038             const md_info_t *md_info = NULL;
05039             md_context_t ctx = MD_CONTEXT_T_INIT;
05040         
05041             memset(md_name, 0x00, 100);
05042             memset(src_str, 0x00, 10000);
05043             memset(key_str, 0x00, 10000);
05044             memset(hash_str, 0x00, 10000);
05045             memset(output, 0x00, 100);
05046         
05047             strncpy( (char *) md_name, "sha256", 100 );
05048             md_info = md_info_from_string( md_name );
05049             fct_chk( md_info != NULL );
05050             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05051         
05052             key_len = unhexify( key_str, "cdffd34e6b16fdc0" );
05053             src_len = unhexify( src_str, "d83e78b99ab61709608972b36e76a575603db742269cc5dd4e7d5ca7816e26b65151c92632550cb4c5253c885d5fce53bc47459a1dbd5652786c4aac0145a532f12c05138af04cbb558101a7af5df478834c2146594dd73690d01a4fe72545894335f427ac70204798068cb86c5a600b40b414ede23590b41e1192373df84fe3" );
05054         
05055             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05056             fct_chk ( ctx.md_ctx != NULL );
05057             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05058             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05059             fct_chk ( 0 == md_free_ctx( &ctx ) );
05060             
05061             hexify( hash_str, output, md_get_size(md_info) );
05062         
05063             fct_chk( strncmp( (char *) hash_str, "c6f0dde266cb4a26d41e8259d33499cc", 16 * 2 ) == 0 );
05064         }
05065         FCT_TEST_END();
05066 #endif /* POLARSSL_SHA2_C */
05067 
05068 #ifdef POLARSSL_SHA2_C
05069 
05070         FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_2)
05071         {
05072             char md_name[100];
05073             unsigned char src_str[10000];
05074             unsigned char key_str[10000];
05075             unsigned char hash_str[10000];
05076             unsigned char output[100];
05077             int key_len, src_len;
05078             const md_info_t *md_info = NULL;
05079             md_context_t ctx = MD_CONTEXT_T_INIT;
05080         
05081             memset(md_name, 0x00, 100);
05082             memset(src_str, 0x00, 10000);
05083             memset(key_str, 0x00, 10000);
05084             memset(hash_str, 0x00, 10000);
05085             memset(output, 0x00, 100);
05086         
05087             strncpy( (char *) md_name, "sha256", 100 );
05088             md_info = md_info_from_string( md_name );
05089             fct_chk( md_info != NULL );
05090             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05091         
05092             key_len = unhexify( key_str, "6d97bb5892245be2" );
05093             src_len = unhexify( src_str, "13c2b391d59c0252ca5d2302beaaf88c4bcd779bb505ad9a122003dfae4cc123ad2bd036f225c4f040021a6b9fb8bd6f0281cf2e2631a732bdc71693cc42ef6d52b6c6912a9ef77b3274eb85ad7f965ae6ed44ac1721962a884ec7acfb4534b1488b1c0c45afa4dae8da1eb7b0a88a3240365d7e4e7d826abbde9f9203fd99d7" );
05094         
05095             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05096             fct_chk ( ctx.md_ctx != NULL );
05097             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05098             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05099             fct_chk ( 0 == md_free_ctx( &ctx ) );
05100             
05101             hexify( hash_str, output, md_get_size(md_info) );
05102         
05103             fct_chk( strncmp( (char *) hash_str, "31588e241b015319a5ab8c4527296498", 16 * 2 ) == 0 );
05104         }
05105         FCT_TEST_END();
05106 #endif /* POLARSSL_SHA2_C */
05107 
05108 #ifdef POLARSSL_SHA2_C
05109 
05110         FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_3)
05111         {
05112             char md_name[100];
05113             unsigned char src_str[10000];
05114             unsigned char key_str[10000];
05115             unsigned char hash_str[10000];
05116             unsigned char output[100];
05117             int key_len, src_len;
05118             const md_info_t *md_info = NULL;
05119             md_context_t ctx = MD_CONTEXT_T_INIT;
05120         
05121             memset(md_name, 0x00, 100);
05122             memset(src_str, 0x00, 10000);
05123             memset(key_str, 0x00, 10000);
05124             memset(hash_str, 0x00, 10000);
05125             memset(output, 0x00, 100);
05126         
05127             strncpy( (char *) md_name, "sha256", 100 );
05128             md_info = md_info_from_string( md_name );
05129             fct_chk( md_info != NULL );
05130             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05131         
05132             key_len = unhexify( key_str, "3c7fc8a70b49007a" );
05133             src_len = unhexify( src_str, "60024e428a39c8b8bb2e9591bad9dc2115dfbfd716b6eb7af30a6eb34560caccbbfa47b710fa8d523aca71e9e5ba10fc1feb1a43556d71f07ea4f33496f093044e8caf1d02b79e46eb1288d5964a7a7494f6b92574c35784eece054c6151281d80822f7d47b8231c35d07f5cb5cf4310ddc844845a01c6bfab514c048eccaf9f" );
05134         
05135             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05136             fct_chk ( ctx.md_ctx != NULL );
05137             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05138             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05139             fct_chk ( 0 == md_free_ctx( &ctx ) );
05140             
05141             hexify( hash_str, output, md_get_size(md_info) );
05142         
05143             fct_chk( strncmp( (char *) hash_str, "1c98c94a32bec9f253c21070f82f8438", 16 * 2 ) == 0 );
05144         }
05145         FCT_TEST_END();
05146 #endif /* POLARSSL_SHA2_C */
05147 
05148 #ifdef POLARSSL_SHA2_C
05149 
05150         FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_4)
05151         {
05152             char md_name[100];
05153             unsigned char src_str[10000];
05154             unsigned char key_str[10000];
05155             unsigned char hash_str[10000];
05156             unsigned char output[100];
05157             int key_len, src_len;
05158             const md_info_t *md_info = NULL;
05159             md_context_t ctx = MD_CONTEXT_T_INIT;
05160         
05161             memset(md_name, 0x00, 100);
05162             memset(src_str, 0x00, 10000);
05163             memset(key_str, 0x00, 10000);
05164             memset(hash_str, 0x00, 10000);
05165             memset(output, 0x00, 100);
05166         
05167             strncpy( (char *) md_name, "sha256", 100 );
05168             md_info = md_info_from_string( md_name );
05169             fct_chk( md_info != NULL );
05170             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05171         
05172             key_len = unhexify( key_str, "369f33f85b927a07" );
05173             src_len = unhexify( src_str, "ae8e2a94ca386d448cbacdb0e9040ae3cb297c296363052cc157455da29a0c95897315fc11e3f12b81e2418da1ec280bccbc00e847584ce9d14deeba7b3c9b8dba958b04bba37551f6c9ba9c060be1a4b8cf43aa62e5078b76c6512c5619b71a6a7cf5727180e1ff14f5a1a3c1691bf8b6ebad365c151e58d749d57adb3a4986" );
05174         
05175             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05176             fct_chk ( ctx.md_ctx != NULL );
05177             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05178             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05179             fct_chk ( 0 == md_free_ctx( &ctx ) );
05180             
05181             hexify( hash_str, output, md_get_size(md_info) );
05182         
05183             fct_chk( strncmp( (char *) hash_str, "60b90383286533d309de46593e6ce39fc51fb00a8d88278c", 24 * 2 ) == 0 );
05184         }
05185         FCT_TEST_END();
05186 #endif /* POLARSSL_SHA2_C */
05187 
05188 #ifdef POLARSSL_SHA2_C
05189 
05190         FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_5)
05191         {
05192             char md_name[100];
05193             unsigned char src_str[10000];
05194             unsigned char key_str[10000];
05195             unsigned char hash_str[10000];
05196             unsigned char output[100];
05197             int key_len, src_len;
05198             const md_info_t *md_info = NULL;
05199             md_context_t ctx = MD_CONTEXT_T_INIT;
05200         
05201             memset(md_name, 0x00, 100);
05202             memset(src_str, 0x00, 10000);
05203             memset(key_str, 0x00, 10000);
05204             memset(hash_str, 0x00, 10000);
05205             memset(output, 0x00, 100);
05206         
05207             strncpy( (char *) md_name, "sha256", 100 );
05208             md_info = md_info_from_string( md_name );
05209             fct_chk( md_info != NULL );
05210             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05211         
05212             key_len = unhexify( key_str, "e5179687582b4dc4" );
05213             src_len = unhexify( src_str, "ce103bdacdf32f614f6727bcb31ca1c2824a850d00f5585b016fb234fe1ef2cd687f302d3c6b738ed89a24060d65c36675d0d96307c72ef3e8a83bfa8402e226de9d5d1724ba75c4879bf41a4a465ce61887d9f49a34757849b48bae81c27ebed76faae2ad669bca04747d409148d40812776e0ae2c395b3cb9c89981ce72d5c" );
05214         
05215             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05216             fct_chk ( ctx.md_ctx != NULL );
05217             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05218             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05219             fct_chk ( 0 == md_free_ctx( &ctx ) );
05220             
05221             hexify( hash_str, output, md_get_size(md_info) );
05222         
05223             fct_chk( strncmp( (char *) hash_str, "509581f6816df4b8cc9f2cf42b7cc6e6a5a1e375a16f2412", 24 * 2 ) == 0 );
05224         }
05225         FCT_TEST_END();
05226 #endif /* POLARSSL_SHA2_C */
05227 
05228 #ifdef POLARSSL_SHA2_C
05229 
05230         FCT_TEST_BGN(generic_multi_step_hmac_sha_256_test_vector_nist_cavs_6)
05231         {
05232             char md_name[100];
05233             unsigned char src_str[10000];
05234             unsigned char key_str[10000];
05235             unsigned char hash_str[10000];
05236             unsigned char output[100];
05237             int key_len, src_len;
05238             const md_info_t *md_info = NULL;
05239             md_context_t ctx = MD_CONTEXT_T_INIT;
05240         
05241             memset(md_name, 0x00, 100);
05242             memset(src_str, 0x00, 10000);
05243             memset(key_str, 0x00, 10000);
05244             memset(hash_str, 0x00, 10000);
05245             memset(output, 0x00, 100);
05246         
05247             strncpy( (char *) md_name, "sha256", 100 );
05248             md_info = md_info_from_string( md_name );
05249             fct_chk( md_info != NULL );
05250             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05251         
05252             key_len = unhexify( key_str, "63cec6246aeb1b61" );
05253             src_len = unhexify( src_str, "c178db908a405fa88aa255b8cad22b4057016585f139ee930388b083d86062fa0b3ea1f23f8a43bd11bee8464bcbd19b5ab9f6a8038d5245516f8274d20c8ee3033a07b908da528fa00343bb595deed500cab9745c4cb6391c23300f0d3584b090b3326c4cfa342620b78f9f5b4f27f7307ed770643ec1764aeae3dcf1a3ec69" );
05254         
05255             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05256             fct_chk ( ctx.md_ctx != NULL );
05257             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05258             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05259             fct_chk ( 0 == md_free_ctx( &ctx ) );
05260             
05261             hexify( hash_str, output, md_get_size(md_info) );
05262         
05263             fct_chk( strncmp( (char *) hash_str, "64f3dd861b7c7d29fce9ae0ce9ed954b5d7141806ee9eec7", 24 * 2 ) == 0 );
05264         }
05265         FCT_TEST_END();
05266 #endif /* POLARSSL_SHA2_C */
05267 
05268 #ifdef POLARSSL_SHA4_C
05269 
05270         FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_1)
05271         {
05272             char md_name[100];
05273             unsigned char src_str[10000];
05274             unsigned char key_str[10000];
05275             unsigned char hash_str[10000];
05276             unsigned char output[100];
05277             int key_len, src_len;
05278             const md_info_t *md_info = NULL;
05279             md_context_t ctx = MD_CONTEXT_T_INIT;
05280         
05281             memset(md_name, 0x00, 100);
05282             memset(src_str, 0x00, 10000);
05283             memset(key_str, 0x00, 10000);
05284             memset(hash_str, 0x00, 10000);
05285             memset(output, 0x00, 100);
05286         
05287             strncpy( (char *) md_name, "sha384", 100 );
05288             md_info = md_info_from_string( md_name );
05289             fct_chk( md_info != NULL );
05290             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05291         
05292             key_len = unhexify( key_str, "91a7401817386948ca952f9a20ee55dc" );
05293             src_len = unhexify( src_str, "2fea5b91035d6d501f3a834fa178bff4e64b99a8450432dafd32e4466b0e1e7781166f8a73f7e036b3b0870920f559f47bd1400a1a906e85e0dcf00a6c26862e9148b23806680f285f1fe4f93cdaf924c181a965465739c14f2268c8be8b471847c74b222577a1310bcdc1a85ef1468aa1a3fd4031213c97324b7509c9050a3d" );
05294         
05295             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05296             fct_chk ( ctx.md_ctx != NULL );
05297             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05298             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05299             fct_chk ( 0 == md_free_ctx( &ctx ) );
05300             
05301             hexify( hash_str, output, md_get_size(md_info) );
05302         
05303             fct_chk( strncmp( (char *) hash_str, "6d7be9490058cf413cc09fd043c224c2ec4fa7859b13783000a9a593c9f75838", 32 * 2 ) == 0 );
05304         }
05305         FCT_TEST_END();
05306 #endif /* POLARSSL_SHA4_C */
05307 
05308 #ifdef POLARSSL_SHA4_C
05309 
05310         FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_2)
05311         {
05312             char md_name[100];
05313             unsigned char src_str[10000];
05314             unsigned char key_str[10000];
05315             unsigned char hash_str[10000];
05316             unsigned char output[100];
05317             int key_len, src_len;
05318             const md_info_t *md_info = NULL;
05319             md_context_t ctx = MD_CONTEXT_T_INIT;
05320         
05321             memset(md_name, 0x00, 100);
05322             memset(src_str, 0x00, 10000);
05323             memset(key_str, 0x00, 10000);
05324             memset(hash_str, 0x00, 10000);
05325             memset(output, 0x00, 100);
05326         
05327             strncpy( (char *) md_name, "sha384", 100 );
05328             md_info = md_info_from_string( md_name );
05329             fct_chk( md_info != NULL );
05330             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05331         
05332             key_len = unhexify( key_str, "d6cac19657061aa90a6da11cd2e9ea47" );
05333             src_len = unhexify( src_str, "9f482e4655173135dfaa22a11bbbe6af263db48716406c5aec162ba3c4b41cad4f5a91558377521191c7343118beee65982929802913d67b6de5c4bdc3d27299bd722219d5ad2efa5bdb9ff7b229fc4bbc3f60719320cf2e7a51cad1133d21bad2d80919b1836ef825308b7c51c6b7677ac782e2bc30007afba065681cbdd215" );
05334         
05335             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05336             fct_chk ( ctx.md_ctx != NULL );
05337             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05338             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05339             fct_chk ( 0 == md_free_ctx( &ctx ) );
05340             
05341             hexify( hash_str, output, md_get_size(md_info) );
05342         
05343             fct_chk( strncmp( (char *) hash_str, "f3d5f3c008175321aa7b2ea379eaa4f8b9dcc60f895ec8940b8162f80a7dfe9f", 32 * 2 ) == 0 );
05344         }
05345         FCT_TEST_END();
05346 #endif /* POLARSSL_SHA4_C */
05347 
05348 #ifdef POLARSSL_SHA4_C
05349 
05350         FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_3)
05351         {
05352             char md_name[100];
05353             unsigned char src_str[10000];
05354             unsigned char key_str[10000];
05355             unsigned char hash_str[10000];
05356             unsigned char output[100];
05357             int key_len, src_len;
05358             const md_info_t *md_info = NULL;
05359             md_context_t ctx = MD_CONTEXT_T_INIT;
05360         
05361             memset(md_name, 0x00, 100);
05362             memset(src_str, 0x00, 10000);
05363             memset(key_str, 0x00, 10000);
05364             memset(hash_str, 0x00, 10000);
05365             memset(output, 0x00, 100);
05366         
05367             strncpy( (char *) md_name, "sha384", 100 );
05368             md_info = md_info_from_string( md_name );
05369             fct_chk( md_info != NULL );
05370             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05371         
05372             key_len = unhexify( key_str, "e06366ad149b8442cd4c1abdddd0afde" );
05373             src_len = unhexify( src_str, "2d140a194c02a5598f69174834679b8371234a0d505491f1bd03e128dd91a8bca2fb812e9d5da71613b5b00952ea78bf450d5b7547dea79135925085c7d3e6f52009c51ca3d88c6c09e9d074b0ee110736e0ec9b478b93efb34d7bf1c41b54decec43eab077a3aa4998ede53f67b4ea36c266745f9643d5360bdc8337c70dabf" );
05374         
05375             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05376             fct_chk ( ctx.md_ctx != NULL );
05377             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05378             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05379             fct_chk ( 0 == md_free_ctx( &ctx ) );
05380             
05381             hexify( hash_str, output, md_get_size(md_info) );
05382         
05383             fct_chk( strncmp( (char *) hash_str, "c19c67eda6fe29f3667bee1c897c333ce7683094ae77e84b4c16378d290895a1", 32 * 2 ) == 0 );
05384         }
05385         FCT_TEST_END();
05386 #endif /* POLARSSL_SHA4_C */
05387 
05388 #ifdef POLARSSL_SHA4_C
05389 
05390         FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_4)
05391         {
05392             char md_name[100];
05393             unsigned char src_str[10000];
05394             unsigned char key_str[10000];
05395             unsigned char hash_str[10000];
05396             unsigned char output[100];
05397             int key_len, src_len;
05398             const md_info_t *md_info = NULL;
05399             md_context_t ctx = MD_CONTEXT_T_INIT;
05400         
05401             memset(md_name, 0x00, 100);
05402             memset(src_str, 0x00, 10000);
05403             memset(key_str, 0x00, 10000);
05404             memset(hash_str, 0x00, 10000);
05405             memset(output, 0x00, 100);
05406         
05407             strncpy( (char *) md_name, "sha384", 100 );
05408             md_info = md_info_from_string( md_name );
05409             fct_chk( md_info != NULL );
05410             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05411         
05412             key_len = unhexify( key_str, "01ac59f42f8bb91d1bd10fe6990d7a87" );
05413             src_len = unhexify( src_str, "3caf18c476edd5615f343ac7b7d3a9da9efade755672d5ba4b8ae8a7505539ea2c124ff755ec0457fbe49e43480b3c71e7f4742ec3693aad115d039f90222b030fdc9440313691716d5302005808c07627483b916fdf61983063c2eb1268f2deeef42fc790334456bc6bad256e31fc9066de7cc7e43d1321b1866db45e905622" );
05414         
05415             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05416             fct_chk ( ctx.md_ctx != NULL );
05417             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05418             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05419             fct_chk ( 0 == md_free_ctx( &ctx ) );
05420             
05421             hexify( hash_str, output, md_get_size(md_info) );
05422         
05423             fct_chk( strncmp( (char *) hash_str, "1985fa2163a5943fc5d92f1fe8831215e7e91f0bff5332bc713a072bdb3a8f9e5c5157463a3bfeb36231416e65973e64", 48 * 2 ) == 0 );
05424         }
05425         FCT_TEST_END();
05426 #endif /* POLARSSL_SHA4_C */
05427 
05428 #ifdef POLARSSL_SHA4_C
05429 
05430         FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_5)
05431         {
05432             char md_name[100];
05433             unsigned char src_str[10000];
05434             unsigned char key_str[10000];
05435             unsigned char hash_str[10000];
05436             unsigned char output[100];
05437             int key_len, src_len;
05438             const md_info_t *md_info = NULL;
05439             md_context_t ctx = MD_CONTEXT_T_INIT;
05440         
05441             memset(md_name, 0x00, 100);
05442             memset(src_str, 0x00, 10000);
05443             memset(key_str, 0x00, 10000);
05444             memset(hash_str, 0x00, 10000);
05445             memset(output, 0x00, 100);
05446         
05447             strncpy( (char *) md_name, "sha384", 100 );
05448             md_info = md_info_from_string( md_name );
05449             fct_chk( md_info != NULL );
05450             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05451         
05452             key_len = unhexify( key_str, "fd74b9d9e102a3a80df1baf0cb35bace" );
05453             src_len = unhexify( src_str, "1a068917584813d1689ccbd0370c2114d537cdc8cc52bf6db16d5535f8f7d1ad0c850a9fa0cf62373ffbf7642b1f1e8164010d350721d798d9f99e9724830399c2fce26377e83d38845675457865c03d4a07d741a505ef028343eb29fd46d0f761f3792886998c1e5c32ac3bc7e6f08faed194b34f06eff4d5d4a5b42c481e0e" );
05454         
05455             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05456             fct_chk ( ctx.md_ctx != NULL );
05457             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05458             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05459             fct_chk ( 0 == md_free_ctx( &ctx ) );
05460             
05461             hexify( hash_str, output, md_get_size(md_info) );
05462         
05463             fct_chk( strncmp( (char *) hash_str, "a981eaf5de3d78b20ebd4414a4edd0657e3667cd808a0dbc430cf7252f73a5b24efa136039207bd59806897457d74e0c", 48 * 2 ) == 0 );
05464         }
05465         FCT_TEST_END();
05466 #endif /* POLARSSL_SHA4_C */
05467 
05468 #ifdef POLARSSL_SHA4_C
05469 
05470         FCT_TEST_BGN(generic_multi_step_hmac_sha_384_test_vector_nist_cavs_5)
05471         {
05472             char md_name[100];
05473             unsigned char src_str[10000];
05474             unsigned char key_str[10000];
05475             unsigned char hash_str[10000];
05476             unsigned char output[100];
05477             int key_len, src_len;
05478             const md_info_t *md_info = NULL;
05479             md_context_t ctx = MD_CONTEXT_T_INIT;
05480         
05481             memset(md_name, 0x00, 100);
05482             memset(src_str, 0x00, 10000);
05483             memset(key_str, 0x00, 10000);
05484             memset(hash_str, 0x00, 10000);
05485             memset(output, 0x00, 100);
05486         
05487             strncpy( (char *) md_name, "sha384", 100 );
05488             md_info = md_info_from_string( md_name );
05489             fct_chk( md_info != NULL );
05490             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05491         
05492             key_len = unhexify( key_str, "9fe794f0e26b669fa5f6883149377c6c" );
05493             src_len = unhexify( src_str, "6010c9745e8f1d44cfdc99e7e0fd79bc4271944c2d1d84dba589073dfc4ca5eb98c59356f60cd87bef28aeb83a832bde339b2087daf942aa1f67876c5d5ed33924bed4143bc12a2be532ccaf64daa7e2bc3c8872b9823b0533b6f5159135effe8c61545536975d7c3a61ba7365ec35f165bc92b4d19eb9156ade17dfa1bb4161" );
05494         
05495             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05496             fct_chk ( ctx.md_ctx != NULL );
05497             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05498             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05499             fct_chk ( 0 == md_free_ctx( &ctx ) );
05500             
05501             hexify( hash_str, output, md_get_size(md_info) );
05502         
05503             fct_chk( strncmp( (char *) hash_str, "915ae61f8754698c2b6ef9629e93441f8541bd4258a5e05372d19136cfaefc0473b48d96119291b38eb1a3cb1982a986", 48 * 2 ) == 0 );
05504         }
05505         FCT_TEST_END();
05506 #endif /* POLARSSL_SHA4_C */
05507 
05508 #ifdef POLARSSL_SHA4_C
05509 
05510         FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_1)
05511         {
05512             char md_name[100];
05513             unsigned char src_str[10000];
05514             unsigned char key_str[10000];
05515             unsigned char hash_str[10000];
05516             unsigned char output[100];
05517             int key_len, src_len;
05518             const md_info_t *md_info = NULL;
05519             md_context_t ctx = MD_CONTEXT_T_INIT;
05520         
05521             memset(md_name, 0x00, 100);
05522             memset(src_str, 0x00, 10000);
05523             memset(key_str, 0x00, 10000);
05524             memset(hash_str, 0x00, 10000);
05525             memset(output, 0x00, 100);
05526         
05527             strncpy( (char *) md_name, "sha512", 100 );
05528             md_info = md_info_from_string( md_name );
05529             fct_chk( md_info != NULL );
05530             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05531         
05532             key_len = unhexify( key_str, "c95a17c09940a691ed2d621571b0eb844ede55a9" );
05533             src_len = unhexify( src_str, "99cd28262e81f34878cdcebf4128e05e2098a7009278a66f4c785784d0e5678f3f2b22f86e982d273b6273a222ec61750b4556d766f1550a7aedfe83faedbc4bdae83fa560d62df17eb914d05fdaa48940551bac81d700f5fca7147295e386e8120d66742ec65c6ee8d89a92217a0f6266d0ddc60bb20ef679ae8299c8502c2f" );
05534         
05535             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05536             fct_chk ( ctx.md_ctx != NULL );
05537             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05538             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05539             fct_chk ( 0 == md_free_ctx( &ctx ) );
05540             
05541             hexify( hash_str, output, md_get_size(md_info) );
05542         
05543             fct_chk( strncmp( (char *) hash_str, "6bc1379d156559ddee2ed420ea5d5c5ff3e454a1059b7ba72c350e77b6e9333c", 32 * 2 ) == 0 );
05544         }
05545         FCT_TEST_END();
05546 #endif /* POLARSSL_SHA4_C */
05547 
05548 #ifdef POLARSSL_SHA4_C
05549 
05550         FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_2)
05551         {
05552             char md_name[100];
05553             unsigned char src_str[10000];
05554             unsigned char key_str[10000];
05555             unsigned char hash_str[10000];
05556             unsigned char output[100];
05557             int key_len, src_len;
05558             const md_info_t *md_info = NULL;
05559             md_context_t ctx = MD_CONTEXT_T_INIT;
05560         
05561             memset(md_name, 0x00, 100);
05562             memset(src_str, 0x00, 10000);
05563             memset(key_str, 0x00, 10000);
05564             memset(hash_str, 0x00, 10000);
05565             memset(output, 0x00, 100);
05566         
05567             strncpy( (char *) md_name, "sha512", 100 );
05568             md_info = md_info_from_string( md_name );
05569             fct_chk( md_info != NULL );
05570             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05571         
05572             key_len = unhexify( key_str, "3b10b8fa718840d1dea8e9fc317476bcf55875fd" );
05573             src_len = unhexify( src_str, "f04f5b7073d7d0274e8354433b390306c5607632f5f589c12edb62d55673aff2366d2e6b24de731adf92e654baa30b1cfd4a069788f65ec1b99b015d904d8832110dbd74eae35a81562d14ce4136d820ad0a55ff5489ba678fbbc1c27663ec1349d70e740f0e0ec27cfbe8971819f4789e486b50a2d7271d77e2aaea50de62fd" );
05574         
05575             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05576             fct_chk ( ctx.md_ctx != NULL );
05577             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05578             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05579             fct_chk ( 0 == md_free_ctx( &ctx ) );
05580             
05581             hexify( hash_str, output, md_get_size(md_info) );
05582         
05583             fct_chk( strncmp( (char *) hash_str, "fc3c38c7a17e3ce06db033f1c172866f01a00045db55f2e234f71c82264f2ba2", 32 * 2 ) == 0 );
05584         }
05585         FCT_TEST_END();
05586 #endif /* POLARSSL_SHA4_C */
05587 
05588 #ifdef POLARSSL_SHA4_C
05589 
05590         FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_3)
05591         {
05592             char md_name[100];
05593             unsigned char src_str[10000];
05594             unsigned char key_str[10000];
05595             unsigned char hash_str[10000];
05596             unsigned char output[100];
05597             int key_len, src_len;
05598             const md_info_t *md_info = NULL;
05599             md_context_t ctx = MD_CONTEXT_T_INIT;
05600         
05601             memset(md_name, 0x00, 100);
05602             memset(src_str, 0x00, 10000);
05603             memset(key_str, 0x00, 10000);
05604             memset(hash_str, 0x00, 10000);
05605             memset(output, 0x00, 100);
05606         
05607             strncpy( (char *) md_name, "sha512", 100 );
05608             md_info = md_info_from_string( md_name );
05609             fct_chk( md_info != NULL );
05610             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05611         
05612             key_len = unhexify( key_str, "4803d311394600dc1e0d8fc8cedeb8bde3fe7c42" );
05613             src_len = unhexify( src_str, "a10c125dd702a97153ad923ba5e9889cfac1ba169de370debe51f233735aa6effcc9785c4b5c7e48c477dc5c411ae6a959118584e26adc94b42c2b29b046f3cf01c65b24a24bd2e620bdf650a23bb4a72655b1100d7ce9a4dab697c6379754b4396c825de4b9eb73f2e6a6c0d0353bbdeaf706612800e137b858fdb30f3311c6" );
05614         
05615             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05616             fct_chk ( ctx.md_ctx != NULL );
05617             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05618             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05619             fct_chk ( 0 == md_free_ctx( &ctx ) );
05620             
05621             hexify( hash_str, output, md_get_size(md_info) );
05622         
05623             fct_chk( strncmp( (char *) hash_str, "7cd8236c55102e6385f52279506df6fcc388ab75092da21395ce14a82b202ffa", 32 * 2 ) == 0 );
05624         }
05625         FCT_TEST_END();
05626 #endif /* POLARSSL_SHA4_C */
05627 
05628 #ifdef POLARSSL_SHA4_C
05629 
05630         FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_4)
05631         {
05632             char md_name[100];
05633             unsigned char src_str[10000];
05634             unsigned char key_str[10000];
05635             unsigned char hash_str[10000];
05636             unsigned char output[100];
05637             int key_len, src_len;
05638             const md_info_t *md_info = NULL;
05639             md_context_t ctx = MD_CONTEXT_T_INIT;
05640         
05641             memset(md_name, 0x00, 100);
05642             memset(src_str, 0x00, 10000);
05643             memset(key_str, 0x00, 10000);
05644             memset(hash_str, 0x00, 10000);
05645             memset(output, 0x00, 100);
05646         
05647             strncpy( (char *) md_name, "sha512", 100 );
05648             md_info = md_info_from_string( md_name );
05649             fct_chk( md_info != NULL );
05650             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05651         
05652             key_len = unhexify( key_str, "aeb2f3b977fa6c8e71e07c5a5c74ff58166de092" );
05653             src_len = unhexify( src_str, "22457355dc76095abd46846b41cfe49a06ce42ac8857b4702fc771508dfb3626e0bfe851df897a07b36811ec433766e4b4166c26301b3493e7440d4554b0ef6ac20f1a530e58fac8aeba4e9ff2d4898d8a28783b49cd269c2965fd7f8e4f2d60cf1e5284f2495145b72382aad90e153a90ecae125ad75336fb128825c23fb8b0" );
05654         
05655             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05656             fct_chk ( ctx.md_ctx != NULL );
05657             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05658             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05659             fct_chk ( 0 == md_free_ctx( &ctx ) );
05660             
05661             hexify( hash_str, output, md_get_size(md_info) );
05662         
05663             fct_chk( strncmp( (char *) hash_str, "fa39bd8fcc3bfa218f9dea5d3b2ce10a7619e31678a56d8a9d927b1fe703b125af445debe9a89a07db6194d27b44d85a", 48 * 2 ) == 0 );
05664         }
05665         FCT_TEST_END();
05666 #endif /* POLARSSL_SHA4_C */
05667 
05668 #ifdef POLARSSL_SHA4_C
05669 
05670         FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_5)
05671         {
05672             char md_name[100];
05673             unsigned char src_str[10000];
05674             unsigned char key_str[10000];
05675             unsigned char hash_str[10000];
05676             unsigned char output[100];
05677             int key_len, src_len;
05678             const md_info_t *md_info = NULL;
05679             md_context_t ctx = MD_CONTEXT_T_INIT;
05680         
05681             memset(md_name, 0x00, 100);
05682             memset(src_str, 0x00, 10000);
05683             memset(key_str, 0x00, 10000);
05684             memset(hash_str, 0x00, 10000);
05685             memset(output, 0x00, 100);
05686         
05687             strncpy( (char *) md_name, "sha512", 100 );
05688             md_info = md_info_from_string( md_name );
05689             fct_chk( md_info != NULL );
05690             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05691         
05692             key_len = unhexify( key_str, "4285d3d7744da52775bb44ca436a3154f7980309" );
05693             src_len = unhexify( src_str, "208f0b6f2de2e5aa5df11927ddc6df485edc1193181c484d0f0a434a95418803101d4de9fdb798f93516a6916fa38a8207de1666fe50fe3441c03b112eaaae6954ed063f7ac4e3c1e3f73b20d153fe9e4857f5e91430f0a70ee820529adac2467469fd18adf10e2af0fea27c0abc83c5a9af77c364a466cffce8bab4e2b70bc1" );
05694         
05695             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05696             fct_chk ( ctx.md_ctx != NULL );
05697             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05698             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05699             fct_chk ( 0 == md_free_ctx( &ctx ) );
05700             
05701             hexify( hash_str, output, md_get_size(md_info) );
05702         
05703             fct_chk( strncmp( (char *) hash_str, "fe7603f205b2774fe0f14ecfa3e338e90608a806d11ca459dff5ce36b1b264ecd3af5f0492a7521d8da3102ba20927a5", 48 * 2 ) == 0 );
05704         }
05705         FCT_TEST_END();
05706 #endif /* POLARSSL_SHA4_C */
05707 
05708 #ifdef POLARSSL_SHA4_C
05709 
05710         FCT_TEST_BGN(generic_multi_step_hmac_sha_512_test_vector_nist_cavs_6)
05711         {
05712             char md_name[100];
05713             unsigned char src_str[10000];
05714             unsigned char key_str[10000];
05715             unsigned char hash_str[10000];
05716             unsigned char output[100];
05717             int key_len, src_len;
05718             const md_info_t *md_info = NULL;
05719             md_context_t ctx = MD_CONTEXT_T_INIT;
05720         
05721             memset(md_name, 0x00, 100);
05722             memset(src_str, 0x00, 10000);
05723             memset(key_str, 0x00, 10000);
05724             memset(hash_str, 0x00, 10000);
05725             memset(output, 0x00, 100);
05726         
05727             strncpy( (char *) md_name, "sha512", 100 );
05728             md_info = md_info_from_string( md_name );
05729             fct_chk( md_info != NULL );
05730             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
05731         
05732             key_len = unhexify( key_str, "8ab783d5acf32efa0d9c0a21abce955e96630d89" );
05733             src_len = unhexify( src_str, "17371e013dce839963d54418e97be4bd9fa3cb2a368a5220f5aa1b8aaddfa3bdefc91afe7c717244fd2fb640f5cb9d9bf3e25f7f0c8bc758883b89dcdce6d749d9672fed222277ece3e84b3ec01b96f70c125fcb3cbee6d19b8ef0873f915f173bdb05d81629ba187cc8ac1934b2f75952fb7616ae6bd812946df694bd2763af" );
05734         
05735             fct_chk ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
05736             fct_chk ( ctx.md_ctx != NULL );
05737             fct_chk ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
05738             fct_chk ( 0 == md_hmac_finish( &ctx, output ) );
05739             fct_chk ( 0 == md_free_ctx( &ctx ) );
05740             
05741             hexify( hash_str, output, md_get_size(md_info) );
05742         
05743             fct_chk( strncmp( (char *) hash_str, "9ac7ca8d1aefc166b046e4cf7602ebe181a0e5055474bff5b342106731da0d7e48e4d87bc0a6f05871574289a1b099f8", 48 * 2 ) == 0 );
05744         }
05745         FCT_TEST_END();
05746 #endif /* POLARSSL_SHA4_C */
05747 
05748 #ifdef POLARSSL_SHA1_C
05749 
05750         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_1)
05751         {
05752             char md_name[100];
05753             unsigned char src_str[10000];
05754             unsigned char hash_str[10000];
05755             unsigned char output[100];
05756             int src_len;
05757             const md_info_t *md_info = NULL;
05758         
05759             memset(md_name, 0x00, 100);
05760             memset(src_str, 0x00, 10000);
05761             memset(hash_str, 0x00, 10000);
05762             memset(output, 0x00, 100);
05763         
05764             strncpy( (char *) md_name, "sha1", 100 );
05765             md_info = md_info_from_string(md_name);
05766             fct_chk( md_info != NULL );
05767         
05768             src_len = unhexify( src_str, "" );
05769             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05770         
05771             hexify( hash_str, output, md_get_size(md_info) );
05772         
05773             fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
05774         }
05775         FCT_TEST_END();
05776 #endif /* POLARSSL_SHA1_C */
05777 
05778 #ifdef POLARSSL_SHA1_C
05779 
05780         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_2)
05781         {
05782             char md_name[100];
05783             unsigned char src_str[10000];
05784             unsigned char hash_str[10000];
05785             unsigned char output[100];
05786             int src_len;
05787             const md_info_t *md_info = NULL;
05788         
05789             memset(md_name, 0x00, 100);
05790             memset(src_str, 0x00, 10000);
05791             memset(hash_str, 0x00, 10000);
05792             memset(output, 0x00, 100);
05793         
05794             strncpy( (char *) md_name, "sha1", 100 );
05795             md_info = md_info_from_string(md_name);
05796             fct_chk( md_info != NULL );
05797         
05798             src_len = unhexify( src_str, "a8" );
05799             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05800         
05801             hexify( hash_str, output, md_get_size(md_info) );
05802         
05803             fct_chk( strcmp( (char *) hash_str, "99f2aa95e36f95c2acb0eaf23998f030638f3f15" ) == 0 );
05804         }
05805         FCT_TEST_END();
05806 #endif /* POLARSSL_SHA1_C */
05807 
05808 #ifdef POLARSSL_SHA1_C
05809 
05810         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_3)
05811         {
05812             char md_name[100];
05813             unsigned char src_str[10000];
05814             unsigned char hash_str[10000];
05815             unsigned char output[100];
05816             int src_len;
05817             const md_info_t *md_info = NULL;
05818         
05819             memset(md_name, 0x00, 100);
05820             memset(src_str, 0x00, 10000);
05821             memset(hash_str, 0x00, 10000);
05822             memset(output, 0x00, 100);
05823         
05824             strncpy( (char *) md_name, "sha1", 100 );
05825             md_info = md_info_from_string(md_name);
05826             fct_chk( md_info != NULL );
05827         
05828             src_len = unhexify( src_str, "3000" );
05829             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05830         
05831             hexify( hash_str, output, md_get_size(md_info) );
05832         
05833             fct_chk( strcmp( (char *) hash_str, "f944dcd635f9801f7ac90a407fbc479964dec024" ) == 0 );
05834         }
05835         FCT_TEST_END();
05836 #endif /* POLARSSL_SHA1_C */
05837 
05838 #ifdef POLARSSL_SHA1_C
05839 
05840         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_4)
05841         {
05842             char md_name[100];
05843             unsigned char src_str[10000];
05844             unsigned char hash_str[10000];
05845             unsigned char output[100];
05846             int src_len;
05847             const md_info_t *md_info = NULL;
05848         
05849             memset(md_name, 0x00, 100);
05850             memset(src_str, 0x00, 10000);
05851             memset(hash_str, 0x00, 10000);
05852             memset(output, 0x00, 100);
05853         
05854             strncpy( (char *) md_name, "sha1", 100 );
05855             md_info = md_info_from_string(md_name);
05856             fct_chk( md_info != NULL );
05857         
05858             src_len = unhexify( src_str, "42749e" );
05859             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05860         
05861             hexify( hash_str, output, md_get_size(md_info) );
05862         
05863             fct_chk( strcmp( (char *) hash_str, "a444319e9b6cc1e8464c511ec0969c37d6bb2619" ) == 0 );
05864         }
05865         FCT_TEST_END();
05866 #endif /* POLARSSL_SHA1_C */
05867 
05868 #ifdef POLARSSL_SHA1_C
05869 
05870         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_5)
05871         {
05872             char md_name[100];
05873             unsigned char src_str[10000];
05874             unsigned char hash_str[10000];
05875             unsigned char output[100];
05876             int src_len;
05877             const md_info_t *md_info = NULL;
05878         
05879             memset(md_name, 0x00, 100);
05880             memset(src_str, 0x00, 10000);
05881             memset(hash_str, 0x00, 10000);
05882             memset(output, 0x00, 100);
05883         
05884             strncpy( (char *) md_name, "sha1", 100 );
05885             md_info = md_info_from_string(md_name);
05886             fct_chk( md_info != NULL );
05887         
05888             src_len = unhexify( src_str, "9fc3fe08" );
05889             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05890         
05891             hexify( hash_str, output, md_get_size(md_info) );
05892         
05893             fct_chk( strcmp( (char *) hash_str, "16a0ff84fcc156fd5d3ca3a744f20a232d172253" ) == 0 );
05894         }
05895         FCT_TEST_END();
05896 #endif /* POLARSSL_SHA1_C */
05897 
05898 #ifdef POLARSSL_SHA1_C
05899 
05900         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_6)
05901         {
05902             char md_name[100];
05903             unsigned char src_str[10000];
05904             unsigned char hash_str[10000];
05905             unsigned char output[100];
05906             int src_len;
05907             const md_info_t *md_info = NULL;
05908         
05909             memset(md_name, 0x00, 100);
05910             memset(src_str, 0x00, 10000);
05911             memset(hash_str, 0x00, 10000);
05912             memset(output, 0x00, 100);
05913         
05914             strncpy( (char *) md_name, "sha1", 100 );
05915             md_info = md_info_from_string(md_name);
05916             fct_chk( md_info != NULL );
05917         
05918             src_len = unhexify( src_str, "b5c1c6f1af" );
05919             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05920         
05921             hexify( hash_str, output, md_get_size(md_info) );
05922         
05923             fct_chk( strcmp( (char *) hash_str, "fec9deebfcdedaf66dda525e1be43597a73a1f93" ) == 0 );
05924         }
05925         FCT_TEST_END();
05926 #endif /* POLARSSL_SHA1_C */
05927 
05928 #ifdef POLARSSL_SHA1_C
05929 
05930         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_7)
05931         {
05932             char md_name[100];
05933             unsigned char src_str[10000];
05934             unsigned char hash_str[10000];
05935             unsigned char output[100];
05936             int src_len;
05937             const md_info_t *md_info = NULL;
05938         
05939             memset(md_name, 0x00, 100);
05940             memset(src_str, 0x00, 10000);
05941             memset(hash_str, 0x00, 10000);
05942             memset(output, 0x00, 100);
05943         
05944             strncpy( (char *) md_name, "sha1", 100 );
05945             md_info = md_info_from_string(md_name);
05946             fct_chk( md_info != NULL );
05947         
05948             src_len = unhexify( src_str, "ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b2548035185813e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a5305da4b1b737fce7cd21c0eb7728d08235a9011" );
05949             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05950         
05951             hexify( hash_str, output, md_get_size(md_info) );
05952         
05953             fct_chk( strcmp( (char *) hash_str, "970111c4e77bcc88cc20459c02b69b4aa8f58217" ) == 0 );
05954         }
05955         FCT_TEST_END();
05956 #endif /* POLARSSL_SHA1_C */
05957 
05958 #ifdef POLARSSL_SHA1_C
05959 
05960         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_8)
05961         {
05962             char md_name[100];
05963             unsigned char src_str[10000];
05964             unsigned char hash_str[10000];
05965             unsigned char output[100];
05966             int src_len;
05967             const md_info_t *md_info = NULL;
05968         
05969             memset(md_name, 0x00, 100);
05970             memset(src_str, 0x00, 10000);
05971             memset(hash_str, 0x00, 10000);
05972             memset(output, 0x00, 100);
05973         
05974             strncpy( (char *) md_name, "sha1", 100 );
05975             md_info = md_info_from_string(md_name);
05976             fct_chk( md_info != NULL );
05977         
05978             src_len = unhexify( src_str, "5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652afe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba553d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38ae485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77414197422be3d36a6080" );
05979             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
05980         
05981             hexify( hash_str, output, md_get_size(md_info) );
05982         
05983             fct_chk( strcmp( (char *) hash_str, "0423dc76a8791107d14e13f5265b343f24cc0f19" ) == 0 );
05984         }
05985         FCT_TEST_END();
05986 #endif /* POLARSSL_SHA1_C */
05987 
05988 #ifdef POLARSSL_SHA1_C
05989 
05990         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_9)
05991         {
05992             char md_name[100];
05993             unsigned char src_str[10000];
05994             unsigned char hash_str[10000];
05995             unsigned char output[100];
05996             int src_len;
05997             const md_info_t *md_info = NULL;
05998         
05999             memset(md_name, 0x00, 100);
06000             memset(src_str, 0x00, 10000);
06001             memset(hash_str, 0x00, 10000);
06002             memset(output, 0x00, 100);
06003         
06004             strncpy( (char *) md_name, "sha1", 100 );
06005             md_info = md_info_from_string(md_name);
06006             fct_chk( md_info != NULL );
06007         
06008             src_len = unhexify( src_str, "0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a007ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec428c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30baa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff57800e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee71366afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32beaea" );
06009             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06010         
06011             hexify( hash_str, output, md_get_size(md_info) );
06012         
06013             fct_chk( strcmp( (char *) hash_str, "6692a71d73e00f27df976bc56df4970650d90e45" ) == 0 );
06014         }
06015         FCT_TEST_END();
06016 #endif /* POLARSSL_SHA1_C */
06017 
06018 #ifdef POLARSSL_SHA1_C
06019 
06020         FCT_TEST_BGN(generic_sha_1_test_vector_nist_cavs_10)
06021         {
06022             char md_name[100];
06023             unsigned char src_str[10000];
06024             unsigned char hash_str[10000];
06025             unsigned char output[100];
06026             int src_len;
06027             const md_info_t *md_info = NULL;
06028         
06029             memset(md_name, 0x00, 100);
06030             memset(src_str, 0x00, 10000);
06031             memset(hash_str, 0x00, 10000);
06032             memset(output, 0x00, 100);
06033         
06034             strncpy( (char *) md_name, "sha1", 100 );
06035             md_info = md_info_from_string(md_name);
06036             fct_chk( md_info != NULL );
06037         
06038             src_len = unhexify( src_str, "8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff" );
06039             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06040         
06041             hexify( hash_str, output, md_get_size(md_info) );
06042         
06043             fct_chk( strcmp( (char *) hash_str, "11863b483809ef88413ca9b0084ac4a5390640af" ) == 0 );
06044         }
06045         FCT_TEST_END();
06046 #endif /* POLARSSL_SHA1_C */
06047 
06048 #ifdef POLARSSL_SHA2_C
06049 
06050         FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_1)
06051         {
06052             char md_name[100];
06053             unsigned char src_str[10000];
06054             unsigned char hash_str[10000];
06055             unsigned char output[100];
06056             int src_len;
06057             const md_info_t *md_info = NULL;
06058         
06059             memset(md_name, 0x00, 100);
06060             memset(src_str, 0x00, 10000);
06061             memset(hash_str, 0x00, 10000);
06062             memset(output, 0x00, 100);
06063         
06064             strncpy( (char *) md_name, "sha224", 100 );
06065             md_info = md_info_from_string(md_name);
06066             fct_chk( md_info != NULL );
06067         
06068             src_len = unhexify( src_str, "" );
06069             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06070         
06071             hexify( hash_str, output, md_get_size(md_info) );
06072         
06073             fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
06074         }
06075         FCT_TEST_END();
06076 #endif /* POLARSSL_SHA2_C */
06077 
06078 #ifdef POLARSSL_SHA2_C
06079 
06080         FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_2)
06081         {
06082             char md_name[100];
06083             unsigned char src_str[10000];
06084             unsigned char hash_str[10000];
06085             unsigned char output[100];
06086             int src_len;
06087             const md_info_t *md_info = NULL;
06088         
06089             memset(md_name, 0x00, 100);
06090             memset(src_str, 0x00, 10000);
06091             memset(hash_str, 0x00, 10000);
06092             memset(output, 0x00, 100);
06093         
06094             strncpy( (char *) md_name, "sha224", 100 );
06095             md_info = md_info_from_string(md_name);
06096             fct_chk( md_info != NULL );
06097         
06098             src_len = unhexify( src_str, "ff" );
06099             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06100         
06101             hexify( hash_str, output, md_get_size(md_info) );
06102         
06103             fct_chk( strcmp( (char *) hash_str, "e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5" ) == 0 );
06104         }
06105         FCT_TEST_END();
06106 #endif /* POLARSSL_SHA2_C */
06107 
06108 #ifdef POLARSSL_SHA2_C
06109 
06110         FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_3)
06111         {
06112             char md_name[100];
06113             unsigned char src_str[10000];
06114             unsigned char hash_str[10000];
06115             unsigned char output[100];
06116             int src_len;
06117             const md_info_t *md_info = NULL;
06118         
06119             memset(md_name, 0x00, 100);
06120             memset(src_str, 0x00, 10000);
06121             memset(hash_str, 0x00, 10000);
06122             memset(output, 0x00, 100);
06123         
06124             strncpy( (char *) md_name, "sha224", 100 );
06125             md_info = md_info_from_string(md_name);
06126             fct_chk( md_info != NULL );
06127         
06128             src_len = unhexify( src_str, "984c" );
06129             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06130         
06131             hexify( hash_str, output, md_get_size(md_info) );
06132         
06133             fct_chk( strcmp( (char *) hash_str, "2fa9df9157d9e027cfbc4c6a9df32e1adc0cbe2328ec2a63c5ae934e" ) == 0 );
06134         }
06135         FCT_TEST_END();
06136 #endif /* POLARSSL_SHA2_C */
06137 
06138 #ifdef POLARSSL_SHA2_C
06139 
06140         FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_4)
06141         {
06142             char md_name[100];
06143             unsigned char src_str[10000];
06144             unsigned char hash_str[10000];
06145             unsigned char output[100];
06146             int src_len;
06147             const md_info_t *md_info = NULL;
06148         
06149             memset(md_name, 0x00, 100);
06150             memset(src_str, 0x00, 10000);
06151             memset(hash_str, 0x00, 10000);
06152             memset(output, 0x00, 100);
06153         
06154             strncpy( (char *) md_name, "sha224", 100 );
06155             md_info = md_info_from_string(md_name);
06156             fct_chk( md_info != NULL );
06157         
06158             src_len = unhexify( src_str, "50efd0" );
06159             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06160         
06161             hexify( hash_str, output, md_get_size(md_info) );
06162         
06163             fct_chk( strcmp( (char *) hash_str, "b5a9820413c2bf8211fbbf5df1337043b32fa4eafaf61a0c8e9ccede" ) == 0 );
06164         }
06165         FCT_TEST_END();
06166 #endif /* POLARSSL_SHA2_C */
06167 
06168 #ifdef POLARSSL_SHA2_C
06169 
06170         FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_5)
06171         {
06172             char md_name[100];
06173             unsigned char src_str[10000];
06174             unsigned char hash_str[10000];
06175             unsigned char output[100];
06176             int src_len;
06177             const md_info_t *md_info = NULL;
06178         
06179             memset(md_name, 0x00, 100);
06180             memset(src_str, 0x00, 10000);
06181             memset(hash_str, 0x00, 10000);
06182             memset(output, 0x00, 100);
06183         
06184             strncpy( (char *) md_name, "sha224", 100 );
06185             md_info = md_info_from_string(md_name);
06186             fct_chk( md_info != NULL );
06187         
06188             src_len = unhexify( src_str, "e5e09924" );
06189             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06190         
06191             hexify( hash_str, output, md_get_size(md_info) );
06192         
06193             fct_chk( strcmp( (char *) hash_str, "fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d" ) == 0 );
06194         }
06195         FCT_TEST_END();
06196 #endif /* POLARSSL_SHA2_C */
06197 
06198 #ifdef POLARSSL_SHA2_C
06199 
06200         FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_6)
06201         {
06202             char md_name[100];
06203             unsigned char src_str[10000];
06204             unsigned char hash_str[10000];
06205             unsigned char output[100];
06206             int src_len;
06207             const md_info_t *md_info = NULL;
06208         
06209             memset(md_name, 0x00, 100);
06210             memset(src_str, 0x00, 10000);
06211             memset(hash_str, 0x00, 10000);
06212             memset(output, 0x00, 100);
06213         
06214             strncpy( (char *) md_name, "sha224", 100 );
06215             md_info = md_info_from_string(md_name);
06216             fct_chk( md_info != NULL );
06217         
06218             src_len = unhexify( src_str, "21ebecb914" );
06219             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06220         
06221             hexify( hash_str, output, md_get_size(md_info) );
06222         
06223             fct_chk( strcmp( (char *) hash_str, "78f4a71c21c694499ce1c7866611b14ace70d905012c356323c7c713" ) == 0 );
06224         }
06225         FCT_TEST_END();
06226 #endif /* POLARSSL_SHA2_C */
06227 
06228 #ifdef POLARSSL_SHA2_C
06229 
06230         FCT_TEST_BGN(generic_sha_224_test_vector_nist_cavs_7)
06231         {
06232             char md_name[100];
06233             unsigned char src_str[10000];
06234             unsigned char hash_str[10000];
06235             unsigned char output[100];
06236             int src_len;
06237             const md_info_t *md_info = NULL;
06238         
06239             memset(md_name, 0x00, 100);
06240             memset(src_str, 0x00, 10000);
06241             memset(hash_str, 0x00, 10000);
06242             memset(output, 0x00, 100);
06243         
06244             strncpy( (char *) md_name, "sha224", 100 );
06245             md_info = md_info_from_string(md_name);
06246             fct_chk( md_info != NULL );
06247         
06248             src_len = unhexify( src_str, "fc488947c1a7a589726b15436b4f3d9556262f98fc6422fc5cdf20f0fad7fe427a3491c86d101ffe6b7514f06268f65b2d269b0f69ad9a97847eff1c16a2438775eb7be6847ccf11cb8b2e8dcd6640b095b49c0693fe3cf4a66e2d9b7ad68bff14f3ad69abf49d0aba36cbe0535202deb6599a47225ef05beb351335cd7bc0f480d691198c7e71305ffd53b39d33242bb79cfd98bfd69e137b5d18b2b89ac9ace01c8dbdcf2533cce3682ecc52118de0c1062ec2126c2e657d6ea3d9e2398e705d4b0b1f1ceecb266dffc4f31bf42744fb1e938dc22a889919ee1e73f463f7871fed720519e32186264b7ef2a0e5d9a18e6c95c0781894f77967f048951dec3b4d892a38710b1e3436d3c29088eb8b3da1789c25db3d3bc6c26081206e7155d210a89b80ca6ea877c41ff9947c0f25625dcb118294a163501f6239c326661a958fd12da4cd15a899f8b88cc723589056eaec5aa04a4cf5dbb6f480f9660423ccf38c486e210707e0fb25e1f126ceb2616f63e147a647dab0af9ebe89d65458bf636154a46e4cab95f5ee62da2c7974cd14b90d3e4f99f81733e85b3c1d5da2b508d9b90f5eed7eff0d9c7649de62bee00375454fee4a39576a5bbfdae428e7f8097bdf7797f167686cb68407e49079e4611ff3402b6384ba7b7e522bd2bb11ce8fd02ea4c1604d163ac4f6dde50b8b1f593f7edaadeac0868ed97df690200680c25f0f5d85431a529e4f339089dcdeda105e4ee51dead704cdf5a605c55fb055c9b0e86b8ba1b564c0dea3eb790a595cb103cb292268b07c5e59371e1a7ef597cd4b22977a820694c9f9aeb55d9de3ef62b75d6e656e3336698d960a3787bf8cf5b926a7faeef52ae128bcb5dc9e66d94b016c7b8e034879171a2d91c381f57e6a815b63b5ee6a6d2ff435b49f14c963966960194430d78f8f87627a67757fb3532b289550894da6dce4817a4e07f4d56877a1102ffcc8befa5c9f8fca6a4574d93ff70376c8861e0f8108cf907fce77ecb49728f86f034f80224b9695682e0824462f76cdb1fd1af151337b0d85419047a7aa284791718a4860cd586f7824b95bc837b6fd4f9be5aade68456e20356aa4d943dac36bf8b67b9e8f9d01a00fcda74b798bafa746c661b010f75b59904b29d0c8041504811c4065f82cf2ead58d2f595cbd8bc3e7043f4d94577b373b7cfe16a36fe564f505c03b70cfeb5e5f411c79481338aa67e86b3f5a2e77c21e454c333ae3da943ab723ab5f4c940395319534a5575f64acba0d0ecc43f60221ed3badf7289c9b3a7b903a2d6c94e15fa4c310dc4fa7faa0c24f405160a1002dbef20e4105d481db982f7243f79400a6e4cd9753c4b9732a47575f504b20c328fe9add7f432a4f075829da07b53b695037dc51737d3cd731934df333cd1a53fcf65aa31baa450ca501a6fae26e322347e618c5a444d92e9fec5a8261ae38b98fee5be77c02cec09ddccd5b3de92036" );
06249             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06250         
06251             hexify( hash_str, output, md_get_size(md_info) );
06252         
06253             fct_chk( strcmp( (char *) hash_str, "1302149d1e197c41813b054c942329d420e366530f5517b470e964fe" ) == 0 );
06254         }
06255         FCT_TEST_END();
06256 #endif /* POLARSSL_SHA2_C */
06257 
06258 #ifdef POLARSSL_SHA2_C
06259 
06260         FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_1)
06261         {
06262             char md_name[100];
06263             unsigned char src_str[10000];
06264             unsigned char hash_str[10000];
06265             unsigned char output[100];
06266             int src_len;
06267             const md_info_t *md_info = NULL;
06268         
06269             memset(md_name, 0x00, 100);
06270             memset(src_str, 0x00, 10000);
06271             memset(hash_str, 0x00, 10000);
06272             memset(output, 0x00, 100);
06273         
06274             strncpy( (char *) md_name, "sha256", 100 );
06275             md_info = md_info_from_string(md_name);
06276             fct_chk( md_info != NULL );
06277         
06278             src_len = unhexify( src_str, "" );
06279             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06280         
06281             hexify( hash_str, output, md_get_size(md_info) );
06282         
06283             fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
06284         }
06285         FCT_TEST_END();
06286 #endif /* POLARSSL_SHA2_C */
06287 
06288 #ifdef POLARSSL_SHA2_C
06289 
06290         FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_2)
06291         {
06292             char md_name[100];
06293             unsigned char src_str[10000];
06294             unsigned char hash_str[10000];
06295             unsigned char output[100];
06296             int src_len;
06297             const md_info_t *md_info = NULL;
06298         
06299             memset(md_name, 0x00, 100);
06300             memset(src_str, 0x00, 10000);
06301             memset(hash_str, 0x00, 10000);
06302             memset(output, 0x00, 100);
06303         
06304             strncpy( (char *) md_name, "sha256", 100 );
06305             md_info = md_info_from_string(md_name);
06306             fct_chk( md_info != NULL );
06307         
06308             src_len = unhexify( src_str, "bd" );
06309             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06310         
06311             hexify( hash_str, output, md_get_size(md_info) );
06312         
06313             fct_chk( strcmp( (char *) hash_str, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b" ) == 0 );
06314         }
06315         FCT_TEST_END();
06316 #endif /* POLARSSL_SHA2_C */
06317 
06318 #ifdef POLARSSL_SHA2_C
06319 
06320         FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_3)
06321         {
06322             char md_name[100];
06323             unsigned char src_str[10000];
06324             unsigned char hash_str[10000];
06325             unsigned char output[100];
06326             int src_len;
06327             const md_info_t *md_info = NULL;
06328         
06329             memset(md_name, 0x00, 100);
06330             memset(src_str, 0x00, 10000);
06331             memset(hash_str, 0x00, 10000);
06332             memset(output, 0x00, 100);
06333         
06334             strncpy( (char *) md_name, "sha256", 100 );
06335             md_info = md_info_from_string(md_name);
06336             fct_chk( md_info != NULL );
06337         
06338             src_len = unhexify( src_str, "5fd4" );
06339             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06340         
06341             hexify( hash_str, output, md_get_size(md_info) );
06342         
06343             fct_chk( strcmp( (char *) hash_str, "7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788" ) == 0 );
06344         }
06345         FCT_TEST_END();
06346 #endif /* POLARSSL_SHA2_C */
06347 
06348 #ifdef POLARSSL_SHA2_C
06349 
06350         FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_4)
06351         {
06352             char md_name[100];
06353             unsigned char src_str[10000];
06354             unsigned char hash_str[10000];
06355             unsigned char output[100];
06356             int src_len;
06357             const md_info_t *md_info = NULL;
06358         
06359             memset(md_name, 0x00, 100);
06360             memset(src_str, 0x00, 10000);
06361             memset(hash_str, 0x00, 10000);
06362             memset(output, 0x00, 100);
06363         
06364             strncpy( (char *) md_name, "sha256", 100 );
06365             md_info = md_info_from_string(md_name);
06366             fct_chk( md_info != NULL );
06367         
06368             src_len = unhexify( src_str, "b0bd69" );
06369             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06370         
06371             hexify( hash_str, output, md_get_size(md_info) );
06372         
06373             fct_chk( strcmp( (char *) hash_str, "4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803" ) == 0 );
06374         }
06375         FCT_TEST_END();
06376 #endif /* POLARSSL_SHA2_C */
06377 
06378 #ifdef POLARSSL_SHA2_C
06379 
06380         FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_5)
06381         {
06382             char md_name[100];
06383             unsigned char src_str[10000];
06384             unsigned char hash_str[10000];
06385             unsigned char output[100];
06386             int src_len;
06387             const md_info_t *md_info = NULL;
06388         
06389             memset(md_name, 0x00, 100);
06390             memset(src_str, 0x00, 10000);
06391             memset(hash_str, 0x00, 10000);
06392             memset(output, 0x00, 100);
06393         
06394             strncpy( (char *) md_name, "sha256", 100 );
06395             md_info = md_info_from_string(md_name);
06396             fct_chk( md_info != NULL );
06397         
06398             src_len = unhexify( src_str, "c98c8e55" );
06399             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06400         
06401             hexify( hash_str, output, md_get_size(md_info) );
06402         
06403             fct_chk( strcmp( (char *) hash_str, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504" ) == 0 );
06404         }
06405         FCT_TEST_END();
06406 #endif /* POLARSSL_SHA2_C */
06407 
06408 #ifdef POLARSSL_SHA2_C
06409 
06410         FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_6)
06411         {
06412             char md_name[100];
06413             unsigned char src_str[10000];
06414             unsigned char hash_str[10000];
06415             unsigned char output[100];
06416             int src_len;
06417             const md_info_t *md_info = NULL;
06418         
06419             memset(md_name, 0x00, 100);
06420             memset(src_str, 0x00, 10000);
06421             memset(hash_str, 0x00, 10000);
06422             memset(output, 0x00, 100);
06423         
06424             strncpy( (char *) md_name, "sha256", 100 );
06425             md_info = md_info_from_string(md_name);
06426             fct_chk( md_info != NULL );
06427         
06428             src_len = unhexify( src_str, "81a723d966" );
06429             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06430         
06431             hexify( hash_str, output, md_get_size(md_info) );
06432         
06433             fct_chk( strcmp( (char *) hash_str, "7516fb8bb11350df2bf386bc3c33bd0f52cb4c67c6e4745e0488e62c2aea2605" ) == 0 );
06434         }
06435         FCT_TEST_END();
06436 #endif /* POLARSSL_SHA2_C */
06437 
06438 #ifdef POLARSSL_SHA2_C
06439 
06440         FCT_TEST_BGN(generic_sha_256_test_vector_nist_cavs_7)
06441         {
06442             char md_name[100];
06443             unsigned char src_str[10000];
06444             unsigned char hash_str[10000];
06445             unsigned char output[100];
06446             int src_len;
06447             const md_info_t *md_info = NULL;
06448         
06449             memset(md_name, 0x00, 100);
06450             memset(src_str, 0x00, 10000);
06451             memset(hash_str, 0x00, 10000);
06452             memset(output, 0x00, 100);
06453         
06454             strncpy( (char *) md_name, "sha256", 100 );
06455             md_info = md_info_from_string(md_name);
06456             fct_chk( md_info != NULL );
06457         
06458             src_len = unhexify( src_str, "8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e" );
06459             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06460         
06461             hexify( hash_str, output, md_get_size(md_info) );
06462         
06463             fct_chk( strcmp( (char *) hash_str, "4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e" ) == 0 );
06464         }
06465         FCT_TEST_END();
06466 #endif /* POLARSSL_SHA2_C */
06467 
06468 #ifdef POLARSSL_SHA4_C
06469 
06470         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_1)
06471         {
06472             char md_name[100];
06473             unsigned char src_str[10000];
06474             unsigned char hash_str[10000];
06475             unsigned char output[100];
06476             int src_len;
06477             const md_info_t *md_info = NULL;
06478         
06479             memset(md_name, 0x00, 100);
06480             memset(src_str, 0x00, 10000);
06481             memset(hash_str, 0x00, 10000);
06482             memset(output, 0x00, 100);
06483         
06484             strncpy( (char *) md_name, "sha384", 100 );
06485             md_info = md_info_from_string(md_name);
06486             fct_chk( md_info != NULL );
06487         
06488             src_len = unhexify( src_str, "" );
06489             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06490         
06491             hexify( hash_str, output, md_get_size(md_info) );
06492         
06493             fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
06494         }
06495         FCT_TEST_END();
06496 #endif /* POLARSSL_SHA4_C */
06497 
06498 #ifdef POLARSSL_SHA4_C
06499 
06500         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_2)
06501         {
06502             char md_name[100];
06503             unsigned char src_str[10000];
06504             unsigned char hash_str[10000];
06505             unsigned char output[100];
06506             int src_len;
06507             const md_info_t *md_info = NULL;
06508         
06509             memset(md_name, 0x00, 100);
06510             memset(src_str, 0x00, 10000);
06511             memset(hash_str, 0x00, 10000);
06512             memset(output, 0x00, 100);
06513         
06514             strncpy( (char *) md_name, "sha384", 100 );
06515             md_info = md_info_from_string(md_name);
06516             fct_chk( md_info != NULL );
06517         
06518             src_len = unhexify( src_str, "ab" );
06519             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06520         
06521             hexify( hash_str, output, md_get_size(md_info) );
06522         
06523             fct_chk( strcmp( (char *) hash_str, "fb94d5be118865f6fcbc978b825da82cff188faec2f66cb84b2537d74b4938469854b0ca89e66fa2e182834736629f3d" ) == 0 );
06524         }
06525         FCT_TEST_END();
06526 #endif /* POLARSSL_SHA4_C */
06527 
06528 #ifdef POLARSSL_SHA4_C
06529 
06530         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_3)
06531         {
06532             char md_name[100];
06533             unsigned char src_str[10000];
06534             unsigned char hash_str[10000];
06535             unsigned char output[100];
06536             int src_len;
06537             const md_info_t *md_info = NULL;
06538         
06539             memset(md_name, 0x00, 100);
06540             memset(src_str, 0x00, 10000);
06541             memset(hash_str, 0x00, 10000);
06542             memset(output, 0x00, 100);
06543         
06544             strncpy( (char *) md_name, "sha384", 100 );
06545             md_info = md_info_from_string(md_name);
06546             fct_chk( md_info != NULL );
06547         
06548             src_len = unhexify( src_str, "7c27" );
06549             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06550         
06551             hexify( hash_str, output, md_get_size(md_info) );
06552         
06553             fct_chk( strcmp( (char *) hash_str, "3d80be467df86d63abb9ea1d3f9cb39cd19890e7f2c53a6200bedc5006842b35e820dc4e0ca90ca9b97ab23ef07080fc" ) == 0 );
06554         }
06555         FCT_TEST_END();
06556 #endif /* POLARSSL_SHA4_C */
06557 
06558 #ifdef POLARSSL_SHA4_C
06559 
06560         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_4)
06561         {
06562             char md_name[100];
06563             unsigned char src_str[10000];
06564             unsigned char hash_str[10000];
06565             unsigned char output[100];
06566             int src_len;
06567             const md_info_t *md_info = NULL;
06568         
06569             memset(md_name, 0x00, 100);
06570             memset(src_str, 0x00, 10000);
06571             memset(hash_str, 0x00, 10000);
06572             memset(output, 0x00, 100);
06573         
06574             strncpy( (char *) md_name, "sha384", 100 );
06575             md_info = md_info_from_string(md_name);
06576             fct_chk( md_info != NULL );
06577         
06578             src_len = unhexify( src_str, "31f5ca" );
06579             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06580         
06581             hexify( hash_str, output, md_get_size(md_info) );
06582         
06583             fct_chk( strcmp( (char *) hash_str, "78d54b943421fdf7ba90a7fb9637c2073aa480454bd841d39ff72f4511fc21fb67797b652c0c823229342873d3bef955" ) == 0 );
06584         }
06585         FCT_TEST_END();
06586 #endif /* POLARSSL_SHA4_C */
06587 
06588 #ifdef POLARSSL_SHA4_C
06589 
06590         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_5)
06591         {
06592             char md_name[100];
06593             unsigned char src_str[10000];
06594             unsigned char hash_str[10000];
06595             unsigned char output[100];
06596             int src_len;
06597             const md_info_t *md_info = NULL;
06598         
06599             memset(md_name, 0x00, 100);
06600             memset(src_str, 0x00, 10000);
06601             memset(hash_str, 0x00, 10000);
06602             memset(output, 0x00, 100);
06603         
06604             strncpy( (char *) md_name, "sha384", 100 );
06605             md_info = md_info_from_string(md_name);
06606             fct_chk( md_info != NULL );
06607         
06608             src_len = unhexify( src_str, "7bdee3f8" );
06609             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06610         
06611             hexify( hash_str, output, md_get_size(md_info) );
06612         
06613             fct_chk( strcmp( (char *) hash_str, "8bdafba0777ee446c3431c2d7b1fbb631089f71d2ca417abc1d230e1aba64ec2f1c187474a6f4077d372c14ad407f99a" ) == 0 );
06614         }
06615         FCT_TEST_END();
06616 #endif /* POLARSSL_SHA4_C */
06617 
06618 #ifdef POLARSSL_SHA4_C
06619 
06620         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_6)
06621         {
06622             char md_name[100];
06623             unsigned char src_str[10000];
06624             unsigned char hash_str[10000];
06625             unsigned char output[100];
06626             int src_len;
06627             const md_info_t *md_info = NULL;
06628         
06629             memset(md_name, 0x00, 100);
06630             memset(src_str, 0x00, 10000);
06631             memset(hash_str, 0x00, 10000);
06632             memset(output, 0x00, 100);
06633         
06634             strncpy( (char *) md_name, "sha384", 100 );
06635             md_info = md_info_from_string(md_name);
06636             fct_chk( md_info != NULL );
06637         
06638             src_len = unhexify( src_str, "8f05604915" );
06639             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06640         
06641             hexify( hash_str, output, md_get_size(md_info) );
06642         
06643             fct_chk( strcmp( (char *) hash_str, "504e414bf1db1060f14c8c799e25b1e0c4dcf1504ebbd129998f0ae283e6de86e0d3c7e879c73ec3b1836c3ee89c2649" ) == 0 );
06644         }
06645         FCT_TEST_END();
06646 #endif /* POLARSSL_SHA4_C */
06647 
06648 #ifdef POLARSSL_SHA4_C
06649 
06650         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_7)
06651         {
06652             char md_name[100];
06653             unsigned char src_str[10000];
06654             unsigned char hash_str[10000];
06655             unsigned char output[100];
06656             int src_len;
06657             const md_info_t *md_info = NULL;
06658         
06659             memset(md_name, 0x00, 100);
06660             memset(src_str, 0x00, 10000);
06661             memset(hash_str, 0x00, 10000);
06662             memset(output, 0x00, 100);
06663         
06664             strncpy( (char *) md_name, "sha384", 100 );
06665             md_info = md_info_from_string(md_name);
06666             fct_chk( md_info != NULL );
06667         
06668             src_len = unhexify( src_str, "665da6eda214" );
06669             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06670         
06671             hexify( hash_str, output, md_get_size(md_info) );
06672         
06673             fct_chk( strcmp( (char *) hash_str, "4c022f112010908848312f8b8f1072625fd5c105399d562ea1d56130619a7eac8dfc3748fd05ee37e4b690be9daa9980" ) == 0 );
06674         }
06675         FCT_TEST_END();
06676 #endif /* POLARSSL_SHA4_C */
06677 
06678 #ifdef POLARSSL_SHA4_C
06679 
06680         FCT_TEST_BGN(generic_sha_384_test_vector_nist_cavs_8)
06681         {
06682             char md_name[100];
06683             unsigned char src_str[10000];
06684             unsigned char hash_str[10000];
06685             unsigned char output[100];
06686             int src_len;
06687             const md_info_t *md_info = NULL;
06688         
06689             memset(md_name, 0x00, 100);
06690             memset(src_str, 0x00, 10000);
06691             memset(hash_str, 0x00, 10000);
06692             memset(output, 0x00, 100);
06693         
06694             strncpy( (char *) md_name, "sha384", 100 );
06695             md_info = md_info_from_string(md_name);
06696             fct_chk( md_info != NULL );
06697         
06698             src_len = unhexify( src_str, "7f46ce506d593c4ed53c82edeb602037e0485befbee03f7f930fe532d18ff2a3f5fd6076672c8145a1bf40dd94f7abab47c9ae71c234213d2ad1069c2dac0b0ba15257ae672b8245960ae55bd50315c0097daa3a318745788d70d14706910809ca6e396237fe4934fa46f9ce782d66606d8bd6b2d283b1160513ce9c24e9f084b97891f99d4cdefc169a029e431ca772ba1bba426fce6f01d8e286014e5acc66b799e4db62bd4783322f8a32ff78e0de3957df50ce10871f4e0680df4e8ca3960af9bc6f4efa8eb3962d18f474eb178c3265cc46b8f2ff5ab1a7449fea297dfcfabfa01f28abbb7289bb354b691b5664ec6d098af51be19947ec5ba7ebd66380d1141953ba78d4aa5401679fa7b0a44db1981f864d3535c45afe4c61183d5b0ad51fae71ca07e34240283959f7530a32c70d95a088e501c230059f333b0670825009e7e22103ef22935830df1fac8ef877f5f3426dd54f7d1128dd871ad9a7d088f94c0e8712013295b8d69ae7623b880978c2d3c6ad26dc478f8dc47f5c0adcc618665dc3dc205a9071b2f2191e16cac5bd89bb59148fc719633752303aa08e518dbc389f0a5482caaa4c507b8729a6f3edd061efb39026cecc6399f51971cf7381d605e144a5928c8c2d1ad7467b05da2f202f4f3234e1aff19a0198a28685721c3d2d52311c721e3fdcbaf30214cdc3acff8c433880e104fb63f2df7ce69a97857819ba7ac00ac8eae1969764fde8f68cf8e0916d7e0c151147d4944f99f42ae50f30e1c79a42d2b6c5188d133d3cbbf69094027b354b295ccd0f7dc5a87d73638bd98ebfb00383ca0fa69cb8dcb35a12510e5e07ad8789047d0b63841a1bb928737e8b0a0c33254f47aa8bfbe3341a09c2b76dbcefa67e30df300d34f7b8465c4f869e51b6bcfe6cf68b238359a645036bf7f63f02924e087ce7457e483b6025a859903cb484574aa3b12cf946f32127d537c33bee3141b5db96d10a148c50ae045f287210757710d6846e04b202f79e87dd9a56bc6da15f84a77a7f63935e1dee00309cd276a8e7176cb04da6bb0e9009534438732cb42d008008853d38d19beba46e61006e30f7efd1bc7c2906b024e4ff898a1b58c448d68b43c6ab63f34f85b3ac6aa4475867e51b583844cb23829f4b30f4bdd817d88e2ef3e7b4fc0a624395b05ec5e8686082b24d29fef2b0d3c29e031d5f94f504b1d3df9361eb5ffbadb242e66c39a8094cfe62f85f639f3fd65fc8ae0c74a8f4c6e1d070b9183a434c722caaa0225f8bcd68614d6f0738ed62f8484ec96077d155c08e26c46be262a73e3551698bd70d8d5610cf37c4c306eed04ba6a040a9c3e6d7e15e8acda17f477c2484cf5c56b813313927be8387b1024f995e98fc87f1029091c01424bdc2b296c2eadb7d25b3e762a2fd0c2dcd1727ddf91db97c5984305265f3695a7f5472f2d72c94d68c27914f14f82aa8dd5fe4e2348b0ca967a3f98626a091552f5d0ffa2bf10350d23c996256c01fdeffb2c2c612519869f877e4929c6e95ff15040f1485e22ed14119880232fef3b57b3848f15b1766a5552879df8f06" );
06699             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06700         
06701             hexify( hash_str, output, md_get_size(md_info) );
06702         
06703             fct_chk( strcmp( (char *) hash_str, "cba9e3eb12a6f83db11e8a6ff40d1049854ee094416bc527fea931d8585428a8ed6242ce81f6769b36e2123a5c23483e" ) == 0 );
06704         }
06705         FCT_TEST_END();
06706 #endif /* POLARSSL_SHA4_C */
06707 
06708 #ifdef POLARSSL_SHA4_C
06709 
06710         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_1)
06711         {
06712             char md_name[100];
06713             unsigned char src_str[10000];
06714             unsigned char hash_str[10000];
06715             unsigned char output[100];
06716             int src_len;
06717             const md_info_t *md_info = NULL;
06718         
06719             memset(md_name, 0x00, 100);
06720             memset(src_str, 0x00, 10000);
06721             memset(hash_str, 0x00, 10000);
06722             memset(output, 0x00, 100);
06723         
06724             strncpy( (char *) md_name, "sha512", 100 );
06725             md_info = md_info_from_string(md_name);
06726             fct_chk( md_info != NULL );
06727         
06728             src_len = unhexify( src_str, "" );
06729             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06730         
06731             hexify( hash_str, output, md_get_size(md_info) );
06732         
06733             fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
06734         }
06735         FCT_TEST_END();
06736 #endif /* POLARSSL_SHA4_C */
06737 
06738 #ifdef POLARSSL_SHA4_C
06739 
06740         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_2)
06741         {
06742             char md_name[100];
06743             unsigned char src_str[10000];
06744             unsigned char hash_str[10000];
06745             unsigned char output[100];
06746             int src_len;
06747             const md_info_t *md_info = NULL;
06748         
06749             memset(md_name, 0x00, 100);
06750             memset(src_str, 0x00, 10000);
06751             memset(hash_str, 0x00, 10000);
06752             memset(output, 0x00, 100);
06753         
06754             strncpy( (char *) md_name, "sha512", 100 );
06755             md_info = md_info_from_string(md_name);
06756             fct_chk( md_info != NULL );
06757         
06758             src_len = unhexify( src_str, "8f" );
06759             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06760         
06761             hexify( hash_str, output, md_get_size(md_info) );
06762         
06763             fct_chk( strcmp( (char *) hash_str, "e4cd2d19931b5aad9c920f45f56f6ce34e3d38c6d319a6e11d0588ab8b838576d6ce6d68eea7c830de66e2bd96458bfa7aafbcbec981d4ed040498c3dd95f22a" ) == 0 );
06764         }
06765         FCT_TEST_END();
06766 #endif /* POLARSSL_SHA4_C */
06767 
06768 #ifdef POLARSSL_SHA4_C
06769 
06770         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_3)
06771         {
06772             char md_name[100];
06773             unsigned char src_str[10000];
06774             unsigned char hash_str[10000];
06775             unsigned char output[100];
06776             int src_len;
06777             const md_info_t *md_info = NULL;
06778         
06779             memset(md_name, 0x00, 100);
06780             memset(src_str, 0x00, 10000);
06781             memset(hash_str, 0x00, 10000);
06782             memset(output, 0x00, 100);
06783         
06784             strncpy( (char *) md_name, "sha512", 100 );
06785             md_info = md_info_from_string(md_name);
06786             fct_chk( md_info != NULL );
06787         
06788             src_len = unhexify( src_str, "e724" );
06789             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06790         
06791             hexify( hash_str, output, md_get_size(md_info) );
06792         
06793             fct_chk( strcmp( (char *) hash_str, "7dbb520221a70287b23dbcf62bfc1b73136d858e86266732a7fffa875ecaa2c1b8f673b5c065d360c563a7b9539349f5f59bef8c0c593f9587e3cd50bb26a231" ) == 0 );
06794         }
06795         FCT_TEST_END();
06796 #endif /* POLARSSL_SHA4_C */
06797 
06798 #ifdef POLARSSL_SHA4_C
06799 
06800         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_4)
06801         {
06802             char md_name[100];
06803             unsigned char src_str[10000];
06804             unsigned char hash_str[10000];
06805             unsigned char output[100];
06806             int src_len;
06807             const md_info_t *md_info = NULL;
06808         
06809             memset(md_name, 0x00, 100);
06810             memset(src_str, 0x00, 10000);
06811             memset(hash_str, 0x00, 10000);
06812             memset(output, 0x00, 100);
06813         
06814             strncpy( (char *) md_name, "sha512", 100 );
06815             md_info = md_info_from_string(md_name);
06816             fct_chk( md_info != NULL );
06817         
06818             src_len = unhexify( src_str, "de4c90" );
06819             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06820         
06821             hexify( hash_str, output, md_get_size(md_info) );
06822         
06823             fct_chk( strcmp( (char *) hash_str, "33ce98281045a5c4c9df0363d8196f1d7dfcd5ee46ac89776fd8a4344c12f123a66788af5bd41ceff1941aa5637654b4064c88c14e00465ab79a2fc6c97e1014" ) == 0 );
06824         }
06825         FCT_TEST_END();
06826 #endif /* POLARSSL_SHA4_C */
06827 
06828 #ifdef POLARSSL_SHA4_C
06829 
06830         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_5)
06831         {
06832             char md_name[100];
06833             unsigned char src_str[10000];
06834             unsigned char hash_str[10000];
06835             unsigned char output[100];
06836             int src_len;
06837             const md_info_t *md_info = NULL;
06838         
06839             memset(md_name, 0x00, 100);
06840             memset(src_str, 0x00, 10000);
06841             memset(hash_str, 0x00, 10000);
06842             memset(output, 0x00, 100);
06843         
06844             strncpy( (char *) md_name, "sha512", 100 );
06845             md_info = md_info_from_string(md_name);
06846             fct_chk( md_info != NULL );
06847         
06848             src_len = unhexify( src_str, "a801e94b" );
06849             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06850         
06851             hexify( hash_str, output, md_get_size(md_info) );
06852         
06853             fct_chk( strcmp( (char *) hash_str, "dadb1b5a27f9fece8d86adb2a51879beb1787ff28f4e8ce162cad7fee0f942efcabbf738bc6f797fc7cc79a3a75048cd4c82ca0757a324695bfb19a557e56e2f" ) == 0 );
06854         }
06855         FCT_TEST_END();
06856 #endif /* POLARSSL_SHA4_C */
06857 
06858 #ifdef POLARSSL_SHA4_C
06859 
06860         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_6)
06861         {
06862             char md_name[100];
06863             unsigned char src_str[10000];
06864             unsigned char hash_str[10000];
06865             unsigned char output[100];
06866             int src_len;
06867             const md_info_t *md_info = NULL;
06868         
06869             memset(md_name, 0x00, 100);
06870             memset(src_str, 0x00, 10000);
06871             memset(hash_str, 0x00, 10000);
06872             memset(output, 0x00, 100);
06873         
06874             strncpy( (char *) md_name, "sha512", 100 );
06875             md_info = md_info_from_string(md_name);
06876             fct_chk( md_info != NULL );
06877         
06878             src_len = unhexify( src_str, "94390d3502" );
06879             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06880         
06881             hexify( hash_str, output, md_get_size(md_info) );
06882         
06883             fct_chk( strcmp( (char *) hash_str, "b6175c4c4cccf69e0ce5f0312010886ea6b34d43673f942ae42483f9cbb7da817de4e11b5d58e25a3d9bd721a22cdffe1c40411cc45df1911fa5506129b69297" ) == 0 );
06884         }
06885         FCT_TEST_END();
06886 #endif /* POLARSSL_SHA4_C */
06887 
06888 #ifdef POLARSSL_SHA4_C
06889 
06890         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_7)
06891         {
06892             char md_name[100];
06893             unsigned char src_str[10000];
06894             unsigned char hash_str[10000];
06895             unsigned char output[100];
06896             int src_len;
06897             const md_info_t *md_info = NULL;
06898         
06899             memset(md_name, 0x00, 100);
06900             memset(src_str, 0x00, 10000);
06901             memset(hash_str, 0x00, 10000);
06902             memset(output, 0x00, 100);
06903         
06904             strncpy( (char *) md_name, "sha512", 100 );
06905             md_info = md_info_from_string(md_name);
06906             fct_chk( md_info != NULL );
06907         
06908             src_len = unhexify( src_str, "49297dd63e5f" );
06909             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06910         
06911             hexify( hash_str, output, md_get_size(md_info) );
06912         
06913             fct_chk( strcmp( (char *) hash_str, "1fcc1e6f6870859d11649f5e5336a9cd16329c029baf04d5a6edf257889a2e9522b497dd656bb402da461307c4ee382e2e89380c8e6e6e7697f1e439f650fa94" ) == 0 );
06914         }
06915         FCT_TEST_END();
06916 #endif /* POLARSSL_SHA4_C */
06917 
06918 #ifdef POLARSSL_SHA4_C
06919 
06920         FCT_TEST_BGN(generic_sha_512_test_vector_nist_cavs_8)
06921         {
06922             char md_name[100];
06923             unsigned char src_str[10000];
06924             unsigned char hash_str[10000];
06925             unsigned char output[100];
06926             int src_len;
06927             const md_info_t *md_info = NULL;
06928         
06929             memset(md_name, 0x00, 100);
06930             memset(src_str, 0x00, 10000);
06931             memset(hash_str, 0x00, 10000);
06932             memset(output, 0x00, 100);
06933         
06934             strncpy( (char *) md_name, "sha512", 100 );
06935             md_info = md_info_from_string(md_name);
06936             fct_chk( md_info != NULL );
06937         
06938             src_len = unhexify( src_str, "990d1ae71a62d7bda9bfdaa1762a68d296eee72a4cd946f287a898fbabc002ea941fd8d4d991030b4d27a637cce501a834bb95eab1b7889a3e784c7968e67cbf552006b206b68f76d9191327524fcc251aeb56af483d10b4e0c6c5e599ee8c0fe4faeca8293844a8547c6a9a90d093f2526873a19ad4a5e776794c68c742fb834793d2dfcb7fea46c63af4b70fd11cb6e41834e72ee40edb067b292a794990c288d5007e73f349fb383af6a756b8301ad6e5e0aa8cd614399bb3a452376b1575afa6bdaeaafc286cb064bb91edef97c632b6c1113d107fa93a0905098a105043c2f05397f702514439a08a9e5ddc196100721d45c8fc17d2ed659376f8a00bd5cb9a0860e26d8a29d8d6aaf52de97e9346033d6db501a35dbbaf97c20b830cd2d18c2532f3a59cc497ee64c0e57d8d060e5069b28d86edf1adcf59144b221ce3ddaef134b3124fbc7dd000240eff0f5f5f41e83cd7f5bb37c9ae21953fe302b0f6e8b68fa91c6ab99265c64b2fd9cd4942be04321bb5d6d71932376c6f2f88e02422ba6a5e2cb765df93fd5dd0728c6abdaf03bce22e0678a544e2c3636f741b6f4447ee58a8fc656b43ef817932176adbfc2e04b2c812c273cd6cbfa4098f0be036a34221fa02643f5ee2e0b38135f2a18ecd2f16ebc45f8eb31b8ab967a1567ee016904188910861ca1fa205c7adaa194b286893ffe2f4fbe0384c2aef72a4522aeafd3ebc71f9db71eeeef86c48394a1c86d5b36c352cc33a0a2c800bc99e62fd65b3a2fd69e0b53996ec13d8ce483ce9319efd9a85acefabdb5342226febb83fd1daf4b24265f50c61c6de74077ef89b6fecf9f29a1f871af1e9f89b2d345cda7499bd45c42fa5d195a1e1a6ba84851889e730da3b2b916e96152ae0c92154b49719841db7e7cc707ba8a5d7b101eb4ac7b629bb327817910fff61580b59aab78182d1a2e33473d05b00b170b29e331870826cfe45af206aa7d0246bbd8566ca7cfb2d3c10bfa1db7dd48dd786036469ce7282093d78b5e1a5b0fc81a54c8ed4ceac1e5305305e78284ac276f5d7862727aff246e17addde50c670028d572cbfc0be2e4f8b2eb28fa68ad7b4c6c2a239c460441bfb5ea049f23b08563b4e47729a59e5986a61a6093dbd54f8c36ebe87edae01f251cb060ad1364ce677d7e8d5a4a4ca966a7241cc360bc2acb280e5f9e9c1b032ad6a180a35e0c5180b9d16d026c865b252098cc1d99ba7375ca31c7702c0d943d5e3dd2f6861fa55bd46d94b67ed3e52eccd8dd06d968e01897d6de97ed3058d91dd" );
06939             fct_chk ( 0 == md( md_info, src_str, src_len, output ) );
06940         
06941             hexify( hash_str, output, md_get_size(md_info) );
06942         
06943             fct_chk( strcmp( (char *) hash_str, "8e4bc6f8b8c60fe4d68c61d9b159c8693c3151c46749af58da228442d927f23359bd6ccd6c2ec8fa3f00a86cecbfa728e1ad60b821ed22fcd309ba91a4138bc9" ) == 0 );
06944         }
06945         FCT_TEST_END();
06946 #endif /* POLARSSL_SHA4_C */
06947 
06948 #ifdef POLARSSL_SHA1_C
06949 
06950         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_1)
06951         {
06952             char md_name[100];
06953             unsigned char src_str[10000];
06954             unsigned char hash_str[10000];
06955             unsigned char output[100];
06956             int src_len;
06957             const md_info_t *md_info = NULL;
06958             md_context_t ctx = MD_CONTEXT_T_INIT;
06959         
06960             memset(md_name, 0x00, 100);
06961             memset(src_str, 0x00, 10000);
06962             memset(hash_str, 0x00, 10000);
06963             memset(output, 0x00, 100);
06964         
06965             strncpy( (char *) md_name, "sha1", 100 );
06966             md_info = md_info_from_string(md_name);
06967             fct_chk( md_info != NULL );
06968             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
06969         
06970             src_len = unhexify( src_str, "" );
06971             
06972             fct_chk ( 0 == md_starts( &ctx ) );
06973             fct_chk ( ctx.md_ctx != NULL );
06974             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
06975             fct_chk ( 0 == md_finish( &ctx, output ) );
06976             fct_chk ( 0 == md_free_ctx( &ctx ) );
06977             
06978             hexify( hash_str, output, md_get_size(md_info) );
06979         
06980             fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
06981         }
06982         FCT_TEST_END();
06983 #endif /* POLARSSL_SHA1_C */
06984 
06985 #ifdef POLARSSL_SHA1_C
06986 
06987         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_2)
06988         {
06989             char md_name[100];
06990             unsigned char src_str[10000];
06991             unsigned char hash_str[10000];
06992             unsigned char output[100];
06993             int src_len;
06994             const md_info_t *md_info = NULL;
06995             md_context_t ctx = MD_CONTEXT_T_INIT;
06996         
06997             memset(md_name, 0x00, 100);
06998             memset(src_str, 0x00, 10000);
06999             memset(hash_str, 0x00, 10000);
07000             memset(output, 0x00, 100);
07001         
07002             strncpy( (char *) md_name, "sha1", 100 );
07003             md_info = md_info_from_string(md_name);
07004             fct_chk( md_info != NULL );
07005             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07006         
07007             src_len = unhexify( src_str, "a8" );
07008             
07009             fct_chk ( 0 == md_starts( &ctx ) );
07010             fct_chk ( ctx.md_ctx != NULL );
07011             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07012             fct_chk ( 0 == md_finish( &ctx, output ) );
07013             fct_chk ( 0 == md_free_ctx( &ctx ) );
07014             
07015             hexify( hash_str, output, md_get_size(md_info) );
07016         
07017             fct_chk( strcmp( (char *) hash_str, "99f2aa95e36f95c2acb0eaf23998f030638f3f15" ) == 0 );
07018         }
07019         FCT_TEST_END();
07020 #endif /* POLARSSL_SHA1_C */
07021 
07022 #ifdef POLARSSL_SHA1_C
07023 
07024         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_3)
07025         {
07026             char md_name[100];
07027             unsigned char src_str[10000];
07028             unsigned char hash_str[10000];
07029             unsigned char output[100];
07030             int src_len;
07031             const md_info_t *md_info = NULL;
07032             md_context_t ctx = MD_CONTEXT_T_INIT;
07033         
07034             memset(md_name, 0x00, 100);
07035             memset(src_str, 0x00, 10000);
07036             memset(hash_str, 0x00, 10000);
07037             memset(output, 0x00, 100);
07038         
07039             strncpy( (char *) md_name, "sha1", 100 );
07040             md_info = md_info_from_string(md_name);
07041             fct_chk( md_info != NULL );
07042             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07043         
07044             src_len = unhexify( src_str, "3000" );
07045             
07046             fct_chk ( 0 == md_starts( &ctx ) );
07047             fct_chk ( ctx.md_ctx != NULL );
07048             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07049             fct_chk ( 0 == md_finish( &ctx, output ) );
07050             fct_chk ( 0 == md_free_ctx( &ctx ) );
07051             
07052             hexify( hash_str, output, md_get_size(md_info) );
07053         
07054             fct_chk( strcmp( (char *) hash_str, "f944dcd635f9801f7ac90a407fbc479964dec024" ) == 0 );
07055         }
07056         FCT_TEST_END();
07057 #endif /* POLARSSL_SHA1_C */
07058 
07059 #ifdef POLARSSL_SHA1_C
07060 
07061         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_4)
07062         {
07063             char md_name[100];
07064             unsigned char src_str[10000];
07065             unsigned char hash_str[10000];
07066             unsigned char output[100];
07067             int src_len;
07068             const md_info_t *md_info = NULL;
07069             md_context_t ctx = MD_CONTEXT_T_INIT;
07070         
07071             memset(md_name, 0x00, 100);
07072             memset(src_str, 0x00, 10000);
07073             memset(hash_str, 0x00, 10000);
07074             memset(output, 0x00, 100);
07075         
07076             strncpy( (char *) md_name, "sha1", 100 );
07077             md_info = md_info_from_string(md_name);
07078             fct_chk( md_info != NULL );
07079             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07080         
07081             src_len = unhexify( src_str, "42749e" );
07082             
07083             fct_chk ( 0 == md_starts( &ctx ) );
07084             fct_chk ( ctx.md_ctx != NULL );
07085             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07086             fct_chk ( 0 == md_finish( &ctx, output ) );
07087             fct_chk ( 0 == md_free_ctx( &ctx ) );
07088             
07089             hexify( hash_str, output, md_get_size(md_info) );
07090         
07091             fct_chk( strcmp( (char *) hash_str, "a444319e9b6cc1e8464c511ec0969c37d6bb2619" ) == 0 );
07092         }
07093         FCT_TEST_END();
07094 #endif /* POLARSSL_SHA1_C */
07095 
07096 #ifdef POLARSSL_SHA1_C
07097 
07098         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_5)
07099         {
07100             char md_name[100];
07101             unsigned char src_str[10000];
07102             unsigned char hash_str[10000];
07103             unsigned char output[100];
07104             int src_len;
07105             const md_info_t *md_info = NULL;
07106             md_context_t ctx = MD_CONTEXT_T_INIT;
07107         
07108             memset(md_name, 0x00, 100);
07109             memset(src_str, 0x00, 10000);
07110             memset(hash_str, 0x00, 10000);
07111             memset(output, 0x00, 100);
07112         
07113             strncpy( (char *) md_name, "sha1", 100 );
07114             md_info = md_info_from_string(md_name);
07115             fct_chk( md_info != NULL );
07116             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07117         
07118             src_len = unhexify( src_str, "9fc3fe08" );
07119             
07120             fct_chk ( 0 == md_starts( &ctx ) );
07121             fct_chk ( ctx.md_ctx != NULL );
07122             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07123             fct_chk ( 0 == md_finish( &ctx, output ) );
07124             fct_chk ( 0 == md_free_ctx( &ctx ) );
07125             
07126             hexify( hash_str, output, md_get_size(md_info) );
07127         
07128             fct_chk( strcmp( (char *) hash_str, "16a0ff84fcc156fd5d3ca3a744f20a232d172253" ) == 0 );
07129         }
07130         FCT_TEST_END();
07131 #endif /* POLARSSL_SHA1_C */
07132 
07133 #ifdef POLARSSL_SHA1_C
07134 
07135         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_6)
07136         {
07137             char md_name[100];
07138             unsigned char src_str[10000];
07139             unsigned char hash_str[10000];
07140             unsigned char output[100];
07141             int src_len;
07142             const md_info_t *md_info = NULL;
07143             md_context_t ctx = MD_CONTEXT_T_INIT;
07144         
07145             memset(md_name, 0x00, 100);
07146             memset(src_str, 0x00, 10000);
07147             memset(hash_str, 0x00, 10000);
07148             memset(output, 0x00, 100);
07149         
07150             strncpy( (char *) md_name, "sha1", 100 );
07151             md_info = md_info_from_string(md_name);
07152             fct_chk( md_info != NULL );
07153             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07154         
07155             src_len = unhexify( src_str, "b5c1c6f1af" );
07156             
07157             fct_chk ( 0 == md_starts( &ctx ) );
07158             fct_chk ( ctx.md_ctx != NULL );
07159             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07160             fct_chk ( 0 == md_finish( &ctx, output ) );
07161             fct_chk ( 0 == md_free_ctx( &ctx ) );
07162             
07163             hexify( hash_str, output, md_get_size(md_info) );
07164         
07165             fct_chk( strcmp( (char *) hash_str, "fec9deebfcdedaf66dda525e1be43597a73a1f93" ) == 0 );
07166         }
07167         FCT_TEST_END();
07168 #endif /* POLARSSL_SHA1_C */
07169 
07170 #ifdef POLARSSL_SHA1_C
07171 
07172         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_7)
07173         {
07174             char md_name[100];
07175             unsigned char src_str[10000];
07176             unsigned char hash_str[10000];
07177             unsigned char output[100];
07178             int src_len;
07179             const md_info_t *md_info = NULL;
07180             md_context_t ctx = MD_CONTEXT_T_INIT;
07181         
07182             memset(md_name, 0x00, 100);
07183             memset(src_str, 0x00, 10000);
07184             memset(hash_str, 0x00, 10000);
07185             memset(output, 0x00, 100);
07186         
07187             strncpy( (char *) md_name, "sha1", 100 );
07188             md_info = md_info_from_string(md_name);
07189             fct_chk( md_info != NULL );
07190             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07191         
07192             src_len = unhexify( src_str, "ec29561244ede706b6eb30a1c371d74450a105c3f9735f7fa9fe38cf67f304a5736a106e92e17139a6813b1c81a4f3d3fb9546ab4296fa9f722826c066869edacd73b2548035185813e22634a9da44000d95a281ff9f264ecce0a931222162d021cca28db5f3c2aa24945ab1e31cb413ae29810fd794cad5dfaf29ec43cb38d198fe4ae1da2359780221405bd6712a5305da4b1b737fce7cd21c0eb7728d08235a9011" );
07193             
07194             fct_chk ( 0 == md_starts( &ctx ) );
07195             fct_chk ( ctx.md_ctx != NULL );
07196             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07197             fct_chk ( 0 == md_finish( &ctx, output ) );
07198             fct_chk ( 0 == md_free_ctx( &ctx ) );
07199             
07200             hexify( hash_str, output, md_get_size(md_info) );
07201         
07202             fct_chk( strcmp( (char *) hash_str, "970111c4e77bcc88cc20459c02b69b4aa8f58217" ) == 0 );
07203         }
07204         FCT_TEST_END();
07205 #endif /* POLARSSL_SHA1_C */
07206 
07207 #ifdef POLARSSL_SHA1_C
07208 
07209         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_8)
07210         {
07211             char md_name[100];
07212             unsigned char src_str[10000];
07213             unsigned char hash_str[10000];
07214             unsigned char output[100];
07215             int src_len;
07216             const md_info_t *md_info = NULL;
07217             md_context_t ctx = MD_CONTEXT_T_INIT;
07218         
07219             memset(md_name, 0x00, 100);
07220             memset(src_str, 0x00, 10000);
07221             memset(hash_str, 0x00, 10000);
07222             memset(output, 0x00, 100);
07223         
07224             strncpy( (char *) md_name, "sha1", 100 );
07225             md_info = md_info_from_string(md_name);
07226             fct_chk( md_info != NULL );
07227             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07228         
07229             src_len = unhexify( src_str, "5fc2c3f6a7e79dc94be526e5166a238899d54927ce470018fbfd668fd9dd97cbf64e2c91584d01da63be3cc9fdff8adfefc3ac728e1e335b9cdc87f069172e323d094b47fa1e652afe4d6aa147a9f46fda33cacb65f3aa12234746b9007a8c85fe982afed7815221e43dba553d8fe8a022cdac1b99eeeea359e5a9d2e72e382dffa6d19f359f4f27dc3434cd27daeeda8e38594873398678065fbb23665aba9309d946135da0e4a4afdadff14db18e85e71dd93c3bf9faf7f25c8194c4269b1ee3d9934097ab990025d9c3aaf63d5109f52335dd3959d38ae485050e4bbb6235574fc0102be8f7a306d6e8de6ba6becf80f37415b57f9898a5824e77414197422be3d36a6080" );
07230             
07231             fct_chk ( 0 == md_starts( &ctx ) );
07232             fct_chk ( ctx.md_ctx != NULL );
07233             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07234             fct_chk ( 0 == md_finish( &ctx, output ) );
07235             fct_chk ( 0 == md_free_ctx( &ctx ) );
07236             
07237             hexify( hash_str, output, md_get_size(md_info) );
07238         
07239             fct_chk( strcmp( (char *) hash_str, "0423dc76a8791107d14e13f5265b343f24cc0f19" ) == 0 );
07240         }
07241         FCT_TEST_END();
07242 #endif /* POLARSSL_SHA1_C */
07243 
07244 #ifdef POLARSSL_SHA1_C
07245 
07246         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_9)
07247         {
07248             char md_name[100];
07249             unsigned char src_str[10000];
07250             unsigned char hash_str[10000];
07251             unsigned char output[100];
07252             int src_len;
07253             const md_info_t *md_info = NULL;
07254             md_context_t ctx = MD_CONTEXT_T_INIT;
07255         
07256             memset(md_name, 0x00, 100);
07257             memset(src_str, 0x00, 10000);
07258             memset(hash_str, 0x00, 10000);
07259             memset(output, 0x00, 100);
07260         
07261             strncpy( (char *) md_name, "sha1", 100 );
07262             md_info = md_info_from_string(md_name);
07263             fct_chk( md_info != NULL );
07264             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07265         
07266             src_len = unhexify( src_str, "0f865f46a8f3aed2da18482aa09a8f390dc9da07d51d1bd10fe0bf5f3928d5927d08733d32075535a6d1c8ac1b2dc6ba0f2f633dc1af68e3f0fa3d85e6c60cb7b56c239dc1519a007ea536a07b518ecca02a6c31b46b76f021620ef3fc6976804018380e5ab9c558ebfc5cb1c9ed2d974722bf8ab6398f1f2b82fa5083f85c16a5767a3a07271d67743f00850ce8ec428c7f22f1cf01f99895c0c844845b06a06cecb0c6cf83eb55a1d4ebc44c2c13f6f7aa5e0e08abfd84e7864279057abc471ee4a45dbbb5774afa24e51791a0eada11093b88681fe30baa3b2e94113dc63342c51ca5d1a6096d0897b626e42cb91761058008f746f35465465540ad8c6b8b60f7e1461b3ce9e6529625984cb8c7d46f07f735be067588a0117f23e34ff57800e2bbe9a1605fde6087fb15d22c5d3ac47566b8c448b0cee40373e5ba6eaa21abee71366afbb27dbbd300477d70c371e7b8963812f5ed4fb784fb2f3bd1d3afe883cdd47ef32beaea" );
07267             
07268             fct_chk ( 0 == md_starts( &ctx ) );
07269             fct_chk ( ctx.md_ctx != NULL );
07270             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07271             fct_chk ( 0 == md_finish( &ctx, output ) );
07272             fct_chk ( 0 == md_free_ctx( &ctx ) );
07273             
07274             hexify( hash_str, output, md_get_size(md_info) );
07275         
07276             fct_chk( strcmp( (char *) hash_str, "6692a71d73e00f27df976bc56df4970650d90e45" ) == 0 );
07277         }
07278         FCT_TEST_END();
07279 #endif /* POLARSSL_SHA1_C */
07280 
07281 #ifdef POLARSSL_SHA1_C
07282 
07283         FCT_TEST_BGN(generic_multi_step_sha_1_test_vector_nist_cavs_10)
07284         {
07285             char md_name[100];
07286             unsigned char src_str[10000];
07287             unsigned char hash_str[10000];
07288             unsigned char output[100];
07289             int src_len;
07290             const md_info_t *md_info = NULL;
07291             md_context_t ctx = MD_CONTEXT_T_INIT;
07292         
07293             memset(md_name, 0x00, 100);
07294             memset(src_str, 0x00, 10000);
07295             memset(hash_str, 0x00, 10000);
07296             memset(output, 0x00, 100);
07297         
07298             strncpy( (char *) md_name, "sha1", 100 );
07299             md_info = md_info_from_string(md_name);
07300             fct_chk( md_info != NULL );
07301             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07302         
07303             src_len = unhexify( src_str, "8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff" );
07304             
07305             fct_chk ( 0 == md_starts( &ctx ) );
07306             fct_chk ( ctx.md_ctx != NULL );
07307             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07308             fct_chk ( 0 == md_finish( &ctx, output ) );
07309             fct_chk ( 0 == md_free_ctx( &ctx ) );
07310             
07311             hexify( hash_str, output, md_get_size(md_info) );
07312         
07313             fct_chk( strcmp( (char *) hash_str, "11863b483809ef88413ca9b0084ac4a5390640af" ) == 0 );
07314         }
07315         FCT_TEST_END();
07316 #endif /* POLARSSL_SHA1_C */
07317 
07318 #ifdef POLARSSL_SHA2_C
07319 
07320         FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_1)
07321         {
07322             char md_name[100];
07323             unsigned char src_str[10000];
07324             unsigned char hash_str[10000];
07325             unsigned char output[100];
07326             int src_len;
07327             const md_info_t *md_info = NULL;
07328             md_context_t ctx = MD_CONTEXT_T_INIT;
07329         
07330             memset(md_name, 0x00, 100);
07331             memset(src_str, 0x00, 10000);
07332             memset(hash_str, 0x00, 10000);
07333             memset(output, 0x00, 100);
07334         
07335             strncpy( (char *) md_name, "sha224", 100 );
07336             md_info = md_info_from_string(md_name);
07337             fct_chk( md_info != NULL );
07338             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07339         
07340             src_len = unhexify( src_str, "" );
07341             
07342             fct_chk ( 0 == md_starts( &ctx ) );
07343             fct_chk ( ctx.md_ctx != NULL );
07344             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07345             fct_chk ( 0 == md_finish( &ctx, output ) );
07346             fct_chk ( 0 == md_free_ctx( &ctx ) );
07347             
07348             hexify( hash_str, output, md_get_size(md_info) );
07349         
07350             fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
07351         }
07352         FCT_TEST_END();
07353 #endif /* POLARSSL_SHA2_C */
07354 
07355 #ifdef POLARSSL_SHA2_C
07356 
07357         FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_2)
07358         {
07359             char md_name[100];
07360             unsigned char src_str[10000];
07361             unsigned char hash_str[10000];
07362             unsigned char output[100];
07363             int src_len;
07364             const md_info_t *md_info = NULL;
07365             md_context_t ctx = MD_CONTEXT_T_INIT;
07366         
07367             memset(md_name, 0x00, 100);
07368             memset(src_str, 0x00, 10000);
07369             memset(hash_str, 0x00, 10000);
07370             memset(output, 0x00, 100);
07371         
07372             strncpy( (char *) md_name, "sha224", 100 );
07373             md_info = md_info_from_string(md_name);
07374             fct_chk( md_info != NULL );
07375             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07376         
07377             src_len = unhexify( src_str, "ff" );
07378             
07379             fct_chk ( 0 == md_starts( &ctx ) );
07380             fct_chk ( ctx.md_ctx != NULL );
07381             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07382             fct_chk ( 0 == md_finish( &ctx, output ) );
07383             fct_chk ( 0 == md_free_ctx( &ctx ) );
07384             
07385             hexify( hash_str, output, md_get_size(md_info) );
07386         
07387             fct_chk( strcmp( (char *) hash_str, "e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5" ) == 0 );
07388         }
07389         FCT_TEST_END();
07390 #endif /* POLARSSL_SHA2_C */
07391 
07392 #ifdef POLARSSL_SHA2_C
07393 
07394         FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_3)
07395         {
07396             char md_name[100];
07397             unsigned char src_str[10000];
07398             unsigned char hash_str[10000];
07399             unsigned char output[100];
07400             int src_len;
07401             const md_info_t *md_info = NULL;
07402             md_context_t ctx = MD_CONTEXT_T_INIT;
07403         
07404             memset(md_name, 0x00, 100);
07405             memset(src_str, 0x00, 10000);
07406             memset(hash_str, 0x00, 10000);
07407             memset(output, 0x00, 100);
07408         
07409             strncpy( (char *) md_name, "sha224", 100 );
07410             md_info = md_info_from_string(md_name);
07411             fct_chk( md_info != NULL );
07412             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07413         
07414             src_len = unhexify( src_str, "984c" );
07415             
07416             fct_chk ( 0 == md_starts( &ctx ) );
07417             fct_chk ( ctx.md_ctx != NULL );
07418             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07419             fct_chk ( 0 == md_finish( &ctx, output ) );
07420             fct_chk ( 0 == md_free_ctx( &ctx ) );
07421             
07422             hexify( hash_str, output, md_get_size(md_info) );
07423         
07424             fct_chk( strcmp( (char *) hash_str, "2fa9df9157d9e027cfbc4c6a9df32e1adc0cbe2328ec2a63c5ae934e" ) == 0 );
07425         }
07426         FCT_TEST_END();
07427 #endif /* POLARSSL_SHA2_C */
07428 
07429 #ifdef POLARSSL_SHA2_C
07430 
07431         FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_4)
07432         {
07433             char md_name[100];
07434             unsigned char src_str[10000];
07435             unsigned char hash_str[10000];
07436             unsigned char output[100];
07437             int src_len;
07438             const md_info_t *md_info = NULL;
07439             md_context_t ctx = MD_CONTEXT_T_INIT;
07440         
07441             memset(md_name, 0x00, 100);
07442             memset(src_str, 0x00, 10000);
07443             memset(hash_str, 0x00, 10000);
07444             memset(output, 0x00, 100);
07445         
07446             strncpy( (char *) md_name, "sha224", 100 );
07447             md_info = md_info_from_string(md_name);
07448             fct_chk( md_info != NULL );
07449             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07450         
07451             src_len = unhexify( src_str, "50efd0" );
07452             
07453             fct_chk ( 0 == md_starts( &ctx ) );
07454             fct_chk ( ctx.md_ctx != NULL );
07455             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07456             fct_chk ( 0 == md_finish( &ctx, output ) );
07457             fct_chk ( 0 == md_free_ctx( &ctx ) );
07458             
07459             hexify( hash_str, output, md_get_size(md_info) );
07460         
07461             fct_chk( strcmp( (char *) hash_str, "b5a9820413c2bf8211fbbf5df1337043b32fa4eafaf61a0c8e9ccede" ) == 0 );
07462         }
07463         FCT_TEST_END();
07464 #endif /* POLARSSL_SHA2_C */
07465 
07466 #ifdef POLARSSL_SHA2_C
07467 
07468         FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_5)
07469         {
07470             char md_name[100];
07471             unsigned char src_str[10000];
07472             unsigned char hash_str[10000];
07473             unsigned char output[100];
07474             int src_len;
07475             const md_info_t *md_info = NULL;
07476             md_context_t ctx = MD_CONTEXT_T_INIT;
07477         
07478             memset(md_name, 0x00, 100);
07479             memset(src_str, 0x00, 10000);
07480             memset(hash_str, 0x00, 10000);
07481             memset(output, 0x00, 100);
07482         
07483             strncpy( (char *) md_name, "sha224", 100 );
07484             md_info = md_info_from_string(md_name);
07485             fct_chk( md_info != NULL );
07486             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07487         
07488             src_len = unhexify( src_str, "e5e09924" );
07489             
07490             fct_chk ( 0 == md_starts( &ctx ) );
07491             fct_chk ( ctx.md_ctx != NULL );
07492             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07493             fct_chk ( 0 == md_finish( &ctx, output ) );
07494             fct_chk ( 0 == md_free_ctx( &ctx ) );
07495             
07496             hexify( hash_str, output, md_get_size(md_info) );
07497         
07498             fct_chk( strcmp( (char *) hash_str, "fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d" ) == 0 );
07499         }
07500         FCT_TEST_END();
07501 #endif /* POLARSSL_SHA2_C */
07502 
07503 #ifdef POLARSSL_SHA2_C
07504 
07505         FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_6)
07506         {
07507             char md_name[100];
07508             unsigned char src_str[10000];
07509             unsigned char hash_str[10000];
07510             unsigned char output[100];
07511             int src_len;
07512             const md_info_t *md_info = NULL;
07513             md_context_t ctx = MD_CONTEXT_T_INIT;
07514         
07515             memset(md_name, 0x00, 100);
07516             memset(src_str, 0x00, 10000);
07517             memset(hash_str, 0x00, 10000);
07518             memset(output, 0x00, 100);
07519         
07520             strncpy( (char *) md_name, "sha224", 100 );
07521             md_info = md_info_from_string(md_name);
07522             fct_chk( md_info != NULL );
07523             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07524         
07525             src_len = unhexify( src_str, "21ebecb914" );
07526             
07527             fct_chk ( 0 == md_starts( &ctx ) );
07528             fct_chk ( ctx.md_ctx != NULL );
07529             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07530             fct_chk ( 0 == md_finish( &ctx, output ) );
07531             fct_chk ( 0 == md_free_ctx( &ctx ) );
07532             
07533             hexify( hash_str, output, md_get_size(md_info) );
07534         
07535             fct_chk( strcmp( (char *) hash_str, "78f4a71c21c694499ce1c7866611b14ace70d905012c356323c7c713" ) == 0 );
07536         }
07537         FCT_TEST_END();
07538 #endif /* POLARSSL_SHA2_C */
07539 
07540 #ifdef POLARSSL_SHA2_C
07541 
07542         FCT_TEST_BGN(generic_multi_step_sha_224_test_vector_nist_cavs_7)
07543         {
07544             char md_name[100];
07545             unsigned char src_str[10000];
07546             unsigned char hash_str[10000];
07547             unsigned char output[100];
07548             int src_len;
07549             const md_info_t *md_info = NULL;
07550             md_context_t ctx = MD_CONTEXT_T_INIT;
07551         
07552             memset(md_name, 0x00, 100);
07553             memset(src_str, 0x00, 10000);
07554             memset(hash_str, 0x00, 10000);
07555             memset(output, 0x00, 100);
07556         
07557             strncpy( (char *) md_name, "sha224", 100 );
07558             md_info = md_info_from_string(md_name);
07559             fct_chk( md_info != NULL );
07560             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07561         
07562             src_len = unhexify( src_str, "fc488947c1a7a589726b15436b4f3d9556262f98fc6422fc5cdf20f0fad7fe427a3491c86d101ffe6b7514f06268f65b2d269b0f69ad9a97847eff1c16a2438775eb7be6847ccf11cb8b2e8dcd6640b095b49c0693fe3cf4a66e2d9b7ad68bff14f3ad69abf49d0aba36cbe0535202deb6599a47225ef05beb351335cd7bc0f480d691198c7e71305ffd53b39d33242bb79cfd98bfd69e137b5d18b2b89ac9ace01c8dbdcf2533cce3682ecc52118de0c1062ec2126c2e657d6ea3d9e2398e705d4b0b1f1ceecb266dffc4f31bf42744fb1e938dc22a889919ee1e73f463f7871fed720519e32186264b7ef2a0e5d9a18e6c95c0781894f77967f048951dec3b4d892a38710b1e3436d3c29088eb8b3da1789c25db3d3bc6c26081206e7155d210a89b80ca6ea877c41ff9947c0f25625dcb118294a163501f6239c326661a958fd12da4cd15a899f8b88cc723589056eaec5aa04a4cf5dbb6f480f9660423ccf38c486e210707e0fb25e1f126ceb2616f63e147a647dab0af9ebe89d65458bf636154a46e4cab95f5ee62da2c7974cd14b90d3e4f99f81733e85b3c1d5da2b508d9b90f5eed7eff0d9c7649de62bee00375454fee4a39576a5bbfdae428e7f8097bdf7797f167686cb68407e49079e4611ff3402b6384ba7b7e522bd2bb11ce8fd02ea4c1604d163ac4f6dde50b8b1f593f7edaadeac0868ed97df690200680c25f0f5d85431a529e4f339089dcdeda105e4ee51dead704cdf5a605c55fb055c9b0e86b8ba1b564c0dea3eb790a595cb103cb292268b07c5e59371e1a7ef597cd4b22977a820694c9f9aeb55d9de3ef62b75d6e656e3336698d960a3787bf8cf5b926a7faeef52ae128bcb5dc9e66d94b016c7b8e034879171a2d91c381f57e6a815b63b5ee6a6d2ff435b49f14c963966960194430d78f8f87627a67757fb3532b289550894da6dce4817a4e07f4d56877a1102ffcc8befa5c9f8fca6a4574d93ff70376c8861e0f8108cf907fce77ecb49728f86f034f80224b9695682e0824462f76cdb1fd1af151337b0d85419047a7aa284791718a4860cd586f7824b95bc837b6fd4f9be5aade68456e20356aa4d943dac36bf8b67b9e8f9d01a00fcda74b798bafa746c661b010f75b59904b29d0c8041504811c4065f82cf2ead58d2f595cbd8bc3e7043f4d94577b373b7cfe16a36fe564f505c03b70cfeb5e5f411c79481338aa67e86b3f5a2e77c21e454c333ae3da943ab723ab5f4c940395319534a5575f64acba0d0ecc43f60221ed3badf7289c9b3a7b903a2d6c94e15fa4c310dc4fa7faa0c24f405160a1002dbef20e4105d481db982f7243f79400a6e4cd9753c4b9732a47575f504b20c328fe9add7f432a4f075829da07b53b695037dc51737d3cd731934df333cd1a53fcf65aa31baa450ca501a6fae26e322347e618c5a444d92e9fec5a8261ae38b98fee5be77c02cec09ddccd5b3de92036" );
07563             
07564             fct_chk ( 0 == md_starts( &ctx ) );
07565             fct_chk ( ctx.md_ctx != NULL );
07566             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07567             fct_chk ( 0 == md_finish( &ctx, output ) );
07568             fct_chk ( 0 == md_free_ctx( &ctx ) );
07569             
07570             hexify( hash_str, output, md_get_size(md_info) );
07571         
07572             fct_chk( strcmp( (char *) hash_str, "1302149d1e197c41813b054c942329d420e366530f5517b470e964fe" ) == 0 );
07573         }
07574         FCT_TEST_END();
07575 #endif /* POLARSSL_SHA2_C */
07576 
07577 #ifdef POLARSSL_SHA2_C
07578 
07579         FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_1)
07580         {
07581             char md_name[100];
07582             unsigned char src_str[10000];
07583             unsigned char hash_str[10000];
07584             unsigned char output[100];
07585             int src_len;
07586             const md_info_t *md_info = NULL;
07587             md_context_t ctx = MD_CONTEXT_T_INIT;
07588         
07589             memset(md_name, 0x00, 100);
07590             memset(src_str, 0x00, 10000);
07591             memset(hash_str, 0x00, 10000);
07592             memset(output, 0x00, 100);
07593         
07594             strncpy( (char *) md_name, "sha256", 100 );
07595             md_info = md_info_from_string(md_name);
07596             fct_chk( md_info != NULL );
07597             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07598         
07599             src_len = unhexify( src_str, "" );
07600             
07601             fct_chk ( 0 == md_starts( &ctx ) );
07602             fct_chk ( ctx.md_ctx != NULL );
07603             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07604             fct_chk ( 0 == md_finish( &ctx, output ) );
07605             fct_chk ( 0 == md_free_ctx( &ctx ) );
07606             
07607             hexify( hash_str, output, md_get_size(md_info) );
07608         
07609             fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
07610         }
07611         FCT_TEST_END();
07612 #endif /* POLARSSL_SHA2_C */
07613 
07614 #ifdef POLARSSL_SHA2_C
07615 
07616         FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_2)
07617         {
07618             char md_name[100];
07619             unsigned char src_str[10000];
07620             unsigned char hash_str[10000];
07621             unsigned char output[100];
07622             int src_len;
07623             const md_info_t *md_info = NULL;
07624             md_context_t ctx = MD_CONTEXT_T_INIT;
07625         
07626             memset(md_name, 0x00, 100);
07627             memset(src_str, 0x00, 10000);
07628             memset(hash_str, 0x00, 10000);
07629             memset(output, 0x00, 100);
07630         
07631             strncpy( (char *) md_name, "sha256", 100 );
07632             md_info = md_info_from_string(md_name);
07633             fct_chk( md_info != NULL );
07634             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07635         
07636             src_len = unhexify( src_str, "bd" );
07637             
07638             fct_chk ( 0 == md_starts( &ctx ) );
07639             fct_chk ( ctx.md_ctx != NULL );
07640             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07641             fct_chk ( 0 == md_finish( &ctx, output ) );
07642             fct_chk ( 0 == md_free_ctx( &ctx ) );
07643             
07644             hexify( hash_str, output, md_get_size(md_info) );
07645         
07646             fct_chk( strcmp( (char *) hash_str, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b" ) == 0 );
07647         }
07648         FCT_TEST_END();
07649 #endif /* POLARSSL_SHA2_C */
07650 
07651 #ifdef POLARSSL_SHA2_C
07652 
07653         FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_3)
07654         {
07655             char md_name[100];
07656             unsigned char src_str[10000];
07657             unsigned char hash_str[10000];
07658             unsigned char output[100];
07659             int src_len;
07660             const md_info_t *md_info = NULL;
07661             md_context_t ctx = MD_CONTEXT_T_INIT;
07662         
07663             memset(md_name, 0x00, 100);
07664             memset(src_str, 0x00, 10000);
07665             memset(hash_str, 0x00, 10000);
07666             memset(output, 0x00, 100);
07667         
07668             strncpy( (char *) md_name, "sha256", 100 );
07669             md_info = md_info_from_string(md_name);
07670             fct_chk( md_info != NULL );
07671             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07672         
07673             src_len = unhexify( src_str, "5fd4" );
07674             
07675             fct_chk ( 0 == md_starts( &ctx ) );
07676             fct_chk ( ctx.md_ctx != NULL );
07677             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07678             fct_chk ( 0 == md_finish( &ctx, output ) );
07679             fct_chk ( 0 == md_free_ctx( &ctx ) );
07680             
07681             hexify( hash_str, output, md_get_size(md_info) );
07682         
07683             fct_chk( strcmp( (char *) hash_str, "7c4fbf484498d21b487b9d61de8914b2eadaf2698712936d47c3ada2558f6788" ) == 0 );
07684         }
07685         FCT_TEST_END();
07686 #endif /* POLARSSL_SHA2_C */
07687 
07688 #ifdef POLARSSL_SHA2_C
07689 
07690         FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_4)
07691         {
07692             char md_name[100];
07693             unsigned char src_str[10000];
07694             unsigned char hash_str[10000];
07695             unsigned char output[100];
07696             int src_len;
07697             const md_info_t *md_info = NULL;
07698             md_context_t ctx = MD_CONTEXT_T_INIT;
07699         
07700             memset(md_name, 0x00, 100);
07701             memset(src_str, 0x00, 10000);
07702             memset(hash_str, 0x00, 10000);
07703             memset(output, 0x00, 100);
07704         
07705             strncpy( (char *) md_name, "sha256", 100 );
07706             md_info = md_info_from_string(md_name);
07707             fct_chk( md_info != NULL );
07708             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07709         
07710             src_len = unhexify( src_str, "b0bd69" );
07711             
07712             fct_chk ( 0 == md_starts( &ctx ) );
07713             fct_chk ( ctx.md_ctx != NULL );
07714             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07715             fct_chk ( 0 == md_finish( &ctx, output ) );
07716             fct_chk ( 0 == md_free_ctx( &ctx ) );
07717             
07718             hexify( hash_str, output, md_get_size(md_info) );
07719         
07720             fct_chk( strcmp( (char *) hash_str, "4096804221093ddccfbf46831490ea63e9e99414858f8d75ff7f642c7ca61803" ) == 0 );
07721         }
07722         FCT_TEST_END();
07723 #endif /* POLARSSL_SHA2_C */
07724 
07725 #ifdef POLARSSL_SHA2_C
07726 
07727         FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_5)
07728         {
07729             char md_name[100];
07730             unsigned char src_str[10000];
07731             unsigned char hash_str[10000];
07732             unsigned char output[100];
07733             int src_len;
07734             const md_info_t *md_info = NULL;
07735             md_context_t ctx = MD_CONTEXT_T_INIT;
07736         
07737             memset(md_name, 0x00, 100);
07738             memset(src_str, 0x00, 10000);
07739             memset(hash_str, 0x00, 10000);
07740             memset(output, 0x00, 100);
07741         
07742             strncpy( (char *) md_name, "sha256", 100 );
07743             md_info = md_info_from_string(md_name);
07744             fct_chk( md_info != NULL );
07745             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07746         
07747             src_len = unhexify( src_str, "c98c8e55" );
07748             
07749             fct_chk ( 0 == md_starts( &ctx ) );
07750             fct_chk ( ctx.md_ctx != NULL );
07751             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07752             fct_chk ( 0 == md_finish( &ctx, output ) );
07753             fct_chk ( 0 == md_free_ctx( &ctx ) );
07754             
07755             hexify( hash_str, output, md_get_size(md_info) );
07756         
07757             fct_chk( strcmp( (char *) hash_str, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504" ) == 0 );
07758         }
07759         FCT_TEST_END();
07760 #endif /* POLARSSL_SHA2_C */
07761 
07762 #ifdef POLARSSL_SHA2_C
07763 
07764         FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_6)
07765         {
07766             char md_name[100];
07767             unsigned char src_str[10000];
07768             unsigned char hash_str[10000];
07769             unsigned char output[100];
07770             int src_len;
07771             const md_info_t *md_info = NULL;
07772             md_context_t ctx = MD_CONTEXT_T_INIT;
07773         
07774             memset(md_name, 0x00, 100);
07775             memset(src_str, 0x00, 10000);
07776             memset(hash_str, 0x00, 10000);
07777             memset(output, 0x00, 100);
07778         
07779             strncpy( (char *) md_name, "sha256", 100 );
07780             md_info = md_info_from_string(md_name);
07781             fct_chk( md_info != NULL );
07782             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07783         
07784             src_len = unhexify( src_str, "81a723d966" );
07785             
07786             fct_chk ( 0 == md_starts( &ctx ) );
07787             fct_chk ( ctx.md_ctx != NULL );
07788             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07789             fct_chk ( 0 == md_finish( &ctx, output ) );
07790             fct_chk ( 0 == md_free_ctx( &ctx ) );
07791             
07792             hexify( hash_str, output, md_get_size(md_info) );
07793         
07794             fct_chk( strcmp( (char *) hash_str, "7516fb8bb11350df2bf386bc3c33bd0f52cb4c67c6e4745e0488e62c2aea2605" ) == 0 );
07795         }
07796         FCT_TEST_END();
07797 #endif /* POLARSSL_SHA2_C */
07798 
07799 #ifdef POLARSSL_SHA2_C
07800 
07801         FCT_TEST_BGN(generic_multi_step_sha_256_test_vector_nist_cavs_7)
07802         {
07803             char md_name[100];
07804             unsigned char src_str[10000];
07805             unsigned char hash_str[10000];
07806             unsigned char output[100];
07807             int src_len;
07808             const md_info_t *md_info = NULL;
07809             md_context_t ctx = MD_CONTEXT_T_INIT;
07810         
07811             memset(md_name, 0x00, 100);
07812             memset(src_str, 0x00, 10000);
07813             memset(hash_str, 0x00, 10000);
07814             memset(output, 0x00, 100);
07815         
07816             strncpy( (char *) md_name, "sha256", 100 );
07817             md_info = md_info_from_string(md_name);
07818             fct_chk( md_info != NULL );
07819             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07820         
07821             src_len = unhexify( src_str, "8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e" );
07822             
07823             fct_chk ( 0 == md_starts( &ctx ) );
07824             fct_chk ( ctx.md_ctx != NULL );
07825             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07826             fct_chk ( 0 == md_finish( &ctx, output ) );
07827             fct_chk ( 0 == md_free_ctx( &ctx ) );
07828             
07829             hexify( hash_str, output, md_get_size(md_info) );
07830         
07831             fct_chk( strcmp( (char *) hash_str, "4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e" ) == 0 );
07832         }
07833         FCT_TEST_END();
07834 #endif /* POLARSSL_SHA2_C */
07835 
07836 #ifdef POLARSSL_SHA4_C
07837 
07838         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_1)
07839         {
07840             char md_name[100];
07841             unsigned char src_str[10000];
07842             unsigned char hash_str[10000];
07843             unsigned char output[100];
07844             int src_len;
07845             const md_info_t *md_info = NULL;
07846             md_context_t ctx = MD_CONTEXT_T_INIT;
07847         
07848             memset(md_name, 0x00, 100);
07849             memset(src_str, 0x00, 10000);
07850             memset(hash_str, 0x00, 10000);
07851             memset(output, 0x00, 100);
07852         
07853             strncpy( (char *) md_name, "sha384", 100 );
07854             md_info = md_info_from_string(md_name);
07855             fct_chk( md_info != NULL );
07856             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07857         
07858             src_len = unhexify( src_str, "" );
07859             
07860             fct_chk ( 0 == md_starts( &ctx ) );
07861             fct_chk ( ctx.md_ctx != NULL );
07862             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07863             fct_chk ( 0 == md_finish( &ctx, output ) );
07864             fct_chk ( 0 == md_free_ctx( &ctx ) );
07865             
07866             hexify( hash_str, output, md_get_size(md_info) );
07867         
07868             fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
07869         }
07870         FCT_TEST_END();
07871 #endif /* POLARSSL_SHA4_C */
07872 
07873 #ifdef POLARSSL_SHA4_C
07874 
07875         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_2)
07876         {
07877             char md_name[100];
07878             unsigned char src_str[10000];
07879             unsigned char hash_str[10000];
07880             unsigned char output[100];
07881             int src_len;
07882             const md_info_t *md_info = NULL;
07883             md_context_t ctx = MD_CONTEXT_T_INIT;
07884         
07885             memset(md_name, 0x00, 100);
07886             memset(src_str, 0x00, 10000);
07887             memset(hash_str, 0x00, 10000);
07888             memset(output, 0x00, 100);
07889         
07890             strncpy( (char *) md_name, "sha384", 100 );
07891             md_info = md_info_from_string(md_name);
07892             fct_chk( md_info != NULL );
07893             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07894         
07895             src_len = unhexify( src_str, "ab" );
07896             
07897             fct_chk ( 0 == md_starts( &ctx ) );
07898             fct_chk ( ctx.md_ctx != NULL );
07899             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07900             fct_chk ( 0 == md_finish( &ctx, output ) );
07901             fct_chk ( 0 == md_free_ctx( &ctx ) );
07902             
07903             hexify( hash_str, output, md_get_size(md_info) );
07904         
07905             fct_chk( strcmp( (char *) hash_str, "fb94d5be118865f6fcbc978b825da82cff188faec2f66cb84b2537d74b4938469854b0ca89e66fa2e182834736629f3d" ) == 0 );
07906         }
07907         FCT_TEST_END();
07908 #endif /* POLARSSL_SHA4_C */
07909 
07910 #ifdef POLARSSL_SHA4_C
07911 
07912         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_3)
07913         {
07914             char md_name[100];
07915             unsigned char src_str[10000];
07916             unsigned char hash_str[10000];
07917             unsigned char output[100];
07918             int src_len;
07919             const md_info_t *md_info = NULL;
07920             md_context_t ctx = MD_CONTEXT_T_INIT;
07921         
07922             memset(md_name, 0x00, 100);
07923             memset(src_str, 0x00, 10000);
07924             memset(hash_str, 0x00, 10000);
07925             memset(output, 0x00, 100);
07926         
07927             strncpy( (char *) md_name, "sha384", 100 );
07928             md_info = md_info_from_string(md_name);
07929             fct_chk( md_info != NULL );
07930             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07931         
07932             src_len = unhexify( src_str, "7c27" );
07933             
07934             fct_chk ( 0 == md_starts( &ctx ) );
07935             fct_chk ( ctx.md_ctx != NULL );
07936             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07937             fct_chk ( 0 == md_finish( &ctx, output ) );
07938             fct_chk ( 0 == md_free_ctx( &ctx ) );
07939             
07940             hexify( hash_str, output, md_get_size(md_info) );
07941         
07942             fct_chk( strcmp( (char *) hash_str, "3d80be467df86d63abb9ea1d3f9cb39cd19890e7f2c53a6200bedc5006842b35e820dc4e0ca90ca9b97ab23ef07080fc" ) == 0 );
07943         }
07944         FCT_TEST_END();
07945 #endif /* POLARSSL_SHA4_C */
07946 
07947 #ifdef POLARSSL_SHA4_C
07948 
07949         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_4)
07950         {
07951             char md_name[100];
07952             unsigned char src_str[10000];
07953             unsigned char hash_str[10000];
07954             unsigned char output[100];
07955             int src_len;
07956             const md_info_t *md_info = NULL;
07957             md_context_t ctx = MD_CONTEXT_T_INIT;
07958         
07959             memset(md_name, 0x00, 100);
07960             memset(src_str, 0x00, 10000);
07961             memset(hash_str, 0x00, 10000);
07962             memset(output, 0x00, 100);
07963         
07964             strncpy( (char *) md_name, "sha384", 100 );
07965             md_info = md_info_from_string(md_name);
07966             fct_chk( md_info != NULL );
07967             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
07968         
07969             src_len = unhexify( src_str, "31f5ca" );
07970             
07971             fct_chk ( 0 == md_starts( &ctx ) );
07972             fct_chk ( ctx.md_ctx != NULL );
07973             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
07974             fct_chk ( 0 == md_finish( &ctx, output ) );
07975             fct_chk ( 0 == md_free_ctx( &ctx ) );
07976             
07977             hexify( hash_str, output, md_get_size(md_info) );
07978         
07979             fct_chk( strcmp( (char *) hash_str, "78d54b943421fdf7ba90a7fb9637c2073aa480454bd841d39ff72f4511fc21fb67797b652c0c823229342873d3bef955" ) == 0 );
07980         }
07981         FCT_TEST_END();
07982 #endif /* POLARSSL_SHA4_C */
07983 
07984 #ifdef POLARSSL_SHA4_C
07985 
07986         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_5)
07987         {
07988             char md_name[100];
07989             unsigned char src_str[10000];
07990             unsigned char hash_str[10000];
07991             unsigned char output[100];
07992             int src_len;
07993             const md_info_t *md_info = NULL;
07994             md_context_t ctx = MD_CONTEXT_T_INIT;
07995         
07996             memset(md_name, 0x00, 100);
07997             memset(src_str, 0x00, 10000);
07998             memset(hash_str, 0x00, 10000);
07999             memset(output, 0x00, 100);
08000         
08001             strncpy( (char *) md_name, "sha384", 100 );
08002             md_info = md_info_from_string(md_name);
08003             fct_chk( md_info != NULL );
08004             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08005         
08006             src_len = unhexify( src_str, "7bdee3f8" );
08007             
08008             fct_chk ( 0 == md_starts( &ctx ) );
08009             fct_chk ( ctx.md_ctx != NULL );
08010             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08011             fct_chk ( 0 == md_finish( &ctx, output ) );
08012             fct_chk ( 0 == md_free_ctx( &ctx ) );
08013             
08014             hexify( hash_str, output, md_get_size(md_info) );
08015         
08016             fct_chk( strcmp( (char *) hash_str, "8bdafba0777ee446c3431c2d7b1fbb631089f71d2ca417abc1d230e1aba64ec2f1c187474a6f4077d372c14ad407f99a" ) == 0 );
08017         }
08018         FCT_TEST_END();
08019 #endif /* POLARSSL_SHA4_C */
08020 
08021 #ifdef POLARSSL_SHA4_C
08022 
08023         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_6)
08024         {
08025             char md_name[100];
08026             unsigned char src_str[10000];
08027             unsigned char hash_str[10000];
08028             unsigned char output[100];
08029             int src_len;
08030             const md_info_t *md_info = NULL;
08031             md_context_t ctx = MD_CONTEXT_T_INIT;
08032         
08033             memset(md_name, 0x00, 100);
08034             memset(src_str, 0x00, 10000);
08035             memset(hash_str, 0x00, 10000);
08036             memset(output, 0x00, 100);
08037         
08038             strncpy( (char *) md_name, "sha384", 100 );
08039             md_info = md_info_from_string(md_name);
08040             fct_chk( md_info != NULL );
08041             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08042         
08043             src_len = unhexify( src_str, "8f05604915" );
08044             
08045             fct_chk ( 0 == md_starts( &ctx ) );
08046             fct_chk ( ctx.md_ctx != NULL );
08047             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08048             fct_chk ( 0 == md_finish( &ctx, output ) );
08049             fct_chk ( 0 == md_free_ctx( &ctx ) );
08050             
08051             hexify( hash_str, output, md_get_size(md_info) );
08052         
08053             fct_chk( strcmp( (char *) hash_str, "504e414bf1db1060f14c8c799e25b1e0c4dcf1504ebbd129998f0ae283e6de86e0d3c7e879c73ec3b1836c3ee89c2649" ) == 0 );
08054         }
08055         FCT_TEST_END();
08056 #endif /* POLARSSL_SHA4_C */
08057 
08058 #ifdef POLARSSL_SHA4_C
08059 
08060         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_7)
08061         {
08062             char md_name[100];
08063             unsigned char src_str[10000];
08064             unsigned char hash_str[10000];
08065             unsigned char output[100];
08066             int src_len;
08067             const md_info_t *md_info = NULL;
08068             md_context_t ctx = MD_CONTEXT_T_INIT;
08069         
08070             memset(md_name, 0x00, 100);
08071             memset(src_str, 0x00, 10000);
08072             memset(hash_str, 0x00, 10000);
08073             memset(output, 0x00, 100);
08074         
08075             strncpy( (char *) md_name, "sha384", 100 );
08076             md_info = md_info_from_string(md_name);
08077             fct_chk( md_info != NULL );
08078             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08079         
08080             src_len = unhexify( src_str, "665da6eda214" );
08081             
08082             fct_chk ( 0 == md_starts( &ctx ) );
08083             fct_chk ( ctx.md_ctx != NULL );
08084             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08085             fct_chk ( 0 == md_finish( &ctx, output ) );
08086             fct_chk ( 0 == md_free_ctx( &ctx ) );
08087             
08088             hexify( hash_str, output, md_get_size(md_info) );
08089         
08090             fct_chk( strcmp( (char *) hash_str, "4c022f112010908848312f8b8f1072625fd5c105399d562ea1d56130619a7eac8dfc3748fd05ee37e4b690be9daa9980" ) == 0 );
08091         }
08092         FCT_TEST_END();
08093 #endif /* POLARSSL_SHA4_C */
08094 
08095 #ifdef POLARSSL_SHA4_C
08096 
08097         FCT_TEST_BGN(generic_multi_step_sha_384_test_vector_nist_cavs_8)
08098         {
08099             char md_name[100];
08100             unsigned char src_str[10000];
08101             unsigned char hash_str[10000];
08102             unsigned char output[100];
08103             int src_len;
08104             const md_info_t *md_info = NULL;
08105             md_context_t ctx = MD_CONTEXT_T_INIT;
08106         
08107             memset(md_name, 0x00, 100);
08108             memset(src_str, 0x00, 10000);
08109             memset(hash_str, 0x00, 10000);
08110             memset(output, 0x00, 100);
08111         
08112             strncpy( (char *) md_name, "sha384", 100 );
08113             md_info = md_info_from_string(md_name);
08114             fct_chk( md_info != NULL );
08115             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08116         
08117             src_len = unhexify( src_str, "7f46ce506d593c4ed53c82edeb602037e0485befbee03f7f930fe532d18ff2a3f5fd6076672c8145a1bf40dd94f7abab47c9ae71c234213d2ad1069c2dac0b0ba15257ae672b8245960ae55bd50315c0097daa3a318745788d70d14706910809ca6e396237fe4934fa46f9ce782d66606d8bd6b2d283b1160513ce9c24e9f084b97891f99d4cdefc169a029e431ca772ba1bba426fce6f01d8e286014e5acc66b799e4db62bd4783322f8a32ff78e0de3957df50ce10871f4e0680df4e8ca3960af9bc6f4efa8eb3962d18f474eb178c3265cc46b8f2ff5ab1a7449fea297dfcfabfa01f28abbb7289bb354b691b5664ec6d098af51be19947ec5ba7ebd66380d1141953ba78d4aa5401679fa7b0a44db1981f864d3535c45afe4c61183d5b0ad51fae71ca07e34240283959f7530a32c70d95a088e501c230059f333b0670825009e7e22103ef22935830df1fac8ef877f5f3426dd54f7d1128dd871ad9a7d088f94c0e8712013295b8d69ae7623b880978c2d3c6ad26dc478f8dc47f5c0adcc618665dc3dc205a9071b2f2191e16cac5bd89bb59148fc719633752303aa08e518dbc389f0a5482caaa4c507b8729a6f3edd061efb39026cecc6399f51971cf7381d605e144a5928c8c2d1ad7467b05da2f202f4f3234e1aff19a0198a28685721c3d2d52311c721e3fdcbaf30214cdc3acff8c433880e104fb63f2df7ce69a97857819ba7ac00ac8eae1969764fde8f68cf8e0916d7e0c151147d4944f99f42ae50f30e1c79a42d2b6c5188d133d3cbbf69094027b354b295ccd0f7dc5a87d73638bd98ebfb00383ca0fa69cb8dcb35a12510e5e07ad8789047d0b63841a1bb928737e8b0a0c33254f47aa8bfbe3341a09c2b76dbcefa67e30df300d34f7b8465c4f869e51b6bcfe6cf68b238359a645036bf7f63f02924e087ce7457e483b6025a859903cb484574aa3b12cf946f32127d537c33bee3141b5db96d10a148c50ae045f287210757710d6846e04b202f79e87dd9a56bc6da15f84a77a7f63935e1dee00309cd276a8e7176cb04da6bb0e9009534438732cb42d008008853d38d19beba46e61006e30f7efd1bc7c2906b024e4ff898a1b58c448d68b43c6ab63f34f85b3ac6aa4475867e51b583844cb23829f4b30f4bdd817d88e2ef3e7b4fc0a624395b05ec5e8686082b24d29fef2b0d3c29e031d5f94f504b1d3df9361eb5ffbadb242e66c39a8094cfe62f85f639f3fd65fc8ae0c74a8f4c6e1d070b9183a434c722caaa0225f8bcd68614d6f0738ed62f8484ec96077d155c08e26c46be262a73e3551698bd70d8d5610cf37c4c306eed04ba6a040a9c3e6d7e15e8acda17f477c2484cf5c56b813313927be8387b1024f995e98fc87f1029091c01424bdc2b296c2eadb7d25b3e762a2fd0c2dcd1727ddf91db97c5984305265f3695a7f5472f2d72c94d68c27914f14f82aa8dd5fe4e2348b0ca967a3f98626a091552f5d0ffa2bf10350d23c996256c01fdeffb2c2c612519869f877e4929c6e95ff15040f1485e22ed14119880232fef3b57b3848f15b1766a5552879df8f06" );
08118             
08119             fct_chk ( 0 == md_starts( &ctx ) );
08120             fct_chk ( ctx.md_ctx != NULL );
08121             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08122             fct_chk ( 0 == md_finish( &ctx, output ) );
08123             fct_chk ( 0 == md_free_ctx( &ctx ) );
08124             
08125             hexify( hash_str, output, md_get_size(md_info) );
08126         
08127             fct_chk( strcmp( (char *) hash_str, "cba9e3eb12a6f83db11e8a6ff40d1049854ee094416bc527fea931d8585428a8ed6242ce81f6769b36e2123a5c23483e" ) == 0 );
08128         }
08129         FCT_TEST_END();
08130 #endif /* POLARSSL_SHA4_C */
08131 
08132 #ifdef POLARSSL_SHA4_C
08133 
08134         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_1)
08135         {
08136             char md_name[100];
08137             unsigned char src_str[10000];
08138             unsigned char hash_str[10000];
08139             unsigned char output[100];
08140             int src_len;
08141             const md_info_t *md_info = NULL;
08142             md_context_t ctx = MD_CONTEXT_T_INIT;
08143         
08144             memset(md_name, 0x00, 100);
08145             memset(src_str, 0x00, 10000);
08146             memset(hash_str, 0x00, 10000);
08147             memset(output, 0x00, 100);
08148         
08149             strncpy( (char *) md_name, "sha512", 100 );
08150             md_info = md_info_from_string(md_name);
08151             fct_chk( md_info != NULL );
08152             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08153         
08154             src_len = unhexify( src_str, "" );
08155             
08156             fct_chk ( 0 == md_starts( &ctx ) );
08157             fct_chk ( ctx.md_ctx != NULL );
08158             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08159             fct_chk ( 0 == md_finish( &ctx, output ) );
08160             fct_chk ( 0 == md_free_ctx( &ctx ) );
08161             
08162             hexify( hash_str, output, md_get_size(md_info) );
08163         
08164             fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
08165         }
08166         FCT_TEST_END();
08167 #endif /* POLARSSL_SHA4_C */
08168 
08169 #ifdef POLARSSL_SHA4_C
08170 
08171         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_2)
08172         {
08173             char md_name[100];
08174             unsigned char src_str[10000];
08175             unsigned char hash_str[10000];
08176             unsigned char output[100];
08177             int src_len;
08178             const md_info_t *md_info = NULL;
08179             md_context_t ctx = MD_CONTEXT_T_INIT;
08180         
08181             memset(md_name, 0x00, 100);
08182             memset(src_str, 0x00, 10000);
08183             memset(hash_str, 0x00, 10000);
08184             memset(output, 0x00, 100);
08185         
08186             strncpy( (char *) md_name, "sha512", 100 );
08187             md_info = md_info_from_string(md_name);
08188             fct_chk( md_info != NULL );
08189             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08190         
08191             src_len = unhexify( src_str, "8f" );
08192             
08193             fct_chk ( 0 == md_starts( &ctx ) );
08194             fct_chk ( ctx.md_ctx != NULL );
08195             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08196             fct_chk ( 0 == md_finish( &ctx, output ) );
08197             fct_chk ( 0 == md_free_ctx( &ctx ) );
08198             
08199             hexify( hash_str, output, md_get_size(md_info) );
08200         
08201             fct_chk( strcmp( (char *) hash_str, "e4cd2d19931b5aad9c920f45f56f6ce34e3d38c6d319a6e11d0588ab8b838576d6ce6d68eea7c830de66e2bd96458bfa7aafbcbec981d4ed040498c3dd95f22a" ) == 0 );
08202         }
08203         FCT_TEST_END();
08204 #endif /* POLARSSL_SHA4_C */
08205 
08206 #ifdef POLARSSL_SHA4_C
08207 
08208         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_3)
08209         {
08210             char md_name[100];
08211             unsigned char src_str[10000];
08212             unsigned char hash_str[10000];
08213             unsigned char output[100];
08214             int src_len;
08215             const md_info_t *md_info = NULL;
08216             md_context_t ctx = MD_CONTEXT_T_INIT;
08217         
08218             memset(md_name, 0x00, 100);
08219             memset(src_str, 0x00, 10000);
08220             memset(hash_str, 0x00, 10000);
08221             memset(output, 0x00, 100);
08222         
08223             strncpy( (char *) md_name, "sha512", 100 );
08224             md_info = md_info_from_string(md_name);
08225             fct_chk( md_info != NULL );
08226             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08227         
08228             src_len = unhexify( src_str, "e724" );
08229             
08230             fct_chk ( 0 == md_starts( &ctx ) );
08231             fct_chk ( ctx.md_ctx != NULL );
08232             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08233             fct_chk ( 0 == md_finish( &ctx, output ) );
08234             fct_chk ( 0 == md_free_ctx( &ctx ) );
08235             
08236             hexify( hash_str, output, md_get_size(md_info) );
08237         
08238             fct_chk( strcmp( (char *) hash_str, "7dbb520221a70287b23dbcf62bfc1b73136d858e86266732a7fffa875ecaa2c1b8f673b5c065d360c563a7b9539349f5f59bef8c0c593f9587e3cd50bb26a231" ) == 0 );
08239         }
08240         FCT_TEST_END();
08241 #endif /* POLARSSL_SHA4_C */
08242 
08243 #ifdef POLARSSL_SHA4_C
08244 
08245         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_4)
08246         {
08247             char md_name[100];
08248             unsigned char src_str[10000];
08249             unsigned char hash_str[10000];
08250             unsigned char output[100];
08251             int src_len;
08252             const md_info_t *md_info = NULL;
08253             md_context_t ctx = MD_CONTEXT_T_INIT;
08254         
08255             memset(md_name, 0x00, 100);
08256             memset(src_str, 0x00, 10000);
08257             memset(hash_str, 0x00, 10000);
08258             memset(output, 0x00, 100);
08259         
08260             strncpy( (char *) md_name, "sha512", 100 );
08261             md_info = md_info_from_string(md_name);
08262             fct_chk( md_info != NULL );
08263             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08264         
08265             src_len = unhexify( src_str, "de4c90" );
08266             
08267             fct_chk ( 0 == md_starts( &ctx ) );
08268             fct_chk ( ctx.md_ctx != NULL );
08269             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08270             fct_chk ( 0 == md_finish( &ctx, output ) );
08271             fct_chk ( 0 == md_free_ctx( &ctx ) );
08272             
08273             hexify( hash_str, output, md_get_size(md_info) );
08274         
08275             fct_chk( strcmp( (char *) hash_str, "33ce98281045a5c4c9df0363d8196f1d7dfcd5ee46ac89776fd8a4344c12f123a66788af5bd41ceff1941aa5637654b4064c88c14e00465ab79a2fc6c97e1014" ) == 0 );
08276         }
08277         FCT_TEST_END();
08278 #endif /* POLARSSL_SHA4_C */
08279 
08280 #ifdef POLARSSL_SHA4_C
08281 
08282         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_5)
08283         {
08284             char md_name[100];
08285             unsigned char src_str[10000];
08286             unsigned char hash_str[10000];
08287             unsigned char output[100];
08288             int src_len;
08289             const md_info_t *md_info = NULL;
08290             md_context_t ctx = MD_CONTEXT_T_INIT;
08291         
08292             memset(md_name, 0x00, 100);
08293             memset(src_str, 0x00, 10000);
08294             memset(hash_str, 0x00, 10000);
08295             memset(output, 0x00, 100);
08296         
08297             strncpy( (char *) md_name, "sha512", 100 );
08298             md_info = md_info_from_string(md_name);
08299             fct_chk( md_info != NULL );
08300             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08301         
08302             src_len = unhexify( src_str, "a801e94b" );
08303             
08304             fct_chk ( 0 == md_starts( &ctx ) );
08305             fct_chk ( ctx.md_ctx != NULL );
08306             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08307             fct_chk ( 0 == md_finish( &ctx, output ) );
08308             fct_chk ( 0 == md_free_ctx( &ctx ) );
08309             
08310             hexify( hash_str, output, md_get_size(md_info) );
08311         
08312             fct_chk( strcmp( (char *) hash_str, "dadb1b5a27f9fece8d86adb2a51879beb1787ff28f4e8ce162cad7fee0f942efcabbf738bc6f797fc7cc79a3a75048cd4c82ca0757a324695bfb19a557e56e2f" ) == 0 );
08313         }
08314         FCT_TEST_END();
08315 #endif /* POLARSSL_SHA4_C */
08316 
08317 #ifdef POLARSSL_SHA4_C
08318 
08319         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_6)
08320         {
08321             char md_name[100];
08322             unsigned char src_str[10000];
08323             unsigned char hash_str[10000];
08324             unsigned char output[100];
08325             int src_len;
08326             const md_info_t *md_info = NULL;
08327             md_context_t ctx = MD_CONTEXT_T_INIT;
08328         
08329             memset(md_name, 0x00, 100);
08330             memset(src_str, 0x00, 10000);
08331             memset(hash_str, 0x00, 10000);
08332             memset(output, 0x00, 100);
08333         
08334             strncpy( (char *) md_name, "sha512", 100 );
08335             md_info = md_info_from_string(md_name);
08336             fct_chk( md_info != NULL );
08337             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08338         
08339             src_len = unhexify( src_str, "94390d3502" );
08340             
08341             fct_chk ( 0 == md_starts( &ctx ) );
08342             fct_chk ( ctx.md_ctx != NULL );
08343             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08344             fct_chk ( 0 == md_finish( &ctx, output ) );
08345             fct_chk ( 0 == md_free_ctx( &ctx ) );
08346             
08347             hexify( hash_str, output, md_get_size(md_info) );
08348         
08349             fct_chk( strcmp( (char *) hash_str, "b6175c4c4cccf69e0ce5f0312010886ea6b34d43673f942ae42483f9cbb7da817de4e11b5d58e25a3d9bd721a22cdffe1c40411cc45df1911fa5506129b69297" ) == 0 );
08350         }
08351         FCT_TEST_END();
08352 #endif /* POLARSSL_SHA4_C */
08353 
08354 #ifdef POLARSSL_SHA4_C
08355 
08356         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_7)
08357         {
08358             char md_name[100];
08359             unsigned char src_str[10000];
08360             unsigned char hash_str[10000];
08361             unsigned char output[100];
08362             int src_len;
08363             const md_info_t *md_info = NULL;
08364             md_context_t ctx = MD_CONTEXT_T_INIT;
08365         
08366             memset(md_name, 0x00, 100);
08367             memset(src_str, 0x00, 10000);
08368             memset(hash_str, 0x00, 10000);
08369             memset(output, 0x00, 100);
08370         
08371             strncpy( (char *) md_name, "sha512", 100 );
08372             md_info = md_info_from_string(md_name);
08373             fct_chk( md_info != NULL );
08374             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08375         
08376             src_len = unhexify( src_str, "49297dd63e5f" );
08377             
08378             fct_chk ( 0 == md_starts( &ctx ) );
08379             fct_chk ( ctx.md_ctx != NULL );
08380             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08381             fct_chk ( 0 == md_finish( &ctx, output ) );
08382             fct_chk ( 0 == md_free_ctx( &ctx ) );
08383             
08384             hexify( hash_str, output, md_get_size(md_info) );
08385         
08386             fct_chk( strcmp( (char *) hash_str, "1fcc1e6f6870859d11649f5e5336a9cd16329c029baf04d5a6edf257889a2e9522b497dd656bb402da461307c4ee382e2e89380c8e6e6e7697f1e439f650fa94" ) == 0 );
08387         }
08388         FCT_TEST_END();
08389 #endif /* POLARSSL_SHA4_C */
08390 
08391 #ifdef POLARSSL_SHA4_C
08392 
08393         FCT_TEST_BGN(generic_multi_step_sha_512_test_vector_nist_cavs_8)
08394         {
08395             char md_name[100];
08396             unsigned char src_str[10000];
08397             unsigned char hash_str[10000];
08398             unsigned char output[100];
08399             int src_len;
08400             const md_info_t *md_info = NULL;
08401             md_context_t ctx = MD_CONTEXT_T_INIT;
08402         
08403             memset(md_name, 0x00, 100);
08404             memset(src_str, 0x00, 10000);
08405             memset(hash_str, 0x00, 10000);
08406             memset(output, 0x00, 100);
08407         
08408             strncpy( (char *) md_name, "sha512", 100 );
08409             md_info = md_info_from_string(md_name);
08410             fct_chk( md_info != NULL );
08411             fct_chk ( 0 == md_init_ctx( &ctx, md_info ) );
08412         
08413             src_len = unhexify( src_str, "990d1ae71a62d7bda9bfdaa1762a68d296eee72a4cd946f287a898fbabc002ea941fd8d4d991030b4d27a637cce501a834bb95eab1b7889a3e784c7968e67cbf552006b206b68f76d9191327524fcc251aeb56af483d10b4e0c6c5e599ee8c0fe4faeca8293844a8547c6a9a90d093f2526873a19ad4a5e776794c68c742fb834793d2dfcb7fea46c63af4b70fd11cb6e41834e72ee40edb067b292a794990c288d5007e73f349fb383af6a756b8301ad6e5e0aa8cd614399bb3a452376b1575afa6bdaeaafc286cb064bb91edef97c632b6c1113d107fa93a0905098a105043c2f05397f702514439a08a9e5ddc196100721d45c8fc17d2ed659376f8a00bd5cb9a0860e26d8a29d8d6aaf52de97e9346033d6db501a35dbbaf97c20b830cd2d18c2532f3a59cc497ee64c0e57d8d060e5069b28d86edf1adcf59144b221ce3ddaef134b3124fbc7dd000240eff0f5f5f41e83cd7f5bb37c9ae21953fe302b0f6e8b68fa91c6ab99265c64b2fd9cd4942be04321bb5d6d71932376c6f2f88e02422ba6a5e2cb765df93fd5dd0728c6abdaf03bce22e0678a544e2c3636f741b6f4447ee58a8fc656b43ef817932176adbfc2e04b2c812c273cd6cbfa4098f0be036a34221fa02643f5ee2e0b38135f2a18ecd2f16ebc45f8eb31b8ab967a1567ee016904188910861ca1fa205c7adaa194b286893ffe2f4fbe0384c2aef72a4522aeafd3ebc71f9db71eeeef86c48394a1c86d5b36c352cc33a0a2c800bc99e62fd65b3a2fd69e0b53996ec13d8ce483ce9319efd9a85acefabdb5342226febb83fd1daf4b24265f50c61c6de74077ef89b6fecf9f29a1f871af1e9f89b2d345cda7499bd45c42fa5d195a1e1a6ba84851889e730da3b2b916e96152ae0c92154b49719841db7e7cc707ba8a5d7b101eb4ac7b629bb327817910fff61580b59aab78182d1a2e33473d05b00b170b29e331870826cfe45af206aa7d0246bbd8566ca7cfb2d3c10bfa1db7dd48dd786036469ce7282093d78b5e1a5b0fc81a54c8ed4ceac1e5305305e78284ac276f5d7862727aff246e17addde50c670028d572cbfc0be2e4f8b2eb28fa68ad7b4c6c2a239c460441bfb5ea049f23b08563b4e47729a59e5986a61a6093dbd54f8c36ebe87edae01f251cb060ad1364ce677d7e8d5a4a4ca966a7241cc360bc2acb280e5f9e9c1b032ad6a180a35e0c5180b9d16d026c865b252098cc1d99ba7375ca31c7702c0d943d5e3dd2f6861fa55bd46d94b67ed3e52eccd8dd06d968e01897d6de97ed3058d91dd" );
08414             
08415             fct_chk ( 0 == md_starts( &ctx ) );
08416             fct_chk ( ctx.md_ctx != NULL );
08417             fct_chk ( 0 == md_update( &ctx, src_str, src_len ) );
08418             fct_chk ( 0 == md_finish( &ctx, output ) );
08419             fct_chk ( 0 == md_free_ctx( &ctx ) );
08420             
08421             hexify( hash_str, output, md_get_size(md_info) );
08422         
08423             fct_chk( strcmp( (char *) hash_str, "8e4bc6f8b8c60fe4d68c61d9b159c8693c3151c46749af58da228442d927f23359bd6ccd6c2ec8fa3f00a86cecbfa728e1ad60b821ed22fcd309ba91a4138bc9" ) == 0 );
08424         }
08425         FCT_TEST_END();
08426 #endif /* POLARSSL_SHA4_C */
08427 
08428 #ifdef POLARSSL_SHA1_C
08429 #ifdef POLARSSL_FS_IO
08430 
08431         FCT_TEST_BGN(generic_sha1_hash_file_1)
08432         {
08433             char md_name[100];
08434             unsigned char hash_str[1000];
08435             unsigned char output[100];
08436             const md_info_t *md_info = NULL;
08437         
08438             memset(md_name, 0x00, 100);
08439             memset(hash_str, 0x00, 1000);
08440             memset(output, 0x00, 100);
08441         
08442             strncpy( (char *) md_name, "sha1", 100 );
08443             md_info = md_info_from_string( md_name );
08444             fct_chk( md_info != NULL );
08445         
08446             md_file( md_info, "data_files/hash_file_1", output);
08447             hexify( hash_str, output, md_get_size(md_info) );
08448         
08449             fct_chk( strcmp( (char *) hash_str, "d21c965b1e768bd7a6aa6869f5f821901d255f9f" ) == 0 );
08450         }
08451         FCT_TEST_END();
08452 #endif /* POLARSSL_SHA1_C */
08453 #endif /* POLARSSL_FS_IO */
08454 
08455 #ifdef POLARSSL_SHA1_C
08456 #ifdef POLARSSL_FS_IO
08457 
08458         FCT_TEST_BGN(generic_sha1_hash_file_2)
08459         {
08460             char md_name[100];
08461             unsigned char hash_str[1000];
08462             unsigned char output[100];
08463             const md_info_t *md_info = NULL;
08464         
08465             memset(md_name, 0x00, 100);
08466             memset(hash_str, 0x00, 1000);
08467             memset(output, 0x00, 100);
08468         
08469             strncpy( (char *) md_name, "sha1", 100 );
08470             md_info = md_info_from_string( md_name );
08471             fct_chk( md_info != NULL );
08472         
08473             md_file( md_info, "data_files/hash_file_2", output);
08474             hexify( hash_str, output, md_get_size(md_info) );
08475         
08476             fct_chk( strcmp( (char *) hash_str, "353f34271f2aef49d23a8913d4a6bd82b2cecdc6" ) == 0 );
08477         }
08478         FCT_TEST_END();
08479 #endif /* POLARSSL_SHA1_C */
08480 #endif /* POLARSSL_FS_IO */
08481 
08482 #ifdef POLARSSL_SHA1_C
08483 #ifdef POLARSSL_FS_IO
08484 
08485         FCT_TEST_BGN(generic_sha1_hash_file_3)
08486         {
08487             char md_name[100];
08488             unsigned char hash_str[1000];
08489             unsigned char output[100];
08490             const md_info_t *md_info = NULL;
08491         
08492             memset(md_name, 0x00, 100);
08493             memset(hash_str, 0x00, 1000);
08494             memset(output, 0x00, 100);
08495         
08496             strncpy( (char *) md_name, "sha1", 100 );
08497             md_info = md_info_from_string( md_name );
08498             fct_chk( md_info != NULL );
08499         
08500             md_file( md_info, "data_files/hash_file_3", output);
08501             hexify( hash_str, output, md_get_size(md_info) );
08502         
08503             fct_chk( strcmp( (char *) hash_str, "93640ed592076328096270c756db2fba9c486b35" ) == 0 );
08504         }
08505         FCT_TEST_END();
08506 #endif /* POLARSSL_SHA1_C */
08507 #endif /* POLARSSL_FS_IO */
08508 
08509 #ifdef POLARSSL_SHA1_C
08510 #ifdef POLARSSL_FS_IO
08511 
08512         FCT_TEST_BGN(generic_sha1_hash_file_4)
08513         {
08514             char md_name[100];
08515             unsigned char hash_str[1000];
08516             unsigned char output[100];
08517             const md_info_t *md_info = NULL;
08518         
08519             memset(md_name, 0x00, 100);
08520             memset(hash_str, 0x00, 1000);
08521             memset(output, 0x00, 100);
08522         
08523             strncpy( (char *) md_name, "sha1", 100 );
08524             md_info = md_info_from_string( md_name );
08525             fct_chk( md_info != NULL );
08526         
08527             md_file( md_info, "data_files/hash_file_4", output);
08528             hexify( hash_str, output, md_get_size(md_info) );
08529         
08530             fct_chk( strcmp( (char *) hash_str, "da39a3ee5e6b4b0d3255bfef95601890afd80709" ) == 0 );
08531         }
08532         FCT_TEST_END();
08533 #endif /* POLARSSL_SHA1_C */
08534 #endif /* POLARSSL_FS_IO */
08535 
08536 #ifdef POLARSSL_SHA2_C
08537 #ifdef POLARSSL_FS_IO
08538 
08539         FCT_TEST_BGN(generic_sha_224_hash_file_1)
08540         {
08541             char md_name[100];
08542             unsigned char hash_str[1000];
08543             unsigned char output[100];
08544             const md_info_t *md_info = NULL;
08545         
08546             memset(md_name, 0x00, 100);
08547             memset(hash_str, 0x00, 1000);
08548             memset(output, 0x00, 100);
08549         
08550             strncpy( (char *) md_name, "sha224", 100 );
08551             md_info = md_info_from_string( md_name );
08552             fct_chk( md_info != NULL );
08553         
08554             md_file( md_info, "data_files/hash_file_1", output);
08555             hexify( hash_str, output, md_get_size(md_info) );
08556         
08557             fct_chk( strcmp( (char *) hash_str, "8606da018870f0c16834a21bc3385704cb1683b9dbab04c5ddb90a48" ) == 0 );
08558         }
08559         FCT_TEST_END();
08560 #endif /* POLARSSL_SHA2_C */
08561 #endif /* POLARSSL_FS_IO */
08562 
08563 #ifdef POLARSSL_SHA2_C
08564 #ifdef POLARSSL_FS_IO
08565 
08566         FCT_TEST_BGN(generic_sha_224_hash_file_2)
08567         {
08568             char md_name[100];
08569             unsigned char hash_str[1000];
08570             unsigned char output[100];
08571             const md_info_t *md_info = NULL;
08572         
08573             memset(md_name, 0x00, 100);
08574             memset(hash_str, 0x00, 1000);
08575             memset(output, 0x00, 100);
08576         
08577             strncpy( (char *) md_name, "sha224", 100 );
08578             md_info = md_info_from_string( md_name );
08579             fct_chk( md_info != NULL );
08580         
08581             md_file( md_info, "data_files/hash_file_2", output);
08582             hexify( hash_str, output, md_get_size(md_info) );
08583         
08584             fct_chk( strcmp( (char *) hash_str, "733b2ab97b6f63f2e29b9a2089756d81e14c93fe4cc9615c0d5e8a03" ) == 0 );
08585         }
08586         FCT_TEST_END();
08587 #endif /* POLARSSL_SHA2_C */
08588 #endif /* POLARSSL_FS_IO */
08589 
08590 #ifdef POLARSSL_SHA2_C
08591 #ifdef POLARSSL_FS_IO
08592 
08593         FCT_TEST_BGN(generic_sha_224_hash_file_3)
08594         {
08595             char md_name[100];
08596             unsigned char hash_str[1000];
08597             unsigned char output[100];
08598             const md_info_t *md_info = NULL;
08599         
08600             memset(md_name, 0x00, 100);
08601             memset(hash_str, 0x00, 1000);
08602             memset(output, 0x00, 100);
08603         
08604             strncpy( (char *) md_name, "sha224", 100 );
08605             md_info = md_info_from_string( md_name );
08606             fct_chk( md_info != NULL );
08607         
08608             md_file( md_info, "data_files/hash_file_3", output);
08609             hexify( hash_str, output, md_get_size(md_info) );
08610         
08611             fct_chk( strcmp( (char *) hash_str, "e1df95867580e2cc2100e9565bf9c2e42c24fe5250c19efe33d1c4fe" ) == 0 );
08612         }
08613         FCT_TEST_END();
08614 #endif /* POLARSSL_SHA2_C */
08615 #endif /* POLARSSL_FS_IO */
08616 
08617 #ifdef POLARSSL_SHA2_C
08618 #ifdef POLARSSL_FS_IO
08619 
08620         FCT_TEST_BGN(generic_sha_224_hash_file_4)
08621         {
08622             char md_name[100];
08623             unsigned char hash_str[1000];
08624             unsigned char output[100];
08625             const md_info_t *md_info = NULL;
08626         
08627             memset(md_name, 0x00, 100);
08628             memset(hash_str, 0x00, 1000);
08629             memset(output, 0x00, 100);
08630         
08631             strncpy( (char *) md_name, "sha224", 100 );
08632             md_info = md_info_from_string( md_name );
08633             fct_chk( md_info != NULL );
08634         
08635             md_file( md_info, "data_files/hash_file_4", output);
08636             hexify( hash_str, output, md_get_size(md_info) );
08637         
08638             fct_chk( strcmp( (char *) hash_str, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" ) == 0 );
08639         }
08640         FCT_TEST_END();
08641 #endif /* POLARSSL_SHA2_C */
08642 #endif /* POLARSSL_FS_IO */
08643 
08644 #ifdef POLARSSL_SHA2_C
08645 #ifdef POLARSSL_FS_IO
08646 
08647         FCT_TEST_BGN(generic_sha_256_hash_file_1)
08648         {
08649             char md_name[100];
08650             unsigned char hash_str[1000];
08651             unsigned char output[100];
08652             const md_info_t *md_info = NULL;
08653         
08654             memset(md_name, 0x00, 100);
08655             memset(hash_str, 0x00, 1000);
08656             memset(output, 0x00, 100);
08657         
08658             strncpy( (char *) md_name, "sha256", 100 );
08659             md_info = md_info_from_string( md_name );
08660             fct_chk( md_info != NULL );
08661         
08662             md_file( md_info, "data_files/hash_file_1", output);
08663             hexify( hash_str, output, md_get_size(md_info) );
08664         
08665             fct_chk( strcmp( (char *) hash_str, "975d0c620d3936886f8a3665e585a3e84aa0501f4225bf53029710242823e391" ) == 0 );
08666         }
08667         FCT_TEST_END();
08668 #endif /* POLARSSL_SHA2_C */
08669 #endif /* POLARSSL_FS_IO */
08670 
08671 #ifdef POLARSSL_SHA2_C
08672 #ifdef POLARSSL_FS_IO
08673 
08674         FCT_TEST_BGN(generic_sha_256_hash_file_2)
08675         {
08676             char md_name[100];
08677             unsigned char hash_str[1000];
08678             unsigned char output[100];
08679             const md_info_t *md_info = NULL;
08680         
08681             memset(md_name, 0x00, 100);
08682             memset(hash_str, 0x00, 1000);
08683             memset(output, 0x00, 100);
08684         
08685             strncpy( (char *) md_name, "sha256", 100 );
08686             md_info = md_info_from_string( md_name );
08687             fct_chk( md_info != NULL );
08688         
08689             md_file( md_info, "data_files/hash_file_2", output);
08690             hexify( hash_str, output, md_get_size(md_info) );
08691         
08692             fct_chk( strcmp( (char *) hash_str, "11fcbf1baa36ca45745f10cc5467aee86f066f80ba2c46806d876bf783022ad2" ) == 0 );
08693         }
08694         FCT_TEST_END();
08695 #endif /* POLARSSL_SHA2_C */
08696 #endif /* POLARSSL_FS_IO */
08697 
08698 #ifdef POLARSSL_SHA2_C
08699 #ifdef POLARSSL_FS_IO
08700 
08701         FCT_TEST_BGN(generic_sha_256_hash_file_3)
08702         {
08703             char md_name[100];
08704             unsigned char hash_str[1000];
08705             unsigned char output[100];
08706             const md_info_t *md_info = NULL;
08707         
08708             memset(md_name, 0x00, 100);
08709             memset(hash_str, 0x00, 1000);
08710             memset(output, 0x00, 100);
08711         
08712             strncpy( (char *) md_name, "sha256", 100 );
08713             md_info = md_info_from_string( md_name );
08714             fct_chk( md_info != NULL );
08715         
08716             md_file( md_info, "data_files/hash_file_3", output);
08717             hexify( hash_str, output, md_get_size(md_info) );
08718         
08719             fct_chk( strcmp( (char *) hash_str, "9ae4b369f9f4f03b86505b46a5469542e00aaff7cf7417a71af6d6d0aba3b70c" ) == 0 );
08720         }
08721         FCT_TEST_END();
08722 #endif /* POLARSSL_SHA2_C */
08723 #endif /* POLARSSL_FS_IO */
08724 
08725 #ifdef POLARSSL_SHA2_C
08726 #ifdef POLARSSL_FS_IO
08727 
08728         FCT_TEST_BGN(generic_sha_256_hash_file_4)
08729         {
08730             char md_name[100];
08731             unsigned char hash_str[1000];
08732             unsigned char output[100];
08733             const md_info_t *md_info = NULL;
08734         
08735             memset(md_name, 0x00, 100);
08736             memset(hash_str, 0x00, 1000);
08737             memset(output, 0x00, 100);
08738         
08739             strncpy( (char *) md_name, "sha256", 100 );
08740             md_info = md_info_from_string( md_name );
08741             fct_chk( md_info != NULL );
08742         
08743             md_file( md_info, "data_files/hash_file_4", output);
08744             hexify( hash_str, output, md_get_size(md_info) );
08745         
08746             fct_chk( strcmp( (char *) hash_str, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) == 0 );
08747         }
08748         FCT_TEST_END();
08749 #endif /* POLARSSL_SHA2_C */
08750 #endif /* POLARSSL_FS_IO */
08751 
08752 #ifdef POLARSSL_SHA4_C
08753 #ifdef POLARSSL_FS_IO
08754 
08755         FCT_TEST_BGN(generic_sha_384_hash_file_1)
08756         {
08757             char md_name[100];
08758             unsigned char hash_str[1000];
08759             unsigned char output[100];
08760             const md_info_t *md_info = NULL;
08761         
08762             memset(md_name, 0x00, 100);
08763             memset(hash_str, 0x00, 1000);
08764             memset(output, 0x00, 100);
08765         
08766             strncpy( (char *) md_name, "sha384", 100 );
08767             md_info = md_info_from_string( md_name );
08768             fct_chk( md_info != NULL );
08769         
08770             md_file( md_info, "data_files/hash_file_1", output);
08771             hexify( hash_str, output, md_get_size(md_info) );
08772         
08773             fct_chk( strcmp( (char *) hash_str, "e0a3e6259d6378001b54ef82f5dd087009c5fad86d8db226a9fe1d14ecbe33a6fc916e3a4b16f5f286424de15d5a8e0e" ) == 0 );
08774         }
08775         FCT_TEST_END();
08776 #endif /* POLARSSL_SHA4_C */
08777 #endif /* POLARSSL_FS_IO */
08778 
08779 #ifdef POLARSSL_SHA4_C
08780 #ifdef POLARSSL_FS_IO
08781 
08782         FCT_TEST_BGN(generic_sha_384_hash_file_2)
08783         {
08784             char md_name[100];
08785             unsigned char hash_str[1000];
08786             unsigned char output[100];
08787             const md_info_t *md_info = NULL;
08788         
08789             memset(md_name, 0x00, 100);
08790             memset(hash_str, 0x00, 1000);
08791             memset(output, 0x00, 100);
08792         
08793             strncpy( (char *) md_name, "sha384", 100 );
08794             md_info = md_info_from_string( md_name );
08795             fct_chk( md_info != NULL );
08796         
08797             md_file( md_info, "data_files/hash_file_2", output);
08798             hexify( hash_str, output, md_get_size(md_info) );
08799         
08800             fct_chk( strcmp( (char *) hash_str, "eff727afc8495c92e2f370f97a317f93c3350324b0646b0f0e264708b3c97d3d332d3c5390e1e47130f5c92f1ef4b9cf" ) == 0 );
08801         }
08802         FCT_TEST_END();
08803 #endif /* POLARSSL_SHA4_C */
08804 #endif /* POLARSSL_FS_IO */
08805 
08806 #ifdef POLARSSL_SHA4_C
08807 #ifdef POLARSSL_FS_IO
08808 
08809         FCT_TEST_BGN(generic_sha_384_hash_file_3)
08810         {
08811             char md_name[100];
08812             unsigned char hash_str[1000];
08813             unsigned char output[100];
08814             const md_info_t *md_info = NULL;
08815         
08816             memset(md_name, 0x00, 100);
08817             memset(hash_str, 0x00, 1000);
08818             memset(output, 0x00, 100);
08819         
08820             strncpy( (char *) md_name, "sha384", 100 );
08821             md_info = md_info_from_string( md_name );
08822             fct_chk( md_info != NULL );
08823         
08824             md_file( md_info, "data_files/hash_file_3", output);
08825             hexify( hash_str, output, md_get_size(md_info) );
08826         
08827             fct_chk( strcmp( (char *) hash_str, "6fc10ebda96a1ccf61777cac72f6034f92533d42052a4bf9f9d929c672973c71e5aeb1213268043c21527ac0f7f349c4" ) == 0 );
08828         }
08829         FCT_TEST_END();
08830 #endif /* POLARSSL_SHA4_C */
08831 #endif /* POLARSSL_FS_IO */
08832 
08833 #ifdef POLARSSL_SHA4_C
08834 #ifdef POLARSSL_FS_IO
08835 
08836         FCT_TEST_BGN(generic_sha_384_hash_file_4)
08837         {
08838             char md_name[100];
08839             unsigned char hash_str[1000];
08840             unsigned char output[100];
08841             const md_info_t *md_info = NULL;
08842         
08843             memset(md_name, 0x00, 100);
08844             memset(hash_str, 0x00, 1000);
08845             memset(output, 0x00, 100);
08846         
08847             strncpy( (char *) md_name, "sha384", 100 );
08848             md_info = md_info_from_string( md_name );
08849             fct_chk( md_info != NULL );
08850         
08851             md_file( md_info, "data_files/hash_file_4", output);
08852             hexify( hash_str, output, md_get_size(md_info) );
08853         
08854             fct_chk( strcmp( (char *) hash_str, "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" ) == 0 );
08855         }
08856         FCT_TEST_END();
08857 #endif /* POLARSSL_SHA4_C */
08858 #endif /* POLARSSL_FS_IO */
08859 
08860 #ifdef POLARSSL_SHA4_C
08861 #ifdef POLARSSL_FS_IO
08862 
08863         FCT_TEST_BGN(generic_sha_512_hash_file_1)
08864         {
08865             char md_name[100];
08866             unsigned char hash_str[1000];
08867             unsigned char output[100];
08868             const md_info_t *md_info = NULL;
08869         
08870             memset(md_name, 0x00, 100);
08871             memset(hash_str, 0x00, 1000);
08872             memset(output, 0x00, 100);
08873         
08874             strncpy( (char *) md_name, "sha512", 100 );
08875             md_info = md_info_from_string( md_name );
08876             fct_chk( md_info != NULL );
08877         
08878             md_file( md_info, "data_files/hash_file_1", output);
08879             hexify( hash_str, output, md_get_size(md_info) );
08880         
08881             fct_chk( strcmp( (char *) hash_str, "d8207a2e1ff2b424f2c4163fe1b723c9bd42e464061eb411e8df730bcd24a7ab3956a6f3ff044a52eb2d262f9e4ca6b524092b544ab78f14d6f9c4cc8ddf335a" ) == 0 );
08882         }
08883         FCT_TEST_END();
08884 #endif /* POLARSSL_SHA4_C */
08885 #endif /* POLARSSL_FS_IO */
08886 
08887 #ifdef POLARSSL_SHA4_C
08888 #ifdef POLARSSL_FS_IO
08889 
08890         FCT_TEST_BGN(generic_sha_512_hash_file_2)
08891         {
08892             char md_name[100];
08893             unsigned char hash_str[1000];
08894             unsigned char output[100];
08895             const md_info_t *md_info = NULL;
08896         
08897             memset(md_name, 0x00, 100);
08898             memset(hash_str, 0x00, 1000);
08899             memset(output, 0x00, 100);
08900         
08901             strncpy( (char *) md_name, "sha512", 100 );
08902             md_info = md_info_from_string( md_name );
08903             fct_chk( md_info != NULL );
08904         
08905             md_file( md_info, "data_files/hash_file_2", output);
08906             hexify( hash_str, output, md_get_size(md_info) );
08907         
08908             fct_chk( strcmp( (char *) hash_str, "ecbb7f0ed8a702b49f16ad3088bcc06ea93451912a7187db15f64d93517b09630b039293aed418d4a00695777b758b1f381548c2fd7b92ce5ed996b32c8734e7" ) == 0 );
08909         }
08910         FCT_TEST_END();
08911 #endif /* POLARSSL_SHA4_C */
08912 #endif /* POLARSSL_FS_IO */
08913 
08914 #ifdef POLARSSL_SHA4_C
08915 #ifdef POLARSSL_FS_IO
08916 
08917         FCT_TEST_BGN(generic_sha_512_hash_file_3)
08918         {
08919             char md_name[100];
08920             unsigned char hash_str[1000];
08921             unsigned char output[100];
08922             const md_info_t *md_info = NULL;
08923         
08924             memset(md_name, 0x00, 100);
08925             memset(hash_str, 0x00, 1000);
08926             memset(output, 0x00, 100);
08927         
08928             strncpy( (char *) md_name, "sha512", 100 );
08929             md_info = md_info_from_string( md_name );
08930             fct_chk( md_info != NULL );
08931         
08932             md_file( md_info, "data_files/hash_file_3", output);
08933             hexify( hash_str, output, md_get_size(md_info) );
08934         
08935             fct_chk( strcmp( (char *) hash_str, "7ccc9b2da71ffde9966c3ce44d7f20945fccf33b1fade4da152b021f1afcc7293382944aa6c09eac67af25f22026758e2bf6bed86ae2a43592677ee50f8eea41" ) == 0 );
08936         }
08937         FCT_TEST_END();
08938 #endif /* POLARSSL_SHA4_C */
08939 #endif /* POLARSSL_FS_IO */
08940 
08941 #ifdef POLARSSL_SHA4_C
08942 #ifdef POLARSSL_FS_IO
08943 
08944         FCT_TEST_BGN(generic_sha_512_hash_file_4)
08945         {
08946             char md_name[100];
08947             unsigned char hash_str[1000];
08948             unsigned char output[100];
08949             const md_info_t *md_info = NULL;
08950         
08951             memset(md_name, 0x00, 100);
08952             memset(hash_str, 0x00, 1000);
08953             memset(output, 0x00, 100);
08954         
08955             strncpy( (char *) md_name, "sha512", 100 );
08956             md_info = md_info_from_string( md_name );
08957             fct_chk( md_info != NULL );
08958         
08959             md_file( md_info, "data_files/hash_file_4", output);
08960             hexify( hash_str, output, md_get_size(md_info) );
08961         
08962             fct_chk( strcmp( (char *) hash_str, "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" ) == 0 );
08963         }
08964         FCT_TEST_END();
08965 #endif /* POLARSSL_SHA4_C */
08966 #endif /* POLARSSL_FS_IO */
08967 
08968     }
08969     FCT_SUITE_END();
08970 
08971 #endif /* POLARSSL_MD_C */
08972 
08973 }
08974 FCT_END();
08975