Skip to content

Commit

Permalink
Complete rewrite
Browse files Browse the repository at this point in the history
- New extension
- Allowing larger than 2^16 bytes
- Reduce overhead
- Skipping old record struct for compatibility with TLS 1.2 middleboxes.
  • Loading branch information
emanjon authored Mar 26, 2024
1 parent 102f3a1 commit 5411112
Showing 1 changed file with 93 additions and 23 deletions.
116 changes: 93 additions & 23 deletions draft-mattsson-tls-super-jumbo-record-limit.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: "Large Record Sizes for TLS and DTLS"
title: "Large Record Sizes for TLS and DTLS with Reduced Overhead"
abbrev: "Large Record Sizes for TLS"
category: std

docname: draft-mattsson-tls-super-jumbo-record-limit-latest
Expand Down Expand Up @@ -44,61 +45,130 @@ normative:
RFC2119:
RFC8174:
RFC8446:
RFC8447:
RFC8449:
RFC9147:
I-D.ietf-tls-tlsflags:

informative:

RFC6083:

--- abstract

RFC 8449 defines a record size limit extension for TLS and DTLS allowing endpoints to negotiate a record size limit smaller than the protocol-defined maximum record size, which is around 2<sup>14</sup> bytes. This document specifies a TLS flag extension to be used in combination with the record size limit extension allowing endpoints to use a record size limit larger than the protocol-defined maximum record size, but not more than about 2<sup>16</sup> bytes.
TLS 1.3 records limit the inner plaintext size to 2<sup>14</sup> + 1 bytes and have 3 bytes overhead for compatibility with middleboxes. This document defines a TLS extension that enables endpoints to negotiate a larger maximum inner plaintext size, up to 2<sup>32</sup> - 256 bytes, with reduced overhead.

--- middle

# Introduction

The records in all versions of TLS have an uint16 length field that could theoretically allow records 65535 octets in size. TLS does however have a lower protocol-defined limit for maximum plaintext record size. For TLS 1.3 {{RFC8446}}, that limit is 2<sup>14</sup> = 16384 octets. In addition, TLS 1.3 expands the plaintext with 1 octet for content type and allow AEAD expansion up to 255 octets (though typically this expansion is only 16 octets).
TLS 1.3 protected records limit the inner plaintext size to 2<sup>14</sup> + 1 bytes and have 3 bytes overhead for compatibility with middleboxes expecting TLS 1.2 records. TLS-based protocols are increasingly used to secure long-lived interfaces in critical infrastructure, such as telecommunication networks. In some infrastructure use cases, the 2<sup>14</sup>-byte limit in TLS leads to more fragmentation, resulting in increased CPU and memory consumption, and might necessitate an additional protocol layer for fragmentation. Allowing 2<sup>32</sup>-byte records would eliminate additional fragmentation in almost all use cases. In {{RFC6083}} (DTLS over SCTP), the 2<sup>14</sup>-byte limit is a severe restriction.

The "record_size_limit" extension {{RFC8449}} enables endpoints to negotiate a lower limit for the maximum plaintext record size, but does not allow endpoints to increase the limits enforced by TLS 1.3 {{RFC8446}}, and DTLS 1.3 {{RFC9147}}. In some use cases such as DTLS over SCTP {{RFC6083}} the 2<sup>14</sup> bytes limit is a severe limitation.

This document defines a "large_record_size" flag extension using the TLS flags extension mechanism {{I-D.ietf-tls-tlsflags}}. The record size limit extension for TLS as specified in {{RFC8449}} used in combination with the flag extension defined in this document allow endpoints to negotiate a record size limit larger than the protocol-defined maximum record size. This can be used to bump up the maximum plaintext record size for protected records to 2<sup>16</sup> - 257 bytes, which is larger than the default limit of 2<sup>14</sup> bytes. This flag extension is defined for version 1.3 of TLS and DTLS.
This document defines a "large_record_size_limit" extension that allows endpoints to negotiate a larger maximum inner plaintext size. This extension is valid in TLS 1.3 and DTLS 1.3. The extension works similarly to the "record_size_limit" extension defined in {{RFC8449}}. Additionally, this document defines new TLS 1.3 TLSLargeCiphertext and DTLS 1.3 unified_hdr structures to enable inner plaintexts up to 2<sup>32</sup> - 256 bytes with reduced overhead. For example, inner plaintexts up to 2<sup>16</sup> - 256
bytes can be supported with 3 bytes less overhead, which is useful in constrained IoT. The "large_record_size_limit" extension is incompatible with middleboxes expecting TLS 1.2 records.

# Terminology

{::boilerplate bcp14-tagged}

# The "large_record_size" Flag Extension {#ex}

When the "large_record_size" flag extension in addition to the "record_size_limit" extension is negotiated, an endpoint MUST be prepared to accept protected records with plaintext of the negotiated length. Since the 2<sup>16</sup> - 1 limit also applies to the ciphertext length, the maximum length of a protected record plaintext that can be negotiated is therefore 2<sup>16</sup> - 257 = 65279 octets. Unprotected messages are still subject to the lower default limits.

The "large_record_size" flag extension MUST be negotiated together with the "record_size_limit" extension and MUST NOT be negotiated together with the "max_fragment_length" extension. A client MUST treat receipt of the "large_record_size" flags extension without the "record_size_limit" extension or together with the "max_fragment_length" extension as a fatal error, and it SHOULD generate an "illegal_parameter" alert.

During resumption, the record size limit is renegotiated. Records are subject to the limits that were set in the handshake that produces the keys that are used to protect those records. This admits the possibility that the extension might not be negotiated when a connection is resumed.
# The "large_record_size_limit" Extension

The ExtensionData of the "large_record_size_limit" extension is LargeRecordSizeLimit:

~~~~~~~~
uint32 LargeRecordSizeLimit;
~~~~~~~~

LargeRecordSizeLimit denotes the maximum size, in bytes, of inner plaintexts that the endpoint is willing to receive. It includes the content type and padding (i.e., the complete length of TLSInnerPlaintext). AEAD expansion is not included.

The large record size limit only applies to records sent toward the endpoint that advertises the limit. An endpoint can send records that are larger than the limit it advertises as its own limit. A TLS endpoint that receives a record larger than its advertised limit MUST generate a fatal "record_overflow" alert; a DTLS endpoint that receives a record larger than its advertised limit MAY either generate a fatal "record_overflow" alert or discard the record. An endpoint MUST NOT add padding to records that would cause the length of TLSInnerPlaintext to exceed the limit advertised by the other endpoint.

Endpoints MUST NOT send a "large_record_size_limit" extension with a value smaller than 64 or larger than 2<sup>32</sup> - 256. An endpoint MUST treat receipt of a smaller or larger value as a fatal error and generate an "illegal_parameter" alert.

The server sends the "large_record_size_limit" extension in the EncryptedExtensions message. During resumption, the limit is renegotiated. Records are subject to the limits that were set in the handshake that produces the keys that are used to protect those records. This admits the possibility that the extension might not be negotiated during resumption.

Unprotected messages and records protected with early_traffic_secret or handshake_traffic_secret are not subject to the large record size limit.

When the "large_record_size_limit" extension is negotiated:

* All TLS 1.3 records protected with application_traffic_secret MUST use the TLSLargeCiphertext structure instead of the TLSCiphertext structure. The size of the length field depends on the limit advertised by the receiver. If the limit is less than
2<sup>16</sup> - 255 an uint16 is used, if the limit is larger than 2<sup>24</sup> - 256 an uint32 is used, and otherwise an uint24 is used. The length is fixed for the connection. Different lengths might be used in different directions.

~~~~~~~~
enum { u16(0), u24(1), u32(2) } Length;
~~~~~~~~
~~~~~~~~
struct {
select (Length.type) {
case u16: uint16;
case u24: uint24;
case u32: uint24;
};
} VarLength;
~~~~~~~~
~~~~~~~~
struct {
VarLength length;
opaque encrypted_record[TLSLargeCiphertext.length];
} TLSLargeCiphertext;
~~~~~~~~

* All DTLS 1.3 records protected with application_traffic_secret and with length present MUST use a unified_hdr structure with a length equal to the TLS 1.3 length field defined above.

~~~~~~~~
0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|0|0|1|C|S|L|E E|
+-+-+-+-+-+-+-+-+
| Connection ID | Legend:
| (if any, |
/ length as / C - Connection ID (CID) present
| negotiated) | S - Sequence number length
+-+-+-+-+-+-+-+-+ L - Length present
| 8 or 16 bit | E - Epoch
|Sequence Number|
+-+-+-+-+-+-+-+-+
| 16, 24, or 32 |
| bit Length |
| (if present) |
+-+-+-+-+-+-+-+-+
~~~~~~~~

* An endpoint MAY generate records protected with application_traffic_secret with inner plaintext that is equal to or smaller than the LargeRecordSizeLimit value it receives from its peer. An endpoint MUST NOT generate a protected record with inner plaintext that is larger than the LargeRecordSizeLimit value it receives from its peer.

The "large_record_size_limit" extension is not compatible with middleboxes expecting TLS 1.2 records and SHOULD NOT be negotiated where such middleboxes are expected.
A server MUST NOT send extension responses to more than one of "large_record_size_limit", "record_size_limit", and "max_fragment_length".
A client MUST treat receipt of more than one of "large_record_size_limit", "record_size_limit", and "max_fragment_length" as a fatal error, and it SHOULD generate an "illegal_parameter" alert.

The Path Maximum Transmission Unit (PMTU) in DTLS also limits the size of records. The record size limit does not affect PMTU discovery and SHOULD be set independently. The record size limit is fixed during the handshake and so should be set based on constraints at the endpoint and not based on the current network environment. In comparison, the PMTU is determined by the network path and can change dynamically over time.

# Limits on Key Usage

The maximum record size limit is an input to the AEAD limits calculations in TLS 1.3 {{RFC8446}} and DTLS 1.3 {{RFC9147}}. Increasing the maximum record size to more than 2<sup>14</sup> + 256 bytes while keeping the same confidentiality and integrity advantage per write key therefore requires lower AEAD limits. When the "large_record_size" has been negotiated record size limit larger than the protocol-defined maximum record size, existing AEAD limits SHALL be decreased by a factor of 4. For example, when AES-CGM is used in TLS 1.3 {{RFC8446}} with a 64 kB record limit, only 2<sup>22.5</sup> records (about 6 million) may be encrypted on a given connection.
The maximum record size limit is an input to the AEAD limits calculations in TLS 1.3 {{RFC8446}} and DTLS 1.3 {{RFC9147}}. Increasing the maximum record size to more than 2<sup>14</sup> + 256 bytes while keeping the same confidentiality and integrity advantage per write key therefore requires lower AEAD limits. When the "large_record_size" has been negotiated record size limit larger than 2<sup>14</sup> + 1
bytes, existing AEAD limits SHALL be decreased by a factor of (LargeRecordSizeLimit) / (2^14-256). For example, when AES-CGM is used in TLS 1.3 {{RFC8446}} with a 64 kB record limit, only arounf 2<sup>22.5</sup> records (about 6 million) may be encrypted on a given connection.

# Security Considerations

Large record sizes might require more memory allocation for senders and receivers. Large record sizes also means that more processing is done before verification of non-authentic records fails.
Large record sizes might require more memory allocation for senders and receivers. Additionally, larger record sizes also means that more processing is done before verification of non-authentic records fails.

The use of larger record sizes can either simplify or complicate traffic analysis, depending on the application. The LargeRecordSizeLimit is just an upper limit and it is still the sender that decides the size of the inner plaintexts up to that limit.

# IANA Considerations

This document registers the following entry to the "TLS Flags" registry defined in {{I-D.ietf-tls-tlsflags}}:
IANA is requested to assign a new value in the TLS ExtensionType Values registry defined by {{RFC8447}}:

* The Extension Name should be large_record_size_limit

* The TLS 1.3 value should be CH, EE

* The DTLS-Only value should be N

* The Recommended value should be Y

* Value: TBD1
* Flag Name: large_record_size
* Messages: CH, EE
* Recommended: Y
* Reference: [This document]
* The Reference should be this document

--- back

# Acknowledgments
{:numbered="false"}

The authors would like to thank {{{Benjamin Kaduk}}} for his valuable comments and feedback.
The authors would like to thank {{{Stephen Farrell}}}, {{{Benjamin Kaduk}}}, and {{{Martin Thomson}}} for their valuable comments and feedback. Some of the text were inspired by and borrowed from {{RFC8449}}.

0 comments on commit 5411112

Please sign in to comment.