Loading crypto/dh/dh_pmeth.c +15 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ typedef struct { int generator; int use_dsa; int subprime_len; int pad; /* message digest used for parameter generation */ const EVP_MD *md; int rfc5114_param; Loading Loading @@ -86,6 +87,7 @@ static int pkey_dh_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) dctx->subprime_len = sctx->subprime_len; dctx->generator = sctx->generator; dctx->use_dsa = sctx->use_dsa; dctx->pad = sctx->pad; dctx->md = sctx->md; dctx->rfc5114_param = sctx->rfc5114_param; dctx->param_nid = sctx->param_nid; Loading Loading @@ -121,6 +123,10 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) dctx->subprime_len = p1; return 1; case EVP_PKEY_CTRL_DH_PAD: dctx->pad = p1; return 1; case EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR: if (dctx->use_dsa) return -2; Loading Loading @@ -255,6 +261,11 @@ static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, typ = atoi(value); return EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ); } if (strcmp(type, "dh_pad") == 0) { int pad; pad = atoi(value); return EVP_PKEY_CTX_set_dh_pad(ctx, pad); } return -2; } Loading Loading @@ -423,6 +434,9 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, *keylen = DH_size(dh); return 1; } if (dctx->pad) ret = DH_compute_key_padded(key, dhpub, dh); else ret = DH_compute_key(key, dhpub, dh); if (ret < 0) return ret; Loading include/openssl/dh.h +5 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,10 @@ int DH_meth_set_generate_params(DH_METHOD *dhm, EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN, \ EVP_PKEY_CTRL_DH_NID, nid, NULL) # define EVP_PKEY_CTX_set_dh_pad(ctx, pad) \ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_DERIVE, \ EVP_PKEY_CTRL_DH_PAD, pad, NULL) # define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ EVP_PKEY_OP_DERIVE, \ Loading Loading @@ -312,6 +316,7 @@ int DH_meth_set_generate_params(DH_METHOD *dhm, # define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13) # define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14) # define EVP_PKEY_CTRL_DH_NID (EVP_PKEY_ALG_CTRL + 15) # define EVP_PKEY_CTRL_DH_PAD (EVP_PKEY_ALG_CTRL + 16) /* KDF types */ # define EVP_PKEY_DH_KDF_NONE 1 Loading Loading
crypto/dh/dh_pmeth.c +15 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ typedef struct { int generator; int use_dsa; int subprime_len; int pad; /* message digest used for parameter generation */ const EVP_MD *md; int rfc5114_param; Loading Loading @@ -86,6 +87,7 @@ static int pkey_dh_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) dctx->subprime_len = sctx->subprime_len; dctx->generator = sctx->generator; dctx->use_dsa = sctx->use_dsa; dctx->pad = sctx->pad; dctx->md = sctx->md; dctx->rfc5114_param = sctx->rfc5114_param; dctx->param_nid = sctx->param_nid; Loading Loading @@ -121,6 +123,10 @@ static int pkey_dh_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) dctx->subprime_len = p1; return 1; case EVP_PKEY_CTRL_DH_PAD: dctx->pad = p1; return 1; case EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR: if (dctx->use_dsa) return -2; Loading Loading @@ -255,6 +261,11 @@ static int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, typ = atoi(value); return EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ); } if (strcmp(type, "dh_pad") == 0) { int pad; pad = atoi(value); return EVP_PKEY_CTX_set_dh_pad(ctx, pad); } return -2; } Loading Loading @@ -423,6 +434,9 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, *keylen = DH_size(dh); return 1; } if (dctx->pad) ret = DH_compute_key_padded(key, dhpub, dh); else ret = DH_compute_key(key, dhpub, dh); if (ret < 0) return ret; Loading
include/openssl/dh.h +5 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,10 @@ int DH_meth_set_generate_params(DH_METHOD *dhm, EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN, \ EVP_PKEY_CTRL_DH_NID, nid, NULL) # define EVP_PKEY_CTX_set_dh_pad(ctx, pad) \ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_DERIVE, \ EVP_PKEY_CTRL_DH_PAD, pad, NULL) # define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \ EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ EVP_PKEY_OP_DERIVE, \ Loading Loading @@ -312,6 +316,7 @@ int DH_meth_set_generate_params(DH_METHOD *dhm, # define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13) # define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14) # define EVP_PKEY_CTRL_DH_NID (EVP_PKEY_ALG_CTRL + 15) # define EVP_PKEY_CTRL_DH_PAD (EVP_PKEY_ALG_CTRL + 16) /* KDF types */ # define EVP_PKEY_DH_KDF_NONE 1 Loading