mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
test.c: fix missed spot in rsa_certgen_test(), and do another _SMALL_STACK refactor of a missed object in rsa_ecc_certgen_test().
This commit is contained in:
@@ -12561,13 +12561,13 @@ static int rsa_certgen_test(RsaKey* key, RsaKey* keypub, WC_RNG* rng, byte* tmp)
|
|||||||
certSz = ret;
|
certSz = ret;
|
||||||
|
|
||||||
#ifdef WOLFSSL_TEST_CERT
|
#ifdef WOLFSSL_TEST_CERT
|
||||||
InitDecodedCert(&decode, der, certSz, HEAP_HINT);
|
InitDecodedCert(decode, der, certSz, HEAP_HINT);
|
||||||
ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
|
ret = ParseCert(decode, CERT_TYPE, NO_VERIFY, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
FreeDecodedCert(&decode);
|
FreeDecodedCert(decode);
|
||||||
ERROR_OUT(-7628, exit_rsa);
|
ERROR_OUT(-7628, exit_rsa);
|
||||||
}
|
}
|
||||||
FreeDecodedCert(&decode);
|
FreeDecodedCert(decode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = SaveDerAndPem(der, certSz, certDerFile, certPemFile,
|
ret = SaveDerAndPem(der, certSz, certDerFile, certPemFile,
|
||||||
@@ -12769,10 +12769,16 @@ static int rsa_ecc_certgen_test(WC_RNG* rng, byte* tmp)
|
|||||||
RsaKey *caKey = (RsaKey *)XMALLOC(sizeof *caKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
RsaKey *caKey = (RsaKey *)XMALLOC(sizeof *caKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
ecc_key *caEccKey = (ecc_key *)XMALLOC(sizeof *caEccKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
ecc_key *caEccKey = (ecc_key *)XMALLOC(sizeof *caEccKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
ecc_key *caEccKeyPub = (ecc_key *)XMALLOC(sizeof *caEccKeyPub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
ecc_key *caEccKeyPub = (ecc_key *)XMALLOC(sizeof *caEccKeyPub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#ifdef WOLFSSL_TEST_CERT
|
||||||
|
DecodedCert *decode = (DecodedCert *)XMALLOC(sizeof *decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
RsaKey caKey_buf, *caKey = &caKey_buf;
|
RsaKey caKey_buf, *caKey = &caKey_buf;
|
||||||
ecc_key caEccKey_buf, *caEccKey = &caEccKey_buf;
|
ecc_key caEccKey_buf, *caEccKey = &caEccKey_buf;
|
||||||
ecc_key caEccKeyPub_buf, *caEccKeyPub = &caEccKeyPub_buf;
|
ecc_key caEccKeyPub_buf, *caEccKeyPub = &caEccKeyPub_buf;
|
||||||
|
#ifdef WOLFSSL_TEST_CERT
|
||||||
|
DecodedCert decode_buf, *decode = &decode_buf;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
byte* der = NULL;
|
byte* der = NULL;
|
||||||
Cert* myCert = NULL;
|
Cert* myCert = NULL;
|
||||||
@@ -12782,14 +12788,15 @@ static int rsa_ecc_certgen_test(WC_RNG* rng, byte* tmp)
|
|||||||
#if (!defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)) \
|
#if (!defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)) \
|
||||||
|| !defined(USE_CERT_BUFFERS_256)
|
|| !defined(USE_CERT_BUFFERS_256)
|
||||||
XFILE file3;
|
XFILE file3;
|
||||||
#endif
|
|
||||||
#ifdef WOLFSSL_TEST_CERT
|
|
||||||
DecodedCert decode;
|
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
if ((caKey == NULL) || (caEccKey == NULL) || (caEccKeyPub == NULL))
|
if ((caKey == NULL) || (caEccKey == NULL) || (caEccKeyPub == NULL)
|
||||||
|
#ifdef WOLFSSL_TEST_CERT
|
||||||
|
|| (decode == NULL)
|
||||||
|
#endif
|
||||||
|
)
|
||||||
ERROR_OUT(MEMORY_E, exit_rsa);
|
ERROR_OUT(MEMORY_E, exit_rsa);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -12937,14 +12944,14 @@ static int rsa_ecc_certgen_test(WC_RNG* rng, byte* tmp)
|
|||||||
certSz = ret;
|
certSz = ret;
|
||||||
|
|
||||||
#ifdef WOLFSSL_TEST_CERT
|
#ifdef WOLFSSL_TEST_CERT
|
||||||
InitDecodedCert(&decode, der, certSz, 0);
|
InitDecodedCert(decode, der, certSz, 0);
|
||||||
ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
|
ret = ParseCert(decode, CERT_TYPE, NO_VERIFY, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
FreeDecodedCert(&decode);
|
FreeDecodedCert(decode);
|
||||||
ERROR_OUT(-7661, exit_rsa);
|
ERROR_OUT(-7661, exit_rsa);
|
||||||
|
|
||||||
}
|
}
|
||||||
FreeDecodedCert(&decode);
|
FreeDecodedCert(decode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = SaveDerAndPem(der, certSz, certEccRsaDerFile, certEccRsaPemFile,
|
ret = SaveDerAndPem(der, certSz, certEccRsaDerFile, certEccRsaPemFile,
|
||||||
@@ -12968,6 +12975,8 @@ exit_rsa:
|
|||||||
wc_ecc_free(caEccKeyPub);
|
wc_ecc_free(caEccKeyPub);
|
||||||
XFREE(caEccKeyPub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(caEccKeyPub, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
}
|
}
|
||||||
|
if (decode != NULL)
|
||||||
|
XFREE(decode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#else
|
#else
|
||||||
wc_FreeRsaKey(caKey);
|
wc_FreeRsaKey(caKey);
|
||||||
wc_ecc_free(caEccKey);
|
wc_ecc_free(caEccKey);
|
||||||
|
Reference in New Issue
Block a user