mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
SP rand_prime: fix length check
-ve length indicates to use a BBS prime (last two bits set)
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user