Merge pull request #516 from dgarske/fix_asn_wo_hmac

Fix build issue with ASN enabled and no HMAC
This commit is contained in:
toddouska 2016-08-06 10:07:00 -07:00 committed by GitHub
commit 49fb0d56b0
2 changed files with 24 additions and 5 deletions

View File

@ -3544,11 +3544,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
@ -7265,7 +7265,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
@ -7286,6 +7290,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:
@ -7327,14 +7337,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;
@ -7358,6 +7374,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

View File

@ -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);