• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/openssl/crypto/dh/

Lines Matching refs:dh

1 /* crypto/dh/dh_key.c */
63 #include <openssl/dh.h>
67 static int generate_key(DH *dh);
68 static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh);
69 static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
73 static int dh_init(DH *dh);
74 static int dh_finish(DH *dh);
76 int DH_generate_key(DH *dh)
78 return dh->meth->generate_key(dh);
81 int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
83 return dh->meth->compute_key(key, pub_key, dh);
102 static int generate_key(DH *dh)
114 if (dh->priv_key == NULL)
121 priv_key=dh->priv_key;
123 if (dh->pub_key == NULL)
129 pub_key=dh->pub_key;
131 if ((dh->method_mont_p == NULL) && (dh->flags & DH_FLAG_CACHE_MONT_P))
133 if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
134 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p,
135 dh->p,ctx)) goto err;
137 mont=(BN_MONT_CTX *)dh->method_mont_p;
141 l = dh->length ? dh->length : BN_num_bits(dh->p)-1; /* secret exponent length */
144 if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, priv_key,dh->p,ctx,mont))
147 dh->pub_key=pub_key;
148 dh->priv_key=priv_key;
154 if ((pub_key != NULL) && (dh->pub_key == NULL)) BN_free(pub_key);
155 if ((priv_key != NULL) && (dh->priv_key == NULL)) BN_free(priv_key);
160 static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
172 if (dh->priv_key == NULL)
177 if ((dh->method_mont_p == NULL) && (dh->flags & DH_FLAG_CACHE_MONT_P))
179 if ((dh->method_mont_p=(char *)BN_MONT_CTX_new()) != NULL)
180 if (!BN_MONT_CTX_set((BN_MONT_CTX *)dh->method_mont_p,
181 dh->p,ctx)) goto err;
184 mont=(BN_MONT_CTX *)dh->method_mont_p;
185 if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key,dh->p,ctx,mont))
198 static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
213 static int dh_init(DH *dh)
215 dh->flags |= DH_FLAG_CACHE_MONT_P;
219 static int dh_finish(DH *dh)
221 if(dh->method_mont_p)
222 BN_MONT_CTX_free((BN_MONT_CTX *)dh->method_mont_p);