diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index d5d124901..7e017ef96 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -4820,7 +4820,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; @@ -4911,6 +4912,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 diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 22dd577ce..d784115a9 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -2765,10 +2765,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) @@ -21956,6 +21960,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); @@ -59660,6 +59671,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 @@ -59717,7 +59729,7 @@ 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 -> @@ -59725,7 +59737,7 @@ static wc_test_ret_t rsa_onlycb_test(myCryptoDevCtx *ctx) * 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