aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/dh/dh_key.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-06-07 21:29:25 +0000
committerBodo Möller <bodo@openssl.org>2000-06-07 21:29:25 +0000
commit6dad7bd69c096cb6ea3b5df02d367d26858077c1 (patch)
tree50c477ad87e876b3fbb22eabe957483c8921af1a /crypto/dh/dh_key.c
parent208f3688e0a76c3ad0ecb18075851b22f6511dc1 (diff)
downloadopenssl-6dad7bd69c096cb6ea3b5df02d367d26858077c1.tar.gz
Speed up DH with small generator.
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r--crypto/dh/dh_key.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c
index 0c7eeaf260..6f9426dd6f 100644
--- a/crypto/dh/dh_key.c
+++ b/crypto/dh/dh_key.c
@@ -193,19 +193,26 @@ err:
static int dh_bn_mod_exp(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx,
BN_MONT_CTX *m_ctx)
-{
- return BN_mod_exp_mont(r, a, p, m, ctx, m_ctx);
-}
+ {
+ if (a->top == 1)
+ {
+ BN_ULONG A = a->d[0];
+ return BN_mod_exp_mont_word(r,A,p,m,ctx,m_ctx);
+ }
+ else
+ return BN_mod_exp_mont(r,a,p,m,ctx,m_ctx);
+ }
+
static int dh_init(DH *dh)
-{
+ {
dh->flags |= DH_FLAG_CACHE_MONT_P;
return(1);
-}
+ }
static int dh_finish(DH *dh)
-{
+ {
if(dh->method_mont_p)
BN_MONT_CTX_free((BN_MONT_CTX *)dh->method_mont_p);
return(1);
-}
+ }