Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 1 | /* BEGIN_HEADER */ |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 2 | #include <polarssl/md2.h> |
| 3 | #include <polarssl/md4.h> |
| 4 | #include <polarssl/md5.h> |
Manuel Pégourié-Gonnard | cab4a88 | 2014-01-17 12:42:35 +0100 | [diff] [blame] | 5 | #include <polarssl/rmd160.h> |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 6 | /* END_HEADER */ |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 7 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 8 | /* BEGIN_CASE depends_on:POLARSSL_MD2_C */ |
| 9 | void md2_text( char *text_src_string, char *hex_hash_string ) |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 10 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 11 | unsigned char src_str[100]; |
| 12 | unsigned char hash_str[33]; |
| 13 | unsigned char output[16]; |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 14 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 15 | memset( src_str, 0x00, sizeof src_str ); |
| 16 | memset( hash_str, 0x00, sizeof hash_str ); |
| 17 | memset( output, 0x00, sizeof output ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 18 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 19 | strcpy( (char *) src_str, text_src_string ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 20 | |
| 21 | md2( src_str, strlen( (char *) src_str ), output ); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 22 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 23 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 24 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 25 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 26 | /* END_CASE */ |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 27 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 28 | /* BEGIN_CASE depends_on:POLARSSL_MD4_C */ |
| 29 | void md4_text( char *text_src_string, char *hex_hash_string ) |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 30 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 31 | unsigned char src_str[100]; |
| 32 | unsigned char hash_str[33]; |
| 33 | unsigned char output[16]; |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 34 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 35 | memset( src_str, 0x00, sizeof src_str ); |
| 36 | memset( hash_str, 0x00, sizeof hash_str ); |
| 37 | memset( output, 0x00, sizeof output ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 38 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 39 | strcpy( (char *) src_str, text_src_string ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 40 | |
| 41 | md4( src_str, strlen( (char *) src_str ), output ); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 42 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 43 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 44 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 45 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 46 | /* END_CASE */ |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 47 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 48 | /* BEGIN_CASE depends_on:POLARSSL_MD5_C */ |
| 49 | void md5_text( char *text_src_string, char *hex_hash_string ) |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 50 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 51 | unsigned char src_str[100]; |
| 52 | unsigned char hash_str[33]; |
| 53 | unsigned char output[16]; |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 54 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 55 | memset( src_str, 0x00, sizeof src_str ); |
| 56 | memset( hash_str, 0x00, sizeof hash_str ); |
| 57 | memset( output, 0x00, sizeof output ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 58 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 59 | strcpy( (char *) src_str, text_src_string ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 60 | |
| 61 | md5( src_str, strlen( (char *) src_str ), output ); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 62 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 63 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 64 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 65 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 66 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 67 | |
Manuel Pégourié-Gonnard | cab4a88 | 2014-01-17 12:42:35 +0100 | [diff] [blame] | 68 | /* BEGIN_CASE depends_on:POLARSSL_RMD160_C */ |
| 69 | void rmd160_text( char *text_src_string, char *hex_hash_string ) |
| 70 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 71 | unsigned char src_str[100]; |
Manuel Pégourié-Gonnard | cab4a88 | 2014-01-17 12:42:35 +0100 | [diff] [blame] | 72 | unsigned char hash_str[41]; |
| 73 | unsigned char output[20]; |
| 74 | |
| 75 | memset(src_str, 0x00, sizeof src_str); |
| 76 | memset(hash_str, 0x00, sizeof hash_str); |
| 77 | memset(output, 0x00, sizeof output); |
| 78 | |
| 79 | strcpy( (char *) src_str, text_src_string ); |
| 80 | |
| 81 | rmd160( src_str, strlen( (char *) src_str ), output ); |
| 82 | hexify( hash_str, output, sizeof output ); |
| 83 | |
| 84 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
| 85 | } |
| 86 | /* END_CASE */ |
| 87 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 88 | /* BEGIN_CASE depends_on:POLARSSL_MD2_C */ |
| 89 | void md2_hmac( int trunc_size, char *hex_key_string, char *hex_src_string, |
| 90 | char *hex_hash_string ) |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 91 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 92 | unsigned char src_str[200]; |
| 93 | unsigned char key_str[200]; |
| 94 | unsigned char hash_str[33]; |
| 95 | unsigned char output[16]; |
Paul Bakker | 69998dd | 2009-07-11 19:15:20 +0000 | [diff] [blame] | 96 | int key_len, src_len; |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 97 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 98 | memset( src_str, 0x00, sizeof src_str ); |
| 99 | memset( key_str, 0x00, sizeof key_str ); |
| 100 | memset( hash_str, 0x00, sizeof hash_str ); |
| 101 | memset( output, 0x00, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 102 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 103 | key_len = unhexify( key_str, hex_key_string ); |
| 104 | src_len = unhexify( src_str, hex_src_string ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 105 | |
| 106 | md2_hmac( key_str, key_len, src_str, src_len, output ); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 107 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 108 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 109 | TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 110 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 111 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 112 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 113 | /* BEGIN_CASE depends_on:POLARSSL_MD4_C */ |
| 114 | void md4_hmac( int trunc_size, char *hex_key_string, char *hex_src_string, |
| 115 | char *hex_hash_string ) |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 116 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 117 | unsigned char src_str[200]; |
| 118 | unsigned char key_str[200]; |
| 119 | unsigned char hash_str[33]; |
| 120 | unsigned char output[16]; |
Paul Bakker | 69998dd | 2009-07-11 19:15:20 +0000 | [diff] [blame] | 121 | int key_len, src_len; |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 122 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 123 | memset( src_str, 0x00, sizeof src_str ); |
| 124 | memset( key_str, 0x00, sizeof key_str ); |
| 125 | memset( hash_str, 0x00, sizeof hash_str ); |
| 126 | memset( output, 0x00, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 127 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 128 | key_len = unhexify( key_str, hex_key_string ); |
| 129 | src_len = unhexify( src_str, hex_src_string ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 130 | |
| 131 | md4_hmac( key_str, key_len, src_str, src_len, output ); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 132 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 133 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 134 | TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 135 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 136 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 137 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 138 | /* BEGIN_CASE depends_on:POLARSSL_MD5_C */ |
| 139 | void md5_hmac( int trunc_size, char *hex_key_string, char *hex_src_string, |
| 140 | char *hex_hash_string ) |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 141 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 142 | unsigned char src_str[200]; |
| 143 | unsigned char key_str[200]; |
| 144 | unsigned char hash_str[33]; |
| 145 | unsigned char output[16]; |
Paul Bakker | 69998dd | 2009-07-11 19:15:20 +0000 | [diff] [blame] | 146 | int key_len, src_len; |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 147 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 148 | memset( src_str, 0x00, sizeof src_str ); |
| 149 | memset( key_str, 0x00, sizeof key_str ); |
| 150 | memset( hash_str, 0x00, sizeof hash_str ); |
| 151 | memset( output, 0x00, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 152 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 153 | key_len = unhexify( key_str, hex_key_string ); |
| 154 | src_len = unhexify( src_str, hex_src_string ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 155 | |
| 156 | md5_hmac( key_str, key_len, src_str, src_len, output ); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 157 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 158 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 159 | TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 160 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 161 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 162 | |
Manuel Pégourié-Gonnard | ff40c3a | 2014-01-17 19:49:15 +0100 | [diff] [blame^] | 163 | /* BEGIN_CASE depends_on:POLARSSL_RMD160_C */ |
| 164 | void rmd160_hmac( int trunc_size, char *hex_key_string, char *hex_src_string, |
| 165 | char *hex_hash_string ) |
| 166 | { |
| 167 | unsigned char src_str[200]; |
| 168 | unsigned char key_str[200]; |
| 169 | unsigned char hash_str[41]; |
| 170 | unsigned char output[20]; |
| 171 | int key_len, src_len; |
| 172 | |
| 173 | memset( src_str, 0x00, sizeof src_str ); |
| 174 | memset( key_str, 0x00, sizeof key_str ); |
| 175 | memset( hash_str, 0x00, sizeof hash_str ); |
| 176 | memset( output, 0x00, sizeof output ); |
| 177 | |
| 178 | key_len = unhexify( key_str, hex_key_string ); |
| 179 | src_len = unhexify( src_str, hex_src_string ); |
| 180 | |
| 181 | rmd160_hmac( key_str, key_len, src_str, src_len, output ); |
| 182 | hexify( hash_str, output, sizeof output ); |
| 183 | |
| 184 | TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); |
| 185 | } |
| 186 | /* END_CASE */ |
| 187 | |
Paul Bakker | 428b9ba | 2013-09-15 15:20:37 +0200 | [diff] [blame] | 188 | /* BEGIN_CASE depends_on:POLARSSL_MD2_C:POLARSSL_FS_IO */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 189 | void md2_file( char *filename, char *hex_hash_string ) |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 190 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 191 | unsigned char hash_str[33]; |
| 192 | unsigned char output[16]; |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 193 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 194 | memset( hash_str, 0x00, sizeof hash_str ); |
| 195 | memset( output, 0x00, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 196 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 197 | md2_file( filename, output); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 198 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 199 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 200 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 201 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 202 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 203 | |
Paul Bakker | 428b9ba | 2013-09-15 15:20:37 +0200 | [diff] [blame] | 204 | /* BEGIN_CASE depends_on:POLARSSL_MD4_C:POLARSSL_FS_IO */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 205 | void md4_file( char *filename, char *hex_hash_string ) |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 206 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 207 | unsigned char hash_str[33]; |
| 208 | unsigned char output[16]; |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 209 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 210 | memset( hash_str, 0x00, sizeof hash_str ); |
| 211 | memset( output, 0x00, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 212 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 213 | md4_file( filename, output); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 214 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 215 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 216 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 217 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 218 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 219 | |
Paul Bakker | 428b9ba | 2013-09-15 15:20:37 +0200 | [diff] [blame] | 220 | /* BEGIN_CASE depends_on:POLARSSL_MD5_C:POLARSSL_FS_IO */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 221 | void md5_file( char *filename, char *hex_hash_string ) |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 222 | { |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 223 | unsigned char hash_str[33]; |
| 224 | unsigned char output[16]; |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 225 | |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 226 | memset( hash_str, 0x00, sizeof hash_str ); |
| 227 | memset( output, 0x00, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 228 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 229 | md5_file( filename, output); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 230 | hexify( hash_str, output, sizeof output ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 231 | |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 232 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 233 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 234 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 235 | |
Manuel Pégourié-Gonnard | cab4a88 | 2014-01-17 12:42:35 +0100 | [diff] [blame] | 236 | /* BEGIN_CASE depends_on:POLARSSL_RMD160_C:POLARSSL_FS_IO */ |
| 237 | void rmd160_file( char *filename, char *hex_hash_string ) |
| 238 | { |
| 239 | unsigned char hash_str[41]; |
| 240 | unsigned char output[20]; |
| 241 | |
| 242 | memset(hash_str, 0x00, sizeof hash_str ); |
| 243 | memset(output, 0x00, sizeof output ); |
| 244 | |
| 245 | rmd160_file( filename, output); |
Manuel Pégourié-Gonnard | 130fe97 | 2014-01-17 14:23:48 +0100 | [diff] [blame] | 246 | hexify( hash_str, output, sizeof output ); |
Manuel Pégourié-Gonnard | cab4a88 | 2014-01-17 12:42:35 +0100 | [diff] [blame] | 247 | |
| 248 | TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); |
| 249 | } |
| 250 | /* END_CASE */ |
| 251 | |
Manuel Pégourié-Gonnard | 2014016 | 2013-10-10 12:48:03 +0200 | [diff] [blame] | 252 | /* BEGIN_CASE depends_on:POLARSSL_MD2_C:POLARSSL_SELF_TEST */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 253 | void md2_selftest() |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 254 | { |
| 255 | TEST_ASSERT( md2_self_test( 0 ) == 0 ); |
| 256 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 257 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 258 | |
Manuel Pégourié-Gonnard | 2014016 | 2013-10-10 12:48:03 +0200 | [diff] [blame] | 259 | /* BEGIN_CASE depends_on:POLARSSL_MD4_C:POLARSSL_SELF_TEST */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 260 | void md4_selftest() |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 261 | { |
| 262 | TEST_ASSERT( md4_self_test( 0 ) == 0 ); |
| 263 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 264 | /* END_CASE */ |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 265 | |
Manuel Pégourié-Gonnard | 2014016 | 2013-10-10 12:48:03 +0200 | [diff] [blame] | 266 | /* BEGIN_CASE depends_on:POLARSSL_MD5_C:POLARSSL_SELF_TEST */ |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 267 | void md5_selftest() |
Paul Bakker | e896fea | 2009-07-06 06:40:23 +0000 | [diff] [blame] | 268 | { |
| 269 | TEST_ASSERT( md5_self_test( 0 ) == 0 ); |
| 270 | } |
Paul Bakker | 33b43f1 | 2013-08-20 11:48:36 +0200 | [diff] [blame] | 271 | /* END_CASE */ |
Manuel Pégourié-Gonnard | cab4a88 | 2014-01-17 12:42:35 +0100 | [diff] [blame] | 272 | |
| 273 | /* BEGIN_CASE depends_on:POLARSSL_RMD160_C:POLARSSL_SELF_TEST */ |
| 274 | void rmd160_selftest() |
| 275 | { |
| 276 | TEST_ASSERT( rmd160_self_test( 0 ) == 0 ); |
| 277 | } |
| 278 | /* END_CASE */ |