Skip to content

Commit 627310d

Browse files
committed
Additional TLS checks
- double check which messages need to be encrypted - check msgs that have to be last in a record ZD17108
1 parent 1aed438 commit 627310d

5 files changed

Lines changed: 372 additions & 17 deletions

File tree

src/dtls13.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ int Dtls13ProcessBufferedMessages(WOLFSSL* ssl)
363363
if (!msg->ready)
364364
break;
365365

366+
ret = MsgCheckEncryption(ssl, msg->type, msg->encrypted);
367+
if (ret != 0) {
368+
SendAlert(ssl, alert_fatal, unexpected_message);
369+
break;
370+
}
371+
366372
/* We may have DTLS <=1.2 msgs stored from before we knew which version
367373
* we were going to use. Interpret correctly. */
368374
if (IsAtLeastTLSv1_3(ssl->version)) {
@@ -1622,6 +1628,13 @@ static int _Dtls13HandshakeRecv(WOLFSSL* ssl, byte* input, word32 size,
16221628
if (ret != 0)
16231629
return PARSE_ERROR;
16241630

1631+
/* Need idx + fragLength as we don't advance the inputBuffer idx value */
1632+
ret = EarlySanityCheckMsgReceived(ssl, handshakeType, idx + fragLength);
1633+
if (ret != 0) {
1634+
WOLFSSL_ERROR(ret);
1635+
return ret;
1636+
}
1637+
16251638
if (ssl->options.side == WOLFSSL_SERVER_END &&
16261639
ssl->options.acceptState < TLS13_ACCEPT_FIRST_REPLY_DONE) {
16271640
if (handshakeType != client_hello) {

0 commit comments

Comments
 (0)