From 141cc94e44db93cded4ce3f0d97b9b5b928f43f2 Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 4 Mar 2021 13:53:53 +1000 Subject: Add a real type for OSSL_CORE_BIO which is distinct from and not castable to BIO Providers (particularly the FIPS provider) needs access to BIOs from libcrypto. Libcrypto is allowed to change the internal format of the BIO structure and it is still expected to work with providers that were already built. This means that the libcrypto BIO must be distinct from and not castable to the provider side OSSL_CORE_BIO. Unfortunately, this requirement was broken in both directions. This fixes things by forcing the two to be different and any casts break loudly. Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14419) --- crypto/store/store_lib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crypto/store') diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index 5d0b3e7397..1aaf9f89a4 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -26,6 +26,7 @@ #include "internal/thread_once.h" #include "internal/cryptlib.h" #include "internal/provider.h" +#include "internal/bio.h" #include "crypto/store.h" #include "store_local.h" @@ -941,9 +942,10 @@ OSSL_STORE_CTX *OSSL_STORE_attach(BIO *bp, const char *scheme, const OSSL_PROVIDER *provider = OSSL_STORE_LOADER_provider(fetched_loader); void *provctx = OSSL_PROVIDER_get0_provider_ctx(provider); + OSSL_CORE_BIO *cbio = ossl_core_bio_new_from_bio(bp); - if ((loader_ctx = - fetched_loader->p_attach(provctx, (OSSL_CORE_BIO *)bp)) == NULL) { + if (cbio == NULL + || (loader_ctx = fetched_loader->p_attach(provctx, cbio)) == NULL) { OSSL_STORE_LOADER_free(fetched_loader); fetched_loader = NULL; } else if (propq != NULL) { @@ -961,6 +963,7 @@ OSSL_STORE_CTX *OSSL_STORE_attach(BIO *bp, const char *scheme, } } loader = fetched_loader; + ossl_core_bio_free(cbio); } if (loader_ctx == NULL) { -- cgit v1.2.3