version 1.32, 2023/05/20 11:44:15 |
version 1.33, 2023/05/20 12:03:02 |
|
|
#define ECDSA_SECONDS 10 |
#define ECDSA_SECONDS 10 |
#define ECDH_SECONDS 10 |
#define ECDH_SECONDS 10 |
|
|
|
#define MAX_UNALIGN 16 |
|
|
#include <math.h> |
#include <math.h> |
#include <signal.h> |
#include <signal.h> |
#include <stdio.h> |
#include <stdio.h> |
|
|
int |
int |
speed_main(int argc, char **argv) |
speed_main(int argc, char **argv) |
{ |
{ |
|
unsigned char *real_buf = NULL, *real_buf2 = NULL; |
unsigned char *buf = NULL, *buf2 = NULL; |
unsigned char *buf = NULL, *buf2 = NULL; |
|
size_t unaligned = 0; |
int mret = 1; |
int mret = 1; |
long count = 0, save_count = 0; |
long count = 0, save_count = 0; |
int i, j, k; |
int i, j, k; |
|
|
for (i = 0; i < RSA_NUM; i++) |
for (i = 0; i < RSA_NUM; i++) |
rsa_key[i] = NULL; |
rsa_key[i] = NULL; |
|
|
if ((buf = malloc(BUFSIZE)) == NULL) { |
if ((buf = real_buf = malloc(BUFSIZE + MAX_UNALIGN)) == NULL) { |
BIO_printf(bio_err, "out of memory\n"); |
BIO_printf(bio_err, "out of memory\n"); |
goto end; |
goto end; |
} |
} |
if ((buf2 = malloc(BUFSIZE)) == NULL) { |
if ((buf2 = real_buf2 = malloc(BUFSIZE + MAX_UNALIGN)) == NULL) { |
BIO_printf(bio_err, "out of memory\n"); |
BIO_printf(bio_err, "out of memory\n"); |
goto end; |
goto end; |
} |
} |
|
|
} |
} |
j--; /* Otherwise, -multi gets confused with an |
j--; /* Otherwise, -multi gets confused with an |
* algorithm. */ |
* algorithm. */ |
|
} else if (argc > 0 && strcmp(*argv, "-unaligned") == 0) { |
|
argc--; |
|
argv++; |
|
if (argc == 0) { |
|
BIO_printf(bio_err, "no alignment offset given\n"); |
|
goto end; |
|
} |
|
unaligned = strtonum(argv[0], 0, MAX_UNALIGN, &errstr); |
|
if (errstr) { |
|
BIO_printf(bio_err, "bad alignment offset: %s", |
|
errstr); |
|
goto end; |
|
} |
|
buf = real_buf + unaligned; |
|
buf2 = real_buf2 + unaligned; |
|
j--; /* Otherwise, -unaligned gets confused with an |
|
* algorithm. */ |
} else if (argc > 0 && strcmp(*argv, "-mr") == 0) { |
} else if (argc > 0 && strcmp(*argv, "-mr") == 0) { |
mr = 1; |
mr = 1; |
j--; /* Otherwise, -mr gets confused with an |
j--; /* Otherwise, -mr gets confused with an |
|
|
BIO_printf(bio_err, "-decrypt time decryption instead of encryption (only EVP).\n"); |
BIO_printf(bio_err, "-decrypt time decryption instead of encryption (only EVP).\n"); |
BIO_printf(bio_err, "-mr produce machine readable output.\n"); |
BIO_printf(bio_err, "-mr produce machine readable output.\n"); |
BIO_printf(bio_err, "-multi n run n benchmarks in parallel.\n"); |
BIO_printf(bio_err, "-multi n run n benchmarks in parallel.\n"); |
|
BIO_printf(bio_err, "-unaligned n use buffers with offset n from proper alignment.\n"); |
goto end; |
goto end; |
} |
} |
argc--; |
argc--; |
|
|
|
|
end: |
end: |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
free(buf); |
free(real_buf); |
free(buf2); |
free(real_buf2); |
for (i = 0; i < RSA_NUM; i++) |
for (i = 0; i < RSA_NUM; i++) |
if (rsa_key[i] != NULL) |
if (rsa_key[i] != NULL) |
RSA_free(rsa_key[i]); |
RSA_free(rsa_key[i]); |