Lines Matching refs:dh
42 #include <dh.h>
87 ltm_dh_generate_key(DH *dh)
90 int have_private_key = (dh->priv_key != NULL);
94 if (dh->p == NULL || dh->g == NULL)
99 size_t bits = BN_num_bits(dh->p);
101 if (dh->priv_key)
102 BN_free(dh->priv_key);
104 dh->priv_key = BN_new();
105 if (dh->priv_key == NULL)
107 if (!BN_rand(dh->priv_key, bits - 1, 0, 0)) {
108 BN_clear_free(dh->priv_key);
109 dh->priv_key = NULL;
113 if (dh->pub_key)
114 BN_free(dh->pub_key);
118 BN2mpz(&priv_key, dh->priv_key);
119 BN2mpz(&g, dh->g);
120 BN2mpz(&p, dh->p);
128 dh->pub_key = mpz2BN(&pub);
130 if (dh->pub_key == NULL)
133 if (DH_check_pubkey(dh, dh->pub_key, &codes) && codes == 0)
140 if (!have_private_key && dh->priv_key) {
141 BN_free(dh->priv_key);
142 dh->priv_key = NULL;
144 if (dh->pub_key) {
145 BN_free(dh->pub_key);
146 dh->pub_key = NULL;
155 ltm_dh_compute_key(unsigned char *shared, const BIGNUM * pub, DH *dh)
160 if (dh->pub_key == NULL || dh->g == NULL || dh->priv_key == NULL)
164 BN2mpz(&p, dh->p);
176 BN2mpz(&priv_key, dh->priv_key);
195 ltm_dh_generate_params(DH *dh, int a, int b, BN_GENCB *callback)
202 ltm_dh_init(DH *dh)
208 ltm_dh_finish(DH *dh)