draft-ietf-httpbis-encryption-encoding-06.txt | draft-ietf-httpbis-encryption-encoding-07.txt | |||
---|---|---|---|---|
HTTP Working Group M. Thomson | HTTP Working Group M. Thomson | |||
Internet-Draft Mozilla | Internet-Draft Mozilla | |||
Intended status: Standards Track December 22, 2016 | Intended status: Standards Track February 13, 2017 | |||
Expires: June 25, 2017 | Expires: August 17, 2017 | |||
Encrypted Content-Encoding for HTTP | Encrypted Content-Encoding for HTTP | |||
draft-ietf-httpbis-encryption-encoding-06 | draft-ietf-httpbis-encryption-encoding-07 | |||
Abstract | Abstract | |||
This memo introduces a content coding for HTTP that allows message | This memo introduces a content coding for HTTP that allows message | |||
payloads to be encrypted. | payloads to be encrypted. | |||
Note to Readers | Note to Readers | |||
Discussion of this draft takes place on the HTTP working group | Discussion of this draft takes place on the HTTP working group | |||
mailing list (ietf-http-wg@w3.org), which is archived at | mailing list (ietf-http-wg@w3.org), which is archived at | |||
skipping to change at page 1, line 41 ¶ | skipping to change at page 1, line 41 ¶ | |||
Internet-Drafts are working documents of the Internet Engineering | Internet-Drafts are working documents of the Internet Engineering | |||
Task Force (IETF). Note that other groups may also distribute | Task Force (IETF). Note that other groups may also distribute | |||
working documents as Internet-Drafts. The list of current Internet- | working documents as Internet-Drafts. The list of current Internet- | |||
Drafts is at http://datatracker.ietf.org/drafts/current/. | Drafts is at http://datatracker.ietf.org/drafts/current/. | |||
Internet-Drafts are draft documents valid for a maximum of six months | Internet-Drafts are draft documents valid for a maximum of six months | |||
and may be updated, replaced, or obsoleted by other documents at any | and may be updated, replaced, or obsoleted by other documents at any | |||
time. It is inappropriate to use Internet-Drafts as reference | time. It is inappropriate to use Internet-Drafts as reference | |||
material or to cite them other than as "work in progress." | material or to cite them other than as "work in progress." | |||
This Internet-Draft will expire on June 25, 2017. | This Internet-Draft will expire on August 17, 2017. | |||
Copyright Notice | Copyright Notice | |||
Copyright (c) 2016 IETF Trust and the persons identified as the | Copyright (c) 2017 IETF Trust and the persons identified as the | |||
document authors. All rights reserved. | document authors. All rights reserved. | |||
This document is subject to BCP 78 and the IETF Trust's Legal | This document is subject to BCP 78 and the IETF Trust's Legal | |||
Provisions Relating to IETF Documents | Provisions Relating to IETF Documents | |||
(http://trustee.ietf.org/license-info) in effect on the date of | (http://trustee.ietf.org/license-info) in effect on the date of | |||
publication of this document. Please review these documents | publication of this document. Please review these documents | |||
carefully, as they describe your rights and restrictions with respect | carefully, as they describe your rights and restrictions with respect | |||
to this document. Code Components extracted from this document must | to this document. Code Components extracted from this document must | |||
include Simplified BSD License text as described in Section 4.e of | include Simplified BSD License text as described in Section 4.e of | |||
the Trust Legal Provisions and are provided without warranty as | the Trust Legal Provisions and are provided without warranty as | |||
skipping to change at page 2, line 24 ¶ | skipping to change at page 2, line 24 ¶ | |||
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 | 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 | |||
1.1. Notational Conventions . . . . . . . . . . . . . . . . . 3 | 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 3 | |||
2. The "aes128gcm" HTTP Content Coding . . . . . . . . . . . . . 3 | 2. The "aes128gcm" HTTP Content Coding . . . . . . . . . . . . . 3 | |||
2.1. Encryption Content Coding Header . . . . . . . . . . . . 5 | 2.1. Encryption Content Coding Header . . . . . . . . . . . . 5 | |||
2.2. Content Encryption Key Derivation . . . . . . . . . . . . 6 | 2.2. Content Encryption Key Derivation . . . . . . . . . . . . 6 | |||
2.3. Nonce Derivation . . . . . . . . . . . . . . . . . . . . 6 | 2.3. Nonce Derivation . . . . . . . . . . . . . . . . . . . . 6 | |||
3. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 7 | 3. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 7 | |||
3.1. Encryption of a Response . . . . . . . . . . . . . . . . 7 | 3.1. Encryption of a Response . . . . . . . . . . . . . . . . 7 | |||
3.2. Encryption with Multiple Records . . . . . . . . . . . . 8 | 3.2. Encryption with Multiple Records . . . . . . . . . . . . 8 | |||
4. Security Considerations . . . . . . . . . . . . . . . . . . . 8 | 4. Security Considerations . . . . . . . . . . . . . . . . . . . 8 | |||
4.1. Key and Nonce Reuse . . . . . . . . . . . . . . . . . . . 9 | 4.1. Message Truncation . . . . . . . . . . . . . . . . . . . 9 | |||
4.2. Data Encryption Limits . . . . . . . . . . . . . . . . . 9 | 4.2. Key and Nonce Reuse . . . . . . . . . . . . . . . . . . . 9 | |||
4.3. Content Integrity . . . . . . . . . . . . . . . . . . . . 10 | 4.3. Data Encryption Limits . . . . . . . . . . . . . . . . . 9 | |||
4.4. Leaking Information in Headers . . . . . . . . . . . . . 10 | 4.4. Content Integrity . . . . . . . . . . . . . . . . . . . . 10 | |||
4.5. Poisoning Storage . . . . . . . . . . . . . . . . . . . . 11 | 4.5. Leaking Information in Header Fields . . . . . . . . . . 10 | |||
4.6. Sizing and Timing Attacks . . . . . . . . . . . . . . . . 11 | 4.6. Poisoning Storage . . . . . . . . . . . . . . . . . . . . 11 | |||
4.7. Sizing and Timing Attacks . . . . . . . . . . . . . . . . 11 | ||||
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11 | 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11 | |||
5.1. The "aes128gcm" HTTP Content Coding . . . . . . . . . . . 11 | 5.1. The "aes128gcm" HTTP Content Coding . . . . . . . . . . . 11 | |||
6. References . . . . . . . . . . . . . . . . . . . . . . . . . 12 | 6. References . . . . . . . . . . . . . . . . . . . . . . . . . 12 | |||
6.1. Normative References . . . . . . . . . . . . . . . . . . 12 | 6.1. Normative References . . . . . . . . . . . . . . . . . . 12 | |||
6.2. Informative References . . . . . . . . . . . . . . . . . 12 | 6.2. Informative References . . . . . . . . . . . . . . . . . 13 | |||
Appendix A. JWE Mapping . . . . . . . . . . . . . . . . . . . . 13 | Appendix A. JWE Mapping . . . . . . . . . . . . . . . . . . . . 14 | |||
Appendix B. Acknowledgements . . . . . . . . . . . . . . . . . . 14 | Appendix B. Acknowledgements . . . . . . . . . . . . . . . . . . 14 | |||
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 14 | Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 15 | |||
1. Introduction | 1. Introduction | |||
It is sometimes desirable to encrypt the contents of a HTTP message | It is sometimes desirable to encrypt the contents of a HTTP message | |||
(request or response) so that when the payload is stored (e.g., with | (request or response) so that when the payload is stored (e.g., with | |||
a HTTP PUT), only someone with the appropriate key can read it. | a HTTP PUT), only someone with the appropriate key can read it. | |||
For example, it might be necessary to store a file on a server | For example, it might be necessary to store a file on a server | |||
without exposing its contents to that server. Furthermore, that same | without exposing its contents to that server. Furthermore, that same | |||
file could be replicated to other servers (to make it more resistant | file could be replicated to other servers (to make it more resistant | |||
skipping to change at page 3, line 15 ¶ | skipping to change at page 3, line 15 ¶ | |||
These uses are not met by the use of TLS [RFC5246], since it only | These uses are not met by the use of TLS [RFC5246], since it only | |||
encrypts the channel between the client and server. | encrypts the channel between the client and server. | |||
This document specifies a content coding (Section 3.1.2 of [RFC7231]) | This document specifies a content coding (Section 3.1.2 of [RFC7231]) | |||
for HTTP to serve these and other use cases. | for HTTP to serve these and other use cases. | |||
This content coding is not a direct adaptation of message-based | This content coding is not a direct adaptation of message-based | |||
encryption formats - such as those that are described by [RFC4880], | encryption formats - such as those that are described by [RFC4880], | |||
[RFC5652], [RFC7516], and [XMLENC] - which are not suited to stream | [RFC5652], [RFC7516], and [XMLENC] - which are not suited to stream | |||
processing, which is necessary for HTTP. The format described here | processing, which is necessary for HTTP. The format described here | |||
cleaves more closely to the lower level constructs described in | follows more closely to the lower level constructs described in | |||
[RFC5116]. | [RFC5116]. | |||
To the extent that message-based encryption formats use the same | To the extent that message-based encryption formats use the same | |||
primitives, the format can be considered as sequence of encrypted | primitives, the format can be considered as sequence of encrypted | |||
messages with a particular profile. For instance, Appendix A | messages with a particular profile. For instance, Appendix A | |||
explains how the format is congruent with a sequence of JSON Web | explains how the format is congruent with a sequence of JSON Web | |||
Encryption [RFC7516] values with a fixed header. | Encryption [RFC7516] values with a fixed header. | |||
This mechanism is likely only a small part of a larger design that | This mechanism is likely only a small part of a larger design that | |||
uses content encryption. How clients and servers acquire and | uses content encryption. How clients and servers acquire and | |||
skipping to change at page 4, line 6 ¶ | skipping to change at page 4, line 6 ¶ | |||
Using this content coding requires knowledge of a key. How this key | Using this content coding requires knowledge of a key. How this key | |||
is acquired is not defined in this document. | is acquired is not defined in this document. | |||
The "aes128gcm" content coding uses a single fixed set of encryption | The "aes128gcm" content coding uses a single fixed set of encryption | |||
primitives. Cipher suite agility is achieved by defining a new | primitives. Cipher suite agility is achieved by defining a new | |||
content coding scheme. This ensures that only the HTTP Accept- | content coding scheme. This ensures that only the HTTP Accept- | |||
Encoding header field is necessary to negotiate the use of | Encoding header field is necessary to negotiate the use of | |||
encryption. | encryption. | |||
The "aes128gcm" content coding uses a fixed record size. The final | The "aes128gcm" content coding uses a fixed record size. The final | |||
encoding consists of a header (see Section 2.1), zero or more fixed | encoding consists of a header (see Section 2.1) and zero or more | |||
size encrypted records, and a partial record. The partial record | fixed size encrypted records; the final record can be smaller than | |||
MUST be shorter than the fixed record size. | the record size. | |||
The record size determines the length of each portion of plaintext | The record size determines the length of each portion of plaintext | |||
that is enciphered, with the exception of the final record, which is | that is enciphered. The record size ("rs") is included in the | |||
necessarily smaller. The record size ("rs") is included in the | ||||
content coding header (see Section 2.1). | content coding header (see Section 2.1). | |||
+-----------+ content of rs octets minus padding | +-----------+ content | |||
| data | less padding (2-65537) and tag (16); | | data | any length up to rs-17 octets | |||
+-----------+ the last record is smaller | +-----------+ | |||
| | | | |||
v | v | |||
+-----+-----------+ add padding to get rs-16 octets; | +-----------+-----+ add a delimiter octet (0x01 or 0x02) | |||
| pad | data | the last record contains | | data | pad | the 0x00-valued octets to rs-16 | |||
+-----+-----------+ up to rs minus 17 octets | +-----------+-----+ (or less on the last record) | |||
| | | | |||
v | v | |||
+--------------------+ encrypt with AEAD_AES_128_GCM; | +--------------------+ encrypt with AEAD_AES_128_GCM; | |||
| ciphertext | final size is rs; | | ciphertext | final size is rs; | |||
+--------------------+ the last record is smaller | +--------------------+ the last record can be smaller | |||
AEAD_AES_128_GCM produces ciphertext 16 octets longer than its input | AEAD_AES_128_GCM produces ciphertext 16 octets longer than its input | |||
plaintext. Therefore, the unencrypted content of each record is | plaintext. Therefore, the unencrypted content of each record is | |||
shorter than the record size by 16 octets. If the final record ends | shorter than the record size by 16 octets. Valid records always | |||
on a record boundary, the encoder MUST append a record that contains | contain at least a padding delimiter octet and a 16 octet | |||
contains only padding and is smaller than the full record size. A | ||||
receiver MUST fail to decrypt if the final record ciphertext is less | ||||
than 18 octets in size or equal to the record size. Valid records | ||||
always contain at least a padding length of 2 octets and a 16 octet | ||||
authentication tag. | authentication tag. | |||
Each record contains a 2 octet padding length and between 0 and 65535 | Each record contains a single padding delimiter octet followed by any | |||
octets of padding, inserted into a record before the content. The | number of zero octets. The last record uses a padding delimiter | |||
padding length is a two octet unsigned integer in network byte order; | octet set to the value 2, all other records have a padding delimiter | |||
padding is that number of zero-valued octets. A receiver MUST fail | octet value of 1. A decrypter MUST fail if the unencrypted content | |||
to decrypt if any padding octet is non-zero, or a record has more | of a record is all zero-valued. A decrypter MUST fail if the last | |||
padding than the record size can accommodate. | record contains a padding delimiter with a value other than 2; a | |||
decrypter MUST fail if any record other than the last contains a | ||||
padding delimiter with a value other than 1. | ||||
The nonce for each record is a 96-bit value constructed from the | The nonce for each record is a 96-bit value constructed from the | |||
record sequence number and the input keying material. Nonce | record sequence number and the input keying material. Nonce | |||
derivation is covered in Section 2.3. | derivation is covered in Section 2.3. | |||
The additional data passed to each invocation of AEAD_AES_128_GCM is | The additional data passed to each invocation of AEAD_AES_128_GCM is | |||
a zero-length octet sequence. | a zero-length octet sequence. | |||
A consequence of this record structure is that range requests | A consequence of this record structure is that range requests | |||
[RFC7233] and random access to encrypted payload bodies are possible | [RFC7233] and random access to encrypted payload bodies are possible | |||
skipping to change at page 5, line 18 ¶ | skipping to change at page 5, line 15 ¶ | |||
of a range cannot be decrypted. Thus, it is best if range requests | of a range cannot be decrypted. Thus, it is best if range requests | |||
start and end on record boundaries. Note however that random access | start and end on record boundaries. Note however that random access | |||
to specific parts of encrypted data could be confounded by the | to specific parts of encrypted data could be confounded by the | |||
presence of padding. | presence of padding. | |||
Selecting the record size most appropriate for a given situation | Selecting the record size most appropriate for a given situation | |||
requires a trade-off. A smaller record size allows decrypted octets | requires a trade-off. A smaller record size allows decrypted octets | |||
to be released more rapidly, which can be appropriate for | to be released more rapidly, which can be appropriate for | |||
applications that depend on responsiveness. Smaller records also | applications that depend on responsiveness. Smaller records also | |||
reduce the additional data required if random access into the | reduce the additional data required if random access into the | |||
ciphertext is needed. Applications that depend on being able to pad | ciphertext is needed. | |||
by arbitrary amounts cannot increase the record size beyond 65537 | ||||
octets. | ||||
Applications that don't depending on streaming, random access, or | Applications that don't depending on streaming, random access, or | |||
arbitrary padding can use larger records, or even a single record. A | arbitrary padding can use larger records, or even a single record. A | |||
larger record size reduces the processing and data overheads. | larger record size reduces processing and data overheads. | |||
2.1. Encryption Content Coding Header | 2.1. Encryption Content Coding Header | |||
The content coding uses a header block that includes all parameters | The content coding uses a header block that includes all parameters | |||
needed to decrypt the content (other than the key). The header block | needed to decrypt the content (other than the key). The header block | |||
is placed in the body of a message ahead of the sequence of records. | is placed in the body of a message ahead of the sequence of records. | |||
+-----------+--------+-----------+---------------+ | +-----------+--------+-----------+---------------+ | |||
| salt (16) | rs (4) | idlen (1) | keyid (idlen) | | | salt (16) | rs (4) | idlen (1) | keyid (idlen) | | |||
+-----------+--------+-----------+---------------+ | +-----------+--------+-----------+---------------+ | |||
skipping to change at page 5, line 47 ¶ | skipping to change at page 5, line 42 ¶ | |||
"aes128gcm" content coding header. The same "salt" parameter | "aes128gcm" content coding header. The same "salt" parameter | |||
value MUST NOT be reused for two different payload bodies that | value MUST NOT be reused for two different payload bodies that | |||
have the same input keying material; generating a random salt for | have the same input keying material; generating a random salt for | |||
every application of the content coding ensures that content | every application of the content coding ensures that content | |||
encryption key reuse is highly unlikely. | encryption key reuse is highly unlikely. | |||
rs: The "rs" or record size parameter contains an unsigned 32-bit | rs: The "rs" or record size parameter contains an unsigned 32-bit | |||
integer in network byte order that describes the record size in | integer in network byte order that describes the record size in | |||
octets. Note that it is therefore impossible to exceed the | octets. Note that it is therefore impossible to exceed the | |||
2^36-31 limit on plaintext input to AEAD_AES_128_GCM. Values | 2^36-31 limit on plaintext input to AEAD_AES_128_GCM. Values | |||
smaller than 19 are invalid. | smaller than 18 are invalid. | |||
keyid: The "keyid" parameter can be used to identify the keying | keyid: The "keyid" parameter can be used to identify the keying | |||
material that is used. Recipients that receive a message are | material that is used. Recipients that receive a message are | |||
expected to know how to retrieve keys; the "keyid" parameter might | expected to know how to retrieve keys; the "keyid" parameter might | |||
be input to that process. A "keyid" parameter SHOULD be a UTF-8 | be input to that process. A "keyid" parameter SHOULD be a UTF-8 | |||
[RFC3629] encoded string, particularly where the identifier might | [RFC3629] encoded string, particularly where the identifier might | |||
need to appear in a textual form. | need to appear in a textual form. | |||
2.2. Content Encryption Key Derivation | 2.2. Content Encryption Key Derivation | |||
skipping to change at page 6, line 43 ¶ | skipping to change at page 6, line 40 ¶ | |||
(CEK), so the length (L) parameter to HKDF is 16. The second step of | (CEK), so the length (L) parameter to HKDF is 16. The second step of | |||
HKDF can therefore be simplified to the first 16 octets of a single | HKDF can therefore be simplified to the first 16 octets of a single | |||
HMAC: | HMAC: | |||
CEK = HMAC-SHA-256(PRK, cek_info || 0x01) | CEK = HMAC-SHA-256(PRK, cek_info || 0x01) | |||
2.3. Nonce Derivation | 2.3. Nonce Derivation | |||
The nonce input to AEAD_AES_128_GCM is constructed for each record. | The nonce input to AEAD_AES_128_GCM is constructed for each record. | |||
The nonce for each record is a 12 octet (96 bit) value that is | The nonce for each record is a 12 octet (96 bit) value that is | |||
produced from the record sequence number and a value derived from the | derived from the record sequence number, input keying material, and | |||
input keying material. | salt. | |||
The input keying material and salt values are input to HKDF with | The input keying material and salt values are input to HKDF with | |||
different info and length parameters. | different info and length parameters. | |||
The length (L) parameter is 12 octets. The info parameter for the | The length (L) parameter is 12 octets. The info parameter for the | |||
nonce is the ASCII-encoded string "Content-Encoding: nonce", | nonce is the ASCII-encoded string "Content-Encoding: nonce", | |||
terminated by a a single zero octet: | terminated by a a single zero octet: | |||
nonce_info = "Content-Encoding: nonce" || 0x00 | nonce_info = "Content-Encoding: nonce" || 0x00 | |||
skipping to change at page 7, line 35 ¶ | skipping to change at page 7, line 31 ¶ | |||
This section shows a few examples of the encrypted content coding. | This section shows a few examples of the encrypted content coding. | |||
Note: All binary values in the examples in this section use base64url | Note: All binary values in the examples in this section use base64url | |||
encoding [RFC7515]. This includes the bodies of requests. | encoding [RFC7515]. This includes the bodies of requests. | |||
Whitespace and line wrapping is added to fit formatting constraints. | Whitespace and line wrapping is added to fit formatting constraints. | |||
3.1. Encryption of a Response | 3.1. Encryption of a Response | |||
Here, a successful HTTP GET response has been encrypted. This uses a | Here, a successful HTTP GET response has been encrypted. This uses a | |||
record size of 4096 and no padding (just the 2 octet padding length), | record size of 4096 and no padding (just the single octet padding | |||
so only a partial record is present. The input keying material is | delimiter), so only a partial record is present. The input keying | |||
identified by an empty string (that is, the "keyid" field in the | material is identified by an empty string (that is, the "keyid" field | |||
header is zero octets in length). | in the header is zero octets in length). | |||
The encrypted data in this example is the UTF-8 encoded string "I am | The encrypted data in this example is the UTF-8 encoded string "I am | |||
the walrus". The input keying material is the value | the walrus". The input keying material is the value "yqdlZ- | |||
"B33e_VeFrOyIHwFTIfmesA" (in base64url). The content body contains a | tYemfogSmv7Ws5PQ" (in base64url). The 54 octet content body contains | |||
single record and is shown here using base64url encoding for | a single record and is shown here using 71 base64url characters for | |||
presentation reasons. | presentation reasons. | |||
HTTP/1.1 200 OK | HTTP/1.1 200 OK | |||
Content-Type: application/octet-stream | Content-Type: application/octet-stream | |||
Content-Length: 54 | Content-Length: 54 | |||
Content-Encoding: aes128gcm | Content-Encoding: aes128gcm | |||
sJvlboCWzB5jr8hI_q9cOQAAEAAANSmxkSVa0-MiNNuF77YHSs-iwaNe_OK0qfmO | I1BsxtFttlv3u_Oo94xnmwAAEAAA-NAVub2qFgBEuQKRapoZu-IxkIva3MEB1PD- | |||
c7NT5WSW | ly8Thjg | |||
Note that the media type has been changed to "application/octet- | Note that the media type has been changed to "application/octet- | |||
stream" to avoid exposing information about the content. | stream" to avoid exposing information about the content. | |||
Alternatively (and equivalently), the Content-Type header field can | Alternatively (and equivalently), the Content-Type header field can | |||
be omitted. | be omitted. | |||
Intermediate values for this example (all shown in base64): | Intermediate values for this example (all shown using base64url): | |||
salt (from header) = sJvlboCWzB5jr8hI_q9cOQ | salt (from header) = I1BsxtFttlv3u_Oo94xnmw | |||
PRK = MLAQxt_DHjM15cdlyU1oUnjq7TFlzToGTkdRmvvxVBw | PRK = zyeH5phsIsgUyd4oiSEIy35x-gIi4aM7y0hCF8mwn9g | |||
CEK = v31u7VGV3soO3wNaMaIdhg | CEK = _wniytB-ofscZDh4tbSjHw | |||
NONCE = XOaygzko98zjUFTJ | NONCE = Bcs8gkIRKLI8GeI8 | |||
plaintext = AABJIGFtIHRoZSB3YWxydXM | plaintext = SSBhbSB0aGUgd2FscnVzAg | |||
3.2. Encryption with Multiple Records | 3.2. Encryption with Multiple Records | |||
This example shows the same message with input keying material of | This example shows the same message with input keying material of | |||
"BO3ZVPxUlnLORbVGMpbT1Q". In this example, the plaintext is split | "BO3ZVPxUlnLORbVGMpbT1Q". In this example, the plaintext is split | |||
into records of 26 octets each (that is, the "rs" field in the header | into records of 25 octets each (that is, the "rs" field in the header | |||
is 26). The first record includes a single octet of padding. This | is 25). The first record includes one 0x00 padding octet. This | |||
means that there are 7 octets of message in the first record, and 8 | means that there are 7 octets of message in the first record, and 8 | |||
in the second. This causes the end of the content to align with a | in the second. A key identifier of the UTF-8 encoded string "a1" is | |||
record boundary, forcing the creation of a third record that contains | also included in the header. | |||
only two octets of the padding length. | ||||
HTTP/1.1 200 OK | HTTP/1.1 200 OK | |||
Content-Length: 93 | Content-Length: 73 | |||
Content-Encoding: aes128gcm | Content-Encoding: aes128gcm | |||
uNCkWiNYzKTnBN9ji3-qWAAAABoCYTGHOqYFz-0in3dpb-VE2GfBngkaPy6bZus_ | uNCkWiNYzKTnBN9ji3-qWAAAABkCYTHOG8chz_gnvgOqdGYovxyjuqRyJFjEDyoF | |||
qLF79s6zQyTSsA0iLOKyd3JqVIwprNzVatRCWZGUx_qsFbJBCQu62RqQuR2d | 1Fvkj6hQPdPHI51OEUKEpgz3SsLWIqS_uA | |||
4. Security Considerations | 4. Security Considerations | |||
This mechanism assumes the presence of a key management framework | This mechanism assumes the presence of a key management framework | |||
that is used to manage the distribution of keys between valid senders | that is used to manage the distribution of keys between valid senders | |||
and receivers. Defining key management is part of composing this | and receivers. Defining key management is part of composing this | |||
mechanism into a larger application, protocol, or framework. | mechanism into a larger application, protocol, or framework. | |||
Implementation of cryptography - and key management in particular - | Implementation of cryptography - and key management in particular - | |||
can be difficult. For instance, implementations need to account for | can be difficult. For instance, implementations need to account for | |||
the potential for exposing keying material on side channels, such as | the potential for exposing keying material on side channels, such as | |||
might be exposed by the time it takes to perform a given operation. | might be exposed by the time it takes to perform a given operation. | |||
The requirements for a good implementation of cryptographic | The requirements for a good implementation of cryptographic | |||
algorithms can change over time. | algorithms can change over time. | |||
4.1. Key and Nonce Reuse | As a content coding, presence of the "aes128gcm" coding might be | |||
transparent to a consumer of a message. Recipients that depend on | ||||
content origin authentication using this mechanism MUST reject | ||||
messages that don't include the "aes128gcm" content coding. | ||||
4.1. Message Truncation | ||||
This content encoding is designed to permit the incremental | ||||
processing of large messages. It also permits random access to | ||||
plaintext in a limited fashion. The content encoding permits a | ||||
receiver to detect when a message is truncated. | ||||
A partially delivered message MUST NOT be processed as though the | ||||
entire message was successfully delivered. For instance, a partially | ||||
delivered message cannot be cached as though it were complete. | ||||
An attacker might exploit willingness to process partial messages to | ||||
cause a receiver to remain in a specific intermediate state. | ||||
Implementations performing processing on partial messages need to | ||||
ensure that any intermediate processing states don't advantage an | ||||
attacker. | ||||
4.2. Key and Nonce Reuse | ||||
Encrypting different plaintext with the same content encryption key | Encrypting different plaintext with the same content encryption key | |||
and nonce in AES-GCM is not safe [RFC5116]. The scheme defined here | and nonce in AES-GCM is not safe [RFC5116]. The scheme defined here | |||
uses a fixed progression of nonce values. Thus, a new content | uses a fixed progression of nonce values. Thus, a new content | |||
encryption key is needed for every application of the content coding. | encryption key is needed for every application of the content coding. | |||
Since input keying material can be reused, a unique "salt" parameter | Since input keying material can be reused, a unique "salt" parameter | |||
is needed to ensure a content encryption key is not reused. | is needed to ensure a content encryption key is not reused. | |||
If a content encryption key is reused - that is, if input keying | If a content encryption key is reused - that is, if input keying | |||
material and salt are reused - this could expose the plaintext and | material and salt are reused - this could expose the plaintext and | |||
the authentication key, nullifying the protection offered by | the authentication key, nullifying the protection offered by | |||
encryption. Thus, if the same input keying material is reused, then | encryption. Thus, if the same input keying material is reused, then | |||
the salt parameter MUST be unique each time. This ensures that the | the salt parameter MUST be unique each time. This ensures that the | |||
content encryption key is not reused. An implementation SHOULD | content encryption key is not reused. An implementation SHOULD | |||
generate a random salt parameter for every message; a counter could | generate a random salt parameter for every message; a counter could | |||
achieve the same result. | achieve the same result. | |||
4.2. Data Encryption Limits | 4.3. Data Encryption Limits | |||
There are limits to the data that AEAD_AES_128_GCM can encipher. The | There are limits to the data that AEAD_AES_128_GCM can encipher. The | |||
maximum value for the record size is limited by the size of the "rs" | maximum value for the record size is limited by the size of the "rs" | |||
field in the header (see Section 2.1), which ensures that the 2^36-31 | field in the header (see Section 2.1), which ensures that the 2^36-31 | |||
limit for a single application of AEAD_AES_128_GCM is not reached | limit for a single application of AEAD_AES_128_GCM is not reached | |||
[RFC5116]. In order to preserve a 2^-40 probability of | [RFC5116]. In order to preserve a 2^-40 probability of | |||
indistinguishability under chosen plaintext attack (IND-CPA), the | indistinguishability under chosen plaintext attack (IND-CPA), the | |||
total amount of plaintext that can be enciphered MUST be less than | total amount of plaintext that can be enciphered with the key derived | |||
2^44.5 blocks of 16 octets [AEBounds]. | from the same input keying material and salt MUST be less than 2^44.5 | |||
blocks of 16 octets [AEBounds]. | ||||
If the record size is a multiple of 16 octets, this means 398 | If the record size is a multiple of 16 octets, this means 398 | |||
terabytes can be encrypted safely, including padding and overhead. | terabytes can be encrypted safely, including padding and overhead. | |||
However, if the record size is not a multiple of 16 octets, the total | However, if the record size is not a multiple of 16 octets, the total | |||
amount of data that can be safely encrypted is reduced because | amount of data that can be safely encrypted is reduced because | |||
partial AES blocks are encrypted. The worst case is a record size of | partial AES blocks are encrypted. The worst case is a record size of | |||
19 octets, for which at most 74 terabytes of plaintext can be | 18 octets, for which at most 74 terabytes of plaintext can be | |||
encrypted, of which at least two-thirds is padding. | encrypted, of which at least half is padding. | |||
4.3. Content Integrity | 4.4. Content Integrity | |||
This mechanism only provides content origin authentication. The | This mechanism only provides content origin authentication. The | |||
authentication tag only ensures that an entity with access to the | authentication tag only ensures that an entity with access to the | |||
content encryption key produced the encrypted data. | content encryption key produced the encrypted data. | |||
Any entity with the content encryption key can therefore produce | Any entity with the content encryption key can therefore produce | |||
content that will be accepted as valid. This includes all recipients | content that will be accepted as valid. This includes all recipients | |||
of the same HTTP message. | of the same HTTP message. | |||
Furthermore, any entity that is able to modify both the Encryption | Furthermore, any entity that is able to modify both the Content- | |||
header field and the HTTP message body can replace the contents. | Encoding header field and the HTTP message body can replace the | |||
Without the content encryption key or the input keying material, | contents. Without the content encryption key or the input keying | |||
modifications to or replacement of parts of a payload body are not | material, modifications to or replacement of parts of a payload body | |||
possible. | are not possible. | |||
4.4. Leaking Information in Headers | 4.5. Leaking Information in Header Fields | |||
Because only the payload body is encrypted, information exposed in | Because only the payload body is encrypted, information exposed in | |||
header fields is visible to anyone who can read the HTTP message. | header fields is visible to anyone who can read the HTTP message. | |||
This could expose side-channel information. | This could expose side-channel information. | |||
For example, the Content-Type header field can leak information about | For example, the Content-Type header field can leak information about | |||
the payload body. | the payload body. | |||
There are a number of strategies available to mitigate this threat, | There are a number of strategies available to mitigate this threat, | |||
depending upon the application's threat model and the users' | depending upon the application's threat model and the users' | |||
skipping to change at page 11, line 5 ¶ | skipping to change at page 11, line 13 ¶ | |||
in other representations, etc.), omit the relevant headers, and/ | in other representations, etc.), omit the relevant headers, and/ | |||
or normalize them. In the case of Content-Type, this could be | or normalize them. In the case of Content-Type, this could be | |||
accomplished by always sending Content-Type: application/octet- | accomplished by always sending Content-Type: application/octet- | |||
stream (the most generic media type), or no Content-Type at all. | stream (the most generic media type), or no Content-Type at all. | |||
3. If it is considered sensitive information and it is not possible | 3. If it is considered sensitive information and it is not possible | |||
to convey it elsewhere, encapsulate the HTTP message using the | to convey it elsewhere, encapsulate the HTTP message using the | |||
application/http media type (Section 8.3.2 of [RFC7230]), | application/http media type (Section 8.3.2 of [RFC7230]), | |||
encrypting that as the payload of the "outer" message. | encrypting that as the payload of the "outer" message. | |||
4.5. Poisoning Storage | 4.6. Poisoning Storage | |||
This mechanism only offers encryption of content; it does not perform | This mechanism only offers encryption of content; it does not perform | |||
authentication or authorization, which still needs to be performed | authentication or authorization, which still needs to be performed | |||
(e.g., by HTTP authentication [RFC7235]). | (e.g., by HTTP authentication [RFC7235]). | |||
This is especially relevant when a HTTP PUT request is accepted by a | This is especially relevant when a HTTP PUT request is accepted by a | |||
server; if the request is unauthenticated, it becomes possible for a | server; if the request is unauthenticated, it becomes possible for a | |||
third party to deny service and/or poison the store. | third party to deny service and/or poison the store. | |||
4.6. Sizing and Timing Attacks | 4.7. Sizing and Timing Attacks | |||
Applications using this mechanism need to be aware that the size of | Applications using this mechanism need to be aware that the size of | |||
encrypted messages, as well as their timing, HTTP methods, URIs and | encrypted messages, as well as their timing, HTTP methods, URIs and | |||
so on, may leak sensitive information. | so on, may leak sensitive information. | |||
This risk can be mitigated through the use of the padding that this | This risk can be mitigated through the use of the padding that this | |||
mechanism provides. Alternatively, splitting up content into | mechanism provides. Alternatively, splitting up content into | |||
segments and storing the separately might reduce exposure. HTTP/2 | segments and storing them separately might reduce exposure. HTTP/2 | |||
[RFC7540] combined with TLS [RFC5246] might be used to hide the size | [RFC7540] combined with TLS [RFC5246] might be used to hide the size | |||
of individual messages. | of individual messages. | |||
Developing a padding strategy is difficult. A good padding strategy | Developing a padding strategy is difficult. A good padding strategy | |||
can depend on context. Common strategies include padding to a small | can depend on context. Common strategies include padding to a small | |||
set of fixed lengths, padding to multiples of a values, or padding to | set of fixed lengths, padding to multiples of a value, or padding to | |||
powers of 2. Even a good strategy can still cause size information | powers of 2. Even a good strategy can still cause size information | |||
to leak if processing activity of a recipient can be observed. This | to leak if processing activity of a recipient can be observed. This | |||
is especially true if the trailing records of a message contain only | is especially true if the trailing records of a message contain only | |||
padding. Distributing non-padding data is recommended to avoid | padding. Distributing non-padding data is recommended to avoid | |||
leaking size information. | leaking size information. | |||
5. IANA Considerations | 5. IANA Considerations | |||
5.1. The "aes128gcm" HTTP Content Coding | 5.1. The "aes128gcm" HTTP Content Coding | |||
skipping to change at page 13, line 48 ¶ | skipping to change at page 14, line 9 ¶ | |||
[XMLENC] Eastlake, D., Reagle, J., Hirsch, F., Roessler, T., | [XMLENC] Eastlake, D., Reagle, J., Hirsch, F., Roessler, T., | |||
Imamura, T., Dillaway, B., Simon, E., Yiu, K., and M. | Imamura, T., Dillaway, B., Simon, E., Yiu, K., and M. | |||
Nystroem, "XML Encryption Syntax and Processing", W3C | Nystroem, "XML Encryption Syntax and Processing", W3C | |||
Recommendation REC-xmlenc-core1-20130411 , January 2013, | Recommendation REC-xmlenc-core1-20130411 , January 2013, | |||
<https://www.w3.org/TR/2013/REC-xmlenc-core1-20130411>. | <https://www.w3.org/TR/2013/REC-xmlenc-core1-20130411>. | |||
Appendix A. JWE Mapping | Appendix A. JWE Mapping | |||
The "aes128gcm" content coding can be considered as a sequence of | The "aes128gcm" content coding can be considered as a sequence of | |||
JSON Web Encryption (JWE) objects [RFC7516], each corresponding to a | JSON Web Encryption (JWE) objects [RFC7516], each corresponding to a | |||
single fixed size record that includes leading padding. The | single fixed size record that includes trailing padding. The | |||
following transformations are applied to a JWE object that might be | following transformations are applied to a JWE object that might be | |||
expressed using the JWE Compact Serialization: | expressed using the JWE Compact Serialization: | |||
o The JWE Protected Header is fixed to the value { "alg": "dir", | o The JWE Protected Header is fixed to the value { "alg": "dir", | |||
"enc": "A128GCM" }, describing direct encryption using AES-GCM | "enc": "A128GCM" }, describing direct encryption using AES-GCM | |||
with a 128-bit content encryption key. This header is not | with a 128-bit content encryption key. This header is not | |||
transmitted, it is instead implied by the value of the Content- | transmitted, it is instead implied by the value of the Content- | |||
Encoding header field. | Encoding header field. | |||
o The JWE Encrypted Key is empty, as stipulated by the direct | o The JWE Encrypted Key is empty, as stipulated by the direct | |||
skipping to change at page 14, line 27 ¶ | skipping to change at page 14, line 35 ¶ | |||
Section 2.3). This value is also not transmitted. | Section 2.3). This value is also not transmitted. | |||
o The final value is the concatenated header, JWE Ciphertext, and | o The final value is the concatenated header, JWE Ciphertext, and | |||
JWE Authentication Tag, all expressed without base64url encoding. | JWE Authentication Tag, all expressed without base64url encoding. | |||
The "." separator is omitted, since the length of these fields is | The "." separator is omitted, since the length of these fields is | |||
known. | known. | |||
Thus, the example in Section 3.1 can be rendered using the JWE | Thus, the example in Section 3.1 can be rendered using the JWE | |||
Compact Serialization as: | Compact Serialization as: | |||
eyAiYWxnIjogImRpciIsICJlbmMiOiAiQTEyOEdDTSIgfQ..31iQYc1v4a36EgyJ. | eyAiYWxnIjogImRpciIsICJlbmMiOiAiQTEyOEdDTSIgfQ..Bcs8gkIRKLI8GeI8. | |||
NSmxkSVa0-MiNNuF77YHSs8.osGjXvzitKn5jnOzU-Vklg | -NAVub2qFgBEuQKRapoZuw.4jGQi9rcwQHU8P6XLxOGOA | |||
Where the first line represents the fixed JWE Protected Header, an | Where the first line represents the fixed JWE Protected Header, an | |||
empty JWE Encrypted Key, and the algorithmically-determined JWE | empty JWE Encrypted Key, and the algorithmically-determined JWE | |||
Initialization Vector. The second line contains the encoded body, | Initialization Vector. The second line contains the encoded body, | |||
split into JWE Ciphertext and JWE Authentication Tag. | split into JWE Ciphertext and JWE Authentication Tag. | |||
Appendix B. Acknowledgements | Appendix B. Acknowledgements | |||
Mark Nottingham was an original author of this document. | Mark Nottingham was an original author of this document. | |||
The following people provided valuable input: Richard Barnes, David | The following people provided valuable input: Richard Barnes, David | |||
Benjamin, Peter Beverloo, JR Conlin, Mike Jones, Stephen Farrell, | Benjamin, Peter Beverloo, JR Conlin, Mike Jones, Stephen Farrell, | |||
Adam Langley, John Mattsson, Julian Reschke, Eric Rescorla, Jim | Adam Langley, James Manger, John Mattsson, Julian Reschke, Eric | |||
Schaad, and Magnus Westerlund. | Rescorla, Jim Schaad, and Magnus Westerlund. | |||
Author's Address | Author's Address | |||
Martin Thomson | Martin Thomson | |||
Mozilla | Mozilla | |||
Email: martin.thomson@gmail.com | Email: martin.thomson@gmail.com | |||
End of changes. 41 change blocks. | ||||
94 lines changed or deleted | 111 lines changed or added | |||
This html diff was produced by rfcdiff 1.45. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |