diff options
author | Matt Caswell <matt@openssl.org> | 2021-05-11 16:50:27 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-05-20 09:35:41 +0100 |
commit | b1c053acdaaee5e653949932f9999370edfc64db (patch) | |
tree | 7415bb7e2ab85cddc2f4e88c36d6924954908584 /crypto/property | |
parent | 366bf9aedbbf719097a891dbf675f46dab8c9276 (diff) |
Ensure mirroring of properties works for subsequent updates
If the global properties are updated after a provider with a child libctx
has already started we need to make sure those updates are mirrored in
that child.
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15242)
Diffstat (limited to 'crypto/property')
-rw-r--r-- | crypto/property/property.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/crypto/property/property.c b/crypto/property/property.c index da6bc84e27..a769a7307e 100644 --- a/crypto/property/property.c +++ b/crypto/property/property.c @@ -74,25 +74,31 @@ typedef struct { DEFINE_SPARSE_ARRAY_OF(ALGORITHM); +typedef struct ossl_global_properties_st { + OSSL_PROPERTY_LIST *list; +#ifndef FIPS_MODULE + unsigned int no_mirrored : 1; +#endif +} OSSL_GLOBAL_PROPERTIES; + static void ossl_method_cache_flush(OSSL_METHOD_STORE *store, int nid); /* Global properties are stored per library context */ -static void ossl_ctx_global_properties_free(void *vstore) +static void ossl_ctx_global_properties_free(void *vglobp) { - OSSL_PROPERTY_LIST **plp = vstore; + OSSL_GLOBAL_PROPERTIES *globp = vglobp; - if (plp != NULL) { - ossl_property_free(*plp); - OPENSSL_free(plp); + if (globp != NULL) { + ossl_property_free(globp->list); + OPENSSL_free(globp); } } static void *ossl_ctx_global_properties_new(OSSL_LIB_CTX *ctx) { - return OPENSSL_zalloc(sizeof(OSSL_PROPERTY_LIST **)); + return OPENSSL_zalloc(sizeof(OSSL_GLOBAL_PROPERTIES)); } - static const OSSL_LIB_CTX_METHOD ossl_ctx_global_properties_method = { OSSL_LIB_CTX_METHOD_DEFAULT_PRIORITY, ossl_ctx_global_properties_new, @@ -102,13 +108,37 @@ static const OSSL_LIB_CTX_METHOD ossl_ctx_global_properties_method = { OSSL_PROPERTY_LIST **ossl_ctx_global_properties(OSSL_LIB_CTX *libctx, int loadconfig) { + OSSL_GLOBAL_PROPERTIES *globp; + #ifndef FIPS_MODULE if (loadconfig && !OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL)) return NULL; #endif - return ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_GLOBAL_PROPERTIES, - &ossl_ctx_global_properties_method); + globp = ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_GLOBAL_PROPERTIES, + &ossl_ctx_global_properties_method); + + return &globp->list; +} + +#ifndef FIPS_MODULE +int ossl_global_properties_no_mirrored(OSSL_LIB_CTX *libctx) +{ + OSSL_GLOBAL_PROPERTIES *globp + = ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_GLOBAL_PROPERTIES, + &ossl_ctx_global_properties_method); + + return globp->no_mirrored ? 1 : 0; +} + +void ossl_global_properties_stop_mirroring(OSSL_LIB_CTX *libctx) +{ + OSSL_GLOBAL_PROPERTIES *globp + = ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_GLOBAL_PROPERTIES, + &ossl_ctx_global_properties_method); + + globp->no_mirrored = 1; } +#endif static int ossl_method_up_ref(METHOD *method) { |