7 Network Working Group R. Friend
8 Request for Comments: 3943 Hifn
9 Category: Informational November 2004
12 Transport Layer Security (TLS) Protocol Compression Using
17 This memo provides information for the Internet community. It does
18 not specify an Internet standard of any kind. Distribution of this
23 Copyright (C) The Internet Society (2004).
27 The Transport Layer Security (TLS) protocol (RFC 2246) includes
28 features to negotiate selection of a lossless data compression method
29 as part of the TLS Handshake Protocol and then to apply the algorithm
30 associated with the selected method as part of the TLS Record
31 Protocol. TLS defines one standard compression method, which
32 specifies that data exchanged via the record protocol will not be
33 compressed. This document describes an additional compression method
34 associated with the Lempel-Ziv-Stac (LZS) lossless data compression
35 algorithm for use with TLS. This document also defines the
36 application of the LZS algorithm to the TLS Record Protocol.
58 Friend Informational [Page 1]
60 RFC 3943 TLS Compression Using LZS November 2004
65 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
66 1.1. General. . . . . . . . . . . . . . . . . . . . . . . . . 2
67 1.2. Specification of Requirements. . . . . . . . . . . . . . 3
68 2. Compression Methods. . . . . . . . . . . . . . . . . . . . . . 3
69 2.1. LZS CompresionMethod . . . . . . . . . . . . . . . . . . 4
70 2.2. Security Issues with Single History Compression. . . . . 4
71 3. LZS Compression. . . . . . . . . . . . . . . . . . . . . . . . 4
72 3.1. Background of LZS Compression . . . . . . . . . . . . . 4
73 3.2. LZS Compression History and Record Processing . . . . . 5
74 3.3. LZS Compressed Record Format . . . . . . . . . . . . . . 6
75 3.4. TLSComp Header Format . . . . . . . . . . . . . . . . . 6
76 3.4.1. Flags. . . . . . . . . . . . . . . . . . . . . . 6
77 3.5. LZS Compression Encoding Format . . . . . . . . . . . . 7
78 3.6. Padding . . . . . . . . . . . . . . . . . . . . . . . . 8
79 4. Sending Compressed Records . . . . . . . . . . . . . . . . . . 8
80 4.1. Transmitter Process. . . . . . . . . . . . . . . . . . . 9
81 4.2. Receiver Process . . . . . . . . . . . . . . . . . . . . 9
82 4.3. Anti-expansion Mechanism . . . . . . . . . . . . . . . . 10
83 5. Internationalization Considerations . . . . . . . . . . . . . 10
84 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10
85 7. Security Considerations. . . . . . . . . . . . . . . . . . . . 11
86 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 11
87 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 12
88 9.1. Normative References . . . . . . . . . . . . . . . . . . 12
89 9.2. Informative References . . . . . . . . . . . . . . . . . 12
90 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 12
91 Full Copyright Statement . . . . . . . . . . . . . . . . . . . . . 13
97 The Transport Layer Security (TLS) protocol (RFC 2246, [2]) includes
98 features to negotiate selection of a lossless data compression method
99 as part of the TLS Handshake Protocol and then to apply the algorithm
100 associated with the selected method as part of the TLS Record
101 Protocol. TLS defines one standard compression method,
102 CompressionMethod.null, which specifies that data exchanged via the
103 record protocol will not be compressed. Although this single
104 compression method helps ensure that TLS implementations are
105 interoperable, the lack of additional standard compression methods
106 has limited the ability to develop interoperative implementations
107 that include data compression.
114 Friend Informational [Page 2]
116 RFC 3943 TLS Compression Using LZS November 2004
119 TLS is used extensively to secure client-server connections on the
120 World Wide Web. Although these connections can often be
121 characterized as short-lived and exchanging relatively small amounts
122 of data, TLS is also being used in environments where connections can
123 be long-lived and the amount of data exchanged can extend into
124 thousands or millions of octets. For example, TLS is now
125 increasingly being used as an alternative Virtual Private Network
126 (VPN) connection. Compression services have long been associated
127 with IPSec and PPTP VPN connections, so extending compression
128 services to TLS VPN connections preserves the user experience for any
129 VPN connection. Compression within TLS is one way to help reduce the
130 bandwidth and latency requirements associated with exchanging large
131 amounts of data while preserving the security services provided by
134 This document describes an additional compression method associated
135 with a lossless data compression algorithm for use with TLS. This
136 document specifies the application of Lempel-Ziv-Stac (LZS)
137 compression, a lossless compression algorithm, to TLS record
138 payloads. This specification also assumes a thorough understanding
139 of the TLS protocol [2].
141 1.2. Specification of Requirements
143 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
144 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
145 document are to be interpreted as described in BCP 14, RFC 2119 [1].
147 2. Compression Methods
149 As described in section 6 of RFC 2246 [2], TLS is a stateful
150 protocol. Compression methods used with TLS can be either stateful
151 (the compressor maintains its state through all compressed records)
152 or stateless (the compressor compresses each record independently),
153 but there seems to be little known benefit in using a stateless
154 compression method within TLS. The LZS compression method described
155 in this document is stateful.
157 Compression algorithms can occasionally expand, rather than compress,
158 input data. The worst-case expansion factor of the LZS compression
159 method is only 12.5%. Thus, TLS records of 15K bytes can never
160 exceed the expansion limits described in section 6.2.2 of RFC 2246
161 [2]. If TLS records of 16K bytes expand to an amount greater than
162 17K bytes, then the uncompressed version of the TLS record must be
163 transmitted, as described below.
170 Friend Informational [Page 3]
172 RFC 3943 TLS Compression Using LZS November 2004
175 2.1. LZS CompressionMethod
177 The LZS CompressionMethod is a 16-bit index and is negotiated as
178 described in RFC 2246 [2] and RFC 3749 [3]. The LZS
179 CompressionMethod is stored in the TLS Record Layer connection state
180 as described in RFC 2246 [2].
182 IANA has assigned 64 as compression method identifier for applying
183 LZS compression to TLS record payloads.
185 2.2. Security Issues with Compression Histories
187 Sharing compression histories between or among more than one TLS
188 session may potentially cause information leakage between the TLS
189 sessions, as pathological compressed data can potentially reference
190 data prior to the beginning of the current record. LZS
191 implementations guard against this situation. However, to avoid this
192 potential threat, implementations supporting TLS compression MUST use
193 separate compression histories for each TLS session. This is not a
194 limitation of LZS compression but is an artifact for any compression
197 Furthermore, the LZS compression history (as well as any compression
198 history) contains plaintext. Specifically, the LZS history contains
199 the last 2K bytes of plaintext of the TLS session. Thus, when the
200 TLS session terminates, the implementation SHOULD treat the history
201 as it does any plaintext (e.g., free memory, overwrite contents).
205 3.1. Background of LZS Compression
207 Starting with a sliding window compression history, similar to LZ1
208 [8], a new, enhanced compression algorithm identified as LZS was
209 developed. The LZS algorithm is a general-purpose lossless
210 compression algorithm for use with a wide variety of data types. Its
211 encoding method is very efficient, providing compression for strings
212 as short as two octets in length.
214 The LZS algorithm uses a sliding window of 2,048 bytes. During
215 compression, redundant sequences of data are replaced with tokens
216 that represent those sequences. During decompression, the original
217 sequences are substituted for the tokens in such a way that the
218 original data is exactly recovered. LZS differs from lossy
219 compression algorithms, such as those often used for video
220 compression, that do not exactly reproduce the original data. The
221 details of LZS compression can be found in section 3.5 below.
226 Friend Informational [Page 4]
228 RFC 3943 TLS Compression Using LZS November 2004
231 3.2. LZS Compression History and Record Processing
233 This standard specifies "stateful" compression -- that is,
234 maintaining the compression history between records within a
235 particular TLS compression session. Within each separate compression
236 history, the LZS CompressionMethod can maintain compression history
237 information when compressing and decompressing record payloads.
238 Stateful compression provides a higher compression ratio to be
239 achieved on the data stream, as compared to stateless compression
240 (resetting the compression history between every record),
241 particularly for small records.
243 Stateful compression requires both a reliable link and sequenced
244 record delivery to ensure that all records can be decompressed in the
245 same order they were compressed. Since TLS and lower-layer protocols
246 provide reliable, sequenced record delivery, compression history
247 information MAY be maintained and exploited when the LZS
248 CompressionMethod is used.
250 Furthermore, there MUST be a separate LZS compression history
251 associated with each open TLS session. This not only provides
252 enhanced security (no potential information leakage between sessions
253 via a shared compression history), but also enables superior
254 compression ratio (bit bandwidth on the connection) across all open
255 TLS sessions with compression. A shared history would require
256 resetting the compression (and decompression) history when switching
257 between TLS sessions, and a single history implementation would
258 require resetting the compression (and decompression) history between
261 The sender MUST reset the compression history prior to compressing
262 the first TLS record of a TLS session after TLS handshake completes.
263 It is advantageous for the sender to maintain the compression history
264 for all subsequent records processed during the TLS session. This
265 results in the greatest compression ratio for a given data set. In
266 either case, this compression history MUST NOT be used for any other
267 open TLS session, to ensure privacy between TLS sessions.
269 The sender MUST "flush" the compressor each time it transmits a
270 compressed record. Flushing means that all data going into the
271 compressor is included in the output, i.e., no data is retained in
272 the hope of achieving better compression. Flushing ensures that each
273 compressed record payload can be decompressed completely. Flushing is
274 necessary to prevent a record's data from spilling over into a later
275 record. This is important for synchronizing compressed data with the
276 authenticated and encrypted data in a TLS record. Flushing is
277 handled automatically in most LZS implementations.
282 Friend Informational [Page 5]
284 RFC 3943 TLS Compression Using LZS November 2004
287 When the TLS session terminates, the implementation SHOULD dispose of
288 the memory resources associated with the related TLS compression
289 history. That is, the compression history SHOULD be handled as the
290 TLS key material is handled.
292 The LZS CompressionMethod also features "decompressing" uncompressed
293 data in order to maintain the history if the "compressed" data
294 actually expanded. The LZS CompressionMethod record format
295 facilitates identifying whether records contain compressed or
296 uncompressed data. The LZS decoding process accommodates
297 decompressing either compressed or uncompressed data.
299 3.3. LZS Compressed Record Format
301 Prior to compression, the uncompressed data (TLSPlaintext.fragment)
302 is composed of a plaintext TLS record. After compression, the
303 compressed data (TLSCompressed.fragment) is composed of an 8-bit
304 TLSComp header followed by the compressed (or uncompressed) data.
306 3.4. TLSComp Header Format
308 The one-octet header has the following structure:
319 The format of the 8-bit Flags TLSComp field is as follows:
322 +-----+-----+-----+-----+-----+-----+-----+-----+
323 | Res | Res | Res | Res | Res | Res | RST | C/U |
324 +-----+-----+-----+-----+-----+-----+-----+-----+
328 Reserved for future use. MUST be set to zero. MUST be ignored by
338 Friend Informational [Page 6]
340 RFC 3943 TLS Compression Using LZS November 2004
343 RST-Reset Compression History
345 The RST bit is used to inform the decompressing peer that the
346 compression history in this TLS session was reset prior to the
347 data contained in this TLS record being compressed. When the RST
348 bit is set to "1", a compression history reset is performed; when
349 RST is set to "0", a compression history reset is not performed.
351 This bit MUST be set to a value of "1" for the first compressed
352 TLS transmitted record of a TLS session. This bit may also be
353 used by the transmitter for other exception cases when the
354 compression history must be reset.
356 C/U-Compressed/Uncompressed Bit
358 The C/U indicates whether the data field contains compressed or
359 uncompressed data. A value of 1 indicates compressed data (often
360 referred to as a compressed record), and a value of 0 indicates
361 uncompressed data (or an uncompressed record).
363 3.5. LZS Compression Encoding Format
365 The LZS compression method, encoding format, and application examples
366 are described in RFC 1967 [6], RFC 1974 [5], and RFC 2395 [4].
368 Some implementations of LZS allow the sending compressor to select
369 from among several options to provide varying compression ratios,
370 processing speeds, and memory requirements. Other implementations of
371 LZS provide optimal compression ratio at byte-per-clock speeds.
373 The receiving LZS decompressor automatically adjusts to the settings
374 selected by the sender. Also, receiving LZS decompressors will
375 update the decompression history with uncompressed data. This
376 facilitates never obtaining less than a 1:1 compression ratio in the
377 session and never transmitting with expanded data.
379 The input to the payload compression algorithm is TLSPlaintext data
380 destined to an active TLS session with compression negotiated. The
381 output of the algorithm is a new (and hopefully smaller)
382 TLSCompressed record. The output payload contains the input
383 payload's data in either compressed or uncompressed format. The
384 input and output payloads are each an integral number of bytes in
387 The output payload is always prepended with the TLSComp header. If
388 the uncompressed form is used, the output payload is identical to the
389 input payload, and the TLSComp header reflects uncompressed data.
394 Friend Informational [Page 7]
396 RFC 3943 TLS Compression Using LZS November 2004
399 If the compressed form is used, encoded as defined in ANSI X3.241
400 [7], and the TLSComp header reflects compressed data. The LZS
401 encoded format is repeated here for informational purposes ONLY.
403 <Compressed Stream> := [<Compressed String>*] <End Marker>
404 <Compressed String> := 0 <Raw Byte> | 1 <Compressed Bytes>
406 <Raw Byte> := <b><b><b><b><b><b><b><b> (8-bit byte)
407 <Compressed Bytes> := <Offset> <Length>
409 <Offset> := 1 <b><b><b><b><b><b><b> | (7-bit offset)
410 0 <b><b><b><b><b><b><b><b><b><b><b> (11-bit offset)
411 <End Marker> := 110000000
415 00 = 2 1111 0110 = 14
416 01 = 3 1111 0111 = 15
417 10 = 4 1111 1000 = 16
418 1100 = 5 1111 1001 = 17
419 1101 = 6 1111 1010 = 18
420 1110 = 7 1111 1011 = 19
421 1111 0000 = 8 1111 1100 = 20
422 1111 0001 = 9 1111 1101 = 21
423 1111 0010 = 10 1111 1110 = 22
424 1111 0011 = 11 1111 1111 0000 = 23
425 1111 0100 = 12 1111 1111 0001 = 24
430 A datagram payload compressed with LZS always ends with the last
431 compressed data byte (also known as the <end marker>), which is used
432 to disambiguate padding. This allows trailing bits, as well as
433 bytes, to be considered padding.
435 The size of a compressed payload MUST be in whole octet units.
437 4. Sending Compressed Datagrams
439 All TLS records processed with a TLS session state that includes LZS
440 compression are processed as follows. The reliable and efficient
441 transport of LZS compressed records in the TLS session depends on the
450 Friend Informational [Page 8]
452 RFC 3943 TLS Compression Using LZS November 2004
455 4.1. Transmitter Process
457 The compression operation results in either compressed or
458 uncompressed data. When a TLS record is received, it is assigned to
459 a particular TLS context that includes the LZS compression history
460 buffer. It is processed according to ANSI X3.241-1994 to form
461 compressed data or used as is to form uncompressed data. For the
462 first record of the session, or for exception conditions, the
463 compression history MUST be cleared. In performing the compression
464 operation, the compression history MUST be updated when either a
465 compressed record or an uncompressed record is produced.
466 Uncompressed TLS records MAY be sent at any time. Uncompressed TLS
467 records MUST be sent if compression causes enough expansion to make
468 the data compression TLS record size exceed the MTU defined in
469 section 6.2.2 in RFC 2246. The output of the compression operation
470 is placed in the fragment field of the TLSCompressed structure
471 (TLSCompressed.fragment).
473 The TLSComp header byte is located just prior to the first byte of
474 the compressed TLS record in TLSCompressed.fragment. The C/U bit in
475 the TLSComp header is set according to whether the data field
476 contains compressed or uncompressed data. The RST bit in the TLSComp
477 header is set to "1" if the compression history was reset prior to
478 compressing the TLSplaintext.fragment that is composed of a
479 TLSCompressed.fragment. Uncompressed data MUST be transmitted (and
480 the C/U bit set to 0) if the "compressed" (expanded) data exceeded
483 4.2. Receiver Process
485 Prior to decompressing the first compressed TLS record in the TLS
486 session, the receiver MUST reset the decompression history.
487 Subsequent records are decompressed in the order received. The
488 receiver decompresses the Payload Data field according to the
489 encoding specified in section 3.5 above.
491 If the received datagram is not compressed, the receiver does not
492 need to perform decompression processing, and the Payload Data field
493 of the datagram is ready for processing by the next protocol layer.
495 After a TLS record is received from the peer and decrypted, the RST
496 and C/U bits MUST be checked.
498 If the C/U bit is set to "1", the resulting compressed data block
499 MUST be decompressed according to section 3.5 above.
501 If the C/U bit is set to "0", the specified decompression history
502 MUST be updated with the received uncompressed data.
506 Friend Informational [Page 9]
508 RFC 3943 TLS Compression Using LZS November 2004
511 If the RST bit is set to "1", the receiving decompression history MAY
512 be reset to an initial state prior to decompressing the TLS record.
513 (However, due to the characteristics of the Hifn LZS algorithm, a
514 decompression history reset is not required). After reset, any
515 compressed or uncompressed data contained in the record is processed.
517 4.3. Anti-expansion Mechanism
519 During compression, there are two workable options for handling
522 1) Send the expanded data (as long as TLSCompressed.length is 17K or
523 less) and maintain the history, thus allowing loss of current
524 bandwidth but preserving future bandwidth on the link.
526 2) Send the uncompressed data and do not clear the compression
527 history; the decompressor will update its history, thus conserving
528 the current bandwidth and future bandwidth on the link.
530 The second option is the preferred option and SHOULD be implemented.
532 There is a third option:
534 3) Send the uncompressed data and clear the history, thus conserving
535 current bandwidth but allowing possible loss of future bandwidth
538 This option SHOULD NOT be implemented.
540 5. Internationalization Considerations
542 The compression method identifiers specified in this document are
543 machine-readable numbers. As such, issues of human
544 internationalization and localization are not introduced.
546 6. IANA Considerations
548 Section 2 of RFC 3749 [3] describes a registry of compression method
549 identifiers to be maintained by the IANA and to be assigned within
552 IANA has assigned an identifier for the LZS compression method from
553 the RFC 2434 Specification Required IANA pool, as described in
554 sections 2 and 5 of RFC 3749 [3].
556 The IANA-assigned compression method identifier for LZS is 64 decimal
562 Friend Informational [Page 10]
564 RFC 3943 TLS Compression Using LZS November 2004
567 7. Security Considerations
569 This document does not introduce any topics that alter the threat
570 model addressed by TLS. The security considerations described
571 throughout RFC 2246 [2] apply here as well.
573 However, combining compression with encryption can sometimes reveal
574 information that would not have been revealed without compression.
575 Data that is the same length before compression might be a different
576 length after compression, so adversaries that observe the length of
577 the compressed data might be able to derive information about the
578 corresponding uncompressed data. Some symmetric encryption
579 ciphersuites do not hide the length of symmetrically encrypted data
580 at all. Others hide it to some extent but not fully. For example,
581 ciphersuites that use stream cipher encryption without padding do not
582 hide length at all; ciphersuites that use Cipher Block Chaining (CBC)
583 encryption with padding provide some length hiding, depending on how
584 the amount of padding is chosen. Use of TLS compression SHOULD take
585 into account that the length of compressed data may leak more
586 information than the length of the original uncompressed data.
588 Another security issue to be aware of is that the LZS compression
589 history contains plaintext. In order to prevent any kind of
590 information leakage outside the system, when a TLS session with
591 compression terminates, the implementation SHOULD treat the
592 compression history as it does plaintext -- that is, care should be
593 taken not to reveal the compression history in any form or to use it
594 again. This is described in sections 2.2 and 3.2 above.
596 This information leakage concept can be extended to the situation of
597 sharing a single compression history across more than one TLS
598 session, as addressed in section 2.2 above.
600 Other security issues are discussed in RFC 3749 [3].
604 The concepts described in this document were derived from RFC 1967
605 [6], RFC 1974 [5], RFC 2395 [4], and RFC 3749 [3]. The author
606 acknowledges the contributions of Scott Hollenbeck, Douglas Whiting,
607 and Russell Dietz, and help from Steve Bellovin, Russ Housley, and
618 Friend Informational [Page 11]
620 RFC 3943 TLS Compression Using LZS November 2004
625 9.1. Normative References
627 [1] Bradner, S., "Key words for use in RFCs to Indicate Requirement
628 Levels", BCP 14, RFC 2119, March 1997.
630 [2] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", RFC
633 [3] Hollenbeck, S. "Transport Layer Security Protocol Compression
634 Methods", RFC 3749, May 2004.
636 9.2. Informative References
638 [4] Friend, R. and R. Monsour, "IP Payload Compression Using LZS",
639 RFC 2395, December 1998.
641 [5] Friend, R. and W. Simpson, "PPP Stac LZS Compression Protocol",
642 RFC 1974, August 1996.
644 [6] Schneider, K. and R. Friend, "PPP LZS-DCP Compression Protocol
645 (LZS-DCP)", RFC 1967, August 1996.
647 [7] American National Standards Institute, Inc., "Data Compression
648 Method for Information Systems," ANSI X3.241-1994, August 1994.
650 [8] Lempel, A. and J. Ziv, "A Universal Algorithm for Sequential
651 Data Compression", IEEE Transactions On Information Theory, Vol.
652 IT-23, No. 3, September 1977.
662 EMail: rfriend@hifn.com
674 Friend Informational [Page 12]
676 RFC 3943 TLS Compression Using LZS November 2004
679 Full Copyright Statement
681 Copyright (C) The Internet Society (2004).
683 This document is subject to the rights, licenses and restrictions
684 contained in BCP 78, and at www.rfc-editor.org, and except as set
685 forth therein, the authors retain all their rights.
687 This document and the information contained herein are provided on an
688 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
689 OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
690 ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
691 INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
692 INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
693 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
695 Intellectual Property
697 The IETF takes no position regarding the validity or scope of any
698 Intellectual Property Rights or other rights that might be claimed to
699 pertain to the implementation or use of the technology described in
700 this document or the extent to which any license under such rights
701 might or might not be available; nor does it represent that it has
702 made any independent effort to identify any such rights. Information
703 on the ISOC's procedures with respect to rights in ISOC Documents can
704 be found in BCP 78 and BCP 79.
706 Copies of IPR disclosures made to the IETF Secretariat and any
707 assurances of licenses to be made available, or the result of an
708 attempt made to obtain a general license or permission for the use of
709 such proprietary rights by implementers or users of this
710 specification can be obtained from the IETF on-line IPR repository at
711 http://www.ietf.org/ipr.
713 The IETF invites any interested party to bring to its attention any
714 copyrights, patents or patent applications, or other proprietary
715 rights that may cover technology that may be required to implement
716 this standard. Please address the information to the IETF at ietf-
721 Funding for the RFC Editor function is currently provided by the
730 Friend Informational [Page 13]