Skip to content

Commit 493bb17

Browse files
committed
Add option to remove early sanity checks
1 parent 627310d commit 493bb17

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/dtls13.c

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

366+
#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
366367
ret = MsgCheckEncryption(ssl, msg->type, msg->encrypted);
367368
if (ret != 0) {
368369
SendAlert(ssl, alert_fatal, unexpected_message);
369370
break;
370371
}
372+
#endif
371373

372374
/* We may have DTLS <=1.2 msgs stored from before we knew which version
373375
* we were going to use. Interpret correctly. */

src/internal.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10718,6 +10718,8 @@ int CheckAvailableSize(WOLFSSL *ssl, int size)
1071810718
return 0;
1071910719
}
1072010720

10721+
#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
10722+
1072110723
int MsgCheckEncryption(WOLFSSL* ssl, byte type, byte encrypted)
1072210724
{
1072310725
#ifdef WOLFSSL_QUIC
@@ -10952,6 +10954,8 @@ static int MsgCheckBoundary(const WOLFSSL* ssl, byte type,
1095210954
return 0;
1095310955
}
1095410956

10957+
#endif /* WOLFSSL_DISABLE_EARLY_SANITY_CHECKS */
10958+
1095510959
/**
1095610960
* This check is performed as soon as the handshake message type becomes known.
1095710961
* These checks can not be delayed and need to be performed when the msg is
@@ -10967,8 +10971,9 @@ static int MsgCheckBoundary(const WOLFSSL* ssl, byte type,
1096710971
*/
1096810972
int EarlySanityCheckMsgReceived(WOLFSSL* ssl, byte type, word32 msgSz)
1096910973
{
10970-
byte version_negotiated = 0;
1097110974
int ret = 0;
10975+
#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
10976+
byte version_negotiated = 0;
1097210977

1097310978
WOLFSSL_ENTER("EarlySanityCheckMsgReceived");
1097410979

@@ -10995,6 +11000,11 @@ int EarlySanityCheckMsgReceived(WOLFSSL* ssl, byte type, word32 msgSz)
1099511000
SendAlert(ssl, alert_fatal, unexpected_message);
1099611001

1099711002
WOLFSSL_LEAVE("EarlySanityCheckMsgReceived", ret);
11003+
#else
11004+
(void)ssl;
11005+
(void)type;
11006+
(void)msgSz;
11007+
#endif
1099811008

1099911009
return ret;
1100011010
}
@@ -17568,11 +17578,13 @@ int DtlsMsgDrain(WOLFSSL* ssl)
1756817578
item->ready && ret == 0) {
1756917579
word32 idx = 0;
1757017580

17581+
#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
1757117582
ret = MsgCheckEncryption(ssl, item->type, item->encrypted);
1757217583
if (ret != 0) {
1757317584
SendAlert(ssl, alert_fatal, unexpected_message);
1757417585
break;
1757517586
}
17587+
#endif
1757617588

1757717589
#ifdef WOLFSSL_NO_TLS12
1757817590
ret = DoTls13HandShakeMsgType(ssl, item->fullMsg, &idx, item->type,

tests/api.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67471,7 +67471,11 @@ static int test_TLSX_CA_NAMES_bad_extension(void)
6747167471
}
6747267472

6747367473
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
67474+
#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
6747467475
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), OUT_OF_ORDER_E);
67476+
#else
67477+
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), BUFFER_ERROR);
67478+
#endif
6747567479

6747667480
wolfSSL_free(ssl_c);
6747767481
ssl_c = NULL;

0 commit comments

Comments
 (0)