diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index b151f16a9..dfbde3f8c 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -3573,11 +3573,11 @@ static int ConfirmSignature(const byte* buf, word32 bufSz, #ifdef WOLFSSL_SMALL_STACK byte* digest; #else - byte digest[MAX_DIGEST_SIZE]; + byte digest[WC_MAX_DIGEST_SIZE]; #endif #ifdef WOLFSSL_SMALL_STACK - digest = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); + digest = (byte*)XMALLOC(WC_MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (digest == NULL) return 0; /* not confirmed */ #endif @@ -7227,7 +7227,11 @@ static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz, int sigAlgoType) { int encSigSz, digestSz, typeH = 0, ret = 0; - byte digest[MAX_DIGEST_SIZE]; /* max size */ +#ifdef WOLFSSL_SMALL_STACK + byte* digest; +#else + byte digest[WC_MAX_DIGEST_SIZE]; /* max size */ +#endif #ifdef WOLFSSL_SMALL_STACK byte* encSig; #else @@ -7248,6 +7252,12 @@ static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz, (void)eccKey; (void)rng; +#ifdef WOLFSSL_SMALL_STACK + digest = (byte*)XMALLOC(WC_MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); + if (digest == NULL) + return 0; /* not confirmed */ +#endif + switch (sigAlgoType) { #ifndef NO_MD5 case CTC_MD5wRSA: @@ -7289,14 +7299,20 @@ static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz, ret = ALGO_ID_E; } - if (ret != 0) + if (ret != 0) { + #ifdef WOLFSSL_SMALL_STACK + XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER); + #endif return ret; + } #ifdef WOLFSSL_SMALL_STACK encSig = (byte*)XMALLOC(MAX_DER_DIGEST_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); - if (encSig == NULL) + if (encSig == NULL) { + XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER); return MEMORY_E; + } #endif ret = ALGO_ID_E; @@ -7320,6 +7336,7 @@ static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz, #endif #ifdef WOLFSSL_SMALL_STACK + XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(encSig, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 05321dbaa..5d2bff6c9 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -6842,6 +6842,8 @@ static int ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerifyCount, int ret; ecc_key userA, userB, pubKey; + (void)testVerifyCount; + wc_ecc_init(&userA); wc_ecc_init(&userB); wc_ecc_init(&pubKey);