mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
Fix to only free existing key in SetStaticEphemeralKey
if the incoming algorithm type has been specified.
This commit is contained in:
11
src/ssl.c
11
src/ssl.c
@@ -48888,13 +48888,17 @@ static int SetStaticEphemeralKey(StaticKeyExchangeInfo_t* staticKE, int keyAlgo,
|
|||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WOLFSSL_ENTER("SetStaticEphemeralKey");
|
||||||
|
|
||||||
/* if key is already set free it */
|
/* if key is already set free it */
|
||||||
#ifndef NO_DH
|
#ifndef NO_DH
|
||||||
if (staticKE->dhKey && (ctx == NULL || staticKE->dhKey != ctx->staticKE.dhKey))
|
if (keyAlgo == WC_PK_TYPE_DH && staticKE->dhKey &&
|
||||||
|
(ctx == NULL || staticKE->dhKey != ctx->staticKE.dhKey))
|
||||||
FreeDer(&staticKE->dhKey);
|
FreeDer(&staticKE->dhKey);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
if (staticKE->ecKey && (ctx == NULL || staticKE->ecKey != ctx->staticKE.ecKey))
|
if (keyAlgo == WC_PK_TYPE_ECDH && staticKE->ecKey &&
|
||||||
|
(ctx == NULL || staticKE->ecKey != ctx->staticKE.ecKey))
|
||||||
FreeDer(&staticKE->ecKey);
|
FreeDer(&staticKE->ecKey);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -48967,6 +48971,9 @@ static int SetStaticEphemeralKey(StaticKeyExchangeInfo_t* staticKE, int keyAlgo,
|
|||||||
XFREE(keyBuf, heap, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(keyBuf, heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
WOLFSSL_LEAVE("SetStaticEphemeralKey", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user