Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit b78dac2

Browse files
committed
QUIC: Handle EndOfEarlyData and MaxEarlyData
1 parent 5f05ffc commit b78dac2

4 files changed

Lines changed: 33 additions & 2 deletions

File tree

ssl/statem/extensions_clnt.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,17 @@ int tls_parse_stoc_early_data(SSL *s, PACKET *pkt, unsigned int context,
19191919
return 0;
19201920
}
19211921

1922+
#ifndef OPENSSL_NO_QUIC
1923+
/*
1924+
* QUIC server must send 0xFFFFFFFF or it's a PROTOCOL_VIOLATION
1925+
* per draft-ietf-quic-tls-24 S4.5
1926+
*/
1927+
if (s->quic_method != NULL && max_early_data != 0xFFFFFFFF) {
1928+
SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_R_INVALID_MAX_EARLY_DATA);
1929+
return 0;
1930+
}
1931+
#endif
1932+
19221933
s->session->ext.max_early_data = max_early_data;
19231934

19241935
return 1;

ssl/statem/extensions_srvr.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,12 +1890,20 @@ EXT_RETURN tls_construct_stoc_early_data(SSL *s, WPACKET *pkt,
18901890
size_t chainidx)
18911891
{
18921892
if (context == SSL_EXT_TLS1_3_NEW_SESSION_TICKET) {
1893-
if (s->max_early_data == 0)
1893+
uint32_t max_early_data = s->max_early_data;
1894+
1895+
if (max_early_data == 0)
18941896
return EXT_RETURN_NOT_SENT;
18951897

1898+
#ifndef OPENSSL_NO_QUIC
1899+
/* QUIC server must always send 0xFFFFFFFF, per draft-ietf-quic-tls-24 S4.5 */
1900+
if (s->quic_method != NULL)
1901+
max_early_data = 0xFFFFFFFF;
1902+
#endif
1903+
18961904
if (!WPACKET_put_bytes_u16(pkt, TLSEXT_TYPE_early_data)
18971905
|| !WPACKET_start_sub_packet_u16(pkt)
1898-
|| !WPACKET_put_bytes_u32(pkt, s->max_early_data)
1906+
|| !WPACKET_put_bytes_u32(pkt, max_early_data)
18991907
|| !WPACKET_close(pkt)) {
19001908
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
19011909
return EXT_RETURN_FAIL;

ssl/statem/statem_clnt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,14 @@ int ossl_statem_client_construct_message(SSL *s, WPACKET *pkt,
904904
break;
905905

906906
case TLS_ST_CW_END_OF_EARLY_DATA:
907+
#ifndef OPENSSL_NO_QUIC
908+
/* QUIC does not send EndOfEarlyData, draft-ietf-quic-tls-24 S8.3 */
909+
if (s->quic_method != NULL) {
910+
*confunc = NULL;
911+
*mt = SSL3_MT_DUMMY;
912+
break;
913+
}
914+
#endif
907915
*confunc = tls_construct_end_of_early_data;
908916
*mt = SSL3_MT_END_OF_EARLY_DATA;
909917
break;

ssl/statem/statem_srvr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ static int ossl_statem_server13_read_transition(SSL *s, int mt)
7676
break;
7777
} else if (s->ext.early_data == SSL_EARLY_DATA_ACCEPTED) {
7878
if (mt == SSL3_MT_END_OF_EARLY_DATA) {
79+
#ifndef OPENSSL_NO_QUIC
80+
if (s->quic_method != NULL)
81+
return 0;
82+
#endif
7983
st->hand_state = TLS_ST_SR_END_OF_EARLY_DATA;
8084
return 1;
8185
}

0 commit comments

Comments
 (0)