evp: support modified gettable/settable ctx calls for KDFs
authorPauli <ppzgs1@gmail.com>
Tue, 23 Feb 2021 00:46:08 +0000 (10:46 +1000)
committerPauli <ppzgs1@gmail.com>
Fri, 26 Feb 2021 08:08:41 +0000 (18:08 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14240)

crypto/evp/kdf_meth.c
include/openssl/kdf.h

index 40e71e8cd8fcb08d19be56ffa86d36bd628263b8..659788a58d8db498ae0514e229c9a83ba366a277 100644 (file)
@@ -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,
index 37c1736a8cc21c7cc653361ea2dad535f50c6ca4..f1bc9a7709ffdcdd7fb11474bef646180e7aa561 100644 (file)
@@ -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),