mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-05 13:44:41 +02:00
Refactor tmpF in RsaMGF1
This commit is contained in:
@@ -855,12 +855,12 @@ static int RsaMGF1(enum wc_HashType hType, byte* seed, word32 seedSz,
|
|||||||
{
|
{
|
||||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
||||||
byte* tmp = NULL;
|
byte* tmp = NULL;
|
||||||
|
byte tmpF = 0; /* 1 if dynamic memory needs freed */
|
||||||
#else
|
#else
|
||||||
byte tmp[RSA_MAX_SIZE/8];
|
byte tmp[RSA_MAX_SIZE/8];
|
||||||
#endif
|
#endif
|
||||||
/* needs to be large enough for seed size plus counter(4) */
|
/* needs to be large enough for seed size plus counter(4) */
|
||||||
byte tmpA[WC_MAX_DIGEST_SIZE + 4];
|
byte tmpA[WC_MAX_DIGEST_SIZE + 4];
|
||||||
byte tmpF = 0; /* 1 if dynamic memory needs freed */
|
|
||||||
word32 tmpSz = 0;
|
word32 tmpSz = 0;
|
||||||
int hLen;
|
int hLen;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -903,8 +903,8 @@ static int RsaMGF1(enum wc_HashType hType, byte* seed, word32 seedSz,
|
|||||||
#endif
|
#endif
|
||||||
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
||||||
tmp = tmpA;
|
tmp = tmpA;
|
||||||
#endif
|
|
||||||
tmpF = 0; /* no need to free memory at end */
|
tmpF = 0; /* no need to free memory at end */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||||
@@ -959,11 +959,12 @@ static int RsaMGF1(enum wc_HashType hType, byte* seed, word32 seedSz,
|
|||||||
}
|
}
|
||||||
counter++;
|
counter++;
|
||||||
} while (idx < outSz);
|
} while (idx < outSz);
|
||||||
|
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
|
||||||
/* check for if dynamic memory was needed, then free */
|
/* check for if dynamic memory was needed, then free */
|
||||||
if (tmpF) {
|
if (tmpF) {
|
||||||
XFREE(tmp, heap, DYNAMIC_TYPE_RSA_BUFFER);
|
XFREE(tmp, heap, DYNAMIC_TYPE_RSA_BUFFER);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||||
wc_HashFree(hash, hType);
|
wc_HashFree(hash, hType);
|
||||||
XFREE(hash, heap, DYNAMIC_TYPE_DIGEST);
|
XFREE(hash, heap, DYNAMIC_TYPE_DIGEST);
|
||||||
|
Reference in New Issue
Block a user