mirror of https://github.com/wolfSSL/wolfssl.git
SP rand_prime: fix length check
-ve length indicates to use a BBS prime (last two bits set)pull/3613/head
parent
ef56bc09f1
commit
40ab08be45
|
@ -12989,13 +12989,11 @@ int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
|
|||
|
||||
(void)heap;
|
||||
|
||||
if ((r == NULL) || (rng == NULL) || len < 0 ) {
|
||||
/* Check NULL parameters and 0 is not prime so 0 bytes is invalid. */
|
||||
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) {
|
||||
|
|
|
@ -30786,6 +30786,9 @@ static int mp_test_param(mp_int* a, mp_int* b, mp_int* r, WC_RNG* rng)
|
|||
ret = mp_rand_prime(NULL, 32, rng, NULL);
|
||||
if (ret != MP_VAL)
|
||||
return -12789;
|
||||
ret = mp_rand_prime(a, 0, rng, NULL);
|
||||
if (ret != MP_VAL)
|
||||
return -9969;
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_SP_MATH_ALL) && !defined(WOLFSSL_RSA_VERIFY_ONLY)
|
||||
|
|
Loading…
Reference in New Issue