summaryrefslogtreecommitdiff
path: root/crypto/encode_decode/decoder_meth.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-06-01 20:04:59 +0200
committerPauli <pauli@openssl.org>2021-06-05 20:30:11 +1000
commit9379bf943a12090de6280e88fb0d246e73658116 (patch)
tree88edd720911933e65a162f1daee9d79c5f383e91 /crypto/encode_decode/decoder_meth.c
parent6ec3b2cf4992a304b4ab36f7b9e9ff130bd495b7 (diff)
downloadopenssl-new-9379bf943a12090de6280e88fb0d246e73658116.tar.gz
DECODER: use property definitions instead of getting implementation parameters
The OSSL_DECODER library used to ask each decoder implementation for certain data in form of parameters to place them correctly in the decoder chain, if at all. These parameters were duplicates of properties of those same implementations, and therefore unnecessarily redundant. Now that we have functionality to query property definition values, those duplicates are no longer needed, and are therefore not looked at any more. This adds the "global" error reason ERR_R_INVALID_PROPERTY_DEFINITION, which can be re-used elsewhere. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15570)
Diffstat (limited to 'crypto/encode_decode/decoder_meth.c')
-rw-r--r--crypto/encode_decode/decoder_meth.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/crypto/encode_decode/decoder_meth.c b/crypto/encode_decode/decoder_meth.c
index 7197b9090d..e203c5fe66 100644
--- a/crypto/encode_decode/decoder_meth.c
+++ b/crypto/encode_decode/decoder_meth.c
@@ -59,6 +59,7 @@ void OSSL_DECODER_free(OSSL_DECODER *decoder)
if (ref > 0)
return;
OPENSSL_free(decoder->base.name);
+ ossl_property_free(decoder->base.parsed_propdef);
ossl_provider_free(decoder->base.prov);
CRYPTO_THREAD_lock_free(decoder->base.lock);
OPENSSL_free(decoder);
@@ -166,6 +167,7 @@ void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
{
OSSL_DECODER *decoder = NULL;
const OSSL_DISPATCH *fns = algodef->implementation;
+ OSSL_LIB_CTX *libctx = ossl_provider_libctx(prov);
if ((decoder = ossl_decoder_new()) == NULL)
return NULL;
@@ -176,6 +178,8 @@ void *ossl_decoder_from_algorithm(int id, const OSSL_ALGORITHM *algodef,
}
decoder->base.propdef = algodef->property_definition;
decoder->base.description = algodef->algorithm_description;
+ decoder->base.parsed_propdef
+ = ossl_parse_property(libctx, algodef->property_definition);
for (; fns->function_id != 0; fns++) {
switch (fns->function_id) {
@@ -421,6 +425,17 @@ const char *OSSL_DECODER_get0_properties(const OSSL_DECODER *decoder)
return decoder->base.propdef;
}
+const OSSL_PROPERTY_LIST *
+ossl_decoder_parsed_properties(const OSSL_DECODER *decoder)
+{
+ if (!ossl_assert(decoder != NULL)) {
+ ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_PASSED_NULL_PARAMETER);
+ return 0;
+ }
+
+ return decoder->base.parsed_propdef;
+}
+
int ossl_decoder_get_number(const OSSL_DECODER *decoder)
{
if (!ossl_assert(decoder != NULL)) {