Skip to content

Commit be99ec3

Browse files
committed
Added check in TLX_Parse to check if KeyShare extension is present
SupportedGroups must be present too (and viceversa). From RFC 8446 Section 9.2.
1 parent 7a0c40e commit be99ec3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/tls.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16737,12 +16737,30 @@ int TLSX_Parse(WOLFSSL* ssl, const byte* input, word16 length, byte msgType,
1673716737
ssl->options.noPskDheKe = 1;
1673816738
}
1673916739
#endif
16740+
#if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
16741+
/* RFC 8446 Section 9.2: ClientHello with KeyShare must
16742+
* contain SupportedGroups and vice-versa. */
16743+
if (IsAtLeastTLSv1_3(ssl->version) && msgType == client_hello && isRequest) {
16744+
int hasKeyShare = !IS_OFF(seenType, TLSX_ToSemaphore(TLSX_KEY_SHARE));
16745+
int hasSupportedGroups = !IS_OFF(seenType, TLSX_ToSemaphore(TLSX_SUPPORTED_GROUPS));
16746+
16747+
if (hasKeyShare && !hasSupportedGroups) {
16748+
WOLFSSL_MSG("ClientHello with KeyShare extension missing required SupportedGroups extension");
16749+
return MISSING_HANDSHAKE_DATA;
16750+
}
16751+
if (hasSupportedGroups && !hasKeyShare) {
16752+
WOLFSSL_MSG("ClientHello with SupportedGroups extension missing required KeyShare extension");
16753+
return MISSING_HANDSHAKE_DATA;
16754+
}
16755+
}
16756+
#endif
1674016757

1674116758
if (ret == 0)
1674216759
ret = SNI_VERIFY_PARSE(ssl, isRequest);
1674316760
if (ret == 0)
1674416761
ret = TCA_VERIFY_PARSE(ssl, isRequest);
1674516762

16763+
WOLFSSL_LEAVE("Leaving TLSX_Parse", ret);
1674616764
return ret;
1674716765
}
1674816766

0 commit comments

Comments
 (0)