Lines Matching refs:dctx
51 DH_PKEY_CTX *dctx; in pkey_dh_init() local
53 if ((dctx = OPENSSL_zalloc(sizeof(*dctx))) == NULL) { in pkey_dh_init()
57 dctx->prime_len = 2048; in pkey_dh_init()
58 dctx->subprime_len = -1; in pkey_dh_init()
59 dctx->generator = 2; in pkey_dh_init()
60 dctx->kdf_type = EVP_PKEY_DH_KDF_NONE; in pkey_dh_init()
62 ctx->data = dctx; in pkey_dh_init()
63 ctx->keygen_info = dctx->gentmp; in pkey_dh_init()
71 DH_PKEY_CTX *dctx = ctx->data; in pkey_dh_cleanup() local
72 if (dctx != NULL) { in pkey_dh_cleanup()
73 OPENSSL_free(dctx->kdf_ukm); in pkey_dh_cleanup()
74 ASN1_OBJECT_free(dctx->kdf_oid); in pkey_dh_cleanup()
75 OPENSSL_free(dctx); in pkey_dh_cleanup()
82 DH_PKEY_CTX *dctx, *sctx; in pkey_dh_copy() local
86 dctx = dst->data; in pkey_dh_copy()
87 dctx->prime_len = sctx->prime_len; in pkey_dh_copy()
88 dctx->subprime_len = sctx->subprime_len; in pkey_dh_copy()
89 dctx->generator = sctx->generator; in pkey_dh_copy()
90 dctx->use_dsa = sctx->use_dsa; in pkey_dh_copy()
91 dctx->pad = sctx->pad; in pkey_dh_copy()
92 dctx->md = sctx->md; in pkey_dh_copy()
93 dctx->rfc5114_param = sctx->rfc5114_param; in pkey_dh_copy()
94 dctx->param_nid = sctx->param_nid; in pkey_dh_copy()
96 dctx->kdf_type = sctx->kdf_type; in pkey_dh_copy()
97 dctx->kdf_oid = OBJ_dup(sctx->kdf_oid); in pkey_dh_copy()
98 if (dctx->kdf_oid == NULL) in pkey_dh_copy()
100 dctx->kdf_md = sctx->kdf_md; in pkey_dh_copy()
102 dctx->kdf_ukm = OPENSSL_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen); in pkey_dh_copy()
103 if (dctx->kdf_ukm == NULL) in pkey_dh_copy()
105 dctx->kdf_ukmlen = sctx->kdf_ukmlen; in pkey_dh_copy()
107 dctx->kdf_outlen = sctx->kdf_outlen; in pkey_dh_copy()
113 DH_PKEY_CTX *dctx = ctx->data; in pkey_dh_ctrl() local
118 dctx->prime_len = p1; in pkey_dh_ctrl()
122 if (dctx->use_dsa == 0) in pkey_dh_ctrl()
124 dctx->subprime_len = p1; in pkey_dh_ctrl()
128 dctx->pad = p1; in pkey_dh_ctrl()
132 if (dctx->use_dsa) in pkey_dh_ctrl()
134 dctx->generator = p1; in pkey_dh_ctrl()
145 dctx->use_dsa = p1; in pkey_dh_ctrl()
149 if (p1 < 1 || p1 > 3 || dctx->param_nid != NID_undef) in pkey_dh_ctrl()
151 dctx->rfc5114_param = p1; in pkey_dh_ctrl()
155 if (p1 <= 0 || dctx->rfc5114_param != 0) in pkey_dh_ctrl()
157 dctx->param_nid = p1; in pkey_dh_ctrl()
166 return dctx->kdf_type; in pkey_dh_ctrl()
173 dctx->kdf_type = p1; in pkey_dh_ctrl()
177 dctx->kdf_md = p2; in pkey_dh_ctrl()
181 *(const EVP_MD **)p2 = dctx->kdf_md; in pkey_dh_ctrl()
187 dctx->kdf_outlen = (size_t)p1; in pkey_dh_ctrl()
191 *(int *)p2 = dctx->kdf_outlen; in pkey_dh_ctrl()
195 OPENSSL_free(dctx->kdf_ukm); in pkey_dh_ctrl()
196 dctx->kdf_ukm = p2; in pkey_dh_ctrl()
198 dctx->kdf_ukmlen = p1; in pkey_dh_ctrl()
200 dctx->kdf_ukmlen = 0; in pkey_dh_ctrl()
204 *(unsigned char **)p2 = dctx->kdf_ukm; in pkey_dh_ctrl()
205 return dctx->kdf_ukmlen; in pkey_dh_ctrl()
208 ASN1_OBJECT_free(dctx->kdf_oid); in pkey_dh_ctrl()
209 dctx->kdf_oid = p2; in pkey_dh_ctrl()
213 *(ASN1_OBJECT **)p2 = dctx->kdf_oid; in pkey_dh_ctrl()
231 DH_PKEY_CTX *dctx = ctx->data; in pkey_dh_ctrl_str() local
236 dctx->rfc5114_param = len; in pkey_dh_ctrl_str()
240 DH_PKEY_CTX *dctx = ctx->data; in pkey_dh_ctrl_str() local
247 dctx->param_nid = nid; in pkey_dh_ctrl_str()
288 static DSA *dsa_dh_generate(DH_PKEY_CTX *dctx, BN_GENCB *pcb) in dsa_dh_generate() argument
292 int prime_len = dctx->prime_len; in dsa_dh_generate()
293 int subprime_len = dctx->subprime_len; in dsa_dh_generate()
294 const EVP_MD *md = dctx->md; in dsa_dh_generate()
295 if (dctx->use_dsa > 2) in dsa_dh_generate()
312 if (dctx->use_dsa == 1) in dsa_dh_generate()
315 else if (dctx->use_dsa == 2) in dsa_dh_generate()
330 DH_PKEY_CTX *dctx = ctx->data; in pkey_dh_paramgen() local
333 if (dctx->rfc5114_param) { in pkey_dh_paramgen()
334 switch (dctx->rfc5114_param) { in pkey_dh_paramgen()
354 if (dctx->param_nid != 0) { in pkey_dh_paramgen()
355 if ((dh = DH_new_by_nid(dctx->param_nid)) == NULL) in pkey_dh_paramgen()
369 if (dctx->use_dsa) { in pkey_dh_paramgen()
371 dsa_dh = dsa_dh_generate(dctx, pcb); in pkey_dh_paramgen()
389 dctx->prime_len, dctx->generator, pcb); in pkey_dh_paramgen()
400 DH_PKEY_CTX *dctx = ctx->data; in pkey_dh_keygen() local
403 if (ctx->pkey == NULL && dctx->param_nid == 0) { in pkey_dh_keygen()
407 if (dctx->param_nid != 0) in pkey_dh_keygen()
408 dh = DH_new_by_nid(dctx->param_nid); in pkey_dh_keygen()
425 DH_PKEY_CTX *dctx = ctx->data; in pkey_dh_derive() local
433 if (dctx->kdf_type == EVP_PKEY_DH_KDF_NONE) { in pkey_dh_derive()
438 if (dctx->pad) in pkey_dh_derive()
448 else if (dctx->kdf_type == EVP_PKEY_DH_KDF_X9_42) { in pkey_dh_derive()
452 if (!dctx->kdf_outlen || !dctx->kdf_oid) in pkey_dh_derive()
455 *keylen = dctx->kdf_outlen; in pkey_dh_derive()
458 if (*keylen != dctx->kdf_outlen) in pkey_dh_derive()
468 if (!DH_KDF_X9_42(key, *keylen, Z, Zlen, dctx->kdf_oid, in pkey_dh_derive()
469 dctx->kdf_ukm, dctx->kdf_ukmlen, dctx->kdf_md)) in pkey_dh_derive()
471 *keylen = dctx->kdf_outlen; in pkey_dh_derive()