summaryrefslogtreecommitdiff
path: root/crypto/encode_decode
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2022-05-04 14:54:13 +1000
committerPauli <pauli@openssl.org>2022-05-06 10:38:55 +1000
commit16ff70a58cfb5c40197e6a940cf4666226f31b79 (patch)
tree06fc97def75b045e9bdd339aeaf5aa3dfdc674b8 /crypto/encode_decode
parent32e3c071373280b69be02ba91fc3204495e2e1bf (diff)
downloadopenssl-new-16ff70a58cfb5c40197e6a940cf4666226f31b79.tar.gz
Remove the _fetch_by_number functions
These functions are unused and untested. They are also implemented rather inefficiently. If we ever needed them in the future, they'd almost surely need to be rewritten more efficiently. Fixes #18227 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18237)
Diffstat (limited to 'crypto/encode_decode')
-rw-r--r--crypto/encode_decode/decoder_meth.c36
-rw-r--r--crypto/encode_decode/encoder_meth.c36
2 files changed, 12 insertions, 60 deletions
diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c
index d622fffb2f..404ad38d97 100644
--- a/crypto/encode_decode/decoder_meth.c
+++ b/crypto/encode_decode/decoder_meth.c
@@ -315,38 +315,27 @@ static void free_decoder(void *method)
/* Fetching support. Can fetch by numeric identity or by name */
static OSSL_DECODER *
-inner_ossl_decoder_fetch(struct decoder_data_st *methdata, int id,
+inner_ossl_decoder_fetch(struct decoder_data_st *methdata,
const char *name, const char *properties)
{
OSSL_METHOD_STORE *store = get_decoder_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_DECODER, 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_DECODER, ERR_R_INTERNAL_ERROR);
- return NULL;
- }
-
- if (id == 0 && name != NULL)
- 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)) {
@@ -409,20 +398,7 @@ OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *libctx, const char *name,
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- method = inner_ossl_decoder_fetch(&methdata, 0, name, properties);
- dealloc_tmp_decoder_store(methdata.tmp_store);
- return method;
-}
-
-OSSL_DECODER *ossl_decoder_fetch_by_number(OSSL_LIB_CTX *libctx, int id,
- const char *properties)
-{
- struct decoder_data_st methdata;
- void *method;
-
- methdata.libctx = libctx;
- methdata.tmp_store = NULL;
- method = inner_ossl_decoder_fetch(&methdata, id, NULL, properties);
+ method = inner_ossl_decoder_fetch(&methdata, name, properties);
dealloc_tmp_decoder_store(methdata.tmp_store);
return method;
}
@@ -552,7 +528,7 @@ void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx,
methdata.libctx = libctx;
methdata.tmp_store = NULL;
- (void)inner_ossl_decoder_fetch(&methdata, 0, NULL, NULL /* properties */);
+ (void)inner_ossl_decoder_fetch(&methdata, NULL, NULL /* properties */);
data.user_fn = user_fn;
data.user_arg = user_arg;
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;