diff options
author | Pauli <paul.dale@oracle.com> | 2020-06-12 10:34:46 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-06-23 21:44:47 +1000 |
commit | f9e504e8b1d4da4b8c9c16ee4c11e9815a800422 (patch) | |
tree | a53b2ee1974b87cdc17f3367338ef4f8abead154 /crypto/evp/evp_fetch.c | |
parent | 1b495200436b57309ca958a7a72affaf75171c1a (diff) |
property: Move global default properties to the library context.
Fixes a problem where global properties don't work with a NULL query.
Specifying an algorithm with a NULL query ignores the default properties.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12123)
Diffstat (limited to 'crypto/evp/evp_fetch.c')
-rw-r--r-- | crypto/evp/evp_fetch.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/crypto/evp/evp_fetch.c b/crypto/evp/evp_fetch.c index 596f592535..f63e135d3a 100644 --- a/crypto/evp/evp_fetch.c +++ b/crypto/evp/evp_fetch.c @@ -361,33 +361,63 @@ void *evp_generic_fetch_by_number(OPENSSL_CTX *libctx, int operation_id, return ret; } -int EVP_set_default_properties(OPENSSL_CTX *libctx, const char *propq) +static int evp_set_default_properties(OPENSSL_CTX *libctx, + OSSL_PROPERTY_LIST *def_prop) { OSSL_METHOD_STORE *store = get_evp_method_store(libctx); - - if (store != NULL) - return ossl_method_store_set_global_properties(store, propq); + OSSL_PROPERTY_LIST **plp = ossl_ctx_global_properties(libctx); + + if (plp != NULL) { + ossl_property_free(*plp); + *plp = def_prop; + if (store != NULL) + ossl_method_store_flush_cache(store); + return 1; + } EVPerr(0, ERR_R_INTERNAL_ERROR); return 0; } +int EVP_set_default_properties(OPENSSL_CTX *libctx, const char *propq) +{ + OSSL_PROPERTY_LIST *pl = NULL; + + if (propq != NULL && (pl = ossl_parse_query(libctx, propq)) == NULL) { + EVPerr(0, EVP_R_DEFAULT_QUERY_PARSE_ERROR); + return 0; + } + return evp_set_default_properties(libctx, pl); +} + static int evp_default_properties_merge(OPENSSL_CTX *libctx, const char *propq) { - OSSL_METHOD_STORE *store = get_evp_method_store(libctx); - - if (store != NULL) - return ossl_method_store_merge_global_properties(store, propq); - EVPerr(0, ERR_R_INTERNAL_ERROR); - return 0; + OSSL_PROPERTY_LIST **plp = ossl_ctx_global_properties(libctx); + OSSL_PROPERTY_LIST *pl1, *pl2; + + if (propq == NULL) + return 1; + if (plp == NULL || *plp == NULL) + return EVP_set_default_properties(libctx, propq); + if ((pl1 = ossl_parse_query(libctx, propq)) == NULL) { + EVPerr(0, EVP_R_DEFAULT_QUERY_PARSE_ERROR); + return 0; + } + pl2 = ossl_property_merge(pl1, *plp); + ossl_property_free(pl1); + if (pl2 == NULL) { + EVPerr(0, ERR_R_MALLOC_FAILURE); + return 0; + } + return evp_set_default_properties(libctx, pl2); } static int evp_default_property_is_enabled(OPENSSL_CTX *libctx, const char *prop_name) { - OSSL_METHOD_STORE *store = get_evp_method_store(libctx); + OSSL_PROPERTY_LIST **plp = ossl_ctx_global_properties(libctx); - return ossl_method_store_global_property_is_enabled(store, prop_name); + return plp != NULL && ossl_property_is_enabled(libctx, prop_name, *plp); } int EVP_default_properties_is_fips_enabled(OPENSSL_CTX *libctx) |