Review comments and cast

This commit is contained in:
Tesfa Mael
2020-12-29 19:48:45 -08:00
parent cedec3ae28
commit d366ca74af
2 changed files with 9 additions and 3 deletions

View File

@ -914,9 +914,12 @@ int wc_RNG_GenerateBlock(WC_RNG* rng, byte* output, word32 sz)
{
int ret;
if (rng == NULL || output == NULL || sz == 0 )
if (rng == NULL || output == NULL)
return BAD_FUNC_ARG;
if (sz == 0)
return 0;
#ifdef WOLF_CRYPTO_CB
if (rng->devId != INVALID_DEVID) {
ret = wc_CryptoCb_RandomBlock(rng, output, sz);

View File

@ -9240,7 +9240,7 @@ int sp_div_2d(sp_int* a, int e, sp_int* r, sp_int* rem)
rem->used = (e + SP_WORD_SIZE - 1) >> SP_WORD_SHIFT;
e &= SP_WORD_MASK;
if (e > 0) {
rem->dp[rem->used - 1] &= (1 << e) - 1;
rem->dp[rem->used - 1] &= ((sp_int_digit)1 << e) - 1;
}
sp_clamp(rem);
}
@ -12979,10 +12979,13 @@ int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
(void)heap;
if ((r == NULL) || (rng == NULL) || len <= 0 ) {
if ((r == NULL) || (rng == NULL) || len < 0 ) {
err = MP_VAL;
}
if (len == 0)
return MP_OKAY;
if (err == MP_OKAY) {
/* get type */
if (len < 0) {