diff options
author | Richard Levitte <levitte@openssl.org> | 2020-03-19 11:16:45 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-04-15 11:03:59 +0200 |
commit | 2b9add696573131fc463d098ed8bcbff1b5829d9 (patch) | |
tree | adccfe1cdba9541fe22d0951d2028f957e7e24a0 /crypto/evp/keymgmt_meth.c | |
parent | a5c864ce901483d6f1067c22cb7c0a6322d351f5 (diff) |
KEYMGMT: Add functions to get param/key generation parameters
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/11328)
Diffstat (limited to 'crypto/evp/keymgmt_meth.c')
-rw-r--r-- | crypto/evp/keymgmt_meth.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/crypto/evp/keymgmt_meth.c b/crypto/evp/keymgmt_meth.c index 07d52ebf68..7ea414e8dd 100644 --- a/crypto/evp/keymgmt_meth.c +++ b/crypto/evp/keymgmt_meth.c @@ -38,7 +38,8 @@ static void *keymgmt_from_dispatch(int name_id, OSSL_PROVIDER *prov) { EVP_KEYMGMT *keymgmt = NULL; - int setparamfncnt = 0, getparamfncnt = 0, setgenparamfncnt = 0; + int setparamfncnt = 0, getparamfncnt = 0; + int setgenparamfncnt = 0, getgenparamfncnt = 0; int importfncnt = 0, exportfncnt = 0; if ((keymgmt = keymgmt_new()) == NULL) { @@ -76,6 +77,20 @@ static void *keymgmt_from_dispatch(int name_id, OSSL_get_OP_keymgmt_gen_settable_params(fns); } break; + case OSSL_FUNC_KEYMGMT_GEN_GET_PARAMS: + if (keymgmt->gen_get_params == NULL) { + getgenparamfncnt++; + keymgmt->gen_get_params = + OSSL_get_OP_keymgmt_gen_get_params(fns); + } + break; + case OSSL_FUNC_KEYMGMT_GEN_GETTABLE_PARAMS: + if (keymgmt->gen_gettable_params == NULL) { + getgenparamfncnt++; + keymgmt->gen_gettable_params = + OSSL_get_OP_keymgmt_gen_gettable_params(fns); + } + break; case OSSL_FUNC_KEYMGMT_GEN: if (keymgmt->gen == NULL) keymgmt->gen = OSSL_get_OP_keymgmt_gen(fns); @@ -171,6 +186,7 @@ static void *keymgmt_from_dispatch(int name_id, || (getparamfncnt != 0 && getparamfncnt != 2) || (setparamfncnt != 0 && setparamfncnt != 2) || (setgenparamfncnt != 0 && setgenparamfncnt != 2) + || (getgenparamfncnt != 0 && getgenparamfncnt != 2) || (importfncnt != 0 && importfncnt != 2) || (exportfncnt != 0 && exportfncnt != 2) || (keymgmt->gen != NULL @@ -319,6 +335,23 @@ const OSSL_PARAM *evp_keymgmt_gen_settable_params(const EVP_KEYMGMT *keymgmt) return keymgmt->gen_settable_params(provctx); } +int evp_keymgmt_gen_get_params(const EVP_KEYMGMT *keymgmt, void *genctx, + OSSL_PARAM params[]) +{ + if (keymgmt->gen_get_params == NULL) + return 0; + return keymgmt->gen_get_params(genctx, params); +} + +const OSSL_PARAM *evp_keymgmt_gen_gettable_params(const EVP_KEYMGMT *keymgmt) +{ + void *provctx = ossl_provider_ctx(EVP_KEYMGMT_provider(keymgmt)); + + if (keymgmt->gen_gettable_params == NULL) + return NULL; + return keymgmt->gen_gettable_params(provctx); +} + void *evp_keymgmt_gen(const EVP_KEYMGMT *keymgmt, void *genctx, OSSL_CALLBACK *cb, void *cbarg) { |