Skip to content

Commit 975033c

Browse files
committed
DTLS: Introduce returnOnGoodCh option for early ClientHello processing return
1 parent 6e82658 commit 975033c

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/ssl.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11012,6 +11012,12 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl,
1101211012
FALL_THROUGH;
1101311013

1101411014
case ACCEPT_FIRST_REPLY_DONE :
11015+
if (ssl->options.returnOnGoodCh) {
11016+
/* Higher level in stack wants us to return. Simulate a
11017+
* WANT_WRITE to accomplish this. */
11018+
ssl->error = WANT_WRITE;
11019+
return WOLFSSL_FATAL_ERROR;
11020+
}
1101511021
if ( (ssl->error = SendServerHello(ssl)) != 0) {
1101611022
#ifdef WOLFSSL_CHECK_ALERT_ON_ERR
1101711023
ProcessReplyEx(ssl, 1); /* See if an alert was sent. */
@@ -11312,15 +11318,19 @@ int wolfDTLS_accept_stateless(WOLFSSL* ssl)
1131211318
if (wolfDTLS_SetChGoodCb(ssl, chGoodDisableReadCB, &cb) != WOLFSSL_SUCCESS)
1131311319
return WOLFSSL_FATAL_ERROR;
1131411320

11321+
ssl->options.returnOnGoodCh = 1;
1131511322
ret = wolfSSL_accept(ssl);
11323+
ssl->options.returnOnGoodCh = 0;
1131611324
/* restore user options */
1131711325
ssl->options.disableRead = disableRead;
1131811326
(void)wolfDTLS_SetChGoodCb(ssl, cb.userCb, cb.userCtx);
1131911327
if (ret == WOLFSSL_SUCCESS) {
1132011328
WOLFSSL_MSG("should not happen. maybe the user called "
1132111329
"wolfDTLS_accept_stateless instead of wolfSSL_accept");
1132211330
}
11323-
else if (ssl->error == WC_NO_ERR_TRACE(WANT_READ)) {
11331+
else if (ssl->error == WC_NO_ERR_TRACE(WANT_READ) ||
11332+
ssl->error == WC_NO_ERR_TRACE(WANT_WRITE)) {
11333+
ssl->error = 0;
1132411334
if (ssl->options.dtlsStateful)
1132511335
ret = WOLFSSL_SUCCESS;
1132611336
else

src/tls13.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14596,6 +14596,12 @@ int wolfSSL_accept_TLSv13(WOLFSSL* ssl)
1459614596
FALL_THROUGH;
1459714597

1459814598
case TLS13_ACCEPT_SECOND_REPLY_DONE :
14599+
if (ssl->options.returnOnGoodCh) {
14600+
/* Higher level in stack wants us to return. Simulate a
14601+
* WANT_WRITE to accomplish this. */
14602+
ssl->error = WANT_WRITE;
14603+
return WOLFSSL_FATAL_ERROR;
14604+
}
1459914605

1460014606
if ((ssl->error = SendTls13ServerHello(ssl, server_hello)) != 0) {
1460114607
WOLFSSL_ERROR(ssl->error);

wolfssl/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5091,6 +5091,7 @@ struct Options {
50915091
#endif
50925092
word16 hrrSentKeyShare:1; /* HRR sent with key share */
50935093
#endif
5094+
word16 returnOnGoodCh:1;
50945095
word16 disableRead:1;
50955096

50965097
#ifdef WOLFSSL_EARLY_DATA

0 commit comments

Comments
 (0)