From: Pauli Date: Tue, 23 Feb 2021 01:03:49 +0000 (+1000) Subject: evp: support modified gettable/settable ctx calls for MACs X-Git-Tag: openssl-3.0.0-alpha13~161 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=35c76a528bb14611d7ff2c77762b16cf28c1fef3;p=thirdparty%2Fopenssl.git evp: support modified gettable/settable ctx calls for MACs Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14240) --- diff --git a/crypto/evp/mac_meth.c b/crypto/evp/mac_meth.c index edf08389e9a..85f87e4c610 100644 --- a/crypto/evp/mac_meth.c +++ b/crypto/evp/mac_meth.c @@ -181,16 +181,42 @@ const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac) const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac) { + void *alg; + if (mac->gettable_ctx_params == NULL) return NULL; - return mac->gettable_ctx_params(ossl_provider_ctx(EVP_MAC_provider(mac))); + alg = ossl_provider_ctx(EVP_MAC_provider(mac)); + return mac->gettable_ctx_params(NULL, alg); } const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac) { + void *alg; + if (mac->settable_ctx_params == NULL) return NULL; - return mac->settable_ctx_params(ossl_provider_ctx(EVP_MAC_provider(mac))); + alg = ossl_provider_ctx(EVP_MAC_provider(mac)); + return mac->settable_ctx_params(NULL, alg); +} + +const OSSL_PARAM *EVP_MAC_CTX_gettable_params(EVP_MAC_CTX *ctx) +{ + void *alg; + + if (ctx->meth->gettable_ctx_params == NULL) + return NULL; + alg = ossl_provider_ctx(EVP_MAC_provider(ctx->meth)); + return ctx->meth->gettable_ctx_params(ctx->data, alg); +} + +const OSSL_PARAM *EVP_MAC_CTX_settable_params(EVP_MAC_CTX *ctx) +{ + void *alg; + + if (ctx->meth->settable_ctx_params == NULL) + return NULL; + alg = ossl_provider_ctx(EVP_MAC_provider(ctx->meth)); + return ctx->meth->settable_ctx_params(ctx->data, alg); } void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx, diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 015cb9f158f..17250be90e8 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -1149,6 +1149,8 @@ int EVP_MAC_final(EVP_MAC_CTX *ctx, const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac); const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac); const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac); +const OSSL_PARAM *EVP_MAC_CTX_gettable_params(EVP_MAC_CTX *ctx); +const OSSL_PARAM *EVP_MAC_CTX_settable_params(EVP_MAC_CTX *ctx); void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_MAC *mac, void *arg),