Home | History | Annotate | Download | only in openssh

Lines Matching refs:dh

1 /* $OpenBSD: dh.c,v 1.48 2009/10/01 11:37:33 grunk Exp $ */
31 #include <openssl/dh.h>
38 #include "dh.h"
124 DH *
193 dh_pub_is_valid(DH *dh, BIGNUM *dh_pub)
201 logit("invalid public DH value: negative");
205 logit("invalid public DH value: <= 1");
213 if (!BN_sub(tmp, dh->p, BN_value_one()) ||
216 logit("invalid public DH value: >= p-1");
224 debug2("bits set: %d/%d", bits_set, BN_num_bits(dh->p));
230 logit("invalid public DH value (%d/%d)", bits_set, BN_num_bits(dh->p));
235 dh_gen_key(DH *dh, int need)
239 if (dh->p == NULL)
240 fatal("dh_gen_key: dh->p == NULL");
241 if (need > INT_MAX / 2 || 2 * need >= BN_num_bits(dh->p))
243 BN_num_bits(dh->p), 2*need);
245 if (dh->priv_key != NULL)
246 BN_clear_free(dh->priv_key);
247 if ((dh->priv_key = BN_new()) == NULL)
250 if (!BN_rand(dh->priv_key, 2*need, 0, 0))
252 if (DH_generate_key(dh) == 0)
254 for (i = 0, bits_set = 0; i <= BN_num_bits(dh->priv_key); i++)
255 if (BN_is_bit_set(dh->priv_key, i))
258 bits_set, BN_num_bits(dh->priv_key));
261 } while (!dh_pub_is_valid(dh, dh->pub_key));
264 DH *
267 DH *dh;
269 if ((dh = DH_new()) == NULL)
272 if (BN_hex2bn(&dh->p, modulus) == 0)
274 if (BN_hex2bn(&dh->g, gen) == 0)
277 return (dh);
285 DH *
288 DH *dh;
290 if ((dh = DH_new()) == NULL)
292 dh->p = modulus;
293 dh->g = gen;
295 return (dh);
298 DH *
312 DH *