Add EVP_KEM_gettable_ctx_params() and EVP_KEM_settable_ctx_params()
authorShane Lontis <shane.lontis@oracle.com>
Tue, 22 Sep 2020 00:36:50 +0000 (10:36 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Fri, 25 Sep 2020 21:13:21 +0000 (07:13 +1000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12943)

crypto/evp/kem.c
doc/man3/EVP_KEM_free.pod
include/openssl/evp.h

index 6f0424075ad287c9f6d7461640128ee241348ade..5b13f0130ac6a9755a0a842492f60b564486c289 100644 (file)
@@ -349,7 +349,6 @@ void EVP_KEM_do_all_provided(OPENSSL_CTX *libctx,
                        (void (*)(void *))EVP_KEM_free);
 }
 
-
 void EVP_KEM_names_do_all(const EVP_KEM *kem,
                           void (*fn)(const char *name, void *data),
                           void *data)
@@ -357,3 +356,25 @@ void EVP_KEM_names_do_all(const EVP_KEM *kem,
     if (kem->prov != NULL)
         evp_names_do_all(kem->prov, kem->name_id, fn, data);
 }
+
+const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem)
+{
+    void *provctx;
+
+    if (kem == NULL || kem->gettable_ctx_params == NULL)
+        return NULL;
+
+    provctx = ossl_provider_ctx(EVP_KEM_provider(kem));
+    return kem->gettable_ctx_params(provctx);
+}
+
+const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem)
+{
+    void *provctx;
+
+    if (kem == NULL || kem->settable_ctx_params == NULL)
+        return NULL;
+
+    provctx = ossl_provider_ctx(EVP_KEM_provider(kem));
+    return kem->settable_ctx_params(provctx);
+}
index 0e3ca12ae3d9a0a1a0e1a6135df7ab200c2ef8d6..de3bee951ddd86ce5aac01576d4aa8e5f511e49a 100644 (file)
@@ -4,7 +4,8 @@
 
 EVP_KEM_fetch, EVP_KEM_free, EVP_KEM_up_ref,
 EVP_KEM_number, EVP_KEM_is_a, EVP_KEM_provider,
-EVP_KEM_do_all_provided, EVP_KEM_names_do_all
+EVP_KEM_do_all_provided, EVP_KEM_names_do_all,
+EVP_KEM_gettable_ctx_params, EVP_KEM_settable_ctx_params
 - Functions to manage EVP_KEM algorithm objects
 
 =head1 SYNOPSIS
@@ -22,6 +23,8 @@ EVP_KEM_do_all_provided, EVP_KEM_names_do_all
                               void (*fn)(EVP_KEM *kem, void *arg), void *arg);
  void EVP_KEM_names_do_all(const EVP_KEM *kem,
                            void (*fn)(const char *name, void *data), void *data);
+ const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem);
+ const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem);
 
 =head1 DESCRIPTION
 
@@ -55,6 +58,11 @@ EVP_KEM_number() returns the internal dynamic number assigned to I<kem>.
 EVP_KEM_names_do_all() traverses all names for I<kem>, and calls I<fn> with
 each name and I<data>.
 
+EVP_KEM_gettable_ctx_params() and EVP_KEM_settable_ctx_params() return
+a constant B<OSSL_PARAM> array that describes the names and types of key
+parameters that can be retrieved or set by a key encapsulation algorithm using
+L<EVP_PKEY_CTX_get_params(3)> and L<EVP_PKEY_CTX_set_params(3)>.
+
 =head1 RETURN VALUES
 
 EVP_KEM_fetch() returns a pointer to an B<EVP_KEM> for success or B<NULL> for
@@ -62,6 +70,9 @@ failure.
 
 EVP_KEM_up_ref() returns 1 for success or 0 otherwise.
 
+EVP_KEM_gettable_ctx_params() and EVP_KEM_settable_ctx_params() return
+a constant B<OSSL_PARAM> array or NULL on error.
+
 =head1 SEE ALSO
 
 L<provider(7)/Fetching algorithms>, L<OSSL_PROVIDER(3)>
index 2948c2c54291e7ed2bcba705b8ab9a61ec84b57f..8c9996b948da1600c451d549160acf742744d09a 100644 (file)
@@ -1687,6 +1687,8 @@ void EVP_KEM_do_all_provided(OPENSSL_CTX *libctx,
                              void (*fn)(EVP_KEM *wrap, void *arg), void *arg);
 void EVP_KEM_names_do_all(const EVP_KEM *wrap,
                           void (*fn)(const char *name, void *data), void *data);
+const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem);
+const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem);
 
 int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
 int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,