Lines Matching defs:dh
73 # include <openssl/dh.h>
123 static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
127 DH *dh);
128 static int ubsec_dh_generate_key(DH *dh);
741 /* This function is aliased to mod_exp (with the dh and mont dropped). */
742 static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
901 DH *dh)
905 k_len = BN_num_bits(dh->p);
911 ret = meth->compute_key(key, pub_key, dh);
916 (unsigned char *)dh->priv_key->d,
917 BN_num_bits(dh->priv_key),
920 (unsigned char *)dh->p->d,
921 BN_num_bits(dh->p), key,
929 ret = meth->compute_key(key, pub_key, dh);
941 static int ubsec_dh_generate_key(DH *dh)
952 if (dh->priv_key == NULL) {
956 priv_key_len = BN_num_bits(dh->p);
957 if (bn_wexpand(priv_key, dh->p->top) == NULL)
960 if (!BN_rand_range(priv_key, dh->p))
965 priv_key = dh->priv_key;
968 if (dh->pub_key == NULL) {
972 pub_key_len = BN_num_bits(dh->p);
973 if (bn_wexpand(pub_key, dh->p->top) == NULL)
976 pub_key = dh->pub_key;
983 ret = meth->generate_key(dh);
992 (unsigned char *)dh->g->d,
993 BN_num_bits(dh->g),
994 (unsigned char *)dh->p->d,
995 BN_num_bits(dh->p), 0, 0,
1004 ret = meth->generate_key(dh);
1011 dh->pub_key = pub_key;
1012 dh->pub_key->top = (pub_key_len + BN_BITS2 - 1) / BN_BITS2;
1013 dh->priv_key = priv_key;
1014 dh->priv_key->top = (priv_key_len + BN_BITS2 - 1) / BN_BITS2;