mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-05 13:44:41 +02:00
This commit is contained in:
17
src/ssl.c
17
src/ssl.c
@@ -2004,20 +2004,29 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz,
|
|||||||
#if !defined(WOLFSSL_OLD_PRIME_CHECK) && !defined(HAVE_FIPS) && \
|
#if !defined(WOLFSSL_OLD_PRIME_CHECK) && !defined(HAVE_FIPS) && \
|
||||||
!defined(HAVE_SELFTEST)
|
!defined(HAVE_SELFTEST)
|
||||||
{
|
{
|
||||||
DhKey checkKey;
|
|
||||||
WC_RNG rng;
|
WC_RNG rng;
|
||||||
int error, freeKey = 0;
|
int error, freeKey = 0;
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
DhKey *checkKey = (DhKey*)XMALLOC(sizeof(DhKey), NULL, DYNAMIC_TYPE_DH);
|
||||||
|
if (checkKey == NULL)
|
||||||
|
return MEMORY_E;
|
||||||
|
#else
|
||||||
|
DhKey checkKey[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
error = wc_InitRng(&rng);
|
error = wc_InitRng(&rng);
|
||||||
if (!error)
|
if (!error)
|
||||||
error = wc_InitDhKey(&checkKey);
|
error = wc_InitDhKey(checkKey);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
freeKey = 1;
|
freeKey = 1;
|
||||||
error = wc_DhSetCheckKey(&checkKey,
|
error = wc_DhSetCheckKey(checkKey,
|
||||||
p, pSz, g, gSz, NULL, 0, 0, &rng);
|
p, pSz, g, gSz, NULL, 0, 0, &rng);
|
||||||
}
|
}
|
||||||
if (freeKey)
|
if (freeKey)
|
||||||
wc_FreeDhKey(&checkKey);
|
wc_FreeDhKey(checkKey);
|
||||||
|
#ifdef WOLFSSL_SMALL_STACK
|
||||||
|
XFREE(checkKey, NULL, DYNAMIC_TYPE_DH);
|
||||||
|
#endif
|
||||||
wc_FreeRng(&rng);
|
wc_FreeRng(&rng);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
Reference in New Issue
Block a user