Skip to content

Commit

Permalink
Additional TLS checks
Browse files Browse the repository at this point in the history
- double check which messages need to be encrypted
- check msgs that have to be last in a record

ZD17108
  • Loading branch information
julek-wolfssl committed Dec 12, 2023
1 parent 1aed438 commit 627310d
Show file tree
Hide file tree
Showing 5 changed files with 372 additions and 17 deletions.
13 changes: 13 additions & 0 deletions src/dtls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ int Dtls13ProcessBufferedMessages(WOLFSSL* ssl)
if (!msg->ready)
break;

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

/* 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 +1628,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
Loading

0 comments on commit 627310d

Please sign in to comment.