• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/openssl/crypto/dh/

Lines Matching defs: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,
70 static int dh_init(DH *dh);
71 static int dh_finish(DH *dh);
73 int DH_generate_key(DH *dh)
76 if (FIPS_mode() && !(dh->meth->flags & DH_FLAG_FIPS_METHOD)
77 && !(dh->flags & DH_FLAG_NON_FIPS_ALLOW)) {
82 return dh->meth->generate_key(dh);
85 int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
88 if (FIPS_mode() && !(dh->meth->flags & DH_FLAG_FIPS_METHOD)
89 && !(dh->flags & DH_FLAG_NON_FIPS_ALLOW)) {
94 return dh->meth->compute_key(key, pub_key, dh);
97 int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh)
100 rv = dh->meth->compute_key(key, pub_key, dh);
103 pad = BN_num_bytes(dh->p) - rv;
128 static int generate_key(DH *dh)
141 if (dh->priv_key == NULL) {
147 priv_key = dh->priv_key;
149 if (dh->pub_key == NULL) {
154 pub_key = dh->pub_key;
156 if (dh->flags & DH_FLAG_CACHE_MONT_P) {
157 mont = BN_MONT_CTX_set_locked(&dh->method_mont_p,
158 CRYPTO_LOCK_DH, dh->p, ctx);
164 if (dh->q) {
166 if (!BN_rand_range(priv_key, dh->q))
172 l = dh->length ? dh->length : BN_num_bits(dh->p) - 1;
182 if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0) {
189 if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, prk, dh->p, ctx, mont))
193 dh->pub_key = pub_key;
194 dh->priv_key = priv_key;
200 if ((pub_key != NULL) && (dh->pub_key == NULL))
202 if ((priv_key != NULL) && (dh->priv_key == NULL))
208 static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
216 if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) {
227 if (dh->priv_key == NULL) {
232 if (dh->flags & DH_FLAG_CACHE_MONT_P) {
233 mont = BN_MONT_CTX_set_locked(&dh->method_mont_p,
234 CRYPTO_LOCK_DH, dh->p, ctx);
235 if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0) {
237 BN_set_flags(dh->priv_key, BN_FLG_CONSTTIME);
243 if (!DH_check_pub_key(dh, pub_key, &check_result) || check_result) {
248 if (!dh->
249 meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key, dh->p, ctx, mont)) {
263 static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
271 if (a->top == 1 && ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) != 0)) {
278 static int dh_init(DH *dh)
280 dh->flags |= DH_FLAG_CACHE_MONT_P;
284 static int dh_finish(DH *dh)
286 if (dh->method_mont_p)
287 BN_MONT_CTX_free(dh->method_mont_p);