aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/dh/dh_key.c
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2005-08-21 16:00:17 +0000
committerBen Laurie <ben@openssl.org>2005-08-21 16:00:17 +0000
commitbf3d6c0c9b58e6a78fa3ac0a60d68ef4fc0aa215 (patch)
tree7431a83a1487ff2ee8e13430ff3c52f58eb715b2 /crypto/dh/dh_key.c
parentb8e8ccdc791e035473c710649fb3e67847c365ff (diff)
downloadopenssl-bf3d6c0c9b58e6a78fa3ac0a60d68ef4fc0aa215.tar.gz
Make D-H safer, include well-known primes.
Diffstat (limited to 'crypto/dh/dh_key.c')
-rw-r--r--crypto/dh/dh_key.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c
index 39eefe387e..cc17c8851b 100644
--- a/crypto/dh/dh_key.c
+++ b/crypto/dh/dh_key.c
@@ -177,6 +177,7 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
BN_MONT_CTX *mont=NULL;
BIGNUM *tmp;
int ret= -1;
+ int check_result;
ctx = BN_CTX_new();
if (ctx == NULL) goto err;
@@ -202,6 +203,12 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
goto err;
}
+ if (!DH_check_pub_key(dh, pub_key, &check_result) || check_result)
+ {
+ DHerr(DH_F_COMPUTE_KEY,DH_R_INVALID_PUBKEY);
+ goto err;
+ }
+
if (!dh->meth->bn_mod_exp(dh, tmp, pub_key, dh->priv_key,dh->p,ctx,mont))
{
DHerr(DH_F_COMPUTE_KEY,ERR_R_BN_LIB);