Fix for crypto callback only

This commit is contained in:
David Garske
2025-09-10 16:03:31 -07:00
parent 436a06e864
commit 6698cb7616
2 changed files with 23 additions and 5 deletions

View File

@@ -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;
@@ -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

View File

@@ -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)
@@ -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);
@@ -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
@@ -59681,7 +59693,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 ->
@@ -59689,7 +59701,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