Skip to content

Commit

Permalink
Merge pull request #7029 from julek-wolfssl/zd/17108-fix
Browse files Browse the repository at this point in the history
Additional TLS checks
  • Loading branch information
SparkiDev committed Dec 13, 2023
2 parents 3b75a41 + 493bb17 commit f12b611
Show file tree
Hide file tree
Showing 5 changed files with 389 additions and 16 deletions.
15 changes: 15 additions & 0 deletions src/dtls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,14 @@ int Dtls13ProcessBufferedMessages(WOLFSSL* ssl)
if (!msg->ready)
break;

#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
ret = MsgCheckEncryption(ssl, msg->type, msg->encrypted);
if (ret != 0) {
SendAlert(ssl, alert_fatal, unexpected_message);
break;
}
#endif

/* We may have DTLS <=1.2 msgs stored from before we knew which version
* we were going to use. Interpret correctly. */
if (IsAtLeastTLSv1_3(ssl->version)) {
Expand Down Expand Up @@ -1622,6 +1630,13 @@ static int _Dtls13HandshakeRecv(WOLFSSL* ssl, byte* input, word32 size,
if (ret != 0)
return PARSE_ERROR;

/* Need idx + fragLength as we don't advance the inputBuffer idx value */
ret = EarlySanityCheckMsgReceived(ssl, handshakeType, idx + fragLength);
if (ret != 0) {
WOLFSSL_ERROR(ret);
return ret;
}

if (ssl->options.side == WOLFSSL_SERVER_END &&
ssl->options.acceptState < TLS13_ACCEPT_FIRST_REPLY_DONE) {
if (handshakeType != client_hello) {
Expand Down

0 comments on commit f12b611

Please sign in to comment.