mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
TLS 1.3: pre-master secret zeroizing
This commit is contained in:
@ -6697,6 +6697,7 @@ void FreeArrays(WOLFSSL* ssl, int keep)
|
|||||||
ssl->session->sessionIDSz = ssl->arrays->sessionIDSz;
|
ssl->session->sessionIDSz = ssl->arrays->sessionIDSz;
|
||||||
}
|
}
|
||||||
if (ssl->arrays->preMasterSecret) {
|
if (ssl->arrays->preMasterSecret) {
|
||||||
|
ForceZero(ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz);
|
||||||
XFREE(ssl->arrays->preMasterSecret, ssl->heap, DYNAMIC_TYPE_SECRET);
|
XFREE(ssl->arrays->preMasterSecret, ssl->heap, DYNAMIC_TYPE_SECRET);
|
||||||
ssl->arrays->preMasterSecret = NULL;
|
ssl->arrays->preMasterSecret = NULL;
|
||||||
}
|
}
|
||||||
|
@ -7164,6 +7164,8 @@ static int SendTls13Finished(WOLFSSL* ssl)
|
|||||||
/* Can send application data now. */
|
/* Can send application data now. */
|
||||||
if ((ret = DeriveMasterSecret(ssl)) != 0)
|
if ((ret = DeriveMasterSecret(ssl)) != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
/* Last use of preMasterSecret - zeroize as soon as possible. */
|
||||||
|
ForceZero(ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz);
|
||||||
#ifdef WOLFSSL_EARLY_DATA
|
#ifdef WOLFSSL_EARLY_DATA
|
||||||
if ((ret = DeriveTls13Keys(ssl, traffic_key, ENCRYPT_SIDE_ONLY, 1))
|
if ((ret = DeriveTls13Keys(ssl, traffic_key, ENCRYPT_SIDE_ONLY, 1))
|
||||||
!= 0) {
|
!= 0) {
|
||||||
@ -8425,6 +8427,9 @@ int DoTls13HandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||||||
if (type == finished) {
|
if (type == finished) {
|
||||||
if ((ret = DeriveMasterSecret(ssl)) != 0)
|
if ((ret = DeriveMasterSecret(ssl)) != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
/* Last use of preMasterSecret - zeroize as soon as possible. */
|
||||||
|
ForceZero(ssl->arrays->preMasterSecret,
|
||||||
|
ssl->arrays->preMasterSz);
|
||||||
#ifdef WOLFSSL_EARLY_DATA
|
#ifdef WOLFSSL_EARLY_DATA
|
||||||
if ((ret = DeriveTls13Keys(ssl, traffic_key,
|
if ((ret = DeriveTls13Keys(ssl, traffic_key,
|
||||||
ENCRYPT_AND_DECRYPT_SIDE,
|
ENCRYPT_AND_DECRYPT_SIDE,
|
||||||
|
Reference in New Issue
Block a user