comparison libtomcrypt/testprof/x86_prof.c @ 1435:f849a5ca2efc

update to libtomcrypt 1.17 (with Dropbear changes)
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Jun 2017 17:50:50 +0800
parents 0cbe8f6dbf9e
children
comparison
equal deleted inserted replaced
1434:27b9ddb06b09 1435:f849a5ca2efc
122 } 122 }
123 123
124 void reg_algs(void) 124 void reg_algs(void)
125 { 125 {
126 int err; 126 int err;
127 #ifdef RIJNDAEL 127 #ifdef LTC_RIJNDAEL
128 register_cipher (&aes_desc); 128 register_cipher (&aes_desc);
129 #endif 129 #endif
130 #ifdef BLOWFISH 130 #ifdef LTC_BLOWFISH
131 register_cipher (&blowfish_desc); 131 register_cipher (&blowfish_desc);
132 #endif 132 #endif
133 #ifdef XTEA 133 #ifdef LTC_XTEA
134 register_cipher (&xtea_desc); 134 register_cipher (&xtea_desc);
135 #endif 135 #endif
136 #ifdef RC5 136 #ifdef LTC_RC5
137 register_cipher (&rc5_desc); 137 register_cipher (&rc5_desc);
138 #endif 138 #endif
139 #ifdef RC6 139 #ifdef LTC_RC6
140 register_cipher (&rc6_desc); 140 register_cipher (&rc6_desc);
141 #endif 141 #endif
142 #ifdef SAFERP 142 #ifdef LTC_SAFERP
143 register_cipher (&saferp_desc); 143 register_cipher (&saferp_desc);
144 #endif 144 #endif
145 #ifdef TWOFISH 145 #ifdef LTC_TWOFISH
146 register_cipher (&twofish_desc); 146 register_cipher (&twofish_desc);
147 #endif 147 #endif
148 #ifdef SAFER 148 #ifdef LTC_SAFER
149 register_cipher (&safer_k64_desc); 149 register_cipher (&safer_k64_desc);
150 register_cipher (&safer_sk64_desc); 150 register_cipher (&safer_sk64_desc);
151 register_cipher (&safer_k128_desc); 151 register_cipher (&safer_k128_desc);
152 register_cipher (&safer_sk128_desc); 152 register_cipher (&safer_sk128_desc);
153 #endif 153 #endif
154 #ifdef RC2 154 #ifdef LTC_RC2
155 register_cipher (&rc2_desc); 155 register_cipher (&rc2_desc);
156 #endif 156 #endif
157 #ifdef DES 157 #ifdef LTC_DES
158 register_cipher (&des_desc); 158 register_cipher (&des_desc);
159 register_cipher (&des3_desc); 159 register_cipher (&des3_desc);
160 #endif 160 #endif
161 #ifdef CAST5 161 #ifdef LTC_CAST5
162 register_cipher (&cast5_desc); 162 register_cipher (&cast5_desc);
163 #endif 163 #endif
164 #ifdef NOEKEON 164 #ifdef LTC_NOEKEON
165 register_cipher (&noekeon_desc); 165 register_cipher (&noekeon_desc);
166 #endif 166 #endif
167 #ifdef SKIPJACK 167 #ifdef LTC_SKIPJACK
168 register_cipher (&skipjack_desc); 168 register_cipher (&skipjack_desc);
169 #endif 169 #endif
170 #ifdef KHAZAD 170 #ifdef LTC_KHAZAD
171 register_cipher (&khazad_desc); 171 register_cipher (&khazad_desc);
172 #endif 172 #endif
173 #ifdef ANUBIS 173 #ifdef LTC_ANUBIS
174 register_cipher (&anubis_desc); 174 register_cipher (&anubis_desc);
175 #endif 175 #endif
176 #ifdef KSEED 176 #ifdef LTC_KSEED
177 register_cipher (&kseed_desc); 177 register_cipher (&kseed_desc);
178 #endif 178 #endif
179 #ifdef LTC_KASUMI 179 #ifdef LTC_KASUMI
180 register_cipher (&kasumi_desc); 180 register_cipher (&kasumi_desc);
181 #endif 181 #endif
182 182 #ifdef LTC_MULTI2
183 #ifdef TIGER 183 register_cipher (&multi2_desc);
184 #endif
185
186 #ifdef LTC_TIGER
184 register_hash (&tiger_desc); 187 register_hash (&tiger_desc);
185 #endif 188 #endif
186 #ifdef MD2 189 #ifdef LTC_MD2
187 register_hash (&md2_desc); 190 register_hash (&md2_desc);
188 #endif 191 #endif
189 #ifdef MD4 192 #ifdef LTC_MD4
190 register_hash (&md4_desc); 193 register_hash (&md4_desc);
191 #endif 194 #endif
192 #ifdef MD5 195 #ifdef LTC_MD5
193 register_hash (&md5_desc); 196 register_hash (&md5_desc);
194 #endif 197 #endif
195 #ifdef SHA1 198 #ifdef LTC_SHA1
196 register_hash (&sha1_desc); 199 register_hash (&sha1_desc);
197 #endif 200 #endif
198 #ifdef SHA224 201 #ifdef LTC_SHA224
199 register_hash (&sha224_desc); 202 register_hash (&sha224_desc);
200 #endif 203 #endif
201 #ifdef SHA256 204 #ifdef LTC_SHA256
202 register_hash (&sha256_desc); 205 register_hash (&sha256_desc);
203 #endif 206 #endif
204 #ifdef SHA384 207 #ifdef LTC_SHA384
205 register_hash (&sha384_desc); 208 register_hash (&sha384_desc);
206 #endif 209 #endif
207 #ifdef SHA512 210 #ifdef LTC_SHA512
208 register_hash (&sha512_desc); 211 register_hash (&sha512_desc);
209 #endif 212 #endif
210 #ifdef RIPEMD128 213 #ifdef LTC_RIPEMD128
211 register_hash (&rmd128_desc); 214 register_hash (&rmd128_desc);
212 #endif 215 #endif
213 #ifdef RIPEMD160 216 #ifdef LTC_RIPEMD160
214 register_hash (&rmd160_desc); 217 register_hash (&rmd160_desc);
215 #endif 218 #endif
216 #ifdef RIPEMD256 219 #ifdef LTC_RIPEMD256
217 register_hash (&rmd256_desc); 220 register_hash (&rmd256_desc);
218 #endif 221 #endif
219 #ifdef RIPEMD320 222 #ifdef LTC_RIPEMD320
220 register_hash (&rmd320_desc); 223 register_hash (&rmd320_desc);
221 #endif 224 #endif
222 #ifdef WHIRLPOOL 225 #ifdef LTC_WHIRLPOOL
223 register_hash (&whirlpool_desc); 226 register_hash (&whirlpool_desc);
224 #endif 227 #endif
225 #ifdef CHC_HASH 228 #ifdef LTC_CHC_HASH
226 register_hash(&chc_desc); 229 register_hash(&chc_desc);
227 if ((err = chc_register(register_cipher(&aes_desc))) != CRYPT_OK) { 230 if ((err = chc_register(register_cipher(&aes_desc))) != CRYPT_OK) {
228 fprintf(stderr, "chc_register error: %s\n", error_to_string(err)); 231 fprintf(stderr, "chc_register error: %s\n", error_to_string(err));
229 exit(EXIT_FAILURE); 232 exit(EXIT_FAILURE);
230 } 233 }
231 #endif 234 #endif
232 235
233 236
234 #ifndef YARROW 237 #ifndef LTC_YARROW
235 #error This demo requires Yarrow. 238 #error This demo requires Yarrow.
236 #endif 239 #endif
237 register_prng(&yarrow_desc); 240 register_prng(&yarrow_desc);
238 #ifdef FORTUNA 241 #ifdef LTC_FORTUNA
239 register_prng(&fortuna_desc); 242 register_prng(&fortuna_desc);
240 #endif 243 #endif
241 #ifdef RC4 244 #ifdef LTC_RC4
242 register_prng(&rc4_desc); 245 register_prng(&rc4_desc);
243 #endif 246 #endif
244 #ifdef SOBER128 247 #ifdef LTC_SOBER128
245 register_prng(&sober128_desc); 248 register_prng(&sober128_desc);
246 #endif 249 #endif
247 250
248 if ((err = rng_make_prng(128, find_prng("yarrow"), &yarrow_prng, NULL)) != CRYPT_OK) { 251 if ((err = rng_make_prng(128, find_prng("yarrow"), &yarrow_prng, NULL)) != CRYPT_OK) {
249 fprintf(stderr, "rng_make_prng failed: %s\n", error_to_string(err)); 252 fprintf(stderr, "rng_make_prng failed: %s\n", error_to_string(err));
757 #undef DO1 760 #undef DO1
758 761
759 } 762 }
760 } 763 }
761 764
762 #ifdef MDSA 765 #ifdef LTC_MDSA
763 /* time various DSA operations */ 766 /* time various DSA operations */
764 void time_dsa(void) 767 void time_dsa(void)
765 { 768 {
766 dsa_key key; 769 dsa_key key;
767 ulong64 t1, t2; 770 ulong64 t1, t2;
802 } 805 }
803 } 806 }
804 #endif 807 #endif
805 808
806 809
807 #ifdef MRSA 810 #ifdef LTC_MRSA
808 /* time various RSA operations */ 811 /* time various RSA operations */
809 void time_rsa(void) 812 void time_rsa(void)
810 { 813 {
811 rsa_key key; 814 rsa_key key;
812 ulong64 t1, t2; 815 ulong64 t1, t2;
996 } 999 }
997 #else 1000 #else
998 void time_katja(void) { fprintf(stderr, "NO Katja\n"); } 1001 void time_katja(void) { fprintf(stderr, "NO Katja\n"); }
999 #endif 1002 #endif
1000 1003
1001 #ifdef MECC 1004 #ifdef LTC_MECC
1002 /* time various ECC operations */ 1005 /* time various ECC operations */
1003 void time_ecc(void) 1006 void time_ecc(void)
1004 { 1007 {
1005 ecc_key key; 1008 ecc_key key;
1006 ulong64 t1, t2; 1009 ulong64 t1, t2;
1164 1167
1165 cipher_idx = find_cipher("aes"); 1168 cipher_idx = find_cipher("aes");
1166 hash_idx = find_hash("sha1"); 1169 hash_idx = find_hash("sha1");
1167 1170
1168 if (cipher_idx == -1 || hash_idx == -1) { 1171 if (cipher_idx == -1 || hash_idx == -1) {
1169 fprintf(stderr, "Warning the MAC tests requires AES and SHA1 to operate... so sorry\n"); 1172 fprintf(stderr, "Warning the MAC tests requires AES and LTC_SHA1 to operate... so sorry\n");
1170 return; 1173 return;
1171 } 1174 }
1172 1175
1173 yarrow_read(buf, MAC_SIZE*1024, &yarrow_prng); 1176 yarrow_read(buf, MAC_SIZE*1024, &yarrow_prng);
1174 yarrow_read(key, 16, &yarrow_prng); 1177 yarrow_read(key, 16, &yarrow_prng);
1184 exit(EXIT_FAILURE); 1187 exit(EXIT_FAILURE);
1185 } 1188 }
1186 t1 = t_read() - t1; 1189 t1 = t_read() - t1;
1187 if (t1 < t2) t2 = t1; 1190 if (t1 < t2) t2 = t1;
1188 } 1191 }
1189 fprintf(stderr, "OMAC-%s\t\t%9llu\n", cipher_descriptor[cipher_idx].name, t2/(ulong64)(MAC_SIZE*1024)); 1192 fprintf(stderr, "LTC_OMAC-%s\t\t%9llu\n", cipher_descriptor[cipher_idx].name, t2/(ulong64)(MAC_SIZE*1024));
1190 #endif 1193 #endif
1191 1194
1192 #ifdef LTC_XCBC 1195 #ifdef LTC_XCBC
1193 t2 = -1; 1196 t2 = -1;
1194 for (x = 0; x < 10000; x++) { 1197 for (x = 0; x < 10000; x++) {
1235 if (t1 < t2) t2 = t1; 1238 if (t1 < t2) t2 = t1;
1236 } 1239 }
1237 fprintf(stderr, "PMAC-AES\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); 1240 fprintf(stderr, "PMAC-AES\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
1238 #endif 1241 #endif
1239 1242
1240 #ifdef PELICAN 1243 #ifdef LTC_PELICAN
1241 t2 = -1; 1244 t2 = -1;
1242 for (x = 0; x < 10000; x++) { 1245 for (x = 0; x < 10000; x++) {
1243 t_start(); 1246 t_start();
1244 t1 = t_read(); 1247 t1 = t_read();
1245 z = 16; 1248 z = 16;
1248 exit(EXIT_FAILURE); 1251 exit(EXIT_FAILURE);
1249 } 1252 }
1250 t1 = t_read() - t1; 1253 t1 = t_read() - t1;
1251 if (t1 < t2) t2 = t1; 1254 if (t1 < t2) t2 = t1;
1252 } 1255 }
1253 fprintf(stderr, "PELICAN \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); 1256 fprintf(stderr, "LTC_PELICAN \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
1254 #endif 1257 #endif
1255 1258
1256 #ifdef LTC_HMAC 1259 #ifdef LTC_HMAC
1257 t2 = -1; 1260 t2 = -1;
1258 for (x = 0; x < 10000; x++) { 1261 for (x = 0; x < 10000; x++) {
1264 exit(EXIT_FAILURE); 1267 exit(EXIT_FAILURE);
1265 } 1268 }
1266 t1 = t_read() - t1; 1269 t1 = t_read() - t1;
1267 if (t1 < t2) t2 = t1; 1270 if (t1 < t2) t2 = t1;
1268 } 1271 }
1269 fprintf(stderr, "HMAC-%s\t\t%9llu\n", hash_descriptor[hash_idx].name, t2/(ulong64)(MAC_SIZE*1024)); 1272 fprintf(stderr, "LTC_HMAC-%s\t\t%9llu\n", hash_descriptor[hash_idx].name, t2/(ulong64)(MAC_SIZE*1024));
1270 #endif 1273 #endif
1271 1274
1272 XFREE(buf); 1275 XFREE(buf);
1273 } 1276 }
1274 1277
1299 1302
1300 yarrow_read(buf, MAC_SIZE*1024, &yarrow_prng); 1303 yarrow_read(buf, MAC_SIZE*1024, &yarrow_prng);
1301 yarrow_read(key, 16, &yarrow_prng); 1304 yarrow_read(key, 16, &yarrow_prng);
1302 yarrow_read(IV, 16, &yarrow_prng); 1305 yarrow_read(IV, 16, &yarrow_prng);
1303 1306
1304 #ifdef EAX_MODE 1307 #ifdef LTC_EAX_MODE
1305 t2 = -1; 1308 t2 = -1;
1306 for (x = 0; x < 10000; x++) { 1309 for (x = 0; x < 10000; x++) {
1307 t_start(); 1310 t_start();
1308 t1 = t_read(); 1311 t1 = t_read();
1309 z = 16; 1312 z = 16;
1315 if (t1 < t2) t2 = t1; 1318 if (t1 < t2) t2 = t1;
1316 } 1319 }
1317 fprintf(stderr, "EAX \t\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); 1320 fprintf(stderr, "EAX \t\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
1318 #endif 1321 #endif
1319 1322
1320 #ifdef OCB_MODE 1323 #ifdef LTC_OCB_MODE
1321 t2 = -1; 1324 t2 = -1;
1322 for (x = 0; x < 10000; x++) { 1325 for (x = 0; x < 10000; x++) {
1323 t_start(); 1326 t_start();
1324 t1 = t_read(); 1327 t1 = t_read();
1325 z = 16; 1328 z = 16;
1331 if (t1 < t2) t2 = t1; 1334 if (t1 < t2) t2 = t1;
1332 } 1335 }
1333 fprintf(stderr, "OCB \t\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); 1336 fprintf(stderr, "OCB \t\t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
1334 #endif 1337 #endif
1335 1338
1336 #ifdef CCM_MODE 1339 #ifdef LTC_CCM_MODE
1337 t2 = -1; 1340 t2 = -1;
1338 for (x = 0; x < 10000; x++) { 1341 for (x = 0; x < 10000; x++) {
1339 t_start(); 1342 t_start();
1340 t1 = t_read(); 1343 t1 = t_read();
1341 z = 16; 1344 z = 16;
1363 } 1366 }
1364 fprintf(stderr, "CCM (precomp) \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); 1367 fprintf(stderr, "CCM (precomp) \t\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
1365 cipher_descriptor[cipher_idx].done(&skey); 1368 cipher_descriptor[cipher_idx].done(&skey);
1366 #endif 1369 #endif
1367 1370
1368 #ifdef GCM_MODE 1371 #ifdef LTC_GCM_MODE
1369 t2 = -1; 1372 t2 = -1;
1370 for (x = 0; x < 100; x++) { 1373 for (x = 0; x < 100; x++) {
1371 t_start(); 1374 t_start();
1372 t1 = t_read(); 1375 t1 = t_read();
1373 z = 16; 1376 z = 16;
1380 } 1383 }
1381 fprintf(stderr, "GCM (no-precomp)\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); 1384 fprintf(stderr, "GCM (no-precomp)\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
1382 1385
1383 { 1386 {
1384 gcm_state gcm 1387 gcm_state gcm
1385 #ifdef GCM_TABLES_SSE2 1388 #ifdef LTC_GCM_TABLES_SSE2
1386 __attribute__ ((aligned (16))) 1389 __attribute__ ((aligned (16)))
1387 #endif 1390 #endif
1388 ; 1391 ;
1389 1392
1390 if ((err = gcm_init(&gcm, cipher_idx, key, 16)) != CRYPT_OK) { fprintf(stderr, "gcm_init: %s\n", error_to_string(err)); exit(EXIT_FAILURE); } 1393 if ((err = gcm_init(&gcm, cipher_idx, key, 16)) != CRYPT_OK) { fprintf(stderr, "gcm_init: %s\n", error_to_string(err)); exit(EXIT_FAILURE); }
1429 time_encmacs_(1); 1432 time_encmacs_(1);
1430 time_encmacs_(4); 1433 time_encmacs_(4);
1431 time_encmacs_(32); 1434 time_encmacs_(32);
1432 } 1435 }
1433 1436
1434 /* $Source: /cvs/libtom/libtomcrypt/testprof/x86_prof.c,v $ */ 1437 /* $Source$ */
1435 /* $Revision: 1.51 $ */ 1438 /* $Revision$ */
1436 /* $Date: 2006/11/21 00:10:18 $ */ 1439 /* $Date$ */