@@ -2652,7 +2652,7 @@ static wc_test_ret_t _SaveDerAndPem(const byte* der, int derSz,
26522652 #ifndef WOLFSSL_NO_MALLOC
26532653 byte* pem;
26542654 #else
2655- byte pem[1024 ];
2655+ byte pem[2048 ];
26562656 #endif
26572657 int pemSz;
26582658
@@ -2668,7 +2668,7 @@ static wc_test_ret_t _SaveDerAndPem(const byte* der, int derSz,
26682668 }
26692669 #else
26702670 if (pemSz > (int)sizeof(pem))
2671- return BAD_FUNC_ARG;
2671+ return WC_TEST_RET_ENC_EC( BAD_FUNC_ARG) ;
26722672 #endif
26732673 /* Convert to PEM */
26742674 pemSz = wc_DerToPem(der, (word32)derSz, pem, (word32)pemSz, pemType);
@@ -18163,7 +18163,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
1816318163 #ifdef WOLFSSL_CERT_GEN
1816418164 static const char* rsaCaCertFile = CERT_ROOT "ca-cert.pem";
1816518165 #endif
18166- #if defined(WOLFSSL_ALT_NAMES) || defined(HAVE_PKCS7)
18166+ #if (defined(WOLFSSL_ALT_NAMES) && !defined(WOLFSSL_NO_MALLOC)) || \
18167+ defined(HAVE_PKCS7)
1816718168 static const char* rsaCaCertDerFile = CERT_ROOT "ca-cert.der";
1816818169 #endif
1816918170 #ifdef HAVE_PKCS7
@@ -18208,7 +18209,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
1820818209 #ifndef NO_RSA
1820918210 static const char* eccKeyPubFileDer = CERT_ROOT "ecc-keyPub.der";
1821018211 #endif
18211- #ifndef NO_ASN_TIME
18212+ #if !defined( NO_ASN_TIME) && !defined(WOLFSSL_NO_MALLOC)
1821218213 static const char* eccCaKeyFile = CERT_ROOT "ca-ecc-key.der";
1821318214 static const char* eccCaCertFile = CERT_ROOT "ca-ecc-cert.pem";
1821418215 #ifdef ENABLE_ECC384_CERT_GEN_TEST
@@ -18264,7 +18265,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
1826418265#ifndef NO_WRITE_TEMP_FILES
1826518266#ifdef HAVE_ECC
1826618267 #ifndef NO_ECC_SECP
18267- #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME)
18268+ #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME) && \
18269+ !defined(WOLFSSL_NO_MALLOC)
1826818270 static const char* certEccPemFile = CERT_WRITE_TEMP_DIR "certecc.pem";
1826918271 static const char* certEccDerFile = CERT_WRITE_TEMP_DIR "certecc.der";
1827018272 #endif
@@ -18286,7 +18288,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
1828618288#endif /* HAVE_ECC */
1828718289
1828818290#ifndef NO_RSA
18289- #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME)
18291+ #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME) && \
18292+ !defined(WOLFSSL_NO_MALLOC)
1829018293 static const char* otherCertDerFile = CERT_WRITE_TEMP_DIR "othercert.der";
1829118294 static const char* certDerFile = CERT_WRITE_TEMP_DIR "cert.der";
1829218295 static const char* otherCertPemFile = CERT_WRITE_TEMP_DIR "othercert.pem";
@@ -20482,7 +20485,7 @@ static wc_test_ret_t rsa_even_mod_test(WC_RNG* rng, RsaKey* key)
2048220485}
2048320486#endif /* WOLFSSL_HAVE_SP_RSA */
2048420487
20485- #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME)
20488+ #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME) && !defined(WOLFSSL_NO_MALLOC)
2048620489static wc_test_ret_t rsa_certgen_test(RsaKey* key, RsaKey* keypub, WC_RNG* rng, byte* tmp)
2048720490{
2048820491#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
@@ -21969,7 +21972,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_test(void)
2196921972 goto exit_rsa;
2197021973#endif
2197121974
21972- #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME)
21975+ #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ASN_TIME) && \
21976+ !defined(WOLFSSL_NO_MALLOC)
2197321977 /* Make Cert / Sign example for RSA cert and RSA CA */
2197421978 ret = rsa_certgen_test(key, keypub, &rng, tmp);
2197521979 if (ret != 0)
@@ -32575,7 +32579,8 @@ static int test_sm2_verify(void)
3257532579#endif /* WOLFSSL_SM2 */
3257632580
3257732581
32578- #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ECC_SECP) && !defined(NO_ASN_TIME)
32582+ #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ECC_SECP) && \
32583+ !defined(NO_ASN_TIME) && !defined(WOLFSSL_NO_MALLOC)
3257932584
3258032585/* Make Cert / Sign example for ECC cert and ECC CA */
3258132586static wc_test_ret_t ecc_test_cert_gen(WC_RNG* rng)
@@ -33612,7 +33617,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_test(void)
3361233617#elif defined(HAVE_ECC_KEY_IMPORT)
3361333618 (void)ecc_test_make_pub; /* for compiler warning */
3361433619#endif
33615- #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ECC_SECP) && !defined(NO_ASN_TIME)
33620+ #if defined(WOLFSSL_CERT_GEN) && !defined(NO_ECC_SECP) && \
33621+ !defined(NO_ASN_TIME) && !defined(WOLFSSL_NO_MALLOC)
3361633622 ret = ecc_test_cert_gen(&rng);
3361733623 if (ret != 0) {
3361833624 printf("ecc_test_cert_gen failed!\n");
@@ -33647,6 +33653,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_test(void)
3364733653#if defined(HAVE_ECC_ENCRYPT) && defined(HAVE_AES_CBC) && \
3364833654 (defined(WOLFSSL_AES_128) || defined(WOLFSSL_AES_256))
3364933655
33656+ #if !defined(WOLFSSL_NO_MALLOC)
33657+
3365033658#if ((! defined(HAVE_FIPS)) || FIPS_VERSION_GE(5,3))
3365133659/* maximum encrypted message:
3365233660 * msgSz (14) + pad (2) + pubKeySz(1+66*2) + ivSz(16) + digestSz(32) = 197 */
@@ -33765,6 +33773,8 @@ static wc_test_ret_t ecc_ctx_kdf_salt_test(WC_RNG* rng, ecc_key* a, ecc_key* b)
3376533773}
3376633774#endif /* !HAVE_FIPS || FIPS_VERSION_GE(5,3) */
3376733775
33776+ #endif /* !WOLFSSL_NO_MALLOC */
33777+
3376833778/* ecc_encrypt_e2e_test() uses wc_ecc_ctx_set_algo(), which was added in
3376933779 * wolfFIPS 5.3.
3377033780 * ecc_encrypt_kat() is used only by ecc_encrypt_e2e_test().
@@ -34007,6 +34017,7 @@ static wc_test_ret_t ecc_encrypt_kat(WC_RNG *rng)
3400734017}
3400834018#endif
3400934019
34020+ #ifndef WOLFSSL_NO_MALLOC
3401034021static wc_test_ret_t ecc_encrypt_e2e_test(WC_RNG* rng, ecc_key* userA, ecc_key* userB,
3401134022 byte encAlgo, byte kdfAlgo, byte macAlgo)
3401234023{
@@ -34275,6 +34286,7 @@ static wc_test_ret_t ecc_encrypt_e2e_test(WC_RNG* rng, ecc_key* userA, ecc_key*
3427534286
3427634287 return ret;
3427734288}
34289+ #endif
3427834290
3427934291#endif /* !HAVE_FIPS || FIPS_VERSION_GE(5,3) */
3428034292
@@ -34350,7 +34362,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_encrypt_test(void)
3435034362
3435134363#if !defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))
3435234364
34353- #if !defined(NO_AES) && defined(HAVE_AES_CBC)
34365+ #if !defined(NO_AES) && defined(HAVE_AES_CBC) && !defined(WOLFSSL_NO_MALLOC)
3435434366#ifdef WOLFSSL_AES_128
3435534367 if (ret == 0) {
3435634368 ret = ecc_encrypt_e2e_test(&rng, userA, userB, ecAES_128_CBC,
@@ -34386,7 +34398,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_encrypt_test(void)
3438634398 }
3438734399#endif
3438834400#endif
34389- #if !defined(NO_AES) && defined(WOLFSSL_AES_COUNTER)
34401+ #if !defined(NO_AES) && defined(WOLFSSL_AES_COUNTER) && !defined(WOLFSSL_NO_MALLOC)
3439034402#ifdef WOLFSSL_AES_128
3439134403 if (ret == 0) {
3439234404 ret = ecc_encrypt_e2e_test(&rng, userA, userB, ecAES_128_CTR,
@@ -34406,7 +34418,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ecc_encrypt_test(void)
3440634418 }
3440734419#endif
3440834420#endif /* !NO_AES && WOLFSSL_AES_COUNTER */
34409- #if !defined(NO_AES) && defined(HAVE_AES_CBC)
34421+ #if !defined(NO_AES) && defined(HAVE_AES_CBC) && !defined(WOLFSSL_NO_MALLOC)
3441034422 if (ret == 0) {
3441134423 ret = ecc_ctx_kdf_salt_test(&rng, userA, userB);
3441234424 }
@@ -37865,15 +37877,20 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ed448_test(void)
3786537877
3786637878 /* test api for import/exporting keys */
3786737879 {
37868- byte *exportPKey = NULL;
37869- byte *exportSKey = NULL;
3787037880 word32 exportPSz = ED448_KEY_SIZE;
3787137881 word32 exportSSz = ED448_KEY_SIZE;
37882+ #ifdef WOLFSSL_NO_MALLOC
37883+ byte exportPKey[exportPSz];
37884+ byte exportSKey[exportSSz];
37885+ #else
37886+ byte *exportPKey = NULL;
37887+ byte *exportSKey = NULL;
3787237888
3787337889 exportPKey = (byte *)XMALLOC(exportPSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
3787437890 exportSKey = (byte *)XMALLOC(exportSSz, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
3787537891 if ((exportPKey == NULL) || (exportSKey == NULL))
3787637892 ERROR_OUT(WC_TEST_RET_ENC_NC, out);
37893+ #endif
3787737894
3787837895 ret = 0;
3787937896
0 commit comments