Skip to content

Commit e6a7be8

Browse files
committed
test: rsa: reset RSA key between operation
1 parent ed2e230 commit e6a7be8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26009,6 +26009,21 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_test(void)
2600926009

2601026010
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) && !defined(WOLFSSL_RSA_PUBLIC_ONLY) && \
2601126011
!defined(WC_NO_RNG) && !defined(WOLF_CRYPTO_CB_ONLY_RSA)
26012+
/* Reload the key so the public-encrypt below is the first operation
26013+
* against it. Exercises backends that distinguish public-only material
26014+
* from full-keypair bindings: a public-encrypt on a freshly-loaded key
26015+
* must not prevent the subsequent private-decrypt from using the private
26016+
* key material the caller originally provided. */
26017+
#ifndef NO_ASN
26018+
wc_FreeRsaKey(key);
26019+
ret = wc_InitRsaKey_ex(key, HEAP_HINT, devId);
26020+
if (ret != 0)
26021+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_rsa);
26022+
idx = 0;
26023+
ret = wc_RsaPrivateKeyDecode(tmp, &idx, key, (word32)bytes);
26024+
if (ret != 0)
26025+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_rsa);
26026+
#endif
2601226027
do {
2601326028
#if defined(WOLFSSL_ASYNC_CRYPT)
2601426029
ret = wc_AsyncWait(ret, &key->asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);

0 commit comments

Comments
 (0)