diff options
author | Pauli <pauli@openssl.org> | 2021-07-08 11:25:11 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-07-12 09:13:41 +1000 |
commit | 09b430cd87bc3b018fb97879eb6a2ea540c8e923 (patch) | |
tree | 6c2cd45cab38bf8d99f1b64eda6f2c5839b54865 /apps/lib | |
parent | ff215713655e721be505cc884aed5d1230c7759e (diff) |
app: add library context and propq arguments to opt_md() and opt_cipher()
Also avoid calling EVP_get_XXXbyname() if legacy paths aren't allowed.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16022)
Diffstat (limited to 'apps/lib')
-rw-r--r-- | apps/lib/opt.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/apps/lib/opt.c b/apps/lib/opt.c index adb0417bd8..157367982d 100644 --- a/apps/lib/opt.c +++ b/apps/lib/opt.c @@ -378,8 +378,10 @@ int opt_cipher_silent(const char *name, EVP_CIPHER **cipherp) EVP_CIPHER *c; ERR_set_mark(); - if ((c = EVP_CIPHER_fetch(NULL, name, NULL)) != NULL - || (c = (EVP_CIPHER *)EVP_get_cipherbyname(name)) != NULL) { + if ((c = EVP_CIPHER_fetch(app_get0_libctx(), name, + app_get0_propq())) != NULL + || (opt_legacy_okay() + && (c = (EVP_CIPHER *)EVP_get_cipherbyname(name)) != NULL)) { ERR_pop_to_mark(); if (cipherp != NULL) { EVP_CIPHER_free(*cipherp); @@ -429,12 +431,19 @@ int opt_cipher(const char *name, EVP_CIPHER **cipherp) */ int opt_md_silent(const char *name, EVP_MD **mdp) { - EVP_MD_free(*mdp); + EVP_MD *md; ERR_set_mark(); - if ((*mdp = EVP_MD_fetch(NULL, name, NULL)) != NULL - || (*mdp = (EVP_MD *)EVP_get_digestbyname(name)) != NULL) { + if ((md = EVP_MD_fetch(app_get0_libctx(), name, app_get0_propq())) != NULL + || (opt_legacy_okay() + && (md = (EVP_MD *)EVP_get_digestbyname(name)) != NULL)) { ERR_pop_to_mark(); + if (mdp != NULL) { + EVP_MD_free(*mdp); + *mdp = md; + } else { + EVP_MD_free(md); + } return 1; } ERR_clear_last_mark(); |