diff options
author | Pauli <ppzgs1@gmail.com> | 2021-03-04 13:53:53 +1000 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-03-11 09:25:57 +1000 |
commit | 141cc94e44db93cded4ce3f0d97b9b5b928f43f2 (patch) | |
tree | 111a6e47c2a86347a6d969d00844a5b2dc8a5805 /crypto/encode_decode/encoder_lib.c | |
parent | 7a45d51ce3268d16409405b9d54d7b4bb77a7fc3 (diff) |
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 <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14419)
Diffstat (limited to 'crypto/encode_decode/encoder_lib.c')
-rw-r--r-- | crypto/encode_decode/encoder_lib.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/encode_decode/encoder_lib.c b/crypto/encode_decode/encoder_lib.c index d15fb27fde..b25529e073 100644 --- a/crypto/encode_decode/encoder_lib.c +++ b/crypto/encode_decode/encoder_lib.c @@ -15,6 +15,7 @@ #include <openssl/params.h> #include <openssl/provider.h> #include <openssl/trace.h> +#include "internal/bio.h" #include "encoder_local.h" struct encoder_process_data_st { @@ -604,6 +605,7 @@ static int encoder_process(struct encoder_process_data_st *data) /* Calling the encoder implementation */ if (ok) { + OSSL_CORE_BIO *cbio = NULL; BIO *current_out = NULL; /* @@ -616,9 +618,10 @@ static int encoder_process(struct encoder_process_data_st *data) == NULL) ok = 0; /* Assume BIO_new() recorded an error */ + if (ok) + ok = (cbio = ossl_core_bio_new_from_bio(current_out)) != NULL; if (ok) { - ok = current_encoder->encode(current_encoder_ctx, - (OSSL_CORE_BIO *)current_out, + ok = current_encoder->encode(current_encoder_ctx, cbio, original_data, current_abstract, data->ctx->selection, ossl_pw_passphrase_callback_enc, @@ -631,6 +634,7 @@ static int encoder_process(struct encoder_process_data_st *data) } OSSL_TRACE_END(ENCODER); } + ossl_core_bio_free(cbio); data->prev_encoder_inst = current_encoder_inst; } } |