diff --git a/wolfcrypt/src/error.c b/wolfcrypt/src/error.c index 75b16b023..b4c617ce8 100644 --- a/wolfcrypt/src/error.c +++ b/wolfcrypt/src/error.c @@ -386,6 +386,9 @@ const char* wc_GetErrorString(int error) case ASN_COUNTRY_SIZE_E: return "Country code size error, either too small or large"; + case MISSING_RNG_E: + return "RNG required but not provided"; + default: return "unknown error number"; diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index 55ac643e4..554fba998 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -812,7 +812,10 @@ static int mp_rand(mp_int* a, int digits, WC_RNG* rng) int ret; mp_digit d; - if (a == NULL || rng == NULL) + if (rng == NULL) + return MISSING_RNG_E; + + if (a == NULL) return BAD_FUNC_ARG; mp_zero(a); diff --git a/wolfssl/wolfcrypt/error-crypt.h b/wolfssl/wolfcrypt/error-crypt.h index 56c6ed8b9..f165f27f5 100644 --- a/wolfssl/wolfcrypt/error-crypt.h +++ b/wolfssl/wolfcrypt/error-crypt.h @@ -173,6 +173,7 @@ enum { WC_KEY_SIZE_E = -234, /* Key size error, either too small or large */ ASN_COUNTRY_SIZE_E = -235, /* ASN Cert Gen, invalid country code size */ + MISSING_RNG_E = -236, /* RNG required but not provided */ MIN_CODE_E = -300 /* errors -101 - -299 */