Added check for wolfmath.c for digits == 0 and test for api.c

This commit is contained in:
Ethan Looney
2020-08-04 13:25:10 -07:00
parent 5641e2ae50
commit 42856287ee
2 changed files with 7 additions and 1 deletions

View File

@@ -33914,6 +33914,12 @@ static int test_mp_rand (void)
ret = 0;
}
}
if (ret == 0) {
ret = mp_rand(&a, 0, &rng);
if (ret == BAD_FUNC_ARG) {
ret = 0;
}
}
if (ret == 0) {
ret = mp_rand(&a, digits, &rng);
}

View File

@@ -146,7 +146,7 @@ int mp_rand(mp_int* a, int digits, WC_RNG* rng)
if (rng == NULL) {
ret = MISSING_RNG_E;
}
else if (a == NULL) {
else if (a == NULL || digits == 0) {
ret = BAD_FUNC_ARG;
}