Lines Matching refs:pdhctx
84 PROV_DH_CTX *pdhctx; in dh_newctx() local
89 pdhctx = OPENSSL_zalloc(sizeof(PROV_DH_CTX)); in dh_newctx()
90 if (pdhctx == NULL) in dh_newctx()
92 OSSL_FIPS_IND_INIT(pdhctx) in dh_newctx()
93 pdhctx->libctx = PROV_LIBCTX_OF(provctx); in dh_newctx()
94 pdhctx->kdf_type = PROV_DH_KDF_NONE; in dh_newctx()
95 return pdhctx; in dh_newctx()
124 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_init() local
127 || pdhctx == NULL in dh_init()
131 DH_free(pdhctx->dh); in dh_init()
132 pdhctx->dh = vdh; in dh_init()
133 pdhctx->kdf_type = PROV_DH_KDF_NONE; in dh_init()
135 OSSL_FIPS_IND_SET_APPROVED(pdhctx) in dh_init()
136 if (!dh_set_ctx_params(pdhctx, params)) in dh_init()
139 if (!dh_check_key(pdhctx)) in dh_init()
162 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_set_peer() local
165 || pdhctx == NULL in dh_set_peer()
167 || !dh_match_params(vdh, pdhctx->dh) in dh_set_peer()
170 DH_free(pdhctx->dhpeer); in dh_set_peer()
171 pdhctx->dhpeer = vdh; in dh_set_peer()
179 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_plain_derive() local
184 if (pdhctx->dh == NULL || pdhctx->dhpeer == NULL) { in dh_plain_derive()
189 dhsize = (size_t)DH_size(pdhctx->dh); in dh_plain_derive()
199 DH_get0_key(pdhctx->dhpeer, &pub_key, NULL); in dh_plain_derive()
201 ret = DH_compute_key_padded(secret, pub_key, pdhctx->dh); in dh_plain_derive()
203 ret = DH_compute_key(secret, pub_key, pdhctx->dh); in dh_plain_derive()
214 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_X9_42_kdf_derive() local
220 *secretlen = pdhctx->kdf_outlen; in dh_X9_42_kdf_derive()
224 if (pdhctx->kdf_outlen > outlen) { in dh_X9_42_kdf_derive()
228 if (!dh_plain_derive(pdhctx, NULL, &stmplen, 0, 1)) in dh_X9_42_kdf_derive()
232 if (!dh_plain_derive(pdhctx, stmp, &stmplen, stmplen, 1)) in dh_X9_42_kdf_derive()
236 if (pdhctx->kdf_type == PROV_DH_KDF_X9_42_ASN1) { in dh_X9_42_kdf_derive()
237 if (!ossl_dh_kdf_X9_42_asn1(secret, pdhctx->kdf_outlen, in dh_X9_42_kdf_derive()
239 pdhctx->kdf_cekalg, in dh_X9_42_kdf_derive()
240 pdhctx->kdf_ukm, in dh_X9_42_kdf_derive()
241 pdhctx->kdf_ukmlen, in dh_X9_42_kdf_derive()
242 pdhctx->kdf_md, in dh_X9_42_kdf_derive()
243 pdhctx->libctx, NULL)) in dh_X9_42_kdf_derive()
246 *secretlen = pdhctx->kdf_outlen; in dh_X9_42_kdf_derive()
256 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_derive() local
261 switch (pdhctx->kdf_type) { in dh_derive()
263 return dh_plain_derive(pdhctx, secret, psecretlen, outlen, in dh_derive()
264 pdhctx->pad); in dh_derive()
266 return dh_X9_42_kdf_derive(pdhctx, secret, psecretlen, outlen); in dh_derive()
275 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_freectx() local
277 OPENSSL_free(pdhctx->kdf_cekalg); in dh_freectx()
278 DH_free(pdhctx->dh); in dh_freectx()
279 DH_free(pdhctx->dhpeer); in dh_freectx()
280 EVP_MD_free(pdhctx->kdf_md); in dh_freectx()
281 OPENSSL_clear_free(pdhctx->kdf_ukm, pdhctx->kdf_ukmlen); in dh_freectx()
283 OPENSSL_free(pdhctx); in dh_freectx()
342 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_set_ctx_params() local
348 if (pdhctx == NULL) in dh_set_ctx_params()
353 if (!OSSL_FIPS_IND_SET_CTX_PARAM(pdhctx, OSSL_FIPS_IND_SETTABLE0, params, in dh_set_ctx_params()
356 if (!OSSL_FIPS_IND_SET_CTX_PARAM(pdhctx, OSSL_FIPS_IND_SETTABLE1, params, in dh_set_ctx_params()
367 pdhctx->kdf_type = PROV_DH_KDF_NONE; in dh_set_ctx_params()
369 pdhctx->kdf_type = PROV_DH_KDF_X9_42_ASN1; in dh_set_ctx_params()
390 EVP_MD_free(pdhctx->kdf_md); in dh_set_ctx_params()
391 pdhctx->kdf_md = EVP_MD_fetch(pdhctx->libctx, name, mdprops); in dh_set_ctx_params()
392 if (pdhctx->kdf_md == NULL) in dh_set_ctx_params()
395 if (EVP_MD_xof(pdhctx->kdf_md)) { in dh_set_ctx_params()
400 if (!digest_check(pdhctx, pdhctx->kdf_md)) { in dh_set_ctx_params()
401 EVP_MD_free(pdhctx->kdf_md); in dh_set_ctx_params()
402 pdhctx->kdf_md = NULL; in dh_set_ctx_params()
414 pdhctx->kdf_outlen = outlen; in dh_set_ctx_params()
422 OPENSSL_free(pdhctx->kdf_ukm); in dh_set_ctx_params()
423 pdhctx->kdf_ukm = NULL; in dh_set_ctx_params()
424 pdhctx->kdf_ukmlen = 0; in dh_set_ctx_params()
429 pdhctx->kdf_ukm = tmp_ukm; in dh_set_ctx_params()
430 pdhctx->kdf_ukmlen = tmp_ukmlen; in dh_set_ctx_params()
438 pdhctx->pad = pad ? 1 : 0; in dh_set_ctx_params()
445 OPENSSL_free(pdhctx->kdf_cekalg); in dh_set_ctx_params()
446 pdhctx->kdf_cekalg = NULL; in dh_set_ctx_params()
450 pdhctx->kdf_cekalg = OPENSSL_strdup(name); in dh_set_ctx_params()
451 if (pdhctx->kdf_cekalg == NULL) in dh_set_ctx_params()
496 PROV_DH_CTX *pdhctx = (PROV_DH_CTX *)vpdhctx; in dh_get_ctx_params() local
499 if (pdhctx == NULL) in dh_get_ctx_params()
506 switch (pdhctx->kdf_type) { in dh_get_ctx_params()
523 && !OSSL_PARAM_set_utf8_string(p, pdhctx->kdf_md == NULL in dh_get_ctx_params()
525 : EVP_MD_get0_name(pdhctx->kdf_md))) { in dh_get_ctx_params()
530 if (p != NULL && !OSSL_PARAM_set_size_t(p, pdhctx->kdf_outlen)) in dh_get_ctx_params()
535 && !OSSL_PARAM_set_octet_ptr(p, pdhctx->kdf_ukm, pdhctx->kdf_ukmlen)) in dh_get_ctx_params()
540 && !OSSL_PARAM_set_utf8_string(p, pdhctx->kdf_cekalg == NULL in dh_get_ctx_params()
541 ? "" : pdhctx->kdf_cekalg)) in dh_get_ctx_params()
543 if (!OSSL_FIPS_IND_GET_CTX_PARAM(pdhctx, params)) in dh_get_ctx_params()