Lines Matching refs:dh
40 #include <dh.h>
85 ltm_dh_generate_key(DH *dh)
88 int have_private_key = (dh->priv_key != NULL);
92 if (dh->p == NULL || dh->g == NULL)
97 size_t bits = BN_num_bits(dh->p);
99 if (dh->priv_key)
100 BN_free(dh->priv_key);
102 dh->priv_key = BN_new();
103 if (dh->priv_key == NULL)
105 if (!BN_rand(dh->priv_key, bits - 1, 0, 0)) {
106 BN_clear_free(dh->priv_key);
107 dh->priv_key = NULL;
111 if (dh->pub_key)
112 BN_free(dh->pub_key);
116 BN2mpz(&priv_key, dh->priv_key);
117 BN2mpz(&g, dh->g);
118 BN2mpz(&p, dh->p);
126 dh->pub_key = mpz2BN(&pub);
128 if (dh->pub_key == NULL)
131 if (DH_check_pubkey(dh, dh->pub_key, &codes) && codes == 0)
138 if (!have_private_key && dh->priv_key) {
139 BN_free(dh->priv_key);
140 dh->priv_key = NULL;
142 if (dh->pub_key) {
143 BN_free(dh->pub_key);
144 dh->pub_key = NULL;
153 ltm_dh_compute_key(unsigned char *shared, const BIGNUM * pub, DH *dh)
158 if (dh->pub_key == NULL || dh->g == NULL || dh->priv_key == NULL)
162 BN2mpz(&p, dh->p);
174 BN2mpz(&priv_key, dh->priv_key);
193 ltm_dh_generate_params(DH *dh, int a, int b, BN_GENCB *callback)
200 ltm_dh_init(DH *dh)
206 ltm_dh_finish(DH *dh)