summaryrefslogtreecommitdiff
path: root/crypto/encode_decode/encoder_meth.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/encode_decode/encoder_meth.c')
-rw-r--r--crypto/encode_decode/encoder_meth.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/crypto/encode_decode/encoder_meth.c b/crypto/encode_decode/encoder_meth.c
index ad7df22544..5309838ff2 100644
--- a/crypto/encode_decode/encoder_meth.c
+++ b/crypto/encode_decode/encoder_meth.c
@@ -325,38 +325,27 @@ static void free_encoder(void *method)
/* Fetching support. Can fetch by numeric identity or by name */
static OSSL_ENCODER *
-inner_ossl_encoder_fetch(struct encoder_data_st *methdata, int id,
+inner_ossl_encoder_fetch(struct encoder_data_st *methdata,
const char *name, const char *properties)
{
OSSL_METHOD_STORE *store = get_encoder_store(methdata->libctx);
OSSL_NAMEMAP *namemap = ossl_namemap_stored(methdata->libctx);
const char *const propq = properties != NULL ? properties : "";
void *method = NULL;
- int unsupported = 0;
+ int unsupported, id;
if (store == NULL || namemap == NULL) {
ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_PASSED_INVALID_ARGUMENT);
return NULL;
}
- /*
- * If we have been passed both an id and a name, we have an
- * internal programming error.
- */
- if (!ossl_assert(id == 0 || name == NULL)) {
- ERR_raise(ERR_LIB_OSSL_ENCODER, ERR_R_INTERNAL_ERROR);
- return NULL;
- }
-
- if (id == 0)
- id = ossl_namemap_name2num(namemap, name);
+ id = name != NULL ? ossl_namemap_name2num(namemap, name) : 0;
/*
* If we haven't found the name yet, chances are that the algorithm to
* be fetched is unsupported.
*/
- if (id == 0)
- unsupported = 1;
+ unsupported = id == 0;
if (id == 0
|| !ossl_method_store_cache_get(store, NULL, id, propq, &method)) {
@@ -418,20 +407,7 @@ OSSL_ENCODER *OSSL_ENCODER_fetch(OSSL_LIB_CTX *libctx, const char *name,
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- method = inner_ossl_encoder_fetch(&methdata, 0, name, properties);
- dealloc_tmp_encoder_store(methdata.tmp_store);
- return method;
-}
-
-OSSL_ENCODER *ossl_encoder_fetch_by_number(OSSL_LIB_CTX *libctx, int id,
- const char *properties)
-{
- struct encoder_data_st methdata;
- void *method;
-
- methdata.libctx = libctx;
- methdata.tmp_store = NULL;
- method = inner_ossl_encoder_fetch(&methdata, id, NULL, properties);
+ method = inner_ossl_encoder_fetch(&methdata, name, properties);
dealloc_tmp_encoder_store(methdata.tmp_store);
return method;
}
@@ -543,7 +519,7 @@ void OSSL_ENCODER_do_all_provided(OSSL_LIB_CTX *libctx,
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- (void)inner_ossl_encoder_fetch(&methdata, 0, NULL, NULL /* properties */);
+ (void)inner_ossl_encoder_fetch(&methdata, NULL, NULL /* properties */);
data.user_fn = user_fn;
data.user_arg = user_arg;