summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src/crypto/dh/dh_key.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libssl/src/crypto/dh/dh_key.c')
-rw-r--r--lib/libssl/src/crypto/dh/dh_key.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/libssl/src/crypto/dh/dh_key.c b/lib/libssl/src/crypto/dh/dh_key.c
index ff125c2296f..648766a6ec4 100644
--- a/lib/libssl/src/crypto/dh/dh_key.c
+++ b/lib/libssl/src/crypto/dh/dh_key.c
@@ -163,6 +163,7 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
BN_MONT_CTX *mont;
BIGNUM *tmp;
int ret= -1;
+ int check_result;
ctx = BN_CTX_new();
if (ctx == NULL) goto err;
@@ -182,6 +183,12 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
}
mont=(BN_MONT_CTX *)dh->method_mont_p;
+
+ if (!DH_check_pub_key(dh, pub_key, &check_result) || check_result)
+ {
+ DHerr(DH_F_DH_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_DH_COMPUTE_KEY,ERR_R_BN_LIB);