check q in wc_CheckPubKey_ex() if available in DhKey

This commit is contained in:
Chris Conlon 2018-03-07 16:55:24 -07:00
parent 6f95677bb8
commit 0ac833790d
1 changed files with 6 additions and 1 deletions

View File

@ -908,6 +908,11 @@ int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz,
if (ret == 0 && prime != NULL) {
if (mp_read_unsigned_bin(&q, prime, primeSz) != MP_OKAY)
ret = MP_READ_E;
} else if (mp_iszero(&key->q) == MP_NO) {
/* use q available in DhKey */
if (mp_copy(&key->q, &q) != MP_OKAY)
ret = MP_INIT_E;
}
/* pub (y) should not be 0 or 1 */
@ -926,7 +931,7 @@ int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz,
ret = MP_CMP_E;
}
if (ret == 0 && prime != NULL) {
if (ret == 0 && (prime != NULL || (mp_iszero(&key->q) == MP_NO) )) {
/* restore key->p into p */
if (mp_copy(&key->p, &p) != MP_OKAY)