Skip to content

Commit 5a89ef9

Browse files
authored
Merge pull request #9497 from douzzer/20251206-old-fips-test_wc_RsaPublicEncryptDecrypt
20251206-old-fips-test_wc_RsaPublicEncryptDecrypt
2 parents 1b7072b + 12d07c4 commit 5a89ef9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/api/test_rsa.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -785,18 +785,15 @@ int test_wc_RsaPublicEncryptDecrypt(void)
785785
WC_DECLARE_VAR(in, byte, TEST_STRING_SZ, NULL);
786786
WC_DECLARE_VAR(plain, byte, TEST_STRING_SZ, NULL);
787787
WC_DECLARE_VAR(cipher, byte, TEST_RSA_BYTES, NULL);
788-
WC_DECLARE_VAR(shortPlain, byte, TEST_STRING_SZ - 4, NULL);
789788

790789
WC_ALLOC_VAR(in, byte, TEST_STRING_SZ, NULL);
791790
WC_ALLOC_VAR(plain, byte, TEST_STRING_SZ, NULL);
792791
WC_ALLOC_VAR(cipher, byte, TEST_RSA_BYTES, NULL);
793-
WC_ALLOC_VAR(shortPlain, byte, TEST_STRING_SZ - 4, NULL);
794792

795793
#ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC
796794
ExpectNotNull(in);
797795
ExpectNotNull(plain);
798796
ExpectNotNull(cipher);
799-
ExpectNotNull(shortPlain);
800797
#endif
801798
ExpectNotNull(XMEMCPY(in, inStr, inLen));
802799

@@ -823,11 +820,20 @@ int test_wc_RsaPublicEncryptDecrypt(void)
823820
ExpectIntEQ(XMEMCMP(plain, inStr, plainLen), 0);
824821
/* Pass bad args - tested in another testing function.*/
825822

826-
/* Test for when plain length is less than required. */
827-
ExpectIntEQ(wc_RsaPrivateDecrypt(cipher, cipherLenResult, shortPlain,
828-
TEST_STRING_SZ - 4, &key), RSA_BUFFER_E);
823+
#if !defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
824+
{
825+
WC_DECLARE_VAR(shortPlain, byte, TEST_STRING_SZ - 4, NULL);
826+
WC_ALLOC_VAR(shortPlain, byte, TEST_STRING_SZ - 4, NULL);
827+
#ifdef WC_DECLARE_VAR_IS_HEAP_ALLOC
828+
ExpectNotNull(shortPlain);
829+
#endif
830+
/* Test for when plain length is less than required. */
831+
ExpectIntEQ(wc_RsaPrivateDecrypt(cipher, cipherLenResult, shortPlain,
832+
TEST_STRING_SZ - 4, &key), RSA_BUFFER_E);
833+
WC_FREE_VAR(shortPlain, NULL);
834+
}
835+
#endif /* !HAVE_SELFTEST && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
829836

830-
WC_FREE_VAR(shortPlain, NULL);
831837
WC_FREE_VAR(in, NULL);
832838
WC_FREE_VAR(plain, NULL);
833839
WC_FREE_VAR(cipher, NULL);

0 commit comments

Comments
 (0)