PolarSSL v1.1.4
test_suite_mdx.c
Go to the documentation of this file.
00001 #include "fct.h"
00002 
00003 #include <polarssl/md2.h>
00004 #include <polarssl/md4.h>
00005 #include <polarssl/md5.h>
00006 
00007 #include <polarssl/config.h>
00008 
00009 #ifdef _MSC_VER
00010 #include <basetsd.h>
00011 typedef UINT32 uint32_t;
00012 #else
00013 #include <inttypes.h>
00014 #endif
00015 
00016 /*
00017  * 32-bit integer manipulation macros (big endian)
00018  */
00019 #ifndef GET_ULONG_BE
00020 #define GET_ULONG_BE(n,b,i)                             \
00021 {                                                       \
00022     (n) = ( (unsigned long) (b)[(i)    ] << 24 )        \
00023         | ( (unsigned long) (b)[(i) + 1] << 16 )        \
00024         | ( (unsigned long) (b)[(i) + 2] <<  8 )        \
00025         | ( (unsigned long) (b)[(i) + 3]       );       \
00026 }
00027 #endif
00028 
00029 #ifndef PUT_ULONG_BE
00030 #define PUT_ULONG_BE(n,b,i)                             \
00031 {                                                       \
00032     (b)[(i)    ] = (unsigned char) ( (n) >> 24 );       \
00033     (b)[(i) + 1] = (unsigned char) ( (n) >> 16 );       \
00034     (b)[(i) + 2] = (unsigned char) ( (n) >>  8 );       \
00035     (b)[(i) + 3] = (unsigned char) ( (n)       );       \
00036 }
00037 #endif
00038 
00039 int unhexify(unsigned char *obuf, const char *ibuf)
00040 {
00041     unsigned char c, c2;
00042     int len = strlen(ibuf) / 2;
00043     assert(!(strlen(ibuf) %1)); // must be even number of bytes
00044 
00045     while (*ibuf != 0)
00046     {
00047         c = *ibuf++;
00048         if( c >= '0' && c <= '9' )
00049             c -= '0';
00050         else if( c >= 'a' && c <= 'f' )
00051             c -= 'a' - 10;
00052         else if( c >= 'A' && c <= 'F' )
00053             c -= 'A' - 10;
00054         else
00055             assert( 0 );
00056 
00057         c2 = *ibuf++;
00058         if( c2 >= '0' && c2 <= '9' )
00059             c2 -= '0';
00060         else if( c2 >= 'a' && c2 <= 'f' )
00061             c2 -= 'a' - 10;
00062         else if( c2 >= 'A' && c2 <= 'F' )
00063             c2 -= 'A' - 10;
00064         else
00065             assert( 0 );
00066 
00067         *obuf++ = ( c << 4 ) | c2;
00068     }
00069 
00070     return len;
00071 }
00072 
00073 void hexify(unsigned char *obuf, const unsigned char *ibuf, int len)
00074 {
00075     unsigned char l, h;
00076 
00077     while (len != 0)
00078     {
00079         h = (*ibuf) / 16;
00080         l = (*ibuf) % 16;
00081 
00082         if( h < 10 )
00083             *obuf++ = '0' + h;
00084         else
00085             *obuf++ = 'a' + h - 10;
00086 
00087         if( l < 10 )
00088             *obuf++ = '0' + l;
00089         else
00090             *obuf++ = 'a' + l - 10;
00091 
00092         ++ibuf;
00093         len--;
00094     }
00095 }
00096 
00106 static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
00107 {
00108     size_t i;
00109 
00110     if( rng_state != NULL )
00111         rng_state  = NULL;
00112 
00113     for( i = 0; i < len; ++i )
00114         output[i] = rand();
00115 
00116     return( 0 );
00117 }
00118 
00124 static int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
00125 {
00126     if( rng_state != NULL )
00127         rng_state  = NULL;
00128 
00129     memset( output, 0, len );
00130 
00131     return( 0 );
00132 }
00133 
00134 typedef struct
00135 {
00136     unsigned char *buf;
00137     size_t length;
00138 } rnd_buf_info;
00139 
00151 static int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
00152 {
00153     rnd_buf_info *info = (rnd_buf_info *) rng_state;
00154     size_t use_len;
00155 
00156     if( rng_state == NULL )
00157         return( rnd_std_rand( NULL, output, len ) );
00158 
00159     use_len = len;
00160     if( len > info->length )
00161         use_len = info->length;
00162 
00163     if( use_len )
00164     {
00165         memcpy( output, info->buf, use_len );
00166         info->buf += use_len;
00167         info->length -= use_len;
00168     }
00169 
00170     if( len - use_len > 0 )
00171         return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
00172 
00173     return( 0 );
00174 }
00175 
00183 typedef struct
00184 {
00185     uint32_t key[16];
00186     uint32_t v0, v1;
00187 } rnd_pseudo_info;
00188 
00197 static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
00198 {
00199     rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
00200     uint32_t i, *k, sum, delta=0x9E3779B9;
00201     unsigned char result[4];
00202 
00203     if( rng_state == NULL )
00204         return( rnd_std_rand( NULL, output, len ) );
00205 
00206     k = info->key;
00207 
00208     while( len > 0 )
00209     {
00210         size_t use_len = ( len > 4 ) ? 4 : len;
00211         sum = 0;
00212 
00213         for( i = 0; i < 32; i++ )
00214         {
00215             info->v0 += (((info->v1 << 4) ^ (info->v1 >> 5)) + info->v1) ^ (sum + k[sum & 3]);
00216             sum += delta;
00217             info->v1 += (((info->v0 << 4) ^ (info->v0 >> 5)) + info->v0) ^ (sum + k[(sum>>11) & 3]);
00218         }
00219 
00220         PUT_ULONG_BE( info->v0, result, 0 );
00221         memcpy( output, result, use_len );
00222         len -= use_len;
00223     }
00224 
00225     return( 0 );
00226 }
00227 
00228 
00229 FCT_BGN()
00230 {
00231 
00232 
00233     FCT_SUITE_BGN(test_suite_mdx)
00234     {
00235 #ifdef POLARSSL_MD2_C
00236 
00237         FCT_TEST_BGN(md2_test_vector_rfc1319_1)
00238         {
00239             unsigned char src_str[1000];
00240             unsigned char hash_str[1000];
00241             unsigned char output[33];
00242         
00243             memset(src_str, 0x00, 1000);
00244             memset(hash_str, 0x00, 1000);
00245             memset(output, 0x00, 33);
00246         
00247             strcpy( (char *) src_str, "" );
00248         
00249             md2( src_str, strlen( (char *) src_str ), output );
00250             hexify( hash_str, output, 16 );
00251         
00252             fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
00253         }
00254         FCT_TEST_END();
00255 #endif /* POLARSSL_MD2_C */
00256 
00257 #ifdef POLARSSL_MD2_C
00258 
00259         FCT_TEST_BGN(md2_test_vector_rfc1319_2)
00260         {
00261             unsigned char src_str[1000];
00262             unsigned char hash_str[1000];
00263             unsigned char output[33];
00264         
00265             memset(src_str, 0x00, 1000);
00266             memset(hash_str, 0x00, 1000);
00267             memset(output, 0x00, 33);
00268         
00269             strcpy( (char *) src_str, "a" );
00270         
00271             md2( src_str, strlen( (char *) src_str ), output );
00272             hexify( hash_str, output, 16 );
00273         
00274             fct_chk( strcmp( (char *) hash_str, "32ec01ec4a6dac72c0ab96fb34c0b5d1" ) == 0 );
00275         }
00276         FCT_TEST_END();
00277 #endif /* POLARSSL_MD2_C */
00278 
00279 #ifdef POLARSSL_MD2_C
00280 
00281         FCT_TEST_BGN(md2_test_vector_rfc1319_3)
00282         {
00283             unsigned char src_str[1000];
00284             unsigned char hash_str[1000];
00285             unsigned char output[33];
00286         
00287             memset(src_str, 0x00, 1000);
00288             memset(hash_str, 0x00, 1000);
00289             memset(output, 0x00, 33);
00290         
00291             strcpy( (char *) src_str, "abc" );
00292         
00293             md2( src_str, strlen( (char *) src_str ), output );
00294             hexify( hash_str, output, 16 );
00295         
00296             fct_chk( strcmp( (char *) hash_str, "da853b0d3f88d99b30283a69e6ded6bb" ) == 0 );
00297         }
00298         FCT_TEST_END();
00299 #endif /* POLARSSL_MD2_C */
00300 
00301 #ifdef POLARSSL_MD2_C
00302 
00303         FCT_TEST_BGN(md2_test_vector_rfc1319_4)
00304         {
00305             unsigned char src_str[1000];
00306             unsigned char hash_str[1000];
00307             unsigned char output[33];
00308         
00309             memset(src_str, 0x00, 1000);
00310             memset(hash_str, 0x00, 1000);
00311             memset(output, 0x00, 33);
00312         
00313             strcpy( (char *) src_str, "message digest" );
00314         
00315             md2( src_str, strlen( (char *) src_str ), output );
00316             hexify( hash_str, output, 16 );
00317         
00318             fct_chk( strcmp( (char *) hash_str, "ab4f496bfb2a530b219ff33031fe06b0" ) == 0 );
00319         }
00320         FCT_TEST_END();
00321 #endif /* POLARSSL_MD2_C */
00322 
00323 #ifdef POLARSSL_MD2_C
00324 
00325         FCT_TEST_BGN(md2_test_vector_rfc1319_5)
00326         {
00327             unsigned char src_str[1000];
00328             unsigned char hash_str[1000];
00329             unsigned char output[33];
00330         
00331             memset(src_str, 0x00, 1000);
00332             memset(hash_str, 0x00, 1000);
00333             memset(output, 0x00, 33);
00334         
00335             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
00336         
00337             md2( src_str, strlen( (char *) src_str ), output );
00338             hexify( hash_str, output, 16 );
00339         
00340             fct_chk( strcmp( (char *) hash_str, "4e8ddff3650292ab5a4108c3aa47940b" ) == 0 );
00341         }
00342         FCT_TEST_END();
00343 #endif /* POLARSSL_MD2_C */
00344 
00345 #ifdef POLARSSL_MD2_C
00346 
00347         FCT_TEST_BGN(md2_test_vector_rfc1319_6)
00348         {
00349             unsigned char src_str[1000];
00350             unsigned char hash_str[1000];
00351             unsigned char output[33];
00352         
00353             memset(src_str, 0x00, 1000);
00354             memset(hash_str, 0x00, 1000);
00355             memset(output, 0x00, 33);
00356         
00357             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
00358         
00359             md2( src_str, strlen( (char *) src_str ), output );
00360             hexify( hash_str, output, 16 );
00361         
00362             fct_chk( strcmp( (char *) hash_str, "da33def2a42df13975352846c30338cd" ) == 0 );
00363         }
00364         FCT_TEST_END();
00365 #endif /* POLARSSL_MD2_C */
00366 
00367 #ifdef POLARSSL_MD2_C
00368 
00369         FCT_TEST_BGN(md2_test_vector_rfc1319_7)
00370         {
00371             unsigned char src_str[1000];
00372             unsigned char hash_str[1000];
00373             unsigned char output[33];
00374         
00375             memset(src_str, 0x00, 1000);
00376             memset(hash_str, 0x00, 1000);
00377             memset(output, 0x00, 33);
00378         
00379             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
00380         
00381             md2( src_str, strlen( (char *) src_str ), output );
00382             hexify( hash_str, output, 16 );
00383         
00384             fct_chk( strcmp( (char *) hash_str, "d5976f79d83d3a0dc9806c3c66f3efd8" ) == 0 );
00385         }
00386         FCT_TEST_END();
00387 #endif /* POLARSSL_MD2_C */
00388 
00389 #ifdef POLARSSL_MD4_C
00390 
00391         FCT_TEST_BGN(md4_test_vector_rfc1320_1)
00392         {
00393             unsigned char src_str[1000];
00394             unsigned char hash_str[1000];
00395             unsigned char output[33];
00396         
00397             memset(src_str, 0x00, 1000);
00398             memset(hash_str, 0x00, 1000);
00399             memset(output, 0x00, 33);
00400         
00401             strcpy( (char *) src_str, "" );
00402         
00403             md4( src_str, strlen( (char *) src_str ), output );
00404             hexify( hash_str, output, 16 );
00405         
00406             fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
00407         }
00408         FCT_TEST_END();
00409 #endif /* POLARSSL_MD4_C */
00410 
00411 #ifdef POLARSSL_MD4_C
00412 
00413         FCT_TEST_BGN(md4_test_vector_rfc1320_2)
00414         {
00415             unsigned char src_str[1000];
00416             unsigned char hash_str[1000];
00417             unsigned char output[33];
00418         
00419             memset(src_str, 0x00, 1000);
00420             memset(hash_str, 0x00, 1000);
00421             memset(output, 0x00, 33);
00422         
00423             strcpy( (char *) src_str, "a" );
00424         
00425             md4( src_str, strlen( (char *) src_str ), output );
00426             hexify( hash_str, output, 16 );
00427         
00428             fct_chk( strcmp( (char *) hash_str, "bde52cb31de33e46245e05fbdbd6fb24" ) == 0 );
00429         }
00430         FCT_TEST_END();
00431 #endif /* POLARSSL_MD4_C */
00432 
00433 #ifdef POLARSSL_MD4_C
00434 
00435         FCT_TEST_BGN(md4_test_vector_rfc1320_3)
00436         {
00437             unsigned char src_str[1000];
00438             unsigned char hash_str[1000];
00439             unsigned char output[33];
00440         
00441             memset(src_str, 0x00, 1000);
00442             memset(hash_str, 0x00, 1000);
00443             memset(output, 0x00, 33);
00444         
00445             strcpy( (char *) src_str, "abc" );
00446         
00447             md4( src_str, strlen( (char *) src_str ), output );
00448             hexify( hash_str, output, 16 );
00449         
00450             fct_chk( strcmp( (char *) hash_str, "a448017aaf21d8525fc10ae87aa6729d" ) == 0 );
00451         }
00452         FCT_TEST_END();
00453 #endif /* POLARSSL_MD4_C */
00454 
00455 #ifdef POLARSSL_MD4_C
00456 
00457         FCT_TEST_BGN(md4_test_vector_rfc1320_4)
00458         {
00459             unsigned char src_str[1000];
00460             unsigned char hash_str[1000];
00461             unsigned char output[33];
00462         
00463             memset(src_str, 0x00, 1000);
00464             memset(hash_str, 0x00, 1000);
00465             memset(output, 0x00, 33);
00466         
00467             strcpy( (char *) src_str, "message digest" );
00468         
00469             md4( src_str, strlen( (char *) src_str ), output );
00470             hexify( hash_str, output, 16 );
00471         
00472             fct_chk( strcmp( (char *) hash_str, "d9130a8164549fe818874806e1c7014b" ) == 0 );
00473         }
00474         FCT_TEST_END();
00475 #endif /* POLARSSL_MD4_C */
00476 
00477 #ifdef POLARSSL_MD4_C
00478 
00479         FCT_TEST_BGN(md4_test_vector_rfc1320_5)
00480         {
00481             unsigned char src_str[1000];
00482             unsigned char hash_str[1000];
00483             unsigned char output[33];
00484         
00485             memset(src_str, 0x00, 1000);
00486             memset(hash_str, 0x00, 1000);
00487             memset(output, 0x00, 33);
00488         
00489             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
00490         
00491             md4( src_str, strlen( (char *) src_str ), output );
00492             hexify( hash_str, output, 16 );
00493         
00494             fct_chk( strcmp( (char *) hash_str, "d79e1c308aa5bbcdeea8ed63df412da9" ) == 0 );
00495         }
00496         FCT_TEST_END();
00497 #endif /* POLARSSL_MD4_C */
00498 
00499 #ifdef POLARSSL_MD4_C
00500 
00501         FCT_TEST_BGN(md4_test_vector_rfc1320_6)
00502         {
00503             unsigned char src_str[1000];
00504             unsigned char hash_str[1000];
00505             unsigned char output[33];
00506         
00507             memset(src_str, 0x00, 1000);
00508             memset(hash_str, 0x00, 1000);
00509             memset(output, 0x00, 33);
00510         
00511             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
00512         
00513             md4( src_str, strlen( (char *) src_str ), output );
00514             hexify( hash_str, output, 16 );
00515         
00516             fct_chk( strcmp( (char *) hash_str, "043f8582f241db351ce627e153e7f0e4" ) == 0 );
00517         }
00518         FCT_TEST_END();
00519 #endif /* POLARSSL_MD4_C */
00520 
00521 #ifdef POLARSSL_MD4_C
00522 
00523         FCT_TEST_BGN(md4_test_vector_rfc1320_7)
00524         {
00525             unsigned char src_str[1000];
00526             unsigned char hash_str[1000];
00527             unsigned char output[33];
00528         
00529             memset(src_str, 0x00, 1000);
00530             memset(hash_str, 0x00, 1000);
00531             memset(output, 0x00, 33);
00532         
00533             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
00534         
00535             md4( src_str, strlen( (char *) src_str ), output );
00536             hexify( hash_str, output, 16 );
00537         
00538             fct_chk( strcmp( (char *) hash_str, "e33b4ddc9c38f2199c3e7b164fcc0536" ) == 0 );
00539         }
00540         FCT_TEST_END();
00541 #endif /* POLARSSL_MD4_C */
00542 
00543 #ifdef POLARSSL_MD5_C
00544 
00545         FCT_TEST_BGN(md5_test_vector_rfc1321_1)
00546         {
00547             unsigned char src_str[1000];
00548             unsigned char hash_str[1000];
00549             unsigned char output[33];
00550         
00551             memset(src_str, 0x00, 1000);
00552             memset(hash_str, 0x00, 1000);
00553             memset(output, 0x00, 33);
00554         
00555             strcpy( (char *) src_str, "" );
00556         
00557             md5( src_str, strlen( (char *) src_str ), output );
00558             hexify( hash_str, output, 16 );
00559         
00560             fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
00561         }
00562         FCT_TEST_END();
00563 #endif /* POLARSSL_MD5_C */
00564 
00565 #ifdef POLARSSL_MD5_C
00566 
00567         FCT_TEST_BGN(md5_test_vector_rfc1321_2)
00568         {
00569             unsigned char src_str[1000];
00570             unsigned char hash_str[1000];
00571             unsigned char output[33];
00572         
00573             memset(src_str, 0x00, 1000);
00574             memset(hash_str, 0x00, 1000);
00575             memset(output, 0x00, 33);
00576         
00577             strcpy( (char *) src_str, "a" );
00578         
00579             md5( src_str, strlen( (char *) src_str ), output );
00580             hexify( hash_str, output, 16 );
00581         
00582             fct_chk( strcmp( (char *) hash_str, "0cc175b9c0f1b6a831c399e269772661" ) == 0 );
00583         }
00584         FCT_TEST_END();
00585 #endif /* POLARSSL_MD5_C */
00586 
00587 #ifdef POLARSSL_MD5_C
00588 
00589         FCT_TEST_BGN(md5_test_vector_rfc1321_3)
00590         {
00591             unsigned char src_str[1000];
00592             unsigned char hash_str[1000];
00593             unsigned char output[33];
00594         
00595             memset(src_str, 0x00, 1000);
00596             memset(hash_str, 0x00, 1000);
00597             memset(output, 0x00, 33);
00598         
00599             strcpy( (char *) src_str, "abc" );
00600         
00601             md5( src_str, strlen( (char *) src_str ), output );
00602             hexify( hash_str, output, 16 );
00603         
00604             fct_chk( strcmp( (char *) hash_str, "900150983cd24fb0d6963f7d28e17f72" ) == 0 );
00605         }
00606         FCT_TEST_END();
00607 #endif /* POLARSSL_MD5_C */
00608 
00609 #ifdef POLARSSL_MD5_C
00610 
00611         FCT_TEST_BGN(md5_test_vector_rfc1321_4)
00612         {
00613             unsigned char src_str[1000];
00614             unsigned char hash_str[1000];
00615             unsigned char output[33];
00616         
00617             memset(src_str, 0x00, 1000);
00618             memset(hash_str, 0x00, 1000);
00619             memset(output, 0x00, 33);
00620         
00621             strcpy( (char *) src_str, "message digest" );
00622         
00623             md5( src_str, strlen( (char *) src_str ), output );
00624             hexify( hash_str, output, 16 );
00625         
00626             fct_chk( strcmp( (char *) hash_str, "f96b697d7cb7938d525a2f31aaf161d0" ) == 0 );
00627         }
00628         FCT_TEST_END();
00629 #endif /* POLARSSL_MD5_C */
00630 
00631 #ifdef POLARSSL_MD5_C
00632 
00633         FCT_TEST_BGN(md5_test_vector_rfc1321_5)
00634         {
00635             unsigned char src_str[1000];
00636             unsigned char hash_str[1000];
00637             unsigned char output[33];
00638         
00639             memset(src_str, 0x00, 1000);
00640             memset(hash_str, 0x00, 1000);
00641             memset(output, 0x00, 33);
00642         
00643             strcpy( (char *) src_str, "abcdefghijklmnopqrstuvwxyz" );
00644         
00645             md5( src_str, strlen( (char *) src_str ), output );
00646             hexify( hash_str, output, 16 );
00647         
00648             fct_chk( strcmp( (char *) hash_str, "c3fcd3d76192e4007dfb496cca67e13b" ) == 0 );
00649         }
00650         FCT_TEST_END();
00651 #endif /* POLARSSL_MD5_C */
00652 
00653 #ifdef POLARSSL_MD5_C
00654 
00655         FCT_TEST_BGN(md5_test_vector_rfc1321_6)
00656         {
00657             unsigned char src_str[1000];
00658             unsigned char hash_str[1000];
00659             unsigned char output[33];
00660         
00661             memset(src_str, 0x00, 1000);
00662             memset(hash_str, 0x00, 1000);
00663             memset(output, 0x00, 33);
00664         
00665             strcpy( (char *) src_str, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" );
00666         
00667             md5( src_str, strlen( (char *) src_str ), output );
00668             hexify( hash_str, output, 16 );
00669         
00670             fct_chk( strcmp( (char *) hash_str, "d174ab98d277d9f5a5611c2c9f419d9f" ) == 0 );
00671         }
00672         FCT_TEST_END();
00673 #endif /* POLARSSL_MD5_C */
00674 
00675 #ifdef POLARSSL_MD5_C
00676 
00677         FCT_TEST_BGN(md5_test_vector_rfc1321_7)
00678         {
00679             unsigned char src_str[1000];
00680             unsigned char hash_str[1000];
00681             unsigned char output[33];
00682         
00683             memset(src_str, 0x00, 1000);
00684             memset(hash_str, 0x00, 1000);
00685             memset(output, 0x00, 33);
00686         
00687             strcpy( (char *) src_str, "12345678901234567890123456789012345678901234567890123456789012345678901234567890" );
00688         
00689             md5( src_str, strlen( (char *) src_str ), output );
00690             hexify( hash_str, output, 16 );
00691         
00692             fct_chk( strcmp( (char *) hash_str, "57edf4a22be3c955ac49da2e2107b67a" ) == 0 );
00693         }
00694         FCT_TEST_END();
00695 #endif /* POLARSSL_MD5_C */
00696 
00697 #ifdef POLARSSL_MD2_C
00698 
00699         FCT_TEST_BGN(hmac_md2_hash_file_openssl_test_1)
00700         {
00701             unsigned char src_str[10000];
00702             unsigned char key_str[10000];
00703             unsigned char hash_str[10000];
00704             unsigned char output[33];
00705             int key_len, src_len;
00706         
00707             memset(src_str, 0x00, 10000);
00708             memset(key_str, 0x00, 10000);
00709             memset(hash_str, 0x00, 10000);
00710             memset(output, 0x00, 33);
00711         
00712             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00713             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00714         
00715             md2_hmac( key_str, key_len, src_str, src_len, output );
00716             hexify( hash_str, output, 16 );
00717         
00718             fct_chk( strncmp( (char *) hash_str, "d5732582f494f5ddf35efd166c85af9c", 16 * 2 ) == 0 );
00719         }
00720         FCT_TEST_END();
00721 #endif /* POLARSSL_MD2_C */
00722 
00723 #ifdef POLARSSL_MD2_C
00724 
00725         FCT_TEST_BGN(hmac_md2_hash_file_openssl_test_2)
00726         {
00727             unsigned char src_str[10000];
00728             unsigned char key_str[10000];
00729             unsigned char hash_str[10000];
00730             unsigned char output[33];
00731             int key_len, src_len;
00732         
00733             memset(src_str, 0x00, 10000);
00734             memset(key_str, 0x00, 10000);
00735             memset(hash_str, 0x00, 10000);
00736             memset(output, 0x00, 33);
00737         
00738             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00739             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
00740         
00741             md2_hmac( key_str, key_len, src_str, src_len, output );
00742             hexify( hash_str, output, 16 );
00743         
00744             fct_chk( strncmp( (char *) hash_str, "54ab68503f7d1b5c7741340dff2722a9", 16 * 2 ) == 0 );
00745         }
00746         FCT_TEST_END();
00747 #endif /* POLARSSL_MD2_C */
00748 
00749 #ifdef POLARSSL_MD2_C
00750 
00751         FCT_TEST_BGN(hmac_md2_hash_file_openssl_test_3)
00752         {
00753             unsigned char src_str[10000];
00754             unsigned char key_str[10000];
00755             unsigned char hash_str[10000];
00756             unsigned char output[33];
00757             int key_len, src_len;
00758         
00759             memset(src_str, 0x00, 10000);
00760             memset(key_str, 0x00, 10000);
00761             memset(hash_str, 0x00, 10000);
00762             memset(output, 0x00, 33);
00763         
00764             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
00765             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00766         
00767             md2_hmac( key_str, key_len, src_str, src_len, output );
00768             hexify( hash_str, output, 16 );
00769         
00770             fct_chk( strncmp( (char *) hash_str, "d850e5f554558cf0fe79a0612e1d0365", 16 * 2 ) == 0 );
00771         }
00772         FCT_TEST_END();
00773 #endif /* POLARSSL_MD2_C */
00774 
00775 #ifdef POLARSSL_MD4_C
00776 
00777         FCT_TEST_BGN(hmac_md4_hash_file_openssl_test_1)
00778         {
00779             unsigned char src_str[10000];
00780             unsigned char key_str[10000];
00781             unsigned char hash_str[10000];
00782             unsigned char output[33];
00783             int key_len, src_len;
00784         
00785             memset(src_str, 0x00, 10000);
00786             memset(key_str, 0x00, 10000);
00787             memset(hash_str, 0x00, 10000);
00788             memset(output, 0x00, 33);
00789         
00790             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00791             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00792         
00793             md4_hmac( key_str, key_len, src_str, src_len, output );
00794             hexify( hash_str, output, 16 );
00795         
00796             fct_chk( strncmp( (char *) hash_str, "eabd0fbefb82fb0063a25a6d7b8bdc0f", 16 * 2 ) == 0 );
00797         }
00798         FCT_TEST_END();
00799 #endif /* POLARSSL_MD4_C */
00800 
00801 #ifdef POLARSSL_MD4_C
00802 
00803         FCT_TEST_BGN(hmac_md4_hash_file_openssl_test_2)
00804         {
00805             unsigned char src_str[10000];
00806             unsigned char key_str[10000];
00807             unsigned char hash_str[10000];
00808             unsigned char output[33];
00809             int key_len, src_len;
00810         
00811             memset(src_str, 0x00, 10000);
00812             memset(key_str, 0x00, 10000);
00813             memset(hash_str, 0x00, 10000);
00814             memset(output, 0x00, 33);
00815         
00816             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00817             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
00818         
00819             md4_hmac( key_str, key_len, src_str, src_len, output );
00820             hexify( hash_str, output, 16 );
00821         
00822             fct_chk( strncmp( (char *) hash_str, "cec3c5e421a7b783aa89cacf78daf6dc", 16 * 2 ) == 0 );
00823         }
00824         FCT_TEST_END();
00825 #endif /* POLARSSL_MD4_C */
00826 
00827 #ifdef POLARSSL_MD4_C
00828 
00829         FCT_TEST_BGN(hmac_md4_hash_file_openssl_test_3)
00830         {
00831             unsigned char src_str[10000];
00832             unsigned char key_str[10000];
00833             unsigned char hash_str[10000];
00834             unsigned char output[33];
00835             int key_len, src_len;
00836         
00837             memset(src_str, 0x00, 10000);
00838             memset(key_str, 0x00, 10000);
00839             memset(hash_str, 0x00, 10000);
00840             memset(output, 0x00, 33);
00841         
00842             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
00843             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00844         
00845             md4_hmac( key_str, key_len, src_str, src_len, output );
00846             hexify( hash_str, output, 16 );
00847         
00848             fct_chk( strncmp( (char *) hash_str, "ad5f0a04116109b397b57f9cc9b6df4b", 16 * 2 ) == 0 );
00849         }
00850         FCT_TEST_END();
00851 #endif /* POLARSSL_MD4_C */
00852 
00853 #ifdef POLARSSL_MD5_C
00854 
00855         FCT_TEST_BGN(hmac_md5_hash_file_openssl_test_1)
00856         {
00857             unsigned char src_str[10000];
00858             unsigned char key_str[10000];
00859             unsigned char hash_str[10000];
00860             unsigned char output[33];
00861             int key_len, src_len;
00862         
00863             memset(src_str, 0x00, 10000);
00864             memset(key_str, 0x00, 10000);
00865             memset(hash_str, 0x00, 10000);
00866             memset(output, 0x00, 33);
00867         
00868             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00869             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00870         
00871             md5_hmac( key_str, key_len, src_str, src_len, output );
00872             hexify( hash_str, output, 16 );
00873         
00874             fct_chk( strncmp( (char *) hash_str, "42552882f00bd4633ea81135a184b284", 16 * 2 ) == 0 );
00875         }
00876         FCT_TEST_END();
00877 #endif /* POLARSSL_MD5_C */
00878 
00879 #ifdef POLARSSL_MD5_C
00880 
00881         FCT_TEST_BGN(hmac_md5_hash_file_openssl_test_2)
00882         {
00883             unsigned char src_str[10000];
00884             unsigned char key_str[10000];
00885             unsigned char hash_str[10000];
00886             unsigned char output[33];
00887             int key_len, src_len;
00888         
00889             memset(src_str, 0x00, 10000);
00890             memset(key_str, 0x00, 10000);
00891             memset(hash_str, 0x00, 10000);
00892             memset(output, 0x00, 33);
00893         
00894             key_len = unhexify( key_str, "61616161616161616161616161616161" );
00895             src_len = unhexify( src_str, "270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5" );
00896         
00897             md5_hmac( key_str, key_len, src_str, src_len, output );
00898             hexify( hash_str, output, 16 );
00899         
00900             fct_chk( strncmp( (char *) hash_str, "a16a842891786d01fe50ba7731db7464", 16 * 2 ) == 0 );
00901         }
00902         FCT_TEST_END();
00903 #endif /* POLARSSL_MD5_C */
00904 
00905 #ifdef POLARSSL_MD5_C
00906 
00907         FCT_TEST_BGN(hmac_md5_hash_file_openssl_test_3)
00908         {
00909             unsigned char src_str[10000];
00910             unsigned char key_str[10000];
00911             unsigned char hash_str[10000];
00912             unsigned char output[33];
00913             int key_len, src_len;
00914         
00915             memset(src_str, 0x00, 10000);
00916             memset(key_str, 0x00, 10000);
00917             memset(hash_str, 0x00, 10000);
00918             memset(output, 0x00, 33);
00919         
00920             key_len = unhexify( key_str, "61616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161" );
00921             src_len = unhexify( src_str, "b91ce5ac77d33c234e61002ed6" );
00922         
00923             md5_hmac( key_str, key_len, src_str, src_len, output );
00924             hexify( hash_str, output, 16 );
00925         
00926             fct_chk( strncmp( (char *) hash_str, "e97f623936f98a7f741c4bd0612fecc2", 16 * 2 ) == 0 );
00927         }
00928         FCT_TEST_END();
00929 #endif /* POLARSSL_MD5_C */
00930 
00931 #ifdef POLARSSL_MD5_C
00932 
00933         FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_1)
00934         {
00935             unsigned char src_str[10000];
00936             unsigned char key_str[10000];
00937             unsigned char hash_str[10000];
00938             unsigned char output[33];
00939             int key_len, src_len;
00940         
00941             memset(src_str, 0x00, 10000);
00942             memset(key_str, 0x00, 10000);
00943             memset(hash_str, 0x00, 10000);
00944             memset(output, 0x00, 33);
00945         
00946             key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
00947             src_len = unhexify( src_str, "4869205468657265" );
00948         
00949             md5_hmac( key_str, key_len, src_str, src_len, output );
00950             hexify( hash_str, output, 16 );
00951         
00952             fct_chk( strncmp( (char *) hash_str, "9294727a3638bb1c13f48ef8158bfc9d", 16 * 2 ) == 0 );
00953         }
00954         FCT_TEST_END();
00955 #endif /* POLARSSL_MD5_C */
00956 
00957 #ifdef POLARSSL_MD5_C
00958 
00959         FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_2)
00960         {
00961             unsigned char src_str[10000];
00962             unsigned char key_str[10000];
00963             unsigned char hash_str[10000];
00964             unsigned char output[33];
00965             int key_len, src_len;
00966         
00967             memset(src_str, 0x00, 10000);
00968             memset(key_str, 0x00, 10000);
00969             memset(hash_str, 0x00, 10000);
00970             memset(output, 0x00, 33);
00971         
00972             key_len = unhexify( key_str, "4a656665" );
00973             src_len = unhexify( src_str, "7768617420646f2079612077616e7420666f72206e6f7468696e673f" );
00974         
00975             md5_hmac( key_str, key_len, src_str, src_len, output );
00976             hexify( hash_str, output, 16 );
00977         
00978             fct_chk( strncmp( (char *) hash_str, "750c783e6ab0b503eaa86e310a5db738", 16 * 2 ) == 0 );
00979         }
00980         FCT_TEST_END();
00981 #endif /* POLARSSL_MD5_C */
00982 
00983 #ifdef POLARSSL_MD5_C
00984 
00985         FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_3)
00986         {
00987             unsigned char src_str[10000];
00988             unsigned char key_str[10000];
00989             unsigned char hash_str[10000];
00990             unsigned char output[33];
00991             int key_len, src_len;
00992         
00993             memset(src_str, 0x00, 10000);
00994             memset(key_str, 0x00, 10000);
00995             memset(hash_str, 0x00, 10000);
00996             memset(output, 0x00, 33);
00997         
00998             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
00999             src_len = unhexify( src_str, "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" );
01000         
01001             md5_hmac( key_str, key_len, src_str, src_len, output );
01002             hexify( hash_str, output, 16 );
01003         
01004             fct_chk( strncmp( (char *) hash_str, "56be34521d144c88dbb8c733f0e8b3f6", 16 * 2 ) == 0 );
01005         }
01006         FCT_TEST_END();
01007 #endif /* POLARSSL_MD5_C */
01008 
01009 #ifdef POLARSSL_MD5_C
01010 
01011         FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_4)
01012         {
01013             unsigned char src_str[10000];
01014             unsigned char key_str[10000];
01015             unsigned char hash_str[10000];
01016             unsigned char output[33];
01017             int key_len, src_len;
01018         
01019             memset(src_str, 0x00, 10000);
01020             memset(key_str, 0x00, 10000);
01021             memset(hash_str, 0x00, 10000);
01022             memset(output, 0x00, 33);
01023         
01024             key_len = unhexify( key_str, "0102030405060708090a0b0c0d0e0f10111213141516171819" );
01025             src_len = unhexify( src_str, "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd" );
01026         
01027             md5_hmac( key_str, key_len, src_str, src_len, output );
01028             hexify( hash_str, output, 16 );
01029         
01030             fct_chk( strncmp( (char *) hash_str, "697eaf0aca3a3aea3a75164746ffaa79", 16 * 2 ) == 0 );
01031         }
01032         FCT_TEST_END();
01033 #endif /* POLARSSL_MD5_C */
01034 
01035 #ifdef POLARSSL_MD5_C
01036 
01037         FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_5)
01038         {
01039             unsigned char src_str[10000];
01040             unsigned char key_str[10000];
01041             unsigned char hash_str[10000];
01042             unsigned char output[33];
01043             int key_len, src_len;
01044         
01045             memset(src_str, 0x00, 10000);
01046             memset(key_str, 0x00, 10000);
01047             memset(hash_str, 0x00, 10000);
01048             memset(output, 0x00, 33);
01049         
01050             key_len = unhexify( key_str, "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" );
01051             src_len = unhexify( src_str, "546573742057697468205472756e636174696f6e" );
01052         
01053             md5_hmac( key_str, key_len, src_str, src_len, output );
01054             hexify( hash_str, output, 16 );
01055         
01056             fct_chk( strncmp( (char *) hash_str, "56461ef2342edc00f9bab995", 12 * 2 ) == 0 );
01057         }
01058         FCT_TEST_END();
01059 #endif /* POLARSSL_MD5_C */
01060 
01061 #ifdef POLARSSL_MD5_C
01062 
01063         FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_6)
01064         {
01065             unsigned char src_str[10000];
01066             unsigned char key_str[10000];
01067             unsigned char hash_str[10000];
01068             unsigned char output[33];
01069             int key_len, src_len;
01070         
01071             memset(src_str, 0x00, 10000);
01072             memset(key_str, 0x00, 10000);
01073             memset(hash_str, 0x00, 10000);
01074             memset(output, 0x00, 33);
01075         
01076             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
01077             src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374" );
01078         
01079             md5_hmac( key_str, key_len, src_str, src_len, output );
01080             hexify( hash_str, output, 16 );
01081         
01082             fct_chk( strncmp( (char *) hash_str, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd", 16 * 2 ) == 0 );
01083         }
01084         FCT_TEST_END();
01085 #endif /* POLARSSL_MD5_C */
01086 
01087 #ifdef POLARSSL_MD5_C
01088 
01089         FCT_TEST_BGN(hmac_md5_test_vector_rfc2202_7)
01090         {
01091             unsigned char src_str[10000];
01092             unsigned char key_str[10000];
01093             unsigned char hash_str[10000];
01094             unsigned char output[33];
01095             int key_len, src_len;
01096         
01097             memset(src_str, 0x00, 10000);
01098             memset(key_str, 0x00, 10000);
01099             memset(hash_str, 0x00, 10000);
01100             memset(output, 0x00, 33);
01101         
01102             key_len = unhexify( key_str, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" );
01103             src_len = unhexify( src_str, "54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461" );
01104         
01105             md5_hmac( key_str, key_len, src_str, src_len, output );
01106             hexify( hash_str, output, 16 );
01107         
01108             fct_chk( strncmp( (char *) hash_str, "6f630fad67cda0ee1fb1f562db3aa53e", 16 * 2 ) == 0 );
01109         }
01110         FCT_TEST_END();
01111 #endif /* POLARSSL_MD5_C */
01112 
01113 #ifdef POLARSSL_MD2_C
01114 
01115         FCT_TEST_BGN(hmac_md2_bouncy_castle_test_1)
01116         {
01117             unsigned char src_str[10000];
01118             unsigned char key_str[10000];
01119             unsigned char hash_str[10000];
01120             unsigned char output[33];
01121             int key_len, src_len;
01122         
01123             memset(src_str, 0x00, 10000);
01124             memset(key_str, 0x00, 10000);
01125             memset(hash_str, 0x00, 10000);
01126             memset(output, 0x00, 33);
01127         
01128             key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
01129             src_len = unhexify( src_str, "4869205468657265" );
01130         
01131             md2_hmac( key_str, key_len, src_str, src_len, output );
01132             hexify( hash_str, output, 16 );
01133         
01134             fct_chk( strncmp( (char *) hash_str, "dc1923ef5f161d35bef839ca8c807808", 16 * 2 ) == 0 );
01135         }
01136         FCT_TEST_END();
01137 #endif /* POLARSSL_MD2_C */
01138 
01139 #ifdef POLARSSL_MD4_C
01140 
01141         FCT_TEST_BGN(hmac_md4_bouncy_castle_test_1)
01142         {
01143             unsigned char src_str[10000];
01144             unsigned char key_str[10000];
01145             unsigned char hash_str[10000];
01146             unsigned char output[33];
01147             int key_len, src_len;
01148         
01149             memset(src_str, 0x00, 10000);
01150             memset(key_str, 0x00, 10000);
01151             memset(hash_str, 0x00, 10000);
01152             memset(output, 0x00, 33);
01153         
01154             key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
01155             src_len = unhexify( src_str, "4869205468657265" );
01156         
01157             md4_hmac( key_str, key_len, src_str, src_len, output );
01158             hexify( hash_str, output, 16 );
01159         
01160             fct_chk( strncmp( (char *) hash_str, "5570ce964ba8c11756cdc3970278ff5a", 16 * 2 ) == 0 );
01161         }
01162         FCT_TEST_END();
01163 #endif /* POLARSSL_MD4_C */
01164 
01165 #ifdef POLARSSL_MD5_C
01166 
01167         FCT_TEST_BGN(hmac_md5_bouncy_castle_test_1)
01168         {
01169             unsigned char src_str[10000];
01170             unsigned char key_str[10000];
01171             unsigned char hash_str[10000];
01172             unsigned char output[33];
01173             int key_len, src_len;
01174         
01175             memset(src_str, 0x00, 10000);
01176             memset(key_str, 0x00, 10000);
01177             memset(hash_str, 0x00, 10000);
01178             memset(output, 0x00, 33);
01179         
01180             key_len = unhexify( key_str, "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b" );
01181             src_len = unhexify( src_str, "4869205468657265" );
01182         
01183             md5_hmac( key_str, key_len, src_str, src_len, output );
01184             hexify( hash_str, output, 16 );
01185         
01186             fct_chk( strncmp( (char *) hash_str, "5ccec34ea9656392457fa1ac27f08fbc", 16 * 2 ) == 0 );
01187         }
01188         FCT_TEST_END();
01189 #endif /* POLARSSL_MD5_C */
01190 
01191 #ifdef POLARSSL_MD2_C
01192 #ifdef POLARSSL_FS_IO
01193 
01194         FCT_TEST_BGN(md2_hash_file_1)
01195         {
01196             unsigned char hash_str[65];
01197             unsigned char output[33];
01198         
01199             memset(hash_str, 0x00, 65);
01200             memset(output, 0x00, 33);
01201         
01202             md2_file( "data_files/hash_file_1", output);
01203             hexify( hash_str, output, 16 );
01204         
01205             fct_chk( strcmp( (char *) hash_str, "b593c098712d2e21628c8986695451a8" ) == 0 );
01206         }
01207         FCT_TEST_END();
01208 #endif /* POLARSSL_MD2_C */
01209 #endif /* POLARSSL_FS_IO */
01210 
01211 #ifdef POLARSSL_MD2_C
01212 #ifdef POLARSSL_FS_IO
01213 
01214         FCT_TEST_BGN(md2_hash_file_2)
01215         {
01216             unsigned char hash_str[65];
01217             unsigned char output[33];
01218         
01219             memset(hash_str, 0x00, 65);
01220             memset(output, 0x00, 33);
01221         
01222             md2_file( "data_files/hash_file_2", output);
01223             hexify( hash_str, output, 16 );
01224         
01225             fct_chk( strcmp( (char *) hash_str, "3c027b7409909a4c4b26bbab69ad9f4f" ) == 0 );
01226         }
01227         FCT_TEST_END();
01228 #endif /* POLARSSL_MD2_C */
01229 #endif /* POLARSSL_FS_IO */
01230 
01231 #ifdef POLARSSL_MD2_C
01232 #ifdef POLARSSL_FS_IO
01233 
01234         FCT_TEST_BGN(md2_hash_file_3)
01235         {
01236             unsigned char hash_str[65];
01237             unsigned char output[33];
01238         
01239             memset(hash_str, 0x00, 65);
01240             memset(output, 0x00, 33);
01241         
01242             md2_file( "data_files/hash_file_3", output);
01243             hexify( hash_str, output, 16 );
01244         
01245             fct_chk( strcmp( (char *) hash_str, "6bb43eb285e81f414083a94cdbe2989d" ) == 0 );
01246         }
01247         FCT_TEST_END();
01248 #endif /* POLARSSL_MD2_C */
01249 #endif /* POLARSSL_FS_IO */
01250 
01251 #ifdef POLARSSL_MD2_C
01252 #ifdef POLARSSL_FS_IO
01253 
01254         FCT_TEST_BGN(md2_hash_file_4)
01255         {
01256             unsigned char hash_str[65];
01257             unsigned char output[33];
01258         
01259             memset(hash_str, 0x00, 65);
01260             memset(output, 0x00, 33);
01261         
01262             md2_file( "data_files/hash_file_4", output);
01263             hexify( hash_str, output, 16 );
01264         
01265             fct_chk( strcmp( (char *) hash_str, "8350e5a3e24c153df2275c9f80692773" ) == 0 );
01266         }
01267         FCT_TEST_END();
01268 #endif /* POLARSSL_MD2_C */
01269 #endif /* POLARSSL_FS_IO */
01270 
01271 #ifdef POLARSSL_MD4_C
01272 #ifdef POLARSSL_FS_IO
01273 
01274         FCT_TEST_BGN(md4_hash_file_1)
01275         {
01276             unsigned char hash_str[65];
01277             unsigned char output[33];
01278         
01279             memset(hash_str, 0x00, 65);
01280             memset(output, 0x00, 33);
01281         
01282             md4_file( "data_files/hash_file_1", output);
01283             hexify( hash_str, output, 16 );
01284         
01285             fct_chk( strcmp( (char *) hash_str, "8d19772c176bd27153b9486715e2c0b9" ) == 0 );
01286         }
01287         FCT_TEST_END();
01288 #endif /* POLARSSL_MD4_C */
01289 #endif /* POLARSSL_FS_IO */
01290 
01291 #ifdef POLARSSL_MD4_C
01292 #ifdef POLARSSL_FS_IO
01293 
01294         FCT_TEST_BGN(md4_hash_file_2)
01295         {
01296             unsigned char hash_str[65];
01297             unsigned char output[33];
01298         
01299             memset(hash_str, 0x00, 65);
01300             memset(output, 0x00, 33);
01301         
01302             md4_file( "data_files/hash_file_2", output);
01303             hexify( hash_str, output, 16 );
01304         
01305             fct_chk( strcmp( (char *) hash_str, "f2ac53b8542882a5a0007c6f84b4d9fd" ) == 0 );
01306         }
01307         FCT_TEST_END();
01308 #endif /* POLARSSL_MD4_C */
01309 #endif /* POLARSSL_FS_IO */
01310 
01311 #ifdef POLARSSL_MD4_C
01312 #ifdef POLARSSL_FS_IO
01313 
01314         FCT_TEST_BGN(md4_hash_file_3)
01315         {
01316             unsigned char hash_str[65];
01317             unsigned char output[33];
01318         
01319             memset(hash_str, 0x00, 65);
01320             memset(output, 0x00, 33);
01321         
01322             md4_file( "data_files/hash_file_3", output);
01323             hexify( hash_str, output, 16 );
01324         
01325             fct_chk( strcmp( (char *) hash_str, "195c15158e2d07881d9a654095ce4a42" ) == 0 );
01326         }
01327         FCT_TEST_END();
01328 #endif /* POLARSSL_MD4_C */
01329 #endif /* POLARSSL_FS_IO */
01330 
01331 #ifdef POLARSSL_MD4_C
01332 #ifdef POLARSSL_FS_IO
01333 
01334         FCT_TEST_BGN(md4_hash_file_4)
01335         {
01336             unsigned char hash_str[65];
01337             unsigned char output[33];
01338         
01339             memset(hash_str, 0x00, 65);
01340             memset(output, 0x00, 33);
01341         
01342             md4_file( "data_files/hash_file_4", output);
01343             hexify( hash_str, output, 16 );
01344         
01345             fct_chk( strcmp( (char *) hash_str, "31d6cfe0d16ae931b73c59d7e0c089c0" ) == 0 );
01346         }
01347         FCT_TEST_END();
01348 #endif /* POLARSSL_MD4_C */
01349 #endif /* POLARSSL_FS_IO */
01350 
01351 #ifdef POLARSSL_MD5_C
01352 #ifdef POLARSSL_FS_IO
01353 
01354         FCT_TEST_BGN(md5_hash_file_1)
01355         {
01356             unsigned char hash_str[65];
01357             unsigned char output[33];
01358         
01359             memset(hash_str, 0x00, 65);
01360             memset(output, 0x00, 33);
01361         
01362             md5_file( "data_files/hash_file_1", output);
01363             hexify( hash_str, output, 16 );
01364         
01365             fct_chk( strcmp( (char *) hash_str, "52bcdc983c9ed64fc148a759b3c7a415" ) == 0 );
01366         }
01367         FCT_TEST_END();
01368 #endif /* POLARSSL_MD5_C */
01369 #endif /* POLARSSL_FS_IO */
01370 
01371 #ifdef POLARSSL_MD5_C
01372 #ifdef POLARSSL_FS_IO
01373 
01374         FCT_TEST_BGN(md5_hash_file_2)
01375         {
01376             unsigned char hash_str[65];
01377             unsigned char output[33];
01378         
01379             memset(hash_str, 0x00, 65);
01380             memset(output, 0x00, 33);
01381         
01382             md5_file( "data_files/hash_file_2", output);
01383             hexify( hash_str, output, 16 );
01384         
01385             fct_chk( strcmp( (char *) hash_str, "d17d466f15891df10542207ae78277f0" ) == 0 );
01386         }
01387         FCT_TEST_END();
01388 #endif /* POLARSSL_MD5_C */
01389 #endif /* POLARSSL_FS_IO */
01390 
01391 #ifdef POLARSSL_MD5_C
01392 #ifdef POLARSSL_FS_IO
01393 
01394         FCT_TEST_BGN(md5_hash_file_3)
01395         {
01396             unsigned char hash_str[65];
01397             unsigned char output[33];
01398         
01399             memset(hash_str, 0x00, 65);
01400             memset(output, 0x00, 33);
01401         
01402             md5_file( "data_files/hash_file_3", output);
01403             hexify( hash_str, output, 16 );
01404         
01405             fct_chk( strcmp( (char *) hash_str, "d945bcc6200ea95d061a2a818167d920" ) == 0 );
01406         }
01407         FCT_TEST_END();
01408 #endif /* POLARSSL_MD5_C */
01409 #endif /* POLARSSL_FS_IO */
01410 
01411 #ifdef POLARSSL_MD5_C
01412 #ifdef POLARSSL_FS_IO
01413 
01414         FCT_TEST_BGN(md5_hash_file_4)
01415         {
01416             unsigned char hash_str[65];
01417             unsigned char output[33];
01418         
01419             memset(hash_str, 0x00, 65);
01420             memset(output, 0x00, 33);
01421         
01422             md5_file( "data_files/hash_file_4", output);
01423             hexify( hash_str, output, 16 );
01424         
01425             fct_chk( strcmp( (char *) hash_str, "d41d8cd98f00b204e9800998ecf8427e" ) == 0 );
01426         }
01427         FCT_TEST_END();
01428 #endif /* POLARSSL_MD5_C */
01429 #endif /* POLARSSL_FS_IO */
01430 
01431 #ifdef POLARSSL_MD2_C
01432 #ifdef POLARSSL_SELF_TEST
01433 
01434         FCT_TEST_BGN(md2_selftest)
01435         {
01436             fct_chk( md2_self_test( 0 ) == 0 );
01437         }
01438         FCT_TEST_END();
01439 #endif /* POLARSSL_MD2_C */
01440 #endif /* POLARSSL_SELF_TEST */
01441 
01442 #ifdef POLARSSL_MD4_C
01443 #ifdef POLARSSL_SELF_TEST
01444 
01445         FCT_TEST_BGN(md4_selftest)
01446         {
01447             fct_chk( md4_self_test( 0 ) == 0 );
01448         }
01449         FCT_TEST_END();
01450 #endif /* POLARSSL_MD4_C */
01451 #endif /* POLARSSL_SELF_TEST */
01452 
01453 #ifdef POLARSSL_MD5_C
01454 #ifdef POLARSSL_SELF_TEST
01455 
01456         FCT_TEST_BGN(md5_selftest)
01457         {
01458             fct_chk( md5_self_test( 0 ) == 0 );
01459         }
01460         FCT_TEST_END();
01461 #endif /* POLARSSL_MD5_C */
01462 #endif /* POLARSSL_SELF_TEST */
01463 
01464     }
01465     FCT_SUITE_END();
01466 
01467 
01468 }
01469 FCT_END();
01470