Lines Matching refs:dh
28 int DH_check_params_ex(const DH *dh) in DH_check_params_ex() argument
32 if (!DH_check_params(dh, &errflags)) in DH_check_params_ex()
48 int DH_check_params(const DH *dh, int *ret) in DH_check_params() argument
57 nid = DH_get_nid((DH *)dh); in DH_check_params()
65 return ossl_ffc_params_FIPS186_4_validate(dh->libctx, &dh->params, in DH_check_params()
69 int DH_check_params(const DH *dh, int *ret) in DH_check_params() argument
76 ctx = BN_CTX_new_ex(dh->libctx); in DH_check_params()
84 if (!BN_is_odd(dh->params.p)) in DH_check_params()
86 if (BN_is_negative(dh->params.g) in DH_check_params()
87 || BN_is_zero(dh->params.g) in DH_check_params()
88 || BN_is_one(dh->params.g)) in DH_check_params()
90 if (BN_copy(tmp, dh->params.p) == NULL || !BN_sub_word(tmp, 1)) in DH_check_params()
92 if (BN_cmp(dh->params.g, tmp) >= 0) in DH_check_params()
94 if (BN_num_bits(dh->params.p) < DH_MIN_MODULUS_BITS) in DH_check_params()
96 if (BN_num_bits(dh->params.p) > OPENSSL_DH_MAX_MODULUS_BITS) in DH_check_params()
111 int DH_check_ex(const DH *dh) in DH_check_ex() argument
115 if (!DH_check(dh, &errflags)) in DH_check_ex()
141 int DH_check(const DH *dh, int *ret) in DH_check() argument
144 return DH_check_params(dh, ret); in DH_check()
149 int nid = DH_get_nid((DH *)dh); in DH_check()
156 if (BN_num_bits(dh->params.p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) { in DH_check()
162 if (!DH_check_params(dh, ret)) in DH_check()
165 ctx = BN_CTX_new_ex(dh->libctx); in DH_check()
174 if (dh->params.q != NULL) { in DH_check()
175 if (BN_ucmp(dh->params.p, dh->params.q) > 0) in DH_check()
182 if (BN_cmp(dh->params.g, BN_value_one()) <= 0) in DH_check()
184 else if (BN_cmp(dh->params.g, dh->params.p) >= 0) in DH_check()
188 if (!BN_mod_exp(t1, dh->params.g, dh->params.q, dh->params.p, ctx)) in DH_check()
193 r = BN_check_prime(dh->params.q, ctx, NULL); in DH_check()
199 if (!BN_div(t1, t2, dh->params.p, dh->params.q, ctx)) in DH_check()
203 if (dh->params.j != NULL in DH_check()
204 && BN_cmp(dh->params.j, t1)) in DH_check()
208 r = BN_check_prime(dh->params.p, ctx, NULL); in DH_check()
213 else if (dh->params.q == NULL) { in DH_check()
214 if (!BN_rshift1(t1, dh->params.p)) in DH_check()
230 int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key) in DH_check_pub_key_ex() argument
234 if (!DH_check_pub_key(dh, pub_key, &errflags)) in DH_check_pub_key_ex()
250 int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) in DH_check_pub_key() argument
253 if (BN_num_bits(dh->params.p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) { in DH_check_pub_key()
259 if (dh->params.q != NULL && BN_ucmp(dh->params.p, dh->params.q) < 0) { in DH_check_pub_key()
264 return ossl_ffc_validate_public_key(&dh->params, pub_key, ret); in DH_check_pub_key()
272 int ossl_dh_check_pub_key_partial(const DH *dh, const BIGNUM *pub_key, int *ret) in ossl_dh_check_pub_key_partial() argument
274 return ossl_ffc_validate_public_key_partial(&dh->params, pub_key, ret) in ossl_dh_check_pub_key_partial()
278 int ossl_dh_check_priv_key(const DH *dh, const BIGNUM *priv_key, int *ret) in ossl_dh_check_priv_key() argument
288 if (dh->params.q != NULL) { in ossl_dh_check_priv_key()
289 upper = dh->params.q; in ossl_dh_check_priv_key()
291 } else if (dh->params.p != NULL) { in ossl_dh_check_priv_key()
296 int length = dh->length; in ossl_dh_check_priv_key()
299 length = BN_num_bits(dh->params.p) - 1; in ossl_dh_check_priv_key()
313 if (DH_get_nid((DH *)dh) != NID_undef && dh->length != 0) { in ossl_dh_check_priv_key()
314 if (!BN_lshift(two_powN, BN_value_one(), dh->length)) in ossl_dh_check_priv_key()
316 if (BN_cmp(two_powN, dh->params.q) < 0) in ossl_dh_check_priv_key()
332 int ossl_dh_check_pairwise(const DH *dh) in ossl_dh_check_pairwise() argument
338 if (dh->params.p == NULL in ossl_dh_check_pairwise()
339 || dh->params.g == NULL in ossl_dh_check_pairwise()
340 || dh->priv_key == NULL in ossl_dh_check_pairwise()
341 || dh->pub_key == NULL) in ossl_dh_check_pairwise()
344 ctx = BN_CTX_new_ex(dh->libctx); in ossl_dh_check_pairwise()
352 if (!ossl_dh_generate_public_key(ctx, dh, dh->priv_key, pub_key)) in ossl_dh_check_pairwise()
355 ret = BN_cmp(pub_key, dh->pub_key) == 0; in ossl_dh_check_pairwise()