Merge pull request #4480 from JacobBarthelmeh/fuzzing

sanity check on q value with DSA sign
This commit is contained in:
Sean Parkinson 2021-10-19 11:10:51 +10:00 committed by GitHub
commit 7447a567e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -19594,6 +19594,9 @@ static int test_wc_DsaSignVerify (void)
mp_free(&key.q);
mp_init(&key.q);
AssertIntEQ(wc_DsaSign(hash, signature, &key, &rng), BAD_FUNC_ARG);
mp_set_int(&key.q, 1);
AssertIntEQ(wc_DsaSign(hash, signature, &key, &rng), BAD_FUNC_ARG);
#endif
if (wc_FreeRng(&rng) && ret == 0) {

View File

@ -762,6 +762,12 @@ int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, WC_RNG* rng)
break;
}
/* if q-1 is 0 or smaller, k will never end up being less than it */
if (mp_iszero(qMinus1) || mp_isneg(qMinus1)) {
ret = BAD_FUNC_ARG;
break;
}
do {
/* Step 4: generate k */
if ((ret = wc_RNG_GenerateBlock(rng, buffer, halfSz))) {