diff options
Diffstat (limited to 'src/usr.bin/openssl/speed.c')
| -rw-r--r-- | src/usr.bin/openssl/speed.c | 554 |
1 files changed, 241 insertions, 313 deletions
diff --git a/src/usr.bin/openssl/speed.c b/src/usr.bin/openssl/speed.c index 9d03c6516e..1ece133f2e 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.41 2025/01/02 13:37:43 tb Exp $ */ | 1 | /* $OpenBSD: speed.c,v 1.50 2025/12/13 01:58:53 kenjiro 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 | * |
| @@ -142,9 +142,6 @@ | |||
| 142 | #ifndef OPENSSL_NO_SHA | 142 | #ifndef OPENSSL_NO_SHA |
| 143 | #include <openssl/sha.h> | 143 | #include <openssl/sha.h> |
| 144 | #endif | 144 | #endif |
| 145 | #ifndef OPENSSL_NO_WHIRLPOOL | ||
| 146 | #include <openssl/whrlpool.h> | ||
| 147 | #endif | ||
| 148 | 145 | ||
| 149 | #define BUFSIZE (1024*8+64) | 146 | #define BUFSIZE (1024*8+64) |
| 150 | volatile sig_atomic_t run; | 147 | volatile sig_atomic_t run; |
| @@ -152,29 +149,78 @@ volatile sig_atomic_t run; | |||
| 152 | static int mr = 0; | 149 | static int mr = 0; |
| 153 | static int usertime = 1; | 150 | static int usertime = 1; |
| 154 | 151 | ||
| 155 | static double Time_F(int s); | 152 | static void print_message(const char *s, int length); |
| 156 | static void print_message(const char *s, long num, int length); | ||
| 157 | static void | 153 | static void |
| 158 | pkey_print_message(const char *str, const char *str2, | 154 | pkey_print_message(const char *str, const char *str2, |
| 159 | long num, int bits, int sec); | 155 | int bits, int sec); |
| 160 | static void print_result(int alg, int run_no, int count, double time_used); | 156 | static void print_result(int alg, int run_no, int count, double time_used); |
| 161 | static int do_multi(int multi); | 157 | static int do_multi(int multi); |
| 162 | 158 | ||
| 163 | #define ALGOR_NUM 32 | ||
| 164 | #define SIZE_NUM 5 | 159 | #define SIZE_NUM 5 |
| 165 | #define RSA_NUM 4 | 160 | #define MAX_ECDH_SIZE 256 |
| 166 | #define DSA_NUM 3 | 161 | |
| 162 | enum { | ||
| 163 | D_MD4, | ||
| 164 | D_MD5, | ||
| 165 | D_HMAC, | ||
| 166 | D_SHA1, | ||
| 167 | D_RMD160, | ||
| 168 | D_RC4, | ||
| 169 | D_CBC_DES, | ||
| 170 | D_EDE3_DES, | ||
| 171 | D_CBC_IDEA, | ||
| 172 | D_CBC_RC2, | ||
| 173 | D_CBC_BF, | ||
| 174 | D_CBC_CAST, | ||
| 175 | D_CBC_128_AES, | ||
| 176 | D_CBC_192_AES, | ||
| 177 | D_CBC_256_AES, | ||
| 178 | D_CBC_128_CML, | ||
| 179 | D_CBC_192_CML, | ||
| 180 | D_CBC_256_CML, | ||
| 181 | D_EVP, | ||
| 182 | D_SHA256, | ||
| 183 | D_SHA512, | ||
| 184 | D_IGE_128_AES, | ||
| 185 | D_IGE_192_AES, | ||
| 186 | D_IGE_256_AES, | ||
| 187 | D_GHASH, | ||
| 188 | D_AES_128_GCM, | ||
| 189 | D_AES_256_GCM, | ||
| 190 | D_CHACHA20_POLY1305, | ||
| 191 | ALGOR_NUM, | ||
| 192 | }; | ||
| 193 | |||
| 194 | enum { | ||
| 195 | R_DSA_512, | ||
| 196 | R_DSA_1024, | ||
| 197 | R_DSA_2048, | ||
| 198 | DSA_NUM, | ||
| 199 | }; | ||
| 200 | |||
| 201 | enum { | ||
| 202 | R_RSA_512, | ||
| 203 | R_RSA_1024, | ||
| 204 | R_RSA_2048, | ||
| 205 | R_RSA_4096, | ||
| 206 | RSA_NUM, | ||
| 207 | }; | ||
| 167 | 208 | ||
| 168 | #define EC_NUM 4 | 209 | enum { |
| 169 | #define MAX_ECDH_SIZE 256 | 210 | R_EC_P224, |
| 211 | R_EC_P256, | ||
| 212 | R_EC_P384, | ||
| 213 | R_EC_P521, | ||
| 214 | EC_NUM, | ||
| 215 | }; | ||
| 170 | 216 | ||
| 171 | static const char *names[ALGOR_NUM] = { | 217 | static const char *names[ALGOR_NUM] = { |
| 172 | "md2", "md4", "md5", "hmac(md5)", "sha1", "rmd160", | 218 | "md4", "md5", "hmac(sha256)", "sha1", "rmd160", |
| 173 | "rc4", "des cbc", "des ede3", "idea cbc", "seed cbc", | 219 | "rc4", "des cbc", "des ede3", "idea cbc", |
| 174 | "rc2 cbc", "rc5-32/12 cbc", "blowfish cbc", "cast cbc", | 220 | "rc2 cbc", "blowfish cbc", "cast cbc", |
| 175 | "aes-128 cbc", "aes-192 cbc", "aes-256 cbc", | 221 | "aes-128 cbc", "aes-192 cbc", "aes-256 cbc", |
| 176 | "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc", | 222 | "camellia-128 cbc", "camellia-192 cbc", "camellia-256 cbc", |
| 177 | "evp", "sha256", "sha512", "whirlpool", | 223 | "evp", "sha256", "sha512", |
| 178 | "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash", | 224 | "aes-128 ige", "aes-192 ige", "aes-256 ige", "ghash", |
| 179 | "aes-128 gcm", "aes-256 gcm", "chacha20 poly1305", | 225 | "aes-128 gcm", "aes-256 gcm", "chacha20 poly1305", |
| 180 | }; | 226 | }; |
| @@ -895,6 +941,22 @@ static const unsigned char test4096[] = { | |||
| 895 | 0xaf, 0xf8, 0x2a, 0x91, 0x9d, 0x50, 0x44, 0x21, 0x17, | 941 | 0xaf, 0xf8, 0x2a, 0x91, 0x9d, 0x50, 0x44, 0x21, 0x17, |
| 896 | }; | 942 | }; |
| 897 | 943 | ||
| 944 | static const unsigned char key16[] = { | ||
| 945 | 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 946 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, | ||
| 947 | }; | ||
| 948 | static const unsigned char key24[] = { | ||
| 949 | 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 950 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, | ||
| 951 | 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, | ||
| 952 | }; | ||
| 953 | static const unsigned char key32[] = { | ||
| 954 | 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 955 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, | ||
| 956 | 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, | ||
| 957 | 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56, | ||
| 958 | }; | ||
| 959 | |||
| 898 | static void | 960 | static void |
| 899 | sig_done(int sig) | 961 | sig_done(int sig) |
| 900 | { | 962 | { |
| @@ -904,16 +966,14 @@ sig_done(int sig) | |||
| 904 | #define START TM_RESET | 966 | #define START TM_RESET |
| 905 | #define STOP TM_GET | 967 | #define STOP TM_GET |
| 906 | 968 | ||
| 907 | |||
| 908 | static double | 969 | static double |
| 909 | Time_F(int s) | 970 | time_f(int s) |
| 910 | { | 971 | { |
| 911 | if (usertime) | 972 | if (usertime) |
| 912 | return app_timer_user(s); | 973 | return app_timer_user(s); |
| 913 | else | ||
| 914 | return app_timer_real(s); | ||
| 915 | } | ||
| 916 | 974 | ||
| 975 | return app_timer_real(s); | ||
| 976 | } | ||
| 917 | 977 | ||
| 918 | static const int KDF1_SHA1_len = 20; | 978 | static const int KDF1_SHA1_len = 20; |
| 919 | static void * | 979 | static void * |
| @@ -937,33 +997,12 @@ speed_main(int argc, char **argv) | |||
| 937 | unsigned char *buf = NULL, *buf2 = NULL; | 997 | unsigned char *buf = NULL, *buf2 = NULL; |
| 938 | size_t unaligned = 0; | 998 | size_t unaligned = 0; |
| 939 | int mret = 1; | 999 | int mret = 1; |
| 940 | long count = 0, save_count = 0; | 1000 | long count = 0; |
| 941 | int i, j, k; | 1001 | int i, j, k; |
| 942 | long rsa_count; | 1002 | long rsa_count; |
| 943 | unsigned rsa_num; | 1003 | unsigned rsa_num; |
| 944 | unsigned char md[EVP_MAX_MD_SIZE]; | 1004 | unsigned char md[EVP_MAX_MD_SIZE]; |
| 945 | #ifndef OPENSSL_NO_MD4 | 1005 | |
| 946 | unsigned char md4[MD4_DIGEST_LENGTH]; | ||
| 947 | #endif | ||
| 948 | #ifndef OPENSSL_NO_MD5 | ||
| 949 | unsigned char md5[MD5_DIGEST_LENGTH]; | ||
| 950 | unsigned char hmac[MD5_DIGEST_LENGTH]; | ||
| 951 | #endif | ||
| 952 | #ifndef OPENSSL_NO_SHA | ||
| 953 | unsigned char sha[SHA_DIGEST_LENGTH]; | ||
| 954 | #ifndef OPENSSL_NO_SHA256 | ||
| 955 | unsigned char sha256[SHA256_DIGEST_LENGTH]; | ||
| 956 | #endif | ||
| 957 | #ifndef OPENSSL_NO_SHA512 | ||
| 958 | unsigned char sha512[SHA512_DIGEST_LENGTH]; | ||
| 959 | #endif | ||
| 960 | #endif | ||
| 961 | #ifndef OPENSSL_NO_WHIRLPOOL | ||
| 962 | unsigned char whirlpool[WHIRLPOOL_DIGEST_LENGTH]; | ||
| 963 | #endif | ||
| 964 | #ifndef OPENSSL_NO_RIPEMD | ||
| 965 | unsigned char rmd160[RIPEMD160_DIGEST_LENGTH]; | ||
| 966 | #endif | ||
| 967 | #ifndef OPENSSL_NO_RC4 | 1006 | #ifndef OPENSSL_NO_RC4 |
| 968 | RC4_KEY rc4_ks; | 1007 | RC4_KEY rc4_ks; |
| 969 | #endif | 1008 | #endif |
| @@ -979,38 +1018,8 @@ speed_main(int argc, char **argv) | |||
| 979 | #ifndef OPENSSL_NO_CAST | 1018 | #ifndef OPENSSL_NO_CAST |
| 980 | CAST_KEY cast_ks; | 1019 | CAST_KEY cast_ks; |
| 981 | #endif | 1020 | #endif |
| 982 | static const unsigned char key16[16] = | ||
| 983 | {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 984 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12}; | ||
| 985 | #ifndef OPENSSL_NO_AES | ||
| 986 | static const unsigned char key24[24] = | ||
| 987 | {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 988 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, | ||
| 989 | 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34}; | ||
| 990 | static const unsigned char key32[32] = | ||
| 991 | {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 992 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, | ||
| 993 | 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, | ||
| 994 | 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56}; | ||
| 995 | #endif | ||
| 996 | #ifndef OPENSSL_NO_CAMELLIA | ||
| 997 | static const unsigned char ckey24[24] = | ||
| 998 | {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 999 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, | ||
| 1000 | 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34}; | ||
| 1001 | static const unsigned char ckey32[32] = | ||
| 1002 | {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, | ||
| 1003 | 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, | ||
| 1004 | 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, | ||
| 1005 | 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12, 0x34, 0x56}; | ||
| 1006 | #endif | ||
| 1007 | #ifndef OPENSSL_NO_AES | ||
| 1008 | #define MAX_BLOCK_SIZE 128 | ||
| 1009 | #else | ||
| 1010 | #define MAX_BLOCK_SIZE 64 | ||
| 1011 | #endif | ||
| 1012 | unsigned char DES_iv[8]; | 1021 | unsigned char DES_iv[8]; |
| 1013 | unsigned char iv[2 * MAX_BLOCK_SIZE / 8]; | 1022 | unsigned char iv[2 * 16]; |
| 1014 | #ifndef OPENSSL_NO_DES | 1023 | #ifndef OPENSSL_NO_DES |
| 1015 | static DES_cblock key = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0}; | 1024 | static DES_cblock key = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0}; |
| 1016 | static DES_cblock key2 = {0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12}; | 1025 | static DES_cblock key2 = {0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12}; |
| @@ -1025,55 +1034,9 @@ speed_main(int argc, char **argv) | |||
| 1025 | #ifndef OPENSSL_NO_CAMELLIA | 1034 | #ifndef OPENSSL_NO_CAMELLIA |
| 1026 | CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3; | 1035 | CAMELLIA_KEY camellia_ks1, camellia_ks2, camellia_ks3; |
| 1027 | #endif | 1036 | #endif |
| 1028 | #define D_MD2 0 | ||
| 1029 | #define D_MD4 1 | ||
| 1030 | #define D_MD5 2 | ||
| 1031 | #define D_HMAC 3 | ||
| 1032 | #define D_SHA1 4 | ||
| 1033 | #define D_RMD160 5 | ||
| 1034 | #define D_RC4 6 | ||
| 1035 | #define D_CBC_DES 7 | ||
| 1036 | #define D_EDE3_DES 8 | ||
| 1037 | #define D_CBC_IDEA 9 | ||
| 1038 | #define D_CBC_SEED 10 | ||
| 1039 | #define D_CBC_RC2 11 | ||
| 1040 | #define D_CBC_RC5 12 | ||
| 1041 | #define D_CBC_BF 13 | ||
| 1042 | #define D_CBC_CAST 14 | ||
| 1043 | #define D_CBC_128_AES 15 | ||
| 1044 | #define D_CBC_192_AES 16 | ||
| 1045 | #define D_CBC_256_AES 17 | ||
| 1046 | #define D_CBC_128_CML 18 | ||
| 1047 | #define D_CBC_192_CML 19 | ||
| 1048 | #define D_CBC_256_CML 20 | ||
| 1049 | #define D_EVP 21 | ||
| 1050 | #define D_SHA256 22 | ||
| 1051 | #define D_SHA512 23 | ||
| 1052 | #define D_WHIRLPOOL 24 | ||
| 1053 | #define D_IGE_128_AES 25 | ||
| 1054 | #define D_IGE_192_AES 26 | ||
| 1055 | #define D_IGE_256_AES 27 | ||
| 1056 | #define D_GHASH 28 | ||
| 1057 | #define D_AES_128_GCM 29 | ||
| 1058 | #define D_AES_256_GCM 30 | ||
| 1059 | #define D_CHACHA20_POLY1305 31 | ||
| 1060 | double d = 0.0; | 1037 | double d = 0.0; |
| 1061 | long c[ALGOR_NUM][SIZE_NUM]; | ||
| 1062 | #define R_DSA_512 0 | ||
| 1063 | #define R_DSA_1024 1 | ||
| 1064 | #define R_DSA_2048 2 | ||
| 1065 | #define R_RSA_512 0 | ||
| 1066 | #define R_RSA_1024 1 | ||
| 1067 | #define R_RSA_2048 2 | ||
| 1068 | #define R_RSA_4096 3 | ||
| 1069 | |||
| 1070 | #define R_EC_P224 0 | ||
| 1071 | #define R_EC_P256 1 | ||
| 1072 | #define R_EC_P384 2 | ||
| 1073 | #define R_EC_P521 3 | ||
| 1074 | 1038 | ||
| 1075 | RSA *rsa_key[RSA_NUM]; | 1039 | RSA *rsa_key[RSA_NUM]; |
| 1076 | long rsa_c[RSA_NUM][2]; | ||
| 1077 | static unsigned int rsa_bits[RSA_NUM] = {512, 1024, 2048, 4096}; | 1040 | static unsigned int rsa_bits[RSA_NUM] = {512, 1024, 2048, 4096}; |
| 1078 | static const unsigned char *rsa_data[RSA_NUM] = | 1041 | static const unsigned char *rsa_data[RSA_NUM] = |
| 1079 | {test512, test1024, test2048, test4096}; | 1042 | {test512, test1024, test2048, test4096}; |
| @@ -1081,7 +1044,6 @@ speed_main(int argc, char **argv) | |||
| 1081 | sizeof(test512), sizeof(test1024), | 1044 | sizeof(test512), sizeof(test1024), |
| 1082 | sizeof(test2048), sizeof(test4096)}; | 1045 | sizeof(test2048), sizeof(test4096)}; |
| 1083 | DSA *dsa_key[DSA_NUM]; | 1046 | DSA *dsa_key[DSA_NUM]; |
| 1084 | long dsa_c[DSA_NUM][2]; | ||
| 1085 | static unsigned int dsa_bits[DSA_NUM] = {512, 1024, 2048}; | 1047 | static unsigned int dsa_bits[DSA_NUM] = {512, 1024, 2048}; |
| 1086 | #ifndef OPENSSL_NO_EC | 1048 | #ifndef OPENSSL_NO_EC |
| 1087 | /* | 1049 | /* |
| @@ -1111,14 +1073,12 @@ speed_main(int argc, char **argv) | |||
| 1111 | unsigned char ecdsasig[256]; | 1073 | unsigned char ecdsasig[256]; |
| 1112 | unsigned int ecdsasiglen; | 1074 | unsigned int ecdsasiglen; |
| 1113 | EC_KEY *ecdsa[EC_NUM]; | 1075 | EC_KEY *ecdsa[EC_NUM]; |
| 1114 | long ecdsa_c[EC_NUM][2]; | ||
| 1115 | 1076 | ||
| 1116 | EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM]; | 1077 | EC_KEY *ecdh_a[EC_NUM], *ecdh_b[EC_NUM]; |
| 1117 | unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE]; | 1078 | unsigned char secret_a[MAX_ECDH_SIZE], secret_b[MAX_ECDH_SIZE]; |
| 1118 | int secret_size_a, secret_size_b; | 1079 | int secret_size_a, secret_size_b; |
| 1119 | int ecdh_checks = 0; | 1080 | int ecdh_checks = 0; |
| 1120 | int secret_idx = 0; | 1081 | int secret_idx = 0; |
| 1121 | long ecdh_c[EC_NUM][2]; | ||
| 1122 | 1082 | ||
| 1123 | int rsa_doit[RSA_NUM]; | 1083 | int rsa_doit[RSA_NUM]; |
| 1124 | int dsa_doit[DSA_NUM]; | 1084 | int dsa_doit[DSA_NUM]; |
| @@ -1161,7 +1121,6 @@ speed_main(int argc, char **argv) | |||
| 1161 | BIO_printf(bio_err, "out of memory\n"); | 1121 | BIO_printf(bio_err, "out of memory\n"); |
| 1162 | goto end; | 1122 | goto end; |
| 1163 | } | 1123 | } |
| 1164 | memset(c, 0, sizeof(c)); | ||
| 1165 | memset(DES_iv, 0, sizeof(DES_iv)); | 1124 | memset(DES_iv, 0, sizeof(DES_iv)); |
| 1166 | memset(iv, 0, sizeof(iv)); | 1125 | memset(iv, 0, sizeof(iv)); |
| 1167 | 1126 | ||
| @@ -1275,11 +1234,6 @@ speed_main(int argc, char **argv) | |||
| 1275 | else | 1234 | else |
| 1276 | #endif | 1235 | #endif |
| 1277 | #endif | 1236 | #endif |
| 1278 | #ifndef OPENSSL_NO_WHIRLPOOL | ||
| 1279 | if (strcmp(*argv, "whirlpool") == 0) | ||
| 1280 | doit[D_WHIRLPOOL] = 1; | ||
| 1281 | else | ||
| 1282 | #endif | ||
| 1283 | #ifndef OPENSSL_NO_RIPEMD | 1237 | #ifndef OPENSSL_NO_RIPEMD |
| 1284 | if (strcmp(*argv, "ripemd") == 0) | 1238 | if (strcmp(*argv, "ripemd") == 0) |
| 1285 | doit[D_RMD160] = 1; | 1239 | doit[D_RMD160] = 1; |
| @@ -1462,16 +1416,12 @@ speed_main(int argc, char **argv) | |||
| 1462 | #ifndef OPENSSL_NO_SHA512 | 1416 | #ifndef OPENSSL_NO_SHA512 |
| 1463 | BIO_printf(bio_err, "sha512 "); | 1417 | BIO_printf(bio_err, "sha512 "); |
| 1464 | #endif | 1418 | #endif |
| 1465 | #ifndef OPENSSL_NO_WHIRLPOOL | ||
| 1466 | BIO_printf(bio_err, "whirlpool"); | ||
| 1467 | #endif | ||
| 1468 | #ifndef OPENSSL_NO_RIPEMD160 | 1419 | #ifndef OPENSSL_NO_RIPEMD160 |
| 1469 | BIO_printf(bio_err, "rmd160"); | 1420 | BIO_printf(bio_err, "rmd160"); |
| 1470 | #endif | 1421 | #endif |
| 1471 | #if !defined(OPENSSL_NO_MD2) || \ | 1422 | #if !defined(OPENSSL_NO_MD2) || \ |
| 1472 | !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \ | 1423 | !defined(OPENSSL_NO_MD4) || !defined(OPENSSL_NO_MD5) || \ |
| 1473 | !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) || \ | 1424 | !defined(OPENSSL_NO_SHA1) || !defined(OPENSSL_NO_RIPEMD160) |
| 1474 | !defined(OPENSSL_NO_WHIRLPOOL) | ||
| 1475 | BIO_printf(bio_err, "\n"); | 1425 | BIO_printf(bio_err, "\n"); |
| 1476 | #endif | 1426 | #endif |
| 1477 | 1427 | ||
| @@ -1602,8 +1552,8 @@ speed_main(int argc, char **argv) | |||
| 1602 | #endif | 1552 | #endif |
| 1603 | #ifndef OPENSSL_NO_CAMELLIA | 1553 | #ifndef OPENSSL_NO_CAMELLIA |
| 1604 | Camellia_set_key(key16, 128, &camellia_ks1); | 1554 | Camellia_set_key(key16, 128, &camellia_ks1); |
| 1605 | Camellia_set_key(ckey24, 192, &camellia_ks2); | 1555 | Camellia_set_key(key24, 192, &camellia_ks2); |
| 1606 | Camellia_set_key(ckey32, 256, &camellia_ks3); | 1556 | Camellia_set_key(key32, 256, &camellia_ks3); |
| 1607 | #endif | 1557 | #endif |
| 1608 | #ifndef OPENSSL_NO_IDEA | 1558 | #ifndef OPENSSL_NO_IDEA |
| 1609 | idea_set_encrypt_key(key16, &idea_ks); | 1559 | idea_set_encrypt_key(key16, &idea_ks); |
| @@ -1620,8 +1570,7 @@ speed_main(int argc, char **argv) | |||
| 1620 | #ifndef OPENSSL_NO_CAST | 1570 | #ifndef OPENSSL_NO_CAST |
| 1621 | CAST_set_key(&cast_ks, 16, key16); | 1571 | CAST_set_key(&cast_ks, 16, key16); |
| 1622 | #endif | 1572 | #endif |
| 1623 | memset(rsa_c, 0, sizeof(rsa_c)); | 1573 | #define COND (run && count<0x7fffffff) |
| 1624 | #define COND(c) (run && count<0x7fffffff) | ||
| 1625 | #define COUNT(d) (count) | 1574 | #define COUNT(d) (count) |
| 1626 | 1575 | ||
| 1627 | memset(&sa, 0, sizeof(sa)); | 1576 | memset(&sa, 0, sizeof(sa)); |
| @@ -1633,11 +1582,11 @@ speed_main(int argc, char **argv) | |||
| 1633 | #ifndef OPENSSL_NO_MD4 | 1582 | #ifndef OPENSSL_NO_MD4 |
| 1634 | if (doit[D_MD4]) { | 1583 | if (doit[D_MD4]) { |
| 1635 | for (j = 0; j < SIZE_NUM; j++) { | 1584 | for (j = 0; j < SIZE_NUM; j++) { |
| 1636 | print_message(names[D_MD4], c[D_MD4][j], lengths[j]); | 1585 | print_message(names[D_MD4], lengths[j]); |
| 1637 | Time_F(START); | 1586 | time_f(START); |
| 1638 | for (count = 0, run = 1; COND(c[D_MD4][j]); count++) | 1587 | for (count = 0, run = 1; COND; count++) |
| 1639 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md4[0]), NULL, EVP_md4(), NULL); | 1588 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_md4(), NULL); |
| 1640 | d = Time_F(STOP); | 1589 | d = time_f(STOP); |
| 1641 | print_result(D_MD4, j, count, d); | 1590 | print_result(D_MD4, j, count, d); |
| 1642 | } | 1591 | } |
| 1643 | } | 1592 | } |
| @@ -1646,17 +1595,17 @@ speed_main(int argc, char **argv) | |||
| 1646 | #ifndef OPENSSL_NO_MD5 | 1595 | #ifndef OPENSSL_NO_MD5 |
| 1647 | if (doit[D_MD5]) { | 1596 | if (doit[D_MD5]) { |
| 1648 | for (j = 0; j < SIZE_NUM; j++) { | 1597 | for (j = 0; j < SIZE_NUM; j++) { |
| 1649 | print_message(names[D_MD5], c[D_MD5][j], lengths[j]); | 1598 | print_message(names[D_MD5], lengths[j]); |
| 1650 | Time_F(START); | 1599 | time_f(START); |
| 1651 | for (count = 0, run = 1; COND(c[D_MD5][j]); count++) | 1600 | for (count = 0, run = 1; COND; count++) |
| 1652 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], &(md5[0]), NULL, EVP_get_digestbyname("md5"), NULL); | 1601 | EVP_Digest(&(buf[0]), (unsigned long) lengths[j], md, NULL, EVP_get_digestbyname("md5"), NULL); |
| 1653 | d = Time_F(STOP); | 1602 | d = time_f(STOP); |
| 1654 | print_result(D_MD5, j, count, d); | 1603 | print_result(D_MD5, j, count, d); |
| 1655 | } | 1604 | } |
| 1656 | } | 1605 | } |
| 1657 | #endif | 1606 | #endif |
| 1658 | 1607 | ||
| 1659 | #if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_HMAC) | 1608 | #if !defined(OPENSSL_NO_SHA256) && !defined(OPENSSL_NO_HMAC) |
| 1660 | if (doit[D_HMAC]) { | 1609 | if (doit[D_HMAC]) { |
| 1661 | HMAC_CTX *hctx; | 1610 | HMAC_CTX *hctx; |
| 1662 | 1611 | ||
| @@ -1666,12 +1615,12 @@ speed_main(int argc, char **argv) | |||
| 1666 | } | 1615 | } |
| 1667 | 1616 | ||
| 1668 | HMAC_Init_ex(hctx, (unsigned char *) "This is a key...", | 1617 | HMAC_Init_ex(hctx, (unsigned char *) "This is a key...", |
| 1669 | 16, EVP_md5(), NULL); | 1618 | 16, EVP_sha256(), NULL); |
| 1670 | 1619 | ||
| 1671 | for (j = 0; j < SIZE_NUM; j++) { | 1620 | for (j = 0; j < SIZE_NUM; j++) { |
| 1672 | print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]); | 1621 | print_message(names[D_HMAC], lengths[j]); |
| 1673 | Time_F(START); | 1622 | time_f(START); |
| 1674 | for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) { | 1623 | for (count = 0, run = 1; COND; count++) { |
| 1675 | if (!HMAC_Init_ex(hctx, NULL, 0, NULL, NULL)) { | 1624 | if (!HMAC_Init_ex(hctx, NULL, 0, NULL, NULL)) { |
| 1676 | HMAC_CTX_free(hctx); | 1625 | HMAC_CTX_free(hctx); |
| 1677 | goto end; | 1626 | goto end; |
| @@ -1680,12 +1629,12 @@ speed_main(int argc, char **argv) | |||
| 1680 | HMAC_CTX_free(hctx); | 1629 | HMAC_CTX_free(hctx); |
| 1681 | goto end; | 1630 | goto end; |
| 1682 | } | 1631 | } |
| 1683 | if (!HMAC_Final(hctx, &(hmac[0]), NULL)) { | 1632 | if (!HMAC_Final(hctx, md, NULL)) { |
| 1684 | HMAC_CTX_free(hctx); | 1633 | HMAC_CTX_free(hctx); |
| 1685 | goto end; | 1634 | goto end; |
| 1686 | } | 1635 | } |
| 1687 | } | 1636 | } |
| 1688 | d = Time_F(STOP); | 1637 | d = time_f(STOP); |
| 1689 | print_result(D_HMAC, j, count, d); | 1638 | print_result(D_HMAC, j, count, d); |
| 1690 | } | 1639 | } |
| 1691 | HMAC_CTX_free(hctx); | 1640 | HMAC_CTX_free(hctx); |
| @@ -1694,22 +1643,22 @@ speed_main(int argc, char **argv) | |||
| 1694 | #ifndef OPENSSL_NO_SHA | 1643 | #ifndef OPENSSL_NO_SHA |
| 1695 | if (doit[D_SHA1]) { | 1644 | if (doit[D_SHA1]) { |
| 1696 | for (j = 0; j < SIZE_NUM; j++) { | 1645 | for (j = 0; j < SIZE_NUM; j++) { |
| 1697 | print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]); | 1646 | print_message(names[D_SHA1], lengths[j]); |
| 1698 | Time_F(START); | 1647 | time_f(START); |
| 1699 | for (count = 0, run = 1; COND(c[D_SHA1][j]); count++) | 1648 | for (count = 0, run = 1; COND; count++) |
| 1700 | EVP_Digest(buf, (unsigned long) lengths[j], &(sha[0]), NULL, EVP_sha1(), NULL); | 1649 | EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_sha1(), NULL); |
| 1701 | d = Time_F(STOP); | 1650 | d = time_f(STOP); |
| 1702 | print_result(D_SHA1, j, count, d); | 1651 | print_result(D_SHA1, j, count, d); |
| 1703 | } | 1652 | } |
| 1704 | } | 1653 | } |
| 1705 | #ifndef OPENSSL_NO_SHA256 | 1654 | #ifndef OPENSSL_NO_SHA256 |
| 1706 | if (doit[D_SHA256]) { | 1655 | if (doit[D_SHA256]) { |
| 1707 | for (j = 0; j < SIZE_NUM; j++) { | 1656 | for (j = 0; j < SIZE_NUM; j++) { |
| 1708 | print_message(names[D_SHA256], c[D_SHA256][j], lengths[j]); | 1657 | print_message(names[D_SHA256], lengths[j]); |
| 1709 | Time_F(START); | 1658 | time_f(START); |
| 1710 | for (count = 0, run = 1; COND(c[D_SHA256][j]); count++) | 1659 | for (count = 0, run = 1; COND; count++) |
| 1711 | SHA256(buf, lengths[j], sha256); | 1660 | SHA256(buf, lengths[j], md); |
| 1712 | d = Time_F(STOP); | 1661 | d = time_f(STOP); |
| 1713 | print_result(D_SHA256, j, count, d); | 1662 | print_result(D_SHA256, j, count, d); |
| 1714 | } | 1663 | } |
| 1715 | } | 1664 | } |
| @@ -1718,38 +1667,25 @@ speed_main(int argc, char **argv) | |||
| 1718 | #ifndef OPENSSL_NO_SHA512 | 1667 | #ifndef OPENSSL_NO_SHA512 |
| 1719 | if (doit[D_SHA512]) { | 1668 | if (doit[D_SHA512]) { |
| 1720 | for (j = 0; j < SIZE_NUM; j++) { | 1669 | for (j = 0; j < SIZE_NUM; j++) { |
| 1721 | print_message(names[D_SHA512], c[D_SHA512][j], lengths[j]); | 1670 | print_message(names[D_SHA512], lengths[j]); |
| 1722 | Time_F(START); | 1671 | time_f(START); |
| 1723 | for (count = 0, run = 1; COND(c[D_SHA512][j]); count++) | 1672 | for (count = 0, run = 1; COND; count++) |
| 1724 | SHA512(buf, lengths[j], sha512); | 1673 | SHA512(buf, lengths[j], md); |
| 1725 | d = Time_F(STOP); | 1674 | d = time_f(STOP); |
| 1726 | print_result(D_SHA512, j, count, d); | 1675 | print_result(D_SHA512, j, count, d); |
| 1727 | } | 1676 | } |
| 1728 | } | 1677 | } |
| 1729 | #endif | 1678 | #endif |
| 1730 | #endif | 1679 | #endif |
| 1731 | 1680 | ||
| 1732 | #ifndef OPENSSL_NO_WHIRLPOOL | ||
| 1733 | if (doit[D_WHIRLPOOL]) { | ||
| 1734 | for (j = 0; j < SIZE_NUM; j++) { | ||
| 1735 | print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], lengths[j]); | ||
| 1736 | Time_F(START); | ||
| 1737 | for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); count++) | ||
| 1738 | WHIRLPOOL(buf, lengths[j], whirlpool); | ||
| 1739 | d = Time_F(STOP); | ||
| 1740 | print_result(D_WHIRLPOOL, j, count, d); | ||
| 1741 | } | ||
| 1742 | } | ||
| 1743 | #endif | ||
| 1744 | |||
| 1745 | #ifndef OPENSSL_NO_RIPEMD | 1681 | #ifndef OPENSSL_NO_RIPEMD |
| 1746 | if (doit[D_RMD160]) { | 1682 | if (doit[D_RMD160]) { |
| 1747 | for (j = 0; j < SIZE_NUM; j++) { | 1683 | for (j = 0; j < SIZE_NUM; j++) { |
| 1748 | print_message(names[D_RMD160], c[D_RMD160][j], lengths[j]); | 1684 | print_message(names[D_RMD160], lengths[j]); |
| 1749 | Time_F(START); | 1685 | time_f(START); |
| 1750 | for (count = 0, run = 1; COND(c[D_RMD160][j]); count++) | 1686 | for (count = 0, run = 1; COND; count++) |
| 1751 | EVP_Digest(buf, (unsigned long) lengths[j], &(rmd160[0]), NULL, EVP_ripemd160(), NULL); | 1687 | EVP_Digest(buf, (unsigned long) lengths[j], md, NULL, EVP_ripemd160(), NULL); |
| 1752 | d = Time_F(STOP); | 1688 | d = time_f(STOP); |
| 1753 | print_result(D_RMD160, j, count, d); | 1689 | print_result(D_RMD160, j, count, d); |
| 1754 | } | 1690 | } |
| 1755 | } | 1691 | } |
| @@ -1757,12 +1693,12 @@ speed_main(int argc, char **argv) | |||
| 1757 | #ifndef OPENSSL_NO_RC4 | 1693 | #ifndef OPENSSL_NO_RC4 |
| 1758 | if (doit[D_RC4]) { | 1694 | if (doit[D_RC4]) { |
| 1759 | for (j = 0; j < SIZE_NUM; j++) { | 1695 | for (j = 0; j < SIZE_NUM; j++) { |
| 1760 | print_message(names[D_RC4], c[D_RC4][j], lengths[j]); | 1696 | print_message(names[D_RC4], lengths[j]); |
| 1761 | Time_F(START); | 1697 | time_f(START); |
| 1762 | for (count = 0, run = 1; COND(c[D_RC4][j]); count++) | 1698 | for (count = 0, run = 1; COND; count++) |
| 1763 | RC4(&rc4_ks, (unsigned int) lengths[j], | 1699 | RC4(&rc4_ks, (unsigned int) lengths[j], |
| 1764 | buf, buf); | 1700 | buf, buf); |
| 1765 | d = Time_F(STOP); | 1701 | d = time_f(STOP); |
| 1766 | print_result(D_RC4, j, count, d); | 1702 | print_result(D_RC4, j, count, d); |
| 1767 | } | 1703 | } |
| 1768 | } | 1704 | } |
| @@ -1770,24 +1706,24 @@ speed_main(int argc, char **argv) | |||
| 1770 | #ifndef OPENSSL_NO_DES | 1706 | #ifndef OPENSSL_NO_DES |
| 1771 | if (doit[D_CBC_DES]) { | 1707 | if (doit[D_CBC_DES]) { |
| 1772 | for (j = 0; j < SIZE_NUM; j++) { | 1708 | for (j = 0; j < SIZE_NUM; j++) { |
| 1773 | print_message(names[D_CBC_DES], c[D_CBC_DES][j], lengths[j]); | 1709 | print_message(names[D_CBC_DES], lengths[j]); |
| 1774 | Time_F(START); | 1710 | time_f(START); |
| 1775 | for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++) | 1711 | for (count = 0, run = 1; COND; count++) |
| 1776 | DES_ncbc_encrypt(buf, buf, lengths[j], &sch, | 1712 | DES_ncbc_encrypt(buf, buf, lengths[j], &sch, |
| 1777 | &DES_iv, DES_ENCRYPT); | 1713 | &DES_iv, DES_ENCRYPT); |
| 1778 | d = Time_F(STOP); | 1714 | d = time_f(STOP); |
| 1779 | print_result(D_CBC_DES, j, count, d); | 1715 | print_result(D_CBC_DES, j, count, d); |
| 1780 | } | 1716 | } |
| 1781 | } | 1717 | } |
| 1782 | if (doit[D_EDE3_DES]) { | 1718 | if (doit[D_EDE3_DES]) { |
| 1783 | for (j = 0; j < SIZE_NUM; j++) { | 1719 | for (j = 0; j < SIZE_NUM; j++) { |
| 1784 | print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], lengths[j]); | 1720 | print_message(names[D_EDE3_DES], lengths[j]); |
| 1785 | Time_F(START); | 1721 | time_f(START); |
| 1786 | for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); count++) | 1722 | for (count = 0, run = 1; COND; count++) |
| 1787 | DES_ede3_cbc_encrypt(buf, buf, lengths[j], | 1723 | DES_ede3_cbc_encrypt(buf, buf, lengths[j], |
| 1788 | &sch, &sch2, &sch3, | 1724 | &sch, &sch2, &sch3, |
| 1789 | &DES_iv, DES_ENCRYPT); | 1725 | &DES_iv, DES_ENCRYPT); |
| 1790 | d = Time_F(STOP); | 1726 | d = time_f(STOP); |
| 1791 | print_result(D_EDE3_DES, j, count, d); | 1727 | print_result(D_EDE3_DES, j, count, d); |
| 1792 | } | 1728 | } |
| 1793 | } | 1729 | } |
| @@ -1795,73 +1731,73 @@ speed_main(int argc, char **argv) | |||
| 1795 | #ifndef OPENSSL_NO_AES | 1731 | #ifndef OPENSSL_NO_AES |
| 1796 | if (doit[D_CBC_128_AES]) { | 1732 | if (doit[D_CBC_128_AES]) { |
| 1797 | for (j = 0; j < SIZE_NUM; j++) { | 1733 | for (j = 0; j < SIZE_NUM; j++) { |
| 1798 | print_message(names[D_CBC_128_AES], c[D_CBC_128_AES][j], lengths[j]); | 1734 | print_message(names[D_CBC_128_AES], lengths[j]); |
| 1799 | Time_F(START); | 1735 | time_f(START); |
| 1800 | for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); count++) | 1736 | for (count = 0, run = 1; COND; count++) |
| 1801 | AES_cbc_encrypt(buf, buf, | 1737 | AES_cbc_encrypt(buf, buf, |
| 1802 | (unsigned long) lengths[j], &aes_ks1, | 1738 | (unsigned long) lengths[j], &aes_ks1, |
| 1803 | iv, AES_ENCRYPT); | 1739 | iv, AES_ENCRYPT); |
| 1804 | d = Time_F(STOP); | 1740 | d = time_f(STOP); |
| 1805 | print_result(D_CBC_128_AES, j, count, d); | 1741 | print_result(D_CBC_128_AES, j, count, d); |
| 1806 | } | 1742 | } |
| 1807 | } | 1743 | } |
| 1808 | if (doit[D_CBC_192_AES]) { | 1744 | if (doit[D_CBC_192_AES]) { |
| 1809 | for (j = 0; j < SIZE_NUM; j++) { | 1745 | for (j = 0; j < SIZE_NUM; j++) { |
| 1810 | print_message(names[D_CBC_192_AES], c[D_CBC_192_AES][j], lengths[j]); | 1746 | print_message(names[D_CBC_192_AES], lengths[j]); |
| 1811 | Time_F(START); | 1747 | time_f(START); |
| 1812 | for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); count++) | 1748 | for (count = 0, run = 1; COND; count++) |
| 1813 | AES_cbc_encrypt(buf, buf, | 1749 | AES_cbc_encrypt(buf, buf, |
| 1814 | (unsigned long) lengths[j], &aes_ks2, | 1750 | (unsigned long) lengths[j], &aes_ks2, |
| 1815 | iv, AES_ENCRYPT); | 1751 | iv, AES_ENCRYPT); |
| 1816 | d = Time_F(STOP); | 1752 | d = time_f(STOP); |
| 1817 | print_result(D_CBC_192_AES, j, count, d); | 1753 | print_result(D_CBC_192_AES, j, count, d); |
| 1818 | } | 1754 | } |
| 1819 | } | 1755 | } |
| 1820 | if (doit[D_CBC_256_AES]) { | 1756 | if (doit[D_CBC_256_AES]) { |
| 1821 | for (j = 0; j < SIZE_NUM; j++) { | 1757 | for (j = 0; j < SIZE_NUM; j++) { |
| 1822 | print_message(names[D_CBC_256_AES], c[D_CBC_256_AES][j], lengths[j]); | 1758 | print_message(names[D_CBC_256_AES], lengths[j]); |
| 1823 | Time_F(START); | 1759 | time_f(START); |
| 1824 | for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); count++) | 1760 | for (count = 0, run = 1; COND; count++) |
| 1825 | AES_cbc_encrypt(buf, buf, | 1761 | AES_cbc_encrypt(buf, buf, |
| 1826 | (unsigned long) lengths[j], &aes_ks3, | 1762 | (unsigned long) lengths[j], &aes_ks3, |
| 1827 | iv, AES_ENCRYPT); | 1763 | iv, AES_ENCRYPT); |
| 1828 | d = Time_F(STOP); | 1764 | d = time_f(STOP); |
| 1829 | print_result(D_CBC_256_AES, j, count, d); | 1765 | print_result(D_CBC_256_AES, j, count, d); |
| 1830 | } | 1766 | } |
| 1831 | } | 1767 | } |
| 1832 | if (doit[D_IGE_128_AES]) { | 1768 | if (doit[D_IGE_128_AES]) { |
| 1833 | for (j = 0; j < SIZE_NUM; j++) { | 1769 | for (j = 0; j < SIZE_NUM; j++) { |
| 1834 | print_message(names[D_IGE_128_AES], c[D_IGE_128_AES][j], lengths[j]); | 1770 | print_message(names[D_IGE_128_AES], lengths[j]); |
| 1835 | Time_F(START); | 1771 | time_f(START); |
| 1836 | for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); count++) | 1772 | for (count = 0, run = 1; COND; count++) |
| 1837 | AES_ige_encrypt(buf, buf2, | 1773 | AES_ige_encrypt(buf, buf2, |
| 1838 | (unsigned long) lengths[j], &aes_ks1, | 1774 | (unsigned long) lengths[j], &aes_ks1, |
| 1839 | iv, AES_ENCRYPT); | 1775 | iv, AES_ENCRYPT); |
| 1840 | d = Time_F(STOP); | 1776 | d = time_f(STOP); |
| 1841 | print_result(D_IGE_128_AES, j, count, d); | 1777 | print_result(D_IGE_128_AES, j, count, d); |
| 1842 | } | 1778 | } |
| 1843 | } | 1779 | } |
| 1844 | if (doit[D_IGE_192_AES]) { | 1780 | if (doit[D_IGE_192_AES]) { |
| 1845 | for (j = 0; j < SIZE_NUM; j++) { | 1781 | for (j = 0; j < SIZE_NUM; j++) { |
| 1846 | print_message(names[D_IGE_192_AES], c[D_IGE_192_AES][j], lengths[j]); | 1782 | print_message(names[D_IGE_192_AES], lengths[j]); |
| 1847 | Time_F(START); | 1783 | time_f(START); |
| 1848 | for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); count++) | 1784 | for (count = 0, run = 1; COND; count++) |
| 1849 | AES_ige_encrypt(buf, buf2, | 1785 | AES_ige_encrypt(buf, buf2, |
| 1850 | (unsigned long) lengths[j], &aes_ks2, | 1786 | (unsigned long) lengths[j], &aes_ks2, |
| 1851 | iv, AES_ENCRYPT); | 1787 | iv, AES_ENCRYPT); |
| 1852 | d = Time_F(STOP); | 1788 | d = time_f(STOP); |
| 1853 | print_result(D_IGE_192_AES, j, count, d); | 1789 | print_result(D_IGE_192_AES, j, count, d); |
| 1854 | } | 1790 | } |
| 1855 | } | 1791 | } |
| 1856 | if (doit[D_IGE_256_AES]) { | 1792 | if (doit[D_IGE_256_AES]) { |
| 1857 | for (j = 0; j < SIZE_NUM; j++) { | 1793 | for (j = 0; j < SIZE_NUM; j++) { |
| 1858 | print_message(names[D_IGE_256_AES], c[D_IGE_256_AES][j], lengths[j]); | 1794 | print_message(names[D_IGE_256_AES], lengths[j]); |
| 1859 | Time_F(START); | 1795 | time_f(START); |
| 1860 | for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); count++) | 1796 | for (count = 0, run = 1; COND; count++) |
| 1861 | AES_ige_encrypt(buf, buf2, | 1797 | AES_ige_encrypt(buf, buf2, |
| 1862 | (unsigned long) lengths[j], &aes_ks3, | 1798 | (unsigned long) lengths[j], &aes_ks3, |
| 1863 | iv, AES_ENCRYPT); | 1799 | iv, AES_ENCRYPT); |
| 1864 | d = Time_F(STOP); | 1800 | d = time_f(STOP); |
| 1865 | print_result(D_IGE_256_AES, j, count, d); | 1801 | print_result(D_IGE_256_AES, j, count, d); |
| 1866 | } | 1802 | } |
| 1867 | } | 1803 | } |
| @@ -1870,11 +1806,11 @@ speed_main(int argc, char **argv) | |||
| 1870 | CRYPTO_gcm128_setiv(ctx, (unsigned char *) "0123456789ab", 12); | 1806 | CRYPTO_gcm128_setiv(ctx, (unsigned char *) "0123456789ab", 12); |
| 1871 | 1807 | ||
| 1872 | for (j = 0; j < SIZE_NUM; j++) { | 1808 | for (j = 0; j < SIZE_NUM; j++) { |
| 1873 | print_message(names[D_GHASH], c[D_GHASH][j], lengths[j]); | 1809 | print_message(names[D_GHASH], lengths[j]); |
| 1874 | Time_F(START); | 1810 | time_f(START); |
| 1875 | for (count = 0, run = 1; COND(c[D_GHASH][j]); count++) | 1811 | for (count = 0, run = 1; COND; count++) |
| 1876 | CRYPTO_gcm128_aad(ctx, buf, lengths[j]); | 1812 | CRYPTO_gcm128_aad(ctx, buf, lengths[j]); |
| 1877 | d = Time_F(STOP); | 1813 | d = time_f(STOP); |
| 1878 | print_result(D_GHASH, j, count, d); | 1814 | print_result(D_GHASH, j, count, d); |
| 1879 | } | 1815 | } |
| 1880 | CRYPTO_gcm128_release(ctx); | 1816 | CRYPTO_gcm128_release(ctx); |
| @@ -1896,12 +1832,12 @@ speed_main(int argc, char **argv) | |||
| 1896 | nonce_len = EVP_AEAD_nonce_length(aead); | 1832 | nonce_len = EVP_AEAD_nonce_length(aead); |
| 1897 | 1833 | ||
| 1898 | for (j = 0; j < SIZE_NUM; j++) { | 1834 | for (j = 0; j < SIZE_NUM; j++) { |
| 1899 | print_message(names[D_AES_128_GCM],c[D_AES_128_GCM][j],lengths[j]); | 1835 | print_message(names[D_AES_128_GCM], lengths[j]); |
| 1900 | Time_F(START); | 1836 | time_f(START); |
| 1901 | for (count = 0, run = 1; COND(c[D_AES_128_GCM][j]); count++) | 1837 | for (count = 0, run = 1; COND; count++) |
| 1902 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, | 1838 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, |
| 1903 | nonce_len, buf, lengths[j], NULL, 0); | 1839 | nonce_len, buf, lengths[j], NULL, 0); |
| 1904 | d=Time_F(STOP); | 1840 | d = time_f(STOP); |
| 1905 | print_result(D_AES_128_GCM,j,count,d); | 1841 | print_result(D_AES_128_GCM,j,count,d); |
| 1906 | } | 1842 | } |
| 1907 | EVP_AEAD_CTX_free(ctx); | 1843 | EVP_AEAD_CTX_free(ctx); |
| @@ -1924,12 +1860,12 @@ speed_main(int argc, char **argv) | |||
| 1924 | nonce_len = EVP_AEAD_nonce_length(aead); | 1860 | nonce_len = EVP_AEAD_nonce_length(aead); |
| 1925 | 1861 | ||
| 1926 | for (j = 0; j < SIZE_NUM; j++) { | 1862 | for (j = 0; j < SIZE_NUM; j++) { |
| 1927 | print_message(names[D_AES_256_GCM],c[D_AES_256_GCM][j],lengths[j]); | 1863 | print_message(names[D_AES_256_GCM], lengths[j]); |
| 1928 | Time_F(START); | 1864 | time_f(START); |
| 1929 | for (count = 0, run = 1; COND(c[D_AES_256_GCM][j]); count++) | 1865 | for (count = 0, run = 1; COND; count++) |
| 1930 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, | 1866 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, |
| 1931 | nonce_len, buf, lengths[j], NULL, 0); | 1867 | nonce_len, buf, lengths[j], NULL, 0); |
| 1932 | d=Time_F(STOP); | 1868 | d = time_f(STOP); |
| 1933 | print_result(D_AES_256_GCM, j, count, d); | 1869 | print_result(D_AES_256_GCM, j, count, d); |
| 1934 | } | 1870 | } |
| 1935 | EVP_AEAD_CTX_free(ctx); | 1871 | EVP_AEAD_CTX_free(ctx); |
| @@ -1953,13 +1889,12 @@ speed_main(int argc, char **argv) | |||
| 1953 | nonce_len = EVP_AEAD_nonce_length(aead); | 1889 | nonce_len = EVP_AEAD_nonce_length(aead); |
| 1954 | 1890 | ||
| 1955 | for (j = 0; j < SIZE_NUM; j++) { | 1891 | for (j = 0; j < SIZE_NUM; j++) { |
| 1956 | print_message(names[D_CHACHA20_POLY1305], | 1892 | print_message(names[D_CHACHA20_POLY1305], lengths[j]); |
| 1957 | c[D_CHACHA20_POLY1305][j], lengths[j]); | 1893 | time_f(START); |
| 1958 | Time_F(START); | 1894 | for (count = 0, run = 1; COND; count++) |
| 1959 | for (count = 0, run = 1; COND(c[D_CHACHA20_POLY1305][j]); count++) | ||
| 1960 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, | 1895 | EVP_AEAD_CTX_seal(ctx, buf, &buf_len, BUFSIZE, nonce, |
| 1961 | nonce_len, buf, lengths[j], NULL, 0); | 1896 | nonce_len, buf, lengths[j], NULL, 0); |
| 1962 | d=Time_F(STOP); | 1897 | d = time_f(STOP); |
| 1963 | print_result(D_CHACHA20_POLY1305, j, count, d); | 1898 | print_result(D_CHACHA20_POLY1305, j, count, d); |
| 1964 | } | 1899 | } |
| 1965 | EVP_AEAD_CTX_free(ctx); | 1900 | EVP_AEAD_CTX_free(ctx); |
| @@ -1968,37 +1903,37 @@ speed_main(int argc, char **argv) | |||
| 1968 | #ifndef OPENSSL_NO_CAMELLIA | 1903 | #ifndef OPENSSL_NO_CAMELLIA |
| 1969 | if (doit[D_CBC_128_CML]) { | 1904 | if (doit[D_CBC_128_CML]) { |
| 1970 | for (j = 0; j < SIZE_NUM; j++) { | 1905 | for (j = 0; j < SIZE_NUM; j++) { |
| 1971 | print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][j], lengths[j]); | 1906 | print_message(names[D_CBC_128_CML], lengths[j]); |
| 1972 | Time_F(START); | 1907 | time_f(START); |
| 1973 | for (count = 0, run = 1; COND(c[D_CBC_128_CML][j]); count++) | 1908 | for (count = 0, run = 1; COND; count++) |
| 1974 | Camellia_cbc_encrypt(buf, buf, | 1909 | Camellia_cbc_encrypt(buf, buf, |
| 1975 | (unsigned long) lengths[j], &camellia_ks1, | 1910 | (unsigned long) lengths[j], &camellia_ks1, |
| 1976 | iv, CAMELLIA_ENCRYPT); | 1911 | iv, CAMELLIA_ENCRYPT); |
| 1977 | d = Time_F(STOP); | 1912 | d = time_f(STOP); |
| 1978 | print_result(D_CBC_128_CML, j, count, d); | 1913 | print_result(D_CBC_128_CML, j, count, d); |
| 1979 | } | 1914 | } |
| 1980 | } | 1915 | } |
| 1981 | if (doit[D_CBC_192_CML]) { | 1916 | if (doit[D_CBC_192_CML]) { |
| 1982 | for (j = 0; j < SIZE_NUM; j++) { | 1917 | for (j = 0; j < SIZE_NUM; j++) { |
| 1983 | print_message(names[D_CBC_192_CML], c[D_CBC_192_CML][j], lengths[j]); | 1918 | print_message(names[D_CBC_192_CML], lengths[j]); |
| 1984 | Time_F(START); | 1919 | time_f(START); |
| 1985 | for (count = 0, run = 1; COND(c[D_CBC_192_CML][j]); count++) | 1920 | for (count = 0, run = 1; COND; count++) |
| 1986 | Camellia_cbc_encrypt(buf, buf, | 1921 | Camellia_cbc_encrypt(buf, buf, |
| 1987 | (unsigned long) lengths[j], &camellia_ks2, | 1922 | (unsigned long) lengths[j], &camellia_ks2, |
| 1988 | iv, CAMELLIA_ENCRYPT); | 1923 | iv, CAMELLIA_ENCRYPT); |
| 1989 | d = Time_F(STOP); | 1924 | d = time_f(STOP); |
| 1990 | print_result(D_CBC_192_CML, j, count, d); | 1925 | print_result(D_CBC_192_CML, j, count, d); |
| 1991 | } | 1926 | } |
| 1992 | } | 1927 | } |
| 1993 | if (doit[D_CBC_256_CML]) { | 1928 | if (doit[D_CBC_256_CML]) { |
| 1994 | for (j = 0; j < SIZE_NUM; j++) { | 1929 | for (j = 0; j < SIZE_NUM; j++) { |
| 1995 | print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][j], lengths[j]); | 1930 | print_message(names[D_CBC_256_CML], lengths[j]); |
| 1996 | Time_F(START); | 1931 | time_f(START); |
| 1997 | for (count = 0, run = 1; COND(c[D_CBC_256_CML][j]); count++) | 1932 | for (count = 0, run = 1; COND; count++) |
| 1998 | Camellia_cbc_encrypt(buf, buf, | 1933 | Camellia_cbc_encrypt(buf, buf, |
| 1999 | (unsigned long) lengths[j], &camellia_ks3, | 1934 | (unsigned long) lengths[j], &camellia_ks3, |
| 2000 | iv, CAMELLIA_ENCRYPT); | 1935 | iv, CAMELLIA_ENCRYPT); |
| 2001 | d = Time_F(STOP); | 1936 | d = time_f(STOP); |
| 2002 | print_result(D_CBC_256_CML, j, count, d); | 1937 | print_result(D_CBC_256_CML, j, count, d); |
| 2003 | } | 1938 | } |
| 2004 | } | 1939 | } |
| @@ -2006,13 +1941,13 @@ speed_main(int argc, char **argv) | |||
| 2006 | #ifndef OPENSSL_NO_IDEA | 1941 | #ifndef OPENSSL_NO_IDEA |
| 2007 | if (doit[D_CBC_IDEA]) { | 1942 | if (doit[D_CBC_IDEA]) { |
| 2008 | for (j = 0; j < SIZE_NUM; j++) { | 1943 | for (j = 0; j < SIZE_NUM; j++) { |
| 2009 | print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][j], lengths[j]); | 1944 | print_message(names[D_CBC_IDEA], lengths[j]); |
| 2010 | Time_F(START); | 1945 | time_f(START); |
| 2011 | for (count = 0, run = 1; COND(c[D_CBC_IDEA][j]); count++) | 1946 | for (count = 0, run = 1; COND; count++) |
| 2012 | idea_cbc_encrypt(buf, buf, | 1947 | idea_cbc_encrypt(buf, buf, |
| 2013 | (unsigned long) lengths[j], &idea_ks, | 1948 | (unsigned long) lengths[j], &idea_ks, |
| 2014 | iv, IDEA_ENCRYPT); | 1949 | iv, IDEA_ENCRYPT); |
| 2015 | d = Time_F(STOP); | 1950 | d = time_f(STOP); |
| 2016 | print_result(D_CBC_IDEA, j, count, d); | 1951 | print_result(D_CBC_IDEA, j, count, d); |
| 2017 | } | 1952 | } |
| 2018 | } | 1953 | } |
| @@ -2020,13 +1955,13 @@ speed_main(int argc, char **argv) | |||
| 2020 | #ifndef OPENSSL_NO_RC2 | 1955 | #ifndef OPENSSL_NO_RC2 |
| 2021 | if (doit[D_CBC_RC2]) { | 1956 | if (doit[D_CBC_RC2]) { |
| 2022 | for (j = 0; j < SIZE_NUM; j++) { | 1957 | for (j = 0; j < SIZE_NUM; j++) { |
| 2023 | print_message(names[D_CBC_RC2], c[D_CBC_RC2][j], lengths[j]); | 1958 | print_message(names[D_CBC_RC2], lengths[j]); |
| 2024 | Time_F(START); | 1959 | time_f(START); |
| 2025 | for (count = 0, run = 1; COND(c[D_CBC_RC2][j]); count++) | 1960 | for (count = 0, run = 1; COND; count++) |
| 2026 | RC2_cbc_encrypt(buf, buf, | 1961 | RC2_cbc_encrypt(buf, buf, |
| 2027 | (unsigned long) lengths[j], &rc2_ks, | 1962 | (unsigned long) lengths[j], &rc2_ks, |
| 2028 | iv, RC2_ENCRYPT); | 1963 | iv, RC2_ENCRYPT); |
| 2029 | d = Time_F(STOP); | 1964 | d = time_f(STOP); |
| 2030 | print_result(D_CBC_RC2, j, count, d); | 1965 | print_result(D_CBC_RC2, j, count, d); |
| 2031 | } | 1966 | } |
| 2032 | } | 1967 | } |
| @@ -2034,13 +1969,13 @@ speed_main(int argc, char **argv) | |||
| 2034 | #ifndef OPENSSL_NO_BF | 1969 | #ifndef OPENSSL_NO_BF |
| 2035 | if (doit[D_CBC_BF]) { | 1970 | if (doit[D_CBC_BF]) { |
| 2036 | for (j = 0; j < SIZE_NUM; j++) { | 1971 | for (j = 0; j < SIZE_NUM; j++) { |
| 2037 | print_message(names[D_CBC_BF], c[D_CBC_BF][j], lengths[j]); | 1972 | print_message(names[D_CBC_BF], lengths[j]); |
| 2038 | Time_F(START); | 1973 | time_f(START); |
| 2039 | for (count = 0, run = 1; COND(c[D_CBC_BF][j]); count++) | 1974 | for (count = 0, run = 1; COND; count++) |
| 2040 | BF_cbc_encrypt(buf, buf, | 1975 | BF_cbc_encrypt(buf, buf, |
| 2041 | (unsigned long) lengths[j], &bf_ks, | 1976 | (unsigned long) lengths[j], &bf_ks, |
| 2042 | iv, BF_ENCRYPT); | 1977 | iv, BF_ENCRYPT); |
| 2043 | d = Time_F(STOP); | 1978 | d = time_f(STOP); |
| 2044 | print_result(D_CBC_BF, j, count, d); | 1979 | print_result(D_CBC_BF, j, count, d); |
| 2045 | } | 1980 | } |
| 2046 | } | 1981 | } |
| @@ -2048,13 +1983,13 @@ speed_main(int argc, char **argv) | |||
| 2048 | #ifndef OPENSSL_NO_CAST | 1983 | #ifndef OPENSSL_NO_CAST |
| 2049 | if (doit[D_CBC_CAST]) { | 1984 | if (doit[D_CBC_CAST]) { |
| 2050 | for (j = 0; j < SIZE_NUM; j++) { | 1985 | for (j = 0; j < SIZE_NUM; j++) { |
| 2051 | print_message(names[D_CBC_CAST], c[D_CBC_CAST][j], lengths[j]); | 1986 | print_message(names[D_CBC_CAST], lengths[j]); |
| 2052 | Time_F(START); | 1987 | time_f(START); |
| 2053 | for (count = 0, run = 1; COND(c[D_CBC_CAST][j]); count++) | 1988 | for (count = 0, run = 1; COND; count++) |
| 2054 | CAST_cbc_encrypt(buf, buf, | 1989 | CAST_cbc_encrypt(buf, buf, |
| 2055 | (unsigned long) lengths[j], &cast_ks, | 1990 | (unsigned long) lengths[j], &cast_ks, |
| 2056 | iv, CAST_ENCRYPT); | 1991 | iv, CAST_ENCRYPT); |
| 2057 | d = Time_F(STOP); | 1992 | d = time_f(STOP); |
| 2058 | print_result(D_CBC_CAST, j, count, d); | 1993 | print_result(D_CBC_CAST, j, count, d); |
| 2059 | } | 1994 | } |
| 2060 | } | 1995 | } |
| @@ -2073,8 +2008,7 @@ speed_main(int argc, char **argv) | |||
| 2073 | * optimization here! names[D_EVP] somehow | 2008 | * optimization here! names[D_EVP] somehow |
| 2074 | * becomes NULL | 2009 | * becomes NULL |
| 2075 | */ | 2010 | */ |
| 2076 | print_message(names[D_EVP], save_count, | 2011 | print_message(names[D_EVP], lengths[j]); |
| 2077 | lengths[j]); | ||
| 2078 | 2012 | ||
| 2079 | if ((ctx = EVP_CIPHER_CTX_new()) == NULL) { | 2013 | if ((ctx = EVP_CIPHER_CTX_new()) == NULL) { |
| 2080 | BIO_printf(bio_err, "Failed to " | 2014 | BIO_printf(bio_err, "Failed to " |
| @@ -2087,30 +2021,29 @@ speed_main(int argc, char **argv) | |||
| 2087 | EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv); | 2021 | EVP_EncryptInit_ex(ctx, evp_cipher, NULL, key16, iv); |
| 2088 | EVP_CIPHER_CTX_set_padding(ctx, 0); | 2022 | EVP_CIPHER_CTX_set_padding(ctx, 0); |
| 2089 | 2023 | ||
| 2090 | Time_F(START); | 2024 | time_f(START); |
| 2091 | if (decrypt) | 2025 | if (decrypt) |
| 2092 | for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) | 2026 | for (count = 0, run = 1; COND; count++) |
| 2093 | EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]); | 2027 | EVP_DecryptUpdate(ctx, buf, &outl, buf, lengths[j]); |
| 2094 | else | 2028 | else |
| 2095 | for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) | 2029 | for (count = 0, run = 1; COND; count++) |
| 2096 | EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[j]); | 2030 | EVP_EncryptUpdate(ctx, buf, &outl, buf, lengths[j]); |
| 2097 | if (decrypt) | 2031 | if (decrypt) |
| 2098 | EVP_DecryptFinal_ex(ctx, buf, &outl); | 2032 | EVP_DecryptFinal_ex(ctx, buf, &outl); |
| 2099 | else | 2033 | else |
| 2100 | EVP_EncryptFinal_ex(ctx, buf, &outl); | 2034 | EVP_EncryptFinal_ex(ctx, buf, &outl); |
| 2101 | d = Time_F(STOP); | 2035 | d = time_f(STOP); |
| 2102 | EVP_CIPHER_CTX_free(ctx); | 2036 | EVP_CIPHER_CTX_free(ctx); |
| 2103 | } | 2037 | } |
| 2104 | if (evp_md) { | 2038 | if (evp_md) { |
| 2105 | names[D_EVP] = OBJ_nid2ln(EVP_MD_type(evp_md)); | 2039 | names[D_EVP] = OBJ_nid2ln(EVP_MD_type(evp_md)); |
| 2106 | print_message(names[D_EVP], save_count, | 2040 | print_message(names[D_EVP], lengths[j]); |
| 2107 | lengths[j]); | ||
| 2108 | 2041 | ||
| 2109 | Time_F(START); | 2042 | time_f(START); |
| 2110 | for (count = 0, run = 1; COND(save_count * 4 * lengths[0] / lengths[j]); count++) | 2043 | for (count = 0, run = 1; COND; count++) |
| 2111 | EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL); | 2044 | EVP_Digest(buf, lengths[j], &(md[0]), NULL, evp_md, NULL); |
| 2112 | 2045 | ||
| 2113 | d = Time_F(STOP); | 2046 | d = time_f(STOP); |
| 2114 | } | 2047 | } |
| 2115 | print_result(D_EVP, j, count, d); | 2048 | print_result(D_EVP, j, count, d); |
| 2116 | } | 2049 | } |
| @@ -2127,11 +2060,11 @@ speed_main(int argc, char **argv) | |||
| 2127 | rsa_count = 1; | 2060 | rsa_count = 1; |
| 2128 | } else { | 2061 | } else { |
| 2129 | pkey_print_message("private", "rsa", | 2062 | pkey_print_message("private", "rsa", |
| 2130 | rsa_c[j][0], rsa_bits[j], | 2063 | rsa_bits[j], |
| 2131 | RSA_SECONDS); | 2064 | RSA_SECONDS); |
| 2132 | /* RSA_blinding_on(rsa_key[j],NULL); */ | 2065 | /* RSA_blinding_on(rsa_key[j],NULL); */ |
| 2133 | Time_F(START); | 2066 | time_f(START); |
| 2134 | for (count = 0, run = 1; COND(rsa_c[j][0]); count++) { | 2067 | for (count = 0, run = 1; COND; count++) { |
| 2135 | ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, | 2068 | ret = RSA_sign(NID_md5_sha1, buf, 36, buf2, |
| 2136 | &rsa_num, rsa_key[j]); | 2069 | &rsa_num, rsa_key[j]); |
| 2137 | if (ret == 0) { | 2070 | if (ret == 0) { |
| @@ -2142,7 +2075,7 @@ speed_main(int argc, char **argv) | |||
| 2142 | break; | 2075 | break; |
| 2143 | } | 2076 | } |
| 2144 | } | 2077 | } |
| 2145 | d = Time_F(STOP); | 2078 | d = time_f(STOP); |
| 2146 | BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n" | 2079 | BIO_printf(bio_err, mr ? "+R1:%ld:%d:%.2f\n" |
| 2147 | : "%ld %d bit private RSA in %.2fs\n", | 2080 | : "%ld %d bit private RSA in %.2fs\n", |
| 2148 | count, rsa_bits[j], d); | 2081 | count, rsa_bits[j], d); |
| @@ -2157,10 +2090,10 @@ speed_main(int argc, char **argv) | |||
| 2157 | rsa_doit[j] = 0; | 2090 | rsa_doit[j] = 0; |
| 2158 | } else { | 2091 | } else { |
| 2159 | pkey_print_message("public", "rsa", | 2092 | pkey_print_message("public", "rsa", |
| 2160 | rsa_c[j][1], rsa_bits[j], | 2093 | rsa_bits[j], |
| 2161 | RSA_SECONDS); | 2094 | RSA_SECONDS); |
| 2162 | Time_F(START); | 2095 | time_f(START); |
| 2163 | for (count = 0, run = 1; COND(rsa_c[j][1]); count++) { | 2096 | for (count = 0, run = 1; COND; count++) { |
| 2164 | ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, | 2097 | ret = RSA_verify(NID_md5_sha1, buf, 36, buf2, |
| 2165 | rsa_num, rsa_key[j]); | 2098 | rsa_num, rsa_key[j]); |
| 2166 | if (ret <= 0) { | 2099 | if (ret <= 0) { |
| @@ -2171,7 +2104,7 @@ speed_main(int argc, char **argv) | |||
| 2171 | break; | 2104 | break; |
| 2172 | } | 2105 | } |
| 2173 | } | 2106 | } |
| 2174 | d = Time_F(STOP); | 2107 | d = time_f(STOP); |
| 2175 | BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n" | 2108 | BIO_printf(bio_err, mr ? "+R2:%ld:%d:%.2f\n" |
| 2176 | : "%ld %d bit public RSA in %.2fs\n", | 2109 | : "%ld %d bit public RSA in %.2fs\n", |
| 2177 | count, rsa_bits[j], d); | 2110 | count, rsa_bits[j], d); |
| @@ -2202,10 +2135,10 @@ speed_main(int argc, char **argv) | |||
| 2202 | rsa_count = 1; | 2135 | rsa_count = 1; |
| 2203 | } else { | 2136 | } else { |
| 2204 | pkey_print_message("sign", "dsa", | 2137 | pkey_print_message("sign", "dsa", |
| 2205 | dsa_c[j][0], dsa_bits[j], | 2138 | dsa_bits[j], |
| 2206 | DSA_SECONDS); | 2139 | DSA_SECONDS); |
| 2207 | Time_F(START); | 2140 | time_f(START); |
| 2208 | for (count = 0, run = 1; COND(dsa_c[j][0]); count++) { | 2141 | for (count = 0, run = 1; COND; count++) { |
| 2209 | ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, | 2142 | ret = DSA_sign(EVP_PKEY_DSA, buf, 20, buf2, |
| 2210 | &kk, dsa_key[j]); | 2143 | &kk, dsa_key[j]); |
| 2211 | if (ret == 0) { | 2144 | if (ret == 0) { |
| @@ -2216,7 +2149,7 @@ speed_main(int argc, char **argv) | |||
| 2216 | break; | 2149 | break; |
| 2217 | } | 2150 | } |
| 2218 | } | 2151 | } |
| 2219 | d = Time_F(STOP); | 2152 | d = time_f(STOP); |
| 2220 | BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n" | 2153 | BIO_printf(bio_err, mr ? "+R3:%ld:%d:%.2f\n" |
| 2221 | : "%ld %d bit DSA signs in %.2fs\n", | 2154 | : "%ld %d bit DSA signs in %.2fs\n", |
| 2222 | count, dsa_bits[j], d); | 2155 | count, dsa_bits[j], d); |
| @@ -2232,10 +2165,10 @@ speed_main(int argc, char **argv) | |||
| 2232 | dsa_doit[j] = 0; | 2165 | dsa_doit[j] = 0; |
| 2233 | } else { | 2166 | } else { |
| 2234 | pkey_print_message("verify", "dsa", | 2167 | pkey_print_message("verify", "dsa", |
| 2235 | dsa_c[j][1], dsa_bits[j], | 2168 | dsa_bits[j], |
| 2236 | DSA_SECONDS); | 2169 | DSA_SECONDS); |
| 2237 | Time_F(START); | 2170 | time_f(START); |
| 2238 | for (count = 0, run = 1; COND(dsa_c[j][1]); count++) { | 2171 | for (count = 0, run = 1; COND; count++) { |
| 2239 | ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, | 2172 | ret = DSA_verify(EVP_PKEY_DSA, buf, 20, buf2, |
| 2240 | kk, dsa_key[j]); | 2173 | kk, dsa_key[j]); |
| 2241 | if (ret <= 0) { | 2174 | if (ret <= 0) { |
| @@ -2246,7 +2179,7 @@ speed_main(int argc, char **argv) | |||
| 2246 | break; | 2179 | break; |
| 2247 | } | 2180 | } |
| 2248 | } | 2181 | } |
| 2249 | d = Time_F(STOP); | 2182 | d = time_f(STOP); |
| 2250 | BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n" | 2183 | BIO_printf(bio_err, mr ? "+R4:%ld:%d:%.2f\n" |
| 2251 | : "%ld %d bit DSA verify in %.2fs\n", | 2184 | : "%ld %d bit DSA verify in %.2fs\n", |
| 2252 | count, dsa_bits[j], d); | 2185 | count, dsa_bits[j], d); |
| @@ -2283,13 +2216,11 @@ speed_main(int argc, char **argv) | |||
| 2283 | rsa_count = 1; | 2216 | rsa_count = 1; |
| 2284 | } else { | 2217 | } else { |
| 2285 | pkey_print_message("sign", "ecdsa", | 2218 | pkey_print_message("sign", "ecdsa", |
| 2286 | ecdsa_c[j][0], | ||
| 2287 | test_curves_bits[j], | 2219 | test_curves_bits[j], |
| 2288 | ECDSA_SECONDS); | 2220 | ECDSA_SECONDS); |
| 2289 | 2221 | ||
| 2290 | Time_F(START); | 2222 | time_f(START); |
| 2291 | for (count = 0, run = 1; COND(ecdsa_c[j][0]); | 2223 | for (count = 0, run = 1; COND; count++) { |
| 2292 | count++) { | ||
| 2293 | ret = ECDSA_sign(0, buf, 20, | 2224 | ret = ECDSA_sign(0, buf, 20, |
| 2294 | ecdsasig, &ecdsasiglen, | 2225 | ecdsasig, &ecdsasiglen, |
| 2295 | ecdsa[j]); | 2226 | ecdsa[j]); |
| @@ -2300,7 +2231,7 @@ speed_main(int argc, char **argv) | |||
| 2300 | break; | 2231 | break; |
| 2301 | } | 2232 | } |
| 2302 | } | 2233 | } |
| 2303 | d = Time_F(STOP); | 2234 | d = time_f(STOP); |
| 2304 | 2235 | ||
| 2305 | BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" : | 2236 | BIO_printf(bio_err, mr ? "+R5:%ld:%d:%.2f\n" : |
| 2306 | "%ld %d bit ECDSA signs in %.2fs \n", | 2237 | "%ld %d bit ECDSA signs in %.2fs \n", |
| @@ -2318,11 +2249,10 @@ speed_main(int argc, char **argv) | |||
| 2318 | ecdsa_doit[j] = 0; | 2249 | ecdsa_doit[j] = 0; |
| 2319 | } else { | 2250 | } else { |
| 2320 | pkey_print_message("verify", "ecdsa", | 2251 | pkey_print_message("verify", "ecdsa", |
| 2321 | ecdsa_c[j][1], | ||
| 2322 | test_curves_bits[j], | 2252 | test_curves_bits[j], |
| 2323 | ECDSA_SECONDS); | 2253 | ECDSA_SECONDS); |
| 2324 | Time_F(START); | 2254 | time_f(START); |
| 2325 | for (count = 0, run = 1; COND(ecdsa_c[j][1]); count++) { | 2255 | for (count = 0, run = 1; COND; count++) { |
| 2326 | ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]); | 2256 | ret = ECDSA_verify(0, buf, 20, ecdsasig, ecdsasiglen, ecdsa[j]); |
| 2327 | if (ret != 1) { | 2257 | if (ret != 1) { |
| 2328 | BIO_printf(bio_err, "ECDSA verify failure\n"); | 2258 | BIO_printf(bio_err, "ECDSA verify failure\n"); |
| @@ -2331,7 +2261,7 @@ speed_main(int argc, char **argv) | |||
| 2331 | break; | 2261 | break; |
| 2332 | } | 2262 | } |
| 2333 | } | 2263 | } |
| 2334 | d = Time_F(STOP); | 2264 | d = time_f(STOP); |
| 2335 | BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n" | 2265 | BIO_printf(bio_err, mr ? "+R6:%ld:%d:%.2f\n" |
| 2336 | : "%ld %d bit ECDSA verify in %.2fs\n", | 2266 | : "%ld %d bit ECDSA verify in %.2fs\n", |
| 2337 | count, test_curves_bits[j], d); | 2267 | count, test_curves_bits[j], d); |
| @@ -2405,18 +2335,16 @@ speed_main(int argc, char **argv) | |||
| 2405 | rsa_count = 1; | 2335 | rsa_count = 1; |
| 2406 | } else { | 2336 | } else { |
| 2407 | pkey_print_message("", "ecdh", | 2337 | pkey_print_message("", "ecdh", |
| 2408 | ecdh_c[j][0], | ||
| 2409 | test_curves_bits[j], | 2338 | test_curves_bits[j], |
| 2410 | ECDH_SECONDS); | 2339 | ECDH_SECONDS); |
| 2411 | Time_F(START); | 2340 | time_f(START); |
| 2412 | for (count = 0, run = 1; | 2341 | for (count = 0, run = 1; COND; count++) { |
| 2413 | COND(ecdh_c[j][0]); count++) { | ||
| 2414 | ECDH_compute_key(secret_a, | 2342 | ECDH_compute_key(secret_a, |
| 2415 | outlen, | 2343 | outlen, |
| 2416 | EC_KEY_get0_public_key(ecdh_b[j]), | 2344 | EC_KEY_get0_public_key(ecdh_b[j]), |
| 2417 | ecdh_a[j], kdf); | 2345 | ecdh_a[j], kdf); |
| 2418 | } | 2346 | } |
| 2419 | d = Time_F(STOP); | 2347 | d = time_f(STOP); |
| 2420 | BIO_printf(bio_err, mr | 2348 | BIO_printf(bio_err, mr |
| 2421 | ? "+R7:%ld:%d:%.2f\n" | 2349 | ? "+R7:%ld:%d:%.2f\n" |
| 2422 | : "%ld %d-bit ECDH ops in %.2fs\n", | 2350 | : "%ld %d-bit ECDH ops in %.2fs\n", |
| @@ -2569,7 +2497,7 @@ show_res: | |||
| 2569 | } | 2497 | } |
| 2570 | 2498 | ||
| 2571 | static void | 2499 | static void |
| 2572 | print_message(const char *s, long num, int length) | 2500 | print_message(const char *s, int length) |
| 2573 | { | 2501 | { |
| 2574 | BIO_printf(bio_err, mr ? "+DT:%s:%d:%d\n" | 2502 | BIO_printf(bio_err, mr ? "+DT:%s:%d:%d\n" |
| 2575 | : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length); | 2503 | : "Doing %s for %ds on %d size blocks: ", s, SECONDS, length); |
| @@ -2578,7 +2506,7 @@ print_message(const char *s, long num, int length) | |||
| 2578 | } | 2506 | } |
| 2579 | 2507 | ||
| 2580 | static void | 2508 | static void |
| 2581 | pkey_print_message(const char *str, const char *str2, long num, | 2509 | pkey_print_message(const char *str, const char *str2, |
| 2582 | int bits, int tm) | 2510 | int bits, int tm) |
| 2583 | { | 2511 | { |
| 2584 | BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n" | 2512 | BIO_printf(bio_err, mr ? "+DTP:%d:%s:%s:%d\n" |
