• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/ap/gpl/timemachine/openssl-0.9.8e/crypto/dh/

Lines Matching refs:dh

1 /* crypto/dh/dh_key.c */
63 #include <openssl/dh.h>
65 static int generate_key(DH *dh);
66 static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
67 static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
71 static int dh_init(DH *dh);
72 static int dh_finish(DH *dh);
74 int DH_generate_key(DH *dh)
76 return dh->meth->generate_key(dh);
79 int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
81 return dh->meth->compute_key(key, pub_key, dh);
101 static int generate_key(DH *dh)
113 if (dh->priv_key == NULL)
120 priv_key=dh->priv_key;
122 if (dh->pub_key == NULL)
128 pub_key=dh->pub_key;
131 if (dh->flags & DH_FLAG_CACHE_MONT_P)
133 mont = BN_MONT_CTX_set_locked(&dh->method_mont_p,
134 CRYPTO_LOCK_DH, dh->p, ctx);
141 l = dh->length ? dh->length : BN_num_bits(dh->p)-1; /* secret exponent length */
149 if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0)
158 if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, prk, dh->p, ctx, mont)) goto err;
161 dh->pub_key=pub_key;
162 dh->priv_key=priv_key;
168 if ((pub_key != NULL) && (dh->pub_key == NULL)) BN_free(pub_key);
169 if ((priv_key != NULL) && (dh->priv_key == NULL)) BN_free(priv_key);
174 static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
182 if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS)
193 if (dh->priv_key == NULL)
199 if (dh->flags & DH_FLAG_CACHE_MONT_P)
201 mont = BN_MONT_CTX_set_locked(&dh->method_mont_p,
202 CRYPTO_LOCK_DH, dh->p, ctx);
203 if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0)
206 BN_set_flags(dh->priv_key, BN_FLG_EXP_CONSTTIME);
212 if (!DH_check_pub_key(dh, pub_key, &check_result) || check_result)
218 if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key,dh->p,ctx,mont))
234 static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
242 if (a->top == 1 && ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) != 0))
252 static int dh_init(DH *dh)
254 dh->flags |= DH_FLAG_CACHE_MONT_P;
258 static int dh_finish(DH *dh)
260 if(dh->method_mont_p)
261 BN_MONT_CTX_free(dh->method_mont_p);