Merge pull request #5151 from SparkiDev/tls13_premaster

TLS 1.3:  pre-master secret zeroizing
pull/5153/head
David Garske 2022-05-17 19:18:43 -07:00 committed by GitHub
commit ac3fc89df9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -6697,6 +6697,7 @@ void FreeArrays(WOLFSSL* ssl, int keep)
ssl->session->sessionIDSz = ssl->arrays->sessionIDSz;
}
if (ssl->arrays->preMasterSecret) {
ForceZero(ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz);
XFREE(ssl->arrays->preMasterSecret, ssl->heap, DYNAMIC_TYPE_SECRET);
ssl->arrays->preMasterSecret = NULL;
}

View File

@ -7164,6 +7164,8 @@ static int SendTls13Finished(WOLFSSL* ssl)
/* Can send application data now. */
if ((ret = DeriveMasterSecret(ssl)) != 0)
return ret;
/* Last use of preMasterSecret - zeroize as soon as possible. */
ForceZero(ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz);
#ifdef WOLFSSL_EARLY_DATA
if ((ret = DeriveTls13Keys(ssl, traffic_key, ENCRYPT_SIDE_ONLY, 1))
!= 0) {
@ -8425,6 +8427,9 @@ int DoTls13HandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx,
if (type == finished) {
if ((ret = DeriveMasterSecret(ssl)) != 0)
return ret;
/* Last use of preMasterSecret - zeroize as soon as possible. */
ForceZero(ssl->arrays->preMasterSecret,
ssl->arrays->preMasterSz);
#ifdef WOLFSSL_EARLY_DATA
if ((ret = DeriveTls13Keys(ssl, traffic_key,
ENCRYPT_AND_DECRYPT_SIDE,