From a5120afda32e67435624cef1fe0d49bf699e4ca5 Mon Sep 17 00:00:00 2001 From: Pauli Date: Tue, 23 Feb 2021 10:46:08 +1000 Subject: [PATCH] evp: support modified gettable/settable ctx calls for KDFs Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14240) --- crypto/evp/kdf_meth.c | 30 ++++++++++++++++++++++++++++-- include/openssl/kdf.h | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/crypto/evp/kdf_meth.c b/crypto/evp/kdf_meth.c index 40e71e8cd8f..659788a58d8 100644 --- a/crypto/evp/kdf_meth.c +++ b/crypto/evp/kdf_meth.c @@ -174,16 +174,42 @@ const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf) const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf) { + void *alg; + if (kdf->gettable_ctx_params == NULL) return NULL; - return kdf->gettable_ctx_params(ossl_provider_ctx(EVP_KDF_provider(kdf))); + alg = ossl_provider_ctx(EVP_KDF_provider(kdf)); + return kdf->gettable_ctx_params(NULL, alg); } const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf) { + void *alg; + if (kdf->settable_ctx_params == NULL) return NULL; - return kdf->settable_ctx_params(ossl_provider_ctx(EVP_KDF_provider(kdf))); + alg = ossl_provider_ctx(EVP_KDF_provider(kdf)); + return kdf->settable_ctx_params(NULL, alg); +} + +const OSSL_PARAM *EVP_KDF_CTX_gettable_params(EVP_KDF_CTX *ctx) +{ + void *alg; + + if (ctx->meth->gettable_ctx_params == NULL) + return NULL; + alg = ossl_provider_ctx(EVP_KDF_provider(ctx->meth)); + return ctx->meth->gettable_ctx_params(ctx->data, alg); +} + +const OSSL_PARAM *EVP_KDF_CTX_settable_params(EVP_KDF_CTX *ctx) +{ + void *alg; + + if (ctx->meth->settable_ctx_params == NULL) + return NULL; + alg = ossl_provider_ctx(EVP_KDF_provider(ctx->meth)); + return ctx->meth->settable_ctx_params(ctx->data, alg); } void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx, diff --git a/include/openssl/kdf.h b/include/openssl/kdf.h index 37c1736a8cc..f1bc9a7709f 100644 --- a/include/openssl/kdf.h +++ b/include/openssl/kdf.h @@ -48,6 +48,8 @@ int EVP_KDF_CTX_set_params(EVP_KDF_CTX *ctx, const OSSL_PARAM params[]); const OSSL_PARAM *EVP_KDF_gettable_params(const EVP_KDF *kdf); const OSSL_PARAM *EVP_KDF_gettable_ctx_params(const EVP_KDF *kdf); const OSSL_PARAM *EVP_KDF_settable_ctx_params(const EVP_KDF *kdf); +const OSSL_PARAM *EVP_KDF_CTX_gettable_params(EVP_KDF_CTX *ctx); +const OSSL_PARAM *EVP_KDF_CTX_settable_params(EVP_KDF_CTX *ctx); void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx, void (*fn)(EVP_KDF *kdf, void *arg), -- 2.47.3