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 | |
parent | Fix Dynamic engine loading so that the call to ENGINE_load_builtin_engines() ... (diff) | |
download | openssl-2b9add696573131fc463d098ed8bcbff1b5829d9.tar.xz openssl-2b9add696573131fc463d098ed8bcbff1b5829d9.zip |
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')
-rw-r--r-- | crypto/evp/evp_local.h | 2 | ||||
-rw-r--r-- | crypto/evp/keymgmt_meth.c | 35 | ||||
-rw-r--r-- | crypto/evp/pmeth_lib.c | 6 |
3 files changed, 42 insertions, 1 deletions
diff --git a/crypto/evp/evp_local.h b/crypto/evp/evp_local.h index 836dc33e26..40f02b340a 100644 --- a/crypto/evp/evp_local.h +++ b/crypto/evp/evp_local.h @@ -86,6 +86,8 @@ struct evp_keymgmt_st { OSSL_OP_keymgmt_gen_set_template_fn *gen_set_template; OSSL_OP_keymgmt_gen_set_params_fn *gen_set_params; OSSL_OP_keymgmt_gen_settable_params_fn *gen_settable_params; + OSSL_OP_keymgmt_gen_get_params_fn *gen_get_params; + OSSL_OP_keymgmt_gen_gettable_params_fn *gen_gettable_params; OSSL_OP_keymgmt_gen_fn *gen; OSSL_OP_keymgmt_gen_cleanup_fn *gen_cleanup; 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) { diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index f36a7363db..dffc2dd5d1 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -611,6 +611,12 @@ int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params) && ctx->op.ciph.cipher->get_ctx_params != NULL) return ctx->op.ciph.cipher->get_ctx_params(ctx->op.ciph.ciphprovctx, params); + if (EVP_PKEY_CTX_IS_GEN_OP(ctx) + && ctx->op.keymgmt.genctx != NULL + && ctx->keymgmt != NULL + && ctx->keymgmt->gen_get_params != NULL) + return evp_keymgmt_gen_get_params(ctx->keymgmt, ctx->op.keymgmt.genctx, + params); return 0; } |