Skip to content

Commit

Permalink
coverity issue 394701 possible derefernce before null check
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed Jul 5, 2024
1 parent ac52660 commit fbdb064
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions wolfcrypt/src/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,17 @@ static int _ifc_pairwise_consistency_test(RsaKey* key, WC_RNG* rng)

int wc_CheckRsaKey(RsaKey* key)
{
DECL_MP_INT_SIZE_DYN(tmp, mp_bitsused(&key->n), RSA_MAX_SIZE);
#ifdef WOLFSSL_SMALL_STACK
WC_RNG *rng = NULL;
#else
WC_RNG rng[1];
#endif
int ret = 0;
DECL_MP_INT_SIZE_DYN(tmp, (key)? mp_bitsused(&key->n) : 0, RSA_MAX_SIZE);

if (key == NULL) {
return BAD_FUNC_ARG;
}

#ifdef WOLFSSL_CAAM
/* can not perform these checks on an encrypted key */
Expand Down Expand Up @@ -711,11 +715,6 @@ int wc_CheckRsaKey(RsaKey* key)
ret = MP_INIT_E;
}

if (ret == 0) {
if (key == NULL)
ret = BAD_FUNC_ARG;
}

if (ret == 0)
ret = _ifc_pairwise_consistency_test(key, rng);

Expand Down

0 comments on commit fbdb064

Please sign in to comment.