Skip to content

Commit fbdb064

Browse files
coverity issue 394701 possible derefernce before null check
1 parent ac52660 commit fbdb064

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

wolfcrypt/src/rsa.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,17 @@ static int _ifc_pairwise_consistency_test(RsaKey* key, WC_RNG* rng)
673673

674674
int wc_CheckRsaKey(RsaKey* key)
675675
{
676-
DECL_MP_INT_SIZE_DYN(tmp, mp_bitsused(&key->n), RSA_MAX_SIZE);
677676
#ifdef WOLFSSL_SMALL_STACK
678677
WC_RNG *rng = NULL;
679678
#else
680679
WC_RNG rng[1];
681680
#endif
682681
int ret = 0;
682+
DECL_MP_INT_SIZE_DYN(tmp, (key)? mp_bitsused(&key->n) : 0, RSA_MAX_SIZE);
683+
684+
if (key == NULL) {
685+
return BAD_FUNC_ARG;
686+
}
683687

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

714-
if (ret == 0) {
715-
if (key == NULL)
716-
ret = BAD_FUNC_ARG;
717-
}
718-
719718
if (ret == 0)
720719
ret = _ifc_pairwise_consistency_test(key, rng);
721720

0 commit comments

Comments
 (0)