mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
AppleM1: Update openssl to v1.1.1l
This commit is contained in:
parent
1fe12b8e8c
commit
b787656eea
990 changed files with 13406 additions and 18710 deletions
128
trunk/3rdparty/openssl-1.1-fit/apps/speed.c
vendored
128
trunk/3rdparty/openssl-1.1-fit/apps/speed.c
vendored
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
|
@ -489,30 +489,35 @@ static const OPT_PAIR rsa_choices[] = {
|
|||
static double rsa_results[RSA_NUM][2]; /* 2 ops: sign then verify */
|
||||
#endif /* OPENSSL_NO_RSA */
|
||||
|
||||
#define R_EC_P160 0
|
||||
#define R_EC_P192 1
|
||||
#define R_EC_P224 2
|
||||
#define R_EC_P256 3
|
||||
#define R_EC_P384 4
|
||||
#define R_EC_P521 5
|
||||
#define R_EC_K163 6
|
||||
#define R_EC_K233 7
|
||||
#define R_EC_K283 8
|
||||
#define R_EC_K409 9
|
||||
#define R_EC_K571 10
|
||||
#define R_EC_B163 11
|
||||
#define R_EC_B233 12
|
||||
#define R_EC_B283 13
|
||||
#define R_EC_B409 14
|
||||
#define R_EC_B571 15
|
||||
#define R_EC_BRP256R1 16
|
||||
#define R_EC_BRP256T1 17
|
||||
#define R_EC_BRP384R1 18
|
||||
#define R_EC_BRP384T1 19
|
||||
#define R_EC_BRP512R1 20
|
||||
#define R_EC_BRP512T1 21
|
||||
#define R_EC_X25519 22
|
||||
#define R_EC_X448 23
|
||||
enum {
|
||||
R_EC_P160,
|
||||
R_EC_P192,
|
||||
R_EC_P224,
|
||||
R_EC_P256,
|
||||
R_EC_P384,
|
||||
R_EC_P521,
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
R_EC_K163,
|
||||
R_EC_K233,
|
||||
R_EC_K283,
|
||||
R_EC_K409,
|
||||
R_EC_K571,
|
||||
R_EC_B163,
|
||||
R_EC_B233,
|
||||
R_EC_B283,
|
||||
R_EC_B409,
|
||||
R_EC_B571,
|
||||
#endif
|
||||
R_EC_BRP256R1,
|
||||
R_EC_BRP256T1,
|
||||
R_EC_BRP384R1,
|
||||
R_EC_BRP384T1,
|
||||
R_EC_BRP512R1,
|
||||
R_EC_BRP512T1,
|
||||
R_EC_X25519,
|
||||
R_EC_X448
|
||||
};
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
static OPT_PAIR ecdsa_choices[] = {
|
||||
{"ecdsap160", R_EC_P160},
|
||||
|
@ -521,6 +526,7 @@ static OPT_PAIR ecdsa_choices[] = {
|
|||
{"ecdsap256", R_EC_P256},
|
||||
{"ecdsap384", R_EC_P384},
|
||||
{"ecdsap521", R_EC_P521},
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
{"ecdsak163", R_EC_K163},
|
||||
{"ecdsak233", R_EC_K233},
|
||||
{"ecdsak283", R_EC_K283},
|
||||
|
@ -531,6 +537,7 @@ static OPT_PAIR ecdsa_choices[] = {
|
|||
{"ecdsab283", R_EC_B283},
|
||||
{"ecdsab409", R_EC_B409},
|
||||
{"ecdsab571", R_EC_B571},
|
||||
# endif
|
||||
{"ecdsabrp256r1", R_EC_BRP256R1},
|
||||
{"ecdsabrp256t1", R_EC_BRP256T1},
|
||||
{"ecdsabrp384r1", R_EC_BRP384R1},
|
||||
|
@ -549,6 +556,7 @@ static const OPT_PAIR ecdh_choices[] = {
|
|||
{"ecdhp256", R_EC_P256},
|
||||
{"ecdhp384", R_EC_P384},
|
||||
{"ecdhp521", R_EC_P521},
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
{"ecdhk163", R_EC_K163},
|
||||
{"ecdhk233", R_EC_K233},
|
||||
{"ecdhk283", R_EC_K283},
|
||||
|
@ -559,6 +567,7 @@ static const OPT_PAIR ecdh_choices[] = {
|
|||
{"ecdhb283", R_EC_B283},
|
||||
{"ecdhb409", R_EC_B409},
|
||||
{"ecdhb571", R_EC_B571},
|
||||
# endif
|
||||
{"ecdhbrp256r1", R_EC_BRP256R1},
|
||||
{"ecdhbrp256t1", R_EC_BRP256T1},
|
||||
{"ecdhbrp384r1", R_EC_BRP384R1},
|
||||
|
@ -1233,8 +1242,6 @@ static int run_benchmark(int async_jobs,
|
|||
OSSL_ASYNC_FD job_fd = 0;
|
||||
size_t num_job_fds = 0;
|
||||
|
||||
run = 1;
|
||||
|
||||
if (async_jobs == 0) {
|
||||
return loop_function((void *)&loopargs);
|
||||
}
|
||||
|
@ -1501,6 +1508,7 @@ int speed_main(int argc, char **argv)
|
|||
{"nistp256", NID_X9_62_prime256v1, 256},
|
||||
{"nistp384", NID_secp384r1, 384},
|
||||
{"nistp521", NID_secp521r1, 521},
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
/* Binary Curves */
|
||||
{"nistk163", NID_sect163k1, 163},
|
||||
{"nistk233", NID_sect233k1, 233},
|
||||
|
@ -1512,6 +1520,7 @@ int speed_main(int argc, char **argv)
|
|||
{"nistb283", NID_sect283r1, 283},
|
||||
{"nistb409", NID_sect409r1, 409},
|
||||
{"nistb571", NID_sect571r1, 571},
|
||||
# endif
|
||||
{"brainpoolP256r1", NID_brainpoolP256r1, 256},
|
||||
{"brainpoolP256t1", NID_brainpoolP256t1, 256},
|
||||
{"brainpoolP384r1", NID_brainpoolP384r1, 384},
|
||||
|
@ -1779,7 +1788,7 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
|
||||
buflen = lengths[size_num - 1];
|
||||
if (buflen < 36) /* size of random vector in RSA bencmark */
|
||||
if (buflen < 36) /* size of random vector in RSA benchmark */
|
||||
buflen = 36;
|
||||
buflen += MAX_MISALIGNMENT + 1;
|
||||
loopargs[i].buf_malloc = app_malloc(buflen, "input buffer");
|
||||
|
@ -2031,6 +2040,7 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
}
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
ecdsa_c[R_EC_K163][0] = count / 1000;
|
||||
ecdsa_c[R_EC_K163][1] = count / 1000 / 2;
|
||||
for (i = R_EC_K233; i <= R_EC_K571; i++) {
|
||||
|
@ -2059,6 +2069,7 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
ecdh_c[R_EC_P160][0] = count / 1000;
|
||||
for (i = R_EC_P192; i <= R_EC_P521; i++) {
|
||||
|
@ -2071,6 +2082,7 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
}
|
||||
# ifndef OPENSSL_NO_EC2M
|
||||
ecdh_c[R_EC_K163][0] = count / 1000;
|
||||
for (i = R_EC_K233; i <= R_EC_K571; i++) {
|
||||
ecdh_c[i][0] = ecdh_c[i - 1][0] / 2;
|
||||
|
@ -2093,6 +2105,7 @@ int speed_main(int argc, char **argv)
|
|||
}
|
||||
}
|
||||
}
|
||||
# endif
|
||||
/* repeated code good to factorize */
|
||||
ecdh_c[R_EC_BRP256R1][0] = count / 1000;
|
||||
for (i = R_EC_BRP384R1; i <= R_EC_BRP512R1; i += 2) {
|
||||
|
@ -2397,7 +2410,7 @@ int speed_main(int argc, char **argv)
|
|||
print_message(names[D_CBC_128_CML], c[D_CBC_128_CML][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_128_CML][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_128_CML][testnum]); count++)
|
||||
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &camellia_ks1,
|
||||
iv, CAMELLIA_ENCRYPT);
|
||||
|
@ -2419,7 +2432,7 @@ int speed_main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_192_CML][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_192_CML][testnum]); count++)
|
||||
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &camellia_ks2,
|
||||
iv, CAMELLIA_ENCRYPT);
|
||||
|
@ -2437,7 +2450,7 @@ int speed_main(int argc, char **argv)
|
|||
print_message(names[D_CBC_256_CML], c[D_CBC_256_CML][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_256_CML][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_256_CML][testnum]); count++)
|
||||
Camellia_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &camellia_ks3,
|
||||
iv, CAMELLIA_ENCRYPT);
|
||||
|
@ -2457,7 +2470,7 @@ int speed_main(int argc, char **argv)
|
|||
print_message(names[D_CBC_IDEA], c[D_CBC_IDEA][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_IDEA][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_IDEA][testnum]); count++)
|
||||
IDEA_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &idea_ks,
|
||||
iv, IDEA_ENCRYPT);
|
||||
|
@ -2477,7 +2490,7 @@ int speed_main(int argc, char **argv)
|
|||
print_message(names[D_CBC_SEED], c[D_CBC_SEED][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_SEED][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_SEED][testnum]); count++)
|
||||
SEED_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &seed_ks, iv, 1);
|
||||
d = Time_F(STOP);
|
||||
|
@ -2500,7 +2513,7 @@ int speed_main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_RC2][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_RC2][testnum]); count++)
|
||||
RC2_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &rc2_ks,
|
||||
iv, RC2_ENCRYPT);
|
||||
|
@ -2524,7 +2537,7 @@ int speed_main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_RC5][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_RC5][testnum]); count++)
|
||||
RC5_32_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &rc5_ks,
|
||||
iv, RC5_ENCRYPT);
|
||||
|
@ -2544,7 +2557,7 @@ int speed_main(int argc, char **argv)
|
|||
print_message(names[D_CBC_BF], c[D_CBC_BF][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_BF][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_BF][testnum]); count++)
|
||||
BF_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &bf_ks,
|
||||
iv, BF_ENCRYPT);
|
||||
|
@ -2564,7 +2577,7 @@ int speed_main(int argc, char **argv)
|
|||
print_message(names[D_CBC_CAST], c[D_CBC_CAST][testnum],
|
||||
lengths[testnum], seconds.sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; COND(c[D_CBC_CAST][testnum]); count++)
|
||||
for (count = 0; COND(c[D_CBC_CAST][testnum]); count++)
|
||||
CAST_cbc_encrypt(loopargs[0].buf, loopargs[0].buf,
|
||||
(size_t)lengths[testnum], &cast_ks,
|
||||
iv, CAST_ENCRYPT);
|
||||
|
@ -2614,16 +2627,28 @@ int speed_main(int argc, char **argv)
|
|||
|
||||
for (k = 0; k < loopargs_len; k++) {
|
||||
loopargs[k].ctx = EVP_CIPHER_CTX_new();
|
||||
EVP_CipherInit_ex(loopargs[k].ctx, evp_cipher, NULL, NULL,
|
||||
iv, decrypt ? 0 : 1);
|
||||
if (loopargs[k].ctx == NULL) {
|
||||
BIO_printf(bio_err, "\nEVP_CIPHER_CTX_new failure\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!EVP_CipherInit_ex(loopargs[k].ctx, evp_cipher, NULL,
|
||||
NULL, iv, decrypt ? 0 : 1)) {
|
||||
BIO_printf(bio_err, "\nEVP_CipherInit_ex failure\n");
|
||||
ERR_print_errors(bio_err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
EVP_CIPHER_CTX_set_padding(loopargs[k].ctx, 0);
|
||||
|
||||
keylen = EVP_CIPHER_CTX_key_length(loopargs[k].ctx);
|
||||
loopargs[k].key = app_malloc(keylen, "evp_cipher key");
|
||||
EVP_CIPHER_CTX_rand_key(loopargs[k].ctx, loopargs[k].key);
|
||||
EVP_CipherInit_ex(loopargs[k].ctx, NULL, NULL,
|
||||
loopargs[k].key, NULL, -1);
|
||||
if (!EVP_CipherInit_ex(loopargs[k].ctx, NULL, NULL,
|
||||
loopargs[k].key, NULL, -1)) {
|
||||
BIO_printf(bio_err, "\nEVP_CipherInit_ex failure\n");
|
||||
ERR_print_errors(bio_err);
|
||||
exit(1);
|
||||
}
|
||||
OPENSSL_clear_free(loopargs[k].key, keylen);
|
||||
}
|
||||
|
||||
|
@ -2979,7 +3004,7 @@ int speed_main(int argc, char **argv)
|
|||
pctx = NULL;
|
||||
}
|
||||
if (kctx == NULL || /* keygen ctx is not null */
|
||||
!EVP_PKEY_keygen_init(kctx) /* init keygen ctx */ ) {
|
||||
EVP_PKEY_keygen_init(kctx) <= 0/* init keygen ctx */ ) {
|
||||
ecdh_checks = 0;
|
||||
BIO_printf(bio_err, "ECDH keygen failure.\n");
|
||||
ERR_print_errors(bio_err);
|
||||
|
@ -2987,12 +3012,12 @@ int speed_main(int argc, char **argv)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!EVP_PKEY_keygen(kctx, &key_A) || /* generate secret key A */
|
||||
!EVP_PKEY_keygen(kctx, &key_B) || /* generate secret key B */
|
||||
if (EVP_PKEY_keygen(kctx, &key_A) <= 0 || /* generate secret key A */
|
||||
EVP_PKEY_keygen(kctx, &key_B) <= 0 || /* generate secret key B */
|
||||
!(ctx = EVP_PKEY_CTX_new(key_A, NULL)) || /* derivation ctx from skeyA */
|
||||
!EVP_PKEY_derive_init(ctx) || /* init derivation ctx */
|
||||
!EVP_PKEY_derive_set_peer(ctx, key_B) || /* set peer pubkey in ctx */
|
||||
!EVP_PKEY_derive(ctx, NULL, &outlen) || /* determine max length */
|
||||
EVP_PKEY_derive_init(ctx) <= 0 || /* init derivation ctx */
|
||||
EVP_PKEY_derive_set_peer(ctx, key_B) <= 0 || /* set peer pubkey in ctx */
|
||||
EVP_PKEY_derive(ctx, NULL, &outlen) <= 0 || /* determine max length */
|
||||
outlen == 0 || /* ensure outlen is a valid size */
|
||||
outlen > MAX_ECDH_SIZE /* avoid buffer overflow */ ) {
|
||||
ecdh_checks = 0;
|
||||
|
@ -3079,8 +3104,8 @@ int speed_main(int argc, char **argv)
|
|||
|
||||
if ((ed_pctx = EVP_PKEY_CTX_new_id(test_ed_curves[testnum].nid, NULL))
|
||||
== NULL
|
||||
|| !EVP_PKEY_keygen_init(ed_pctx)
|
||||
|| !EVP_PKEY_keygen(ed_pctx, &ed_pkey)) {
|
||||
|| EVP_PKEY_keygen_init(ed_pctx) <= 0
|
||||
|| EVP_PKEY_keygen(ed_pctx, &ed_pkey) <= 0) {
|
||||
st = 0;
|
||||
EVP_PKEY_CTX_free(ed_pctx);
|
||||
break;
|
||||
|
@ -3368,6 +3393,7 @@ static void print_message(const char *s, long num, int length, int tm)
|
|||
mr ? "+DT:%s:%d:%d\n"
|
||||
: "Doing %s for %ds on %d size blocks: ", s, tm, length);
|
||||
(void)BIO_flush(bio_err);
|
||||
run = 1;
|
||||
alarm(tm);
|
||||
#else
|
||||
BIO_printf(bio_err,
|
||||
|
@ -3385,6 +3411,7 @@ static void pkey_print_message(const char *str, const char *str2, long num,
|
|||
mr ? "+DTP:%d:%s:%s:%d\n"
|
||||
: "Doing %u bits %s %s's for %ds: ", bits, str, str2, tm);
|
||||
(void)BIO_flush(bio_err);
|
||||
run = 1;
|
||||
alarm(tm);
|
||||
#else
|
||||
BIO_printf(bio_err,
|
||||
|
@ -3557,6 +3584,7 @@ static int do_multi(int multi, int size_num)
|
|||
p = buf + 4;
|
||||
k = atoi(sstrsep(&p, sep));
|
||||
sstrsep(&p, sep);
|
||||
sstrsep(&p, sep);
|
||||
|
||||
d = atof(sstrsep(&p, sep));
|
||||
eddsa_results[k][0] += d;
|
||||
|
@ -3614,7 +3642,7 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher, int lengths_single,
|
|||
for (j = 0; j < num; j++) {
|
||||
print_message(alg_name, 0, mblengths[j], seconds->sym);
|
||||
Time_F(START);
|
||||
for (count = 0, run = 1; run && count < 0x7fffffff; count++) {
|
||||
for (count = 0; run && count < 0x7fffffff; count++) {
|
||||
unsigned char aad[EVP_AEAD_TLS1_AAD_LEN];
|
||||
EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM mb_param;
|
||||
size_t len = mblengths[j];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue