diff options
author | Richard Levitte <levitte@openssl.org> | 2020-09-14 11:35:07 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-09-20 17:31:54 +0200 |
commit | 48b62fb33aa0c5bce52b939fcd94780736491a5d (patch) | |
tree | c9faa14517c8073ae72737d5f2f6d1a118d15079 /crypto/encode_decode/decoder_pkey.c | |
parent | ae12eac074be92e14c11a36b90e1c95eca3723f1 (diff) |
DECODER: Some cleanups, and aligning with OSSL_ENCODER
Mostly source nits, but also removing a couple of OSSL_DECODER_PARAM
macros that are never used or even make sense.
Also, some function names weren't quite consistent. They were made a
bit more consistent in the OSSL_ENCODER API, now we bring that back to
OSSL_DECODER.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12873)
Diffstat (limited to 'crypto/encode_decode/decoder_pkey.c')
-rw-r--r-- | crypto/encode_decode/decoder_pkey.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/crypto/encode_decode/decoder_pkey.c b/crypto/encode_decode/decoder_pkey.c index dfc7cccab1..2e07d0d7cc 100644 --- a/crypto/encode_decode/decoder_pkey.c +++ b/crypto/encode_decode/decoder_pkey.c @@ -62,9 +62,8 @@ static int decoder_construct_EVP_PKEY(OSSL_DECODER_INSTANCE *decoder_inst, void *construct_data) { struct decoder_EVP_PKEY_data_st *data = construct_data; - OSSL_DECODER *decoder = - OSSL_DECODER_INSTANCE_decoder(decoder_inst); - void *decoderctx = OSSL_DECODER_INSTANCE_decoder_ctx(decoder_inst); + OSSL_DECODER *decoder = OSSL_DECODER_INSTANCE_get_decoder(decoder_inst); + void *decoderctx = OSSL_DECODER_INSTANCE_get_decoder_ctx(decoder_inst); size_t i, end_i; /* * |object_ref| points to a provider reference to an object, its exact @@ -207,7 +206,7 @@ static void collect_keymgmt(EVP_KEYMGMT *keymgmt, void *arg) if (!EVP_KEYMGMT_up_ref(keymgmt) /* ref++ */) return; if (sk_EVP_KEYMGMT_push(data->process_data->keymgmts, keymgmt) <= 0) { - EVP_KEYMGMT_free(keymgmt); /* ref-- */ + EVP_KEYMGMT_free(keymgmt); /* ref-- */ return; } @@ -301,17 +300,16 @@ int ossl_decoder_ctx_setup_for_EVP_PKEY(OSSL_DECODER_CTX *ctx, if (data->error_occured) goto err; - /* If we found no decoders to match the keymgmts, we err */ - if (OSSL_DECODER_CTX_num_decoders(ctx) == 0) - goto err; + if (OSSL_DECODER_CTX_get_num_decoders(ctx) != 0) { + if (!OSSL_DECODER_CTX_set_construct(ctx, decoder_construct_EVP_PKEY) + || !OSSL_DECODER_CTX_set_construct_data(ctx, data->process_data) + || !OSSL_DECODER_CTX_set_cleanup(ctx, + decoder_clean_EVP_PKEY_construct_arg)) + goto err; - if (!OSSL_DECODER_CTX_set_construct(ctx, decoder_construct_EVP_PKEY) - || !OSSL_DECODER_CTX_set_construct_data(ctx, data->process_data) - || !OSSL_DECODER_CTX_set_cleanup(ctx, - decoder_clean_EVP_PKEY_construct_arg)) - goto err; + data->process_data = NULL; /* Avoid it being freed */ + } - data->process_data = NULL; ok = 1; err: if (data != NULL) { |