Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion wolfcrypt/src/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -4816,7 +4816,8 @@ int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng)
{
#ifndef WC_NO_RNG
#if !defined(WOLFSSL_CRYPTOCELL) && \
(!defined(WOLFSSL_SE050) || defined(WOLFSSL_SE050_NO_RSA))
(!defined(WOLFSSL_SE050) || defined(WOLFSSL_SE050_NO_RSA)) && \
!defined(WOLF_CRYPTO_CB_ONLY_RSA)
#ifdef WOLFSSL_SMALL_STACK
mp_int *p = NULL;
mp_int *q = NULL;
Expand Down Expand Up @@ -4907,6 +4908,11 @@ int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng)
/* fall-through when unavailable */
#endif
}
#if !defined(WOLF_CRYPTO_CB_FIND) && defined(WOLF_CRYPTO_CB_ONLY_RSA)
else {
err = NO_VALID_DEVID;
}
#endif
#endif

#ifndef WOLF_CRYPTO_CB_ONLY_RSA
Expand Down
20 changes: 16 additions & 4 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2761,10 +2761,14 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\

#endif /* NO_MAIN_DRIVER */

#if defined(WOLF_CRYPTO_CB_ONLY_ECC) || defined(WOLF_CRYPTO_CB_ONLY_RSA)
#undef NO_WRITE_TEMP_FILES
#define NO_WRITE_TEMP_FILES
#endif

/* helper to save DER, convert to PEM and save PEM */
#if !defined(NO_ASN) && (defined(HAVE_ECC) || !defined(NO_DSA) || \
(!defined(NO_RSA) && (defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN)))) \
&& !defined(WOLF_CRYPTO_CB_ONLY_ECC)
(!defined(NO_RSA) && (defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN))))

#if !defined(NO_FILESYSTEM) && !defined(NO_WRITE_TEMP_FILES)
#define SaveDerAndPem(d, dSz, fD, fP, pT) _SaveDerAndPem(d, dSz, fD, fP, pT, WC_TEST_RET_LN)
Expand Down Expand Up @@ -21952,6 +21956,13 @@ static wc_test_ret_t rsa_keygen_test(WC_RNG* rng)
int keySz = 2048;
#endif

#ifdef WOLF_CRYPTO_CB_ONLY_RSA
if (devId == INVALID_DEVID) {
/* must call keygen with devId */
return 0;
}
#endif

#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
if (! genKey)
ERROR_OUT(WC_TEST_RET_ENC_EC(MEMORY_E), exit_rsa);
Expand Down Expand Up @@ -59624,6 +59635,7 @@ static wc_test_ret_t rsa_onlycb_test(myCryptoDevCtx *ctx)

#ifdef WOLFSSL_KEY_GEN
WC_RNG rng;
word32 keySz = 2048;
#endif

#ifdef USE_CERT_BUFFERS_1024
Expand Down Expand Up @@ -59681,15 +59693,15 @@ static wc_test_ret_t rsa_onlycb_test(myCryptoDevCtx *ctx)
* wc_MakeRsaKey(CBONLY_TEST_DEVID) expects to return 0(success)
*/
ctx->exampleVar = 99;
ret = wc_MakeRsaKey(key, keySz, WC_RSA_EXPONENT, rng);
ret = wc_MakeRsaKey(key, keySz, WC_RSA_EXPONENT, &rng);
if (ret != 0)
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb);
/* wc_MakeRsaKey() -> rsa cb ->
* myCryptoDevCb -> wc_MakeRsaKey(INVALID_DEVID)
* wc_MakeRsaKey(CBONLY_TEST_DEVID) expects to return NO_VALID_DEVID(failure)
*/
ctx->exampleVar = 1;
ret = wc_MakeRsaKey(key, keySz, WC_RSA_EXPONENT, rng);
ret = wc_MakeRsaKey(key, keySz, WC_RSA_EXPONENT, &rng);
if (ret != WC_NO_ERR_TRACE(NO_VALID_DEVID)) {
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb);
} else
Expand Down
Loading