summaryrefslogtreecommitdiffstats
path: root/crypto/dh/dh_lib.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-08-04 03:21:21 +0200
committerShane Lontis <shane.lontis@oracle.com>2020-08-11 12:39:19 +0200
commit116d2510f7e95d1e6f4a6b9db2df1ec8d11b61fb (patch)
treef05970c6c5e9c20e0fb38659d1391fed1e175b8f /crypto/dh/dh_lib.c
parentAdd DHX support to keymanager (diff)
downloadopenssl-116d2510f7e95d1e6f4a6b9db2df1ec8d11b61fb.tar.xz
openssl-116d2510f7e95d1e6f4a6b9db2df1ec8d11b61fb.zip
Add dh_kdf support to provider
Similiar to ecdh this supports the legacy kdf inside the provider dh key exchange. The supporting EVP_PKEY_CTX macros have been changed into mehtods and moved into dh_ctrl.c New kdfs such as SSKDF should be done as a seperate pass after doing the derive. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12575)
Diffstat (limited to 'crypto/dh/dh_lib.c')
-rw-r--r--crypto/dh/dh_lib.c192
1 files changed, 0 insertions, 192 deletions
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c
index 2a3921a137..a6f4e64137 100644
--- a/crypto/dh/dh_lib.c
+++ b/crypto/dh/dh_lib.c
@@ -344,195 +344,3 @@ int dh_ffc_params_fromdata(DH *dh, const OSSL_PARAM params[])
}
return ret;
}
-
-static int dh_paramgen_check(EVP_PKEY_CTX *ctx)
-{
- if (ctx == NULL || !EVP_PKEY_CTX_IS_GEN_OP(ctx)) {
- ERR_raise(ERR_LIB_EVP, EVP_R_COMMAND_NOT_SUPPORTED);
- /* Uses the same return values as EVP_PKEY_CTX_ctrl */
- return -2;
- }
- /* If key type not DH return error */
- if (ctx->pmeth != NULL
- && ctx->pmeth->pkey_id != EVP_PKEY_DH
- && ctx->pmeth->pkey_id != EVP_PKEY_DHX)
- return -1;
- return 1;
-}
-
-int EVP_PKEY_CTX_set_dh_paramgen_gindex(EVP_PKEY_CTX *ctx, int gindex)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
- *p++ = OSSL_PARAM_construct_int(OSSL_PKEY_PARAM_FFC_GINDEX, &gindex);
- *p++ = OSSL_PARAM_construct_end();
-
- return EVP_PKEY_CTX_set_params(ctx, params);
-}
-
-int EVP_PKEY_CTX_set_dh_paramgen_seed(EVP_PKEY_CTX *ctx,
- const unsigned char *seed,
- size_t seedlen)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
- *p++ = OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_FFC_SEED,
- (void *)seed, seedlen);
- *p++ = OSSL_PARAM_construct_end();
-
- return EVP_PKEY_CTX_set_params(ctx, params);
-}
-
-int EVP_PKEY_CTX_set_dh_paramgen_type(EVP_PKEY_CTX *ctx, int typ)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
- const char *name;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
-#if !defined(FIPS_MODULE)
- /* TODO(3.0): Remove this eventually when no more legacy */
- if (ctx->op.keymgmt.genctx == NULL)
- return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN,
- EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL);
-#endif
-
- name = dh_gen_type_id2name(typ);
- if (name == NULL)
- return 0;
- *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_FFC_TYPE,
- (char *) name, 0);
- *p++ = OSSL_PARAM_construct_end();
-
- return EVP_PKEY_CTX_set_params(ctx, params);
-}
-
-int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int pbits)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
- size_t bits = pbits;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
-#if !defined(FIPS_MODULE)
- /* TODO(3.0): Remove this eventually when no more legacy */
- if (ctx->op.keymgmt.genctx == NULL)
- return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN,
- EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, pbits,
- NULL);
-#endif
- *p++ = OSSL_PARAM_construct_size_t(OSSL_PKEY_PARAM_FFC_PBITS, &bits);
- *p++ = OSSL_PARAM_construct_end();
- return EVP_PKEY_CTX_set_params(ctx, params);
-}
-
-int EVP_PKEY_CTX_set_dh_paramgen_subprime_len(EVP_PKEY_CTX *ctx, int qbits)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
- size_t bits2 = qbits;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
-#if !defined(FIPS_MODULE)
- /* TODO(3.0): Remove this eventually when no more legacy */
- if (ctx->op.keymgmt.genctx == NULL)
- return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN,
- EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, qbits,
- NULL);
-#endif
- *p++ = OSSL_PARAM_construct_size_t(OSSL_PKEY_PARAM_FFC_QBITS, &bits2);
- *p++ = OSSL_PARAM_construct_end();
-
- return EVP_PKEY_CTX_set_params(ctx, params);
-}
-
-int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
-#if !defined(FIPS_MODULE)
- /* TODO(3.0): Remove this eventually when no more legacy */
- if (ctx->op.keymgmt.genctx == NULL)
- return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN,
- EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL);
-#endif
-
- *p++ = OSSL_PARAM_construct_int(OSSL_PKEY_PARAM_DH_GENERATOR, &gen);
- *p++ = OSSL_PARAM_construct_end();
-
- return EVP_PKEY_CTX_set_params(ctx, params);
-}
-
-int EVP_PKEY_CTX_set_dh_rfc5114(EVP_PKEY_CTX *ctx, int gen)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
- const char *name;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
-#if !defined(FIPS_MODULE)
- /* TODO(3.0): Remove this eventually when no more legacy */
- if (ctx->op.keymgmt.genctx == NULL)
- return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN,
- EVP_PKEY_CTRL_DH_RFC5114, gen, NULL);
-#endif
- name = ffc_named_group_from_uid(gen);
- if (name == NULL)
- return 0;
-
- *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
- (void *)name, 0);
- *p++ = OSSL_PARAM_construct_end();
- return EVP_PKEY_CTX_set_params(ctx, params);
-}
-
-int EVP_PKEY_CTX_set_dhx_rfc5114(EVP_PKEY_CTX *ctx, int gen)
-{
- return EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen);
-}
-
-int EVP_PKEY_CTX_set_dh_nid(EVP_PKEY_CTX *ctx, int nid)
-{
- int ret;
- OSSL_PARAM params[2], *p = params;
- const char *name;
-
- if ((ret = dh_paramgen_check(ctx)) <= 0)
- return ret;
-
-#if !defined(FIPS_MODULE)
- /* TODO(3.0): Remove this eventually when no more legacy */
- if (ctx->op.keymgmt.genctx == NULL)
- return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH,
- EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN,
- EVP_PKEY_CTRL_DH_NID, nid, NULL);
-#endif
- name = ffc_named_group_from_uid(nid);
- if (name == NULL)
- return 0;
-
- *p++ = OSSL_PARAM_construct_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME,
- (void *)name, 0);
- *p++ = OSSL_PARAM_construct_end();
- return EVP_PKEY_CTX_set_params(ctx, params);
-}