Lines Matching refs:dh

77   DH *dh = (DH *)OPENSSL_malloc(sizeof(DH));  in DH_new()  local
78 if (dh == NULL) { in DH_new()
83 memset(dh, 0, sizeof(DH)); in DH_new()
85 CRYPTO_MUTEX_init(&dh->method_mont_p_lock); in DH_new()
87 dh->references = 1; in DH_new()
88 CRYPTO_new_ex_data(&dh->ex_data); in DH_new()
90 return dh; in DH_new()
93 void DH_free(DH *dh) { in DH_free() argument
94 if (dh == NULL) { in DH_free()
98 if (!CRYPTO_refcount_dec_and_test_zero(&dh->references)) { in DH_free()
102 CRYPTO_free_ex_data(&g_ex_data_class, dh, &dh->ex_data); in DH_free()
104 BN_MONT_CTX_free(dh->method_mont_p); in DH_free()
105 BN_clear_free(dh->p); in DH_free()
106 BN_clear_free(dh->g); in DH_free()
107 BN_clear_free(dh->q); in DH_free()
108 BN_clear_free(dh->j); in DH_free()
109 OPENSSL_free(dh->seed); in DH_free()
110 BN_clear_free(dh->counter); in DH_free()
111 BN_clear_free(dh->pub_key); in DH_free()
112 BN_clear_free(dh->priv_key); in DH_free()
113 CRYPTO_MUTEX_cleanup(&dh->method_mont_p_lock); in DH_free()
115 OPENSSL_free(dh); in DH_free()
118 int DH_generate_parameters_ex(DH *dh, int prime_bits, int generator, BN_GENCB *cb) { in DH_generate_parameters_ex() argument
162 if (dh->p == NULL) { in DH_generate_parameters_ex()
163 dh->p = BN_new(); in DH_generate_parameters_ex()
164 if (dh->p == NULL) { in DH_generate_parameters_ex()
168 if (dh->g == NULL) { in DH_generate_parameters_ex()
169 dh->g = BN_new(); in DH_generate_parameters_ex()
170 if (dh->g == NULL) { in DH_generate_parameters_ex()
211 if (!BN_generate_prime_ex(dh->p, prime_bits, 1, t1, t2, cb)) { in DH_generate_parameters_ex()
217 if (!BN_set_word(dh->g, g)) { in DH_generate_parameters_ex()
234 int DH_generate_key(DH *dh) { in DH_generate_key() argument
243 if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) { in DH_generate_key()
253 if (dh->priv_key == NULL) { in DH_generate_key()
260 priv_key = dh->priv_key; in DH_generate_key()
263 if (dh->pub_key == NULL) { in DH_generate_key()
269 pub_key = dh->pub_key; in DH_generate_key()
272 mont = BN_MONT_CTX_set_locked(&dh->method_mont_p, &dh->method_mont_p_lock, in DH_generate_key()
273 dh->p, ctx); in DH_generate_key()
279 if (dh->q) { in DH_generate_key()
281 if (!BN_rand_range(priv_key, dh->q)) { in DH_generate_key()
287 DH_check_standard_parameters(dh); in DH_generate_key()
288 l = dh->priv_length ? dh->priv_length : BN_num_bits(dh->p) - 1; in DH_generate_key()
296 if (!BN_mod_exp_mont(pub_key, dh->g, &local_priv, dh->p, ctx, mont)) { in DH_generate_key()
300 dh->pub_key = pub_key; in DH_generate_key()
301 dh->priv_key = priv_key; in DH_generate_key()
309 if (dh->pub_key == NULL) { in DH_generate_key()
312 if (dh->priv_key == NULL) { in DH_generate_key()
319 int DH_compute_key(unsigned char *out, const BIGNUM *peers_key, DH *dh) { in DH_compute_key() argument
327 if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) { in DH_compute_key()
342 if (dh->priv_key == NULL) { in DH_compute_key()
347 mont = BN_MONT_CTX_set_locked(&dh->method_mont_p, &dh->method_mont_p_lock, in DH_compute_key()
348 dh->p, ctx); in DH_compute_key()
353 if (!DH_check_pub_key(dh, peers_key, &check_result) || check_result) { in DH_compute_key()
358 BN_with_flags(&local_priv, dh->priv_key, BN_FLG_CONSTTIME); in DH_compute_key()
359 if (!BN_mod_exp_mont(shared_key, peers_key, &local_priv, dh->p, ctx, in DH_compute_key()
376 int DH_size(const DH *dh) { return BN_num_bytes(dh->p); } in DH_size() argument
378 unsigned DH_num_bits(const DH *dh) { return BN_num_bits(dh->p); } in DH_num_bits() argument
380 int DH_up_ref(DH *dh) { in DH_up_ref() argument
381 CRYPTO_refcount_inc(&dh->references); in DH_up_ref()
433 DH *DHparams_dup(const DH *dh) { in DHparams_dup() argument
439 if (!int_dh_param_copy(ret, dh, -1)) { in DHparams_dup()