Skip to content

Commit f810dc2

Browse files
committed
Add check for KeyShare in ServerHello
Fixes ZD21171
1 parent ca5b484 commit f810dc2

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

src/tls.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10094,6 +10094,8 @@ int TLSX_KeyShare_Parse(WOLFSSL* ssl, const byte* input, word16 length,
1009410094
if (length < OPAQUE16_LEN)
1009510095
return BUFFER_ERROR;
1009610096

10097+
ssl->options.shSentKeyShare = 1;
10098+
1009710099
/* The data is the named group the server wants to use. */
1009810100
ato16(input, &group);
1009910101

src/tls13.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5559,7 +5559,8 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
55595559
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
55605560
ssl->options.pskNegotiated == 0 &&
55615561
#endif
5562-
ssl->session->namedGroup == 0) {
5562+
(ssl->session->namedGroup == 0 ||
5563+
ssl->options.shSentKeyShare == 0)) {
55635564
return EXT_MISSING;
55645565
}
55655566

tests/api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28906,7 +28906,7 @@ static int test_TLSX_CA_NAMES_bad_extension(void)
2890628906

2890728907
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
2890828908
#ifndef WOLFSSL_DISABLE_EARLY_SANITY_CHECKS
28909-
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WC_NO_ERR_TRACE(OUT_OF_ORDER_E));
28909+
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WC_NO_ERR_TRACE(EXT_MISSING));
2891028910
#else
2891128911
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WC_NO_ERR_TRACE(BUFFER_ERROR));
2891228912
#endif

wolfssl/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5107,6 +5107,7 @@ struct Options {
51075107
word16 hrrSentCookie:1; /* HRR sent with cookie */
51085108
#endif
51095109
word16 hrrSentKeyShare:1; /* HRR sent with key share */
5110+
word16 shSentKeyShare:1; /* SH sent with key share */
51105111
#endif
51115112
word16 returnOnGoodCh:1;
51125113
word16 disableRead:1;

0 commit comments

Comments
 (0)