Stream Compression (original) (raw)
XEP-0138: Stream Compression
- Introduction
- Use Case
- Business Rules
- Mandatory-to-Implement Technologies
- Optional Technologies
- Implementation Notes
- Security Considerations
- IANA Considerations
- XMPP Registrar Considerations
- XML Schemas
- Stream Feature
- Protocol Namespace
Appendices
- Document Information
- Author Information
- Legal Notices
- Relation to XMPP
- Discussion Venue
- Requirements Conformance
- Notes
- Revision History
- Bib(La)Tex Entry
1. Introduction¶
XMPP Core [1] specifies the use of Transport Layer Security (TLS; see RFC 5246 [2]) for encryption of XML streams, and TLS includes the ability to compress encrypted traffic (see RFC 3749 [3]). However, not all computing platforms are able to implement TLS, and traffic compression may be desirable for communication by applications on such computing platforms. This document defines a mechanism for negotiating the compression of XML streams outside the context of TLS.
2. Use Case¶
The protocol flow is as follows:
Example 1. Receiving Entity Offers Stream Compression Feature¶
stream:features zlib lzw
Note: The element MUST contain at least one child element. Each element MUST contain XML character data that specifies the name of a compression method, and such method names SHOULD be registered as described in the Compression Methods Registry section of this document. The methods SHOULD be provided in order of preference.
The initiating entity then MAY request compression by specifying one of the methods advertised by the receiving entity:
Example 2. Initiating Entity Requests Stream Compression¶
zlibNote: If the initiating entity did not understand any of the advertised compression methods, it SHOULD ignore the compression option and proceed as if no compression methods were advertised.
If the initiating entity requests a stream compression method that is not supported by the receiving entity, the receiving entity MUST return an error:
Example 3. Receiving Entity Reports That Method is Unsupported¶
If the receiving entity finds the requested method unacceptable or unworkable for any other reason, it MUST return a error:
Example 4. Receiving Entity Reports That Negotiation of Stream Compression Failed¶
Note: Failure of the negotiation SHOULD NOT be treated as an unrecoverable error and therefore SHOULD NOT result in a stream error. In particular, the initiating entity is free to retry the compression negotiation if it fails.
If no error occurs, the receiving entity MUST inform the initiating entity that compression has been successfully negotiated:
Example 5. Receiving Entity Acknowledges Negotiation of Stream Compression¶
Both entities MUST now consider the previous (uncompressed) stream to be null and void, just as with TLS negotiation and SASL negotiation (as specified in RFC 3920 [4]) and MUST begin compressed communications with a new (compressed) stream. Therefore the initiating entity MUST initiate a new stream to the receiving entity:
Example 6. Initiating Entity Initiates New (Compressed) Stream¶
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='shakespeare.lit'>
If compression processing fails after the new (compressed) stream has been established, the entity that detects the error SHOULD generate a stream error and close the stream:
Example 7. Entity Closes Stream Because of a Processing Error¶
3. Business Rules¶
The following business rules apply:
- If stream compression is negotiated, it MUST be used in both directions.
- TLS compression and stream compression SHOULD NOT be used simultaneously.
- Stream compression MAY be offered after TLS negotiation if TLS compression is not used.
For detailed recommendations regarding the order of stream feature negotiation, refer to Recommended Order of Stream Feature Negotiation (XEP-0170) [5].
4. Mandatory-to-Implement Technologies¶
Support for the ZLIB compression method as specified in RFC 1950 [6] is REQUIRED.
All other methods are OPTIONAL; such methods may be defined in future specifications or by registration as described in the Compression Methods Registry section of this document.
5. Optional Technologies¶
Implementations MAY support the following methods in addition to ZLIB:
6. Implementation Notes¶
When using ZLIB for compression, the sending application SHOULD complete a partial flush of ZLIB when its current send is complete. Note that this statement is deliberately somewhat vague: the sending application may end up performing this partial flush after sending every XML stanza, but on the other hand may perform the partial flush only after sending a group of stanzas that have been queued up for delivery. When to flush the state of the compression application is up to the sending application.
7. Security Considerations¶
Due to attacks like CRIME that apply equally to the zlib method defined here, this method is deemed insecure.
8. IANA Considerations¶
This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [8].
9. XMPP Registrar Considerations¶
9.1 Stream Features¶
The XMPP Registrar [9] includes 'http://jabber.org/features/compress' in its registry of stream features.
9.2 Protocol Namespaces¶
The XMPP Registrar includes 'http://jabber.org/protocol/compress' in its registry of protocol namespaces.
9.3 Compression Methods Registry¶
The XMPP Registrar maintains a registry of compression methods at <https://xmpp.org/registrar/compress.html>.
9.3.1 Process¶
In order to submit new values to this registry, the registrant shall define an XML fragment of the following form and either include it in the relevant XMPP Extension Protocol or send it to the email address registrar@xmpp.org:
the XML character data of the method element a natural-language description of the compression method the document that specifies or registers the compression methodThe registrant may register more than one compression method at a time, each contained in a separate element.
9.3.2 Registration¶
zlib the ZLIB compression method RFC 195010. XML Schemas¶
10.1 Stream Feature¶
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://jabber.org/features/compress' xmlns='http://jabber.org/features/compress' elementFormDefault='qualified'>
xs:annotation xs:documentation The protocol documented by this schema is defined in XEP-0138: http://www.xmpp.org/extensions/xep-0138.html
<xs:element name='compression'> xs:complexType xs:sequence <xs:element name='method' type='xs:NCName' maxOccurs='unbounded'/>
10.2 Protocol Namespace¶
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://jabber.org/protocol/compress' xmlns='http://jabber.org/protocol/compress' elementFormDefault='qualified'>
xs:annotation xs:documentation The protocol documented by this schema is defined in XEP-0138: http://www.xmpp.org/extensions/xep-0138.html
<xs:import namespace='urn:ietf:params:xml:ns:xmpp-stanzas' schemaLocation='http://xmpp.org/schemas/stanzaerror.xsd'/>
<xs:element name='compress'> xs:complexType xs:sequence <xs:element name='method' type='xs:NCName' minOccurs='1' maxOccurs='unbounded'/>
<xs:element name='compressed' type='empty'/>
<xs:element name='failure'> xs:complexType xs:choice <xs:element name='setup-failed' type='empty'/> <xs:element name='processing-failed' type='empty'/> <xs:element name='unsupported-method' type='empty'/> <xs:sequence xmlns:err='urn:ietf:params:xml:ns:xmpp-stanzas'> <xs:group ref='err:stanzaErrorGroup'/> <xs:element ref='err:text' minOccurs='0'/>
<xs:simpleType name='empty'> <xs:restriction base='xs:string'> <xs:enumeration value=''/>
Appendices
Appendix A: Document Information¶
Series
Number
0138
Publisher
Status
Type
Version
2.1
Last Updated
2022-02-10
Approving Body
Dependencies
XMPP Core
Supersedes
None
Superseded By
None
Short Name
compress
Schema
XML Schema for the 'compress' namespace: <http://www.xmpp.org/schemas/compress.xsd>
XML Schema for the 'feature' namespace: <http://www.xmpp.org/schemas/compress-feature.xsd>
Registry
<https://xmpp.org/registrar/compress.html>
Source Control
This document in other formats:XML PDF
Appendix B: Author Information¶
Joe Hildebrand
JabberID
Peter Saint-Andre
JabberID
URI
Appendix C: Legal Notices¶
Copyright
This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).
Permissions
Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.
Disclaimer of Warranty
## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##
Limitation of Liability
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.
IPR Conformance
This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).
Visual Presentation
The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.
Appendix D: Relation to XMPP¶
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
Appendix E: Discussion Venue¶
The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.
Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.
Errata can be sent to <editor@xmpp.org>.
Appendix F: Requirements Conformance¶
The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
Appendix G: Notes¶
Appendix H: Revision History¶
Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/
- Version 2.1 (2022-02-10)¶
Obsolete due to security vulnerability.
tjb - Version 2.0 (2009-05-27)¶
Per a vote of the XMPP Council, advanced status to Final.
psa - Version 1.3 (2007-09-26)¶
Moved specification of LZW algorithm to XEP-0229.
psa - Version 1.2 (2007-08-22)¶
Clarified when compression shall be considered to start; per XEP-0170, specified that compression should be negotiated after SASL.
psa - Version 1.1 (2005-12-14)¶
More completely specified error handling; mentioned LZW (DCLZ) method.
psa - Version 1.0 (2005-06-16)¶
Per a vote of the Jabber Council, advanced status to Draft.
psa - Version 0.5 (2005-05-18)¶
Modifications to address Council feedback: used RFC 3920 terminology; specified error conditions; specified ZLIB as mandatory to implement.
psa - Version 0.4 (2005-05-11)¶
Corrected several errors in the schemas.
psa - Version 0.3 (2005-03-28)¶
Specified compression methods registry.
psa - Version 0.2 (2004-09-28)¶
Fixed TLS text per list discussion.
psa - Version 0.1 (2004-07-16)¶
Initial version.
jjh/psa
Appendix I: Bib(La)TeX Entry
@report{hildebrand2004compress, title = {Stream Compression}, author = {Hildebrand, Joe and Saint-Andre, Peter}, type = {XEP}, number = {0138}, version = {2.1}, institution = {XMPP Standards Foundation}, url = {https://xmpp.org/extensions/xep-0138.html}, date = {2004-07-16/2022-02-10}, }
END