diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/openssl/speed.c | 113 |
1 files changed, 96 insertions, 17 deletions
diff --git a/src/usr.bin/openssl/speed.c b/src/usr.bin/openssl/speed.c index a149a31afa..a0fa9dcd8b 100644 --- a/src/usr.bin/openssl/speed.c +++ b/src/usr.bin/openssl/speed.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: speed.c,v 1.12 2015/09/11 20:55:59 jsing Exp $ */ | 1 | /* $OpenBSD: speed.c,v 1.13 2015/09/12 15:49:53 bcook Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -150,7 +150,7 @@ | |||
150 | #include "./testdsa.h" | 150 | #include "./testdsa.h" |
151 | #include "./testrsa.h" | 151 | #include "./testrsa.h" |
152 | 152 | ||
153 | #define BUFSIZE (1024*8+1) | 153 | #define BUFSIZE (1024*8+64) |
154 | int run = 0; | 154 | int run = 0; |
155 | 155 | ||
156 | static int mr = 0; | 156 | static int mr = 0; |
@@ -164,7 +164,7 @@ pkey_print_message(const char *str, const char *str2, | |||
164 | static void print_result(int alg, int run_no, int count, double time_used); | 164 | static void print_result(int alg, int run_no, int count, double time_used); |
165 | static int do_multi(int multi); | 165 | static int do_multi(int multi); |
166 | 166 | ||
167 | #define ALGOR_NUM 30 | 167 | #define ALGOR_NUM 33 |
168 | #define SIZE_NUM 5 | 168 | #define SIZE_NUM 5 |
169 | #define RSA_NUM 4 | 169 | #define RSA_NUM 4 |
170 | #define DSA_NUM 3 | 170 | #define DSA_NUM 3 |
@@ -179,7 +179,9 @@ static const char *names[ALGOR_NUM] = { | |||
179 | "aes-128 cbc", "aes-192 cbc", "aes-256 cbc", | 179 | "aes-128 cbc", "aes-192 cbc", "aes-256 cbc", |
180 | "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc", | 180 | "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc", |
181 | "evp", "sha256", "sha512", "whirlpool", | 181 | "evp", "sha256", "sha512", "whirlpool", |
182 | "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash" }; | 182 | "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash", |
183 | "aes-128 gcm", "aes-256 gcm", "chacha20 poly1305", | ||
184 | }; | ||
183 | static double results[ALGOR_NUM][SIZE_NUM]; | 185 | static double results[ALGOR_NUM][SIZE_NUM]; |
184 | static int lengths[SIZE_NUM] = {16, 64, 256, 1024, 8 * 1024}; | 186 | static int lengths[SIZE_NUM] = {16, 64, 256, 1024, 8 * 1024}; |
185 | static double rsa_results[RSA_NUM][2]; | 187 | static double rsa_results[RSA_NUM][2]; |
@@ -344,6 +346,9 @@ speed_main(int argc, char **argv) | |||
344 | #define D_IGE_192_AES 27 | 346 | #define D_IGE_192_AES 27 |
345 | #define D_IGE_256_AES 28 | 347 | #define D_IGE_256_AES 28 |
346 | #define D_GHASH 29 | 348 | #define D_GHASH 29 |
349 | #define D_AES_128_GCM 30 | ||
350 | #define D_AES_256_GCM 31 | ||
351 | #define D_CHACHA20_POLY1305 32 | ||
347 | double d = 0.0; | 352 | double d = 0.0; |
348 | long c[ALGOR_NUM][SIZE_NUM]; | 353 | long c[ALGOR_NUM][SIZE_NUM]; |
349 | #define R_DSA_512 0 | 354 | #define R_DSA_512 0 |
@@ -700,9 +705,13 @@ speed_main(int argc, char **argv) | |||
700 | doit[D_CBC_128_AES] = 1; | 705 | doit[D_CBC_128_AES] = 1; |
701 | doit[D_CBC_192_AES] = 1; | 706 | doit[D_CBC_192_AES] = 1; |
702 | doit[D_CBC_256_AES] = 1; | 707 | doit[D_CBC_256_AES] = 1; |
703 | } else if (strcmp(*argv, "ghash") == 0) { | 708 | } else if (strcmp(*argv, "ghash") == 0) |
704 | doit[D_GHASH] = 1; | 709 | doit[D_GHASH] = 1; |
705 | } else | 710 | else if (strcmp(*argv,"aes-128-gcm") == 0) |
711 | doit[D_AES_128_GCM]=1; | ||
712 | else if (strcmp(*argv,"aes-256-gcm") == 0) | ||
713 | doit[D_AES_256_GCM]=1; | ||
714 | else | ||
706 | #endif | 715 | #endif |
707 | #ifndef OPENSSL_NO_CAMELLIA | 716 | #ifndef OPENSSL_NO_CAMELLIA |
708 | if (strcmp(*argv, "camellia") == 0) { | 717 | if (strcmp(*argv, "camellia") == 0) { |
@@ -711,6 +720,11 @@ speed_main(int argc, char **argv) | |||
711 | doit[D_CBC_256_CML] = 1; | 720 | doit[D_CBC_256_CML] = 1; |
712 | } else | 721 | } else |
713 | #endif | 722 | #endif |
723 | #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) | ||
724 | if (strcmp(*argv,"chacha20-poly1305") == 0) | ||
725 | doit[D_CHACHA20_POLY1305]=1; | ||
726 | else | ||
727 | #endif | ||
714 | if (strcmp(*argv, "rsa") == 0) { | 728 | if (strcmp(*argv, "rsa") == 0) { |
715 | rsa_doit[R_RSA_512] = 1; | 729 | rsa_doit[R_RSA_512] = 1; |
716 | rsa_doit[R_RSA_1024] = 1; | 730 | rsa_doit[R_RSA_1024] = 1; |
@@ -836,18 +850,15 @@ speed_main(int argc, char **argv) | |||
836 | BIO_printf(bio_err, "rc2-cbc "); | 850 | BIO_printf(bio_err, "rc2-cbc "); |
837 | #endif | 851 | #endif |
838 | #ifndef OPENSSL_NO_BF | 852 | #ifndef OPENSSL_NO_BF |
839 | BIO_printf(bio_err, "bf-cbc"); | 853 | BIO_printf(bio_err, "bf-cbc "); |
840 | #endif | ||
841 | #if !defined(OPENSSL_NO_IDEA) || !defined(OPENSSL_NO_SEED) || !defined(OPENSSL_NO_RC2) || \ | ||
842 | !defined(OPENSSL_NO_BF) || !defined(OPENSSL_NO_RC5) | ||
843 | BIO_printf(bio_err, "\n"); | ||
844 | #endif | 854 | #endif |
845 | #ifndef OPENSSL_NO_DES | 855 | #ifndef OPENSSL_NO_DES |
846 | BIO_printf(bio_err, "des-cbc des-ede3 "); | 856 | BIO_printf(bio_err, "des-cbc des-ede3\n"); |
847 | #endif | 857 | #endif |
848 | #ifndef OPENSSL_NO_AES | 858 | #ifndef OPENSSL_NO_AES |
849 | BIO_printf(bio_err, "aes-128-cbc aes-192-cbc aes-256-cbc "); | 859 | BIO_printf(bio_err, "aes-128-cbc aes-192-cbc aes-256-cbc "); |
850 | BIO_printf(bio_err, "aes-128-ige aes-192-ige aes-256-ige "); | 860 | BIO_printf(bio_err, "aes-128-ige aes-192-ige aes-256-ige\n"); |
861 | BIO_printf(bio_err, "aes-128-gcm aes-256-gcm "); | ||
851 | #endif | 862 | #endif |
852 | #ifndef OPENSSL_NO_CAMELLIA | 863 | #ifndef OPENSSL_NO_CAMELLIA |
853 | BIO_printf(bio_err, "\n"); | 864 | BIO_printf(bio_err, "\n"); |
@@ -856,6 +867,9 @@ speed_main(int argc, char **argv) | |||
856 | #ifndef OPENSSL_NO_RC4 | 867 | #ifndef OPENSSL_NO_RC4 |
857 | BIO_printf(bio_err, "rc4"); | 868 | BIO_printf(bio_err, "rc4"); |
858 | #endif | 869 | #endif |
870 | #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) | ||
871 | BIO_printf(bio_err," chacha20-poly1305"); | ||
872 | #endif | ||
859 | BIO_printf(bio_err, "\n"); | 873 | BIO_printf(bio_err, "\n"); |
860 | 874 | ||
861 | BIO_printf(bio_err, "rsa512 rsa1024 rsa2048 rsa4096\n"); | 875 | BIO_printf(bio_err, "rsa512 rsa1024 rsa2048 rsa4096\n"); |
@@ -863,12 +877,10 @@ speed_main(int argc, char **argv) | |||
863 | BIO_printf(bio_err, "dsa512 dsa1024 dsa2048\n"); | 877 | BIO_printf(bio_err, "dsa512 dsa1024 dsa2048\n"); |
864 | BIO_printf(bio_err, "ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n"); | 878 | BIO_printf(bio_err, "ecdsap160 ecdsap192 ecdsap224 ecdsap256 ecdsap384 ecdsap521\n"); |
865 | BIO_printf(bio_err, "ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n"); | 879 | BIO_printf(bio_err, "ecdsak163 ecdsak233 ecdsak283 ecdsak409 ecdsak571\n"); |
866 | BIO_printf(bio_err, "ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571\n"); | 880 | BIO_printf(bio_err, "ecdsab163 ecdsab233 ecdsab283 ecdsab409 ecdsab571 ecdsa\n"); |
867 | BIO_printf(bio_err, "ecdsa\n"); | ||
868 | BIO_printf(bio_err, "ecdhp160 ecdhp192 ecdhp224 ecdhp256 ecdhp384 ecdhp521\n"); | 881 | BIO_printf(bio_err, "ecdhp160 ecdhp192 ecdhp224 ecdhp256 ecdhp384 ecdhp521\n"); |
869 | BIO_printf(bio_err, "ecdhk163 ecdhk233 ecdhk283 ecdhk409 ecdhk571\n"); | 882 | BIO_printf(bio_err, "ecdhk163 ecdhk233 ecdhk283 ecdhk409 ecdhk571\n"); |
870 | BIO_printf(bio_err, "ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571\n"); | 883 | BIO_printf(bio_err, "ecdhb163 ecdhb233 ecdhb283 ecdhb409 ecdhb571 ecdh\n"); |
871 | BIO_printf(bio_err, "ecdh\n"); | ||
872 | 884 | ||
873 | #ifndef OPENSSL_NO_IDEA | 885 | #ifndef OPENSSL_NO_IDEA |
874 | BIO_printf(bio_err, "idea "); | 886 | BIO_printf(bio_err, "idea "); |
@@ -1220,6 +1232,73 @@ speed_main(int argc, char **argv) | |||
1220 | } | 1232 | } |
1221 | CRYPTO_gcm128_release(ctx); | 1233 | CRYPTO_gcm128_release(ctx); |
1222 | } | 1234 | } |
1235 | if (doit[D_AES_128_GCM]) { | ||
1236 | const EVP_AEAD *aead = EVP_aead_aes_128_gcm(); | ||
1237 | static const unsigned char nonce[32] = {0}; | ||
1238 | size_t buf_len, nonce_len; | ||
1239 | EVP_AEAD_CTX ctx; | ||
1240 | |||
1241 | EVP_AEAD_CTX_init(&ctx, aead, key32, EVP_AEAD_key_length(aead), | ||
1242 | EVP_AEAD_DEFAULT_TAG_LENGTH, NULL); | ||
1243 | nonce_len = EVP_AEAD_nonce_length(aead); | ||
1244 | |||
1245 | for (j = 0; j < SIZE_NUM; j++) { | ||
1246 | print_message(names[D_AES_128_GCM],c[D_AES_128_GCM][j],lengths[j]); | ||
1247 | Time_F(START); | ||
1248 | for (count = 0, run = 1; COND(c[D_AES_128_GCM][j]); count++) | ||
1249 | EVP_AEAD_CTX_seal(&ctx, buf, &buf_len, BUFSIZE, nonce, | ||
1250 | nonce_len, buf, lengths[j], NULL, 0); | ||
1251 | d=Time_F(STOP); | ||
1252 | print_result(D_AES_128_GCM,j,count,d); | ||
1253 | } | ||
1254 | EVP_AEAD_CTX_cleanup(&ctx); | ||
1255 | } | ||
1256 | |||
1257 | if (doit[D_AES_256_GCM]) { | ||
1258 | const EVP_AEAD *aead = EVP_aead_aes_256_gcm(); | ||
1259 | static const unsigned char nonce[32] = {0}; | ||
1260 | size_t buf_len, nonce_len; | ||
1261 | EVP_AEAD_CTX ctx; | ||
1262 | |||
1263 | EVP_AEAD_CTX_init(&ctx, aead, key32, EVP_AEAD_key_length(aead), | ||
1264 | EVP_AEAD_DEFAULT_TAG_LENGTH, NULL); | ||
1265 | nonce_len = EVP_AEAD_nonce_length(aead); | ||
1266 | |||
1267 | for (j = 0; j < SIZE_NUM; j++) { | ||
1268 | print_message(names[D_AES_256_GCM],c[D_AES_256_GCM][j],lengths[j]); | ||
1269 | Time_F(START); | ||
1270 | for (count = 0, run = 1; COND(c[D_AES_256_GCM][j]); count++) | ||
1271 | EVP_AEAD_CTX_seal(&ctx, buf, &buf_len, BUFSIZE, nonce, | ||
1272 | nonce_len, buf, lengths[j], NULL, 0); | ||
1273 | d=Time_F(STOP); | ||
1274 | print_result(D_AES_256_GCM, j, count, d); | ||
1275 | } | ||
1276 | EVP_AEAD_CTX_cleanup(&ctx); | ||
1277 | } | ||
1278 | #endif | ||
1279 | #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) | ||
1280 | if (doit[D_CHACHA20_POLY1305]) { | ||
1281 | const EVP_AEAD *aead = EVP_aead_chacha20_poly1305(); | ||
1282 | static const unsigned char nonce[32] = {0}; | ||
1283 | size_t buf_len, nonce_len; | ||
1284 | EVP_AEAD_CTX ctx; | ||
1285 | |||
1286 | EVP_AEAD_CTX_init(&ctx, aead, key32, EVP_AEAD_key_length(aead), | ||
1287 | EVP_AEAD_DEFAULT_TAG_LENGTH, NULL); | ||
1288 | nonce_len = EVP_AEAD_nonce_length(aead); | ||
1289 | |||
1290 | for (j = 0; j < SIZE_NUM; j++) { | ||
1291 | print_message(names[D_CHACHA20_POLY1305], | ||
1292 | c[D_CHACHA20_POLY1305][j], lengths[j]); | ||
1293 | Time_F(START); | ||
1294 | for (count = 0, run = 1; COND(c[D_CHACHA20_POLY1305][j]); count++) | ||
1295 | EVP_AEAD_CTX_seal(&ctx, buf, &buf_len, BUFSIZE, nonce, | ||
1296 | nonce_len, buf, lengths[j], NULL, 0); | ||
1297 | d=Time_F(STOP); | ||
1298 | print_result(D_CHACHA20_POLY1305, j, count, d); | ||
1299 | } | ||
1300 | EVP_AEAD_CTX_cleanup(&ctx); | ||
1301 | } | ||
1223 | #endif | 1302 | #endif |
1224 | #ifndef OPENSSL_NO_CAMELLIA | 1303 | #ifndef OPENSSL_NO_CAMELLIA |
1225 | if (doit[D_CBC_128_CML]) { | 1304 | if (doit[D_CBC_128_CML]) { |