--- 1/draft-ietf-httpbis-encryption-encoding-02.txt 2016-10-09 22:16:00.696078007 -0700 +++ 2/draft-ietf-httpbis-encryption-encoding-03.txt 2016-10-09 22:16:00.732078934 -0700 @@ -1,22 +1,22 @@ HTTP Working Group M. Thomson Internet-Draft Mozilla -Intended status: Standards Track June 29, 2016 -Expires: December 31, 2016 +Intended status: Standards Track October 9, 2016 +Expires: April 12, 2017 Encrypted Content-Encoding for HTTP - draft-ietf-httpbis-encryption-encoding-02 + draft-ietf-httpbis-encryption-encoding-03 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. Note to Readers Discussion of this draft takes place on the HTTP working group mailing list (ietf-http-wg@w3.org), which is archived at https://lists.w3.org/Archives/Public/ietf-http-wg/ . Working Group information can be found at http://httpwg.github.io/ ; source code and issues list for this draft can be found at @@ -30,103 +30,95 @@ Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on December 31, 2016. + This Internet-Draft will expire on April 12, 2017. Copyright Notice Copyright (c) 2016 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 - 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 4 - 2. The "aesgcm" HTTP Content Encoding . . . . . . . . . . . . . 4 + 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 3 + 2. The "aesgcm" HTTP Content Coding . . . . . . . . . . . . . . 4 3. The Encryption HTTP Header Field . . . . . . . . . . . . . . 6 3.1. Encryption Header Field Parameters . . . . . . . . . . . 6 3.2. Content Encryption Key Derivation . . . . . . . . . . . . 7 3.3. Nonce Derivation . . . . . . . . . . . . . . . . . . . . 8 4. Crypto-Key Header Field . . . . . . . . . . . . . . . . . . . 8 - 4.1. Explicit Key . . . . . . . . . . . . . . . . . . . . . . 9 - 4.2. Diffie-Hellman . . . . . . . . . . . . . . . . . . . . . 9 - 4.3. Pre-shared Authentication Secrets . . . . . . . . . . . . 11 - 5. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 11 - 5.1. Successful GET Response . . . . . . . . . . . . . . . . . 12 - 5.2. Encryption and Compression . . . . . . . . . . . . . . . 12 - 5.3. Encryption with More Than One Key . . . . . . . . . . . . 12 - 5.4. Encryption with Explicit Key . . . . . . . . . . . . . . 13 - 5.5. Encryption with Multiple Records . . . . . . . . . . . . 13 - 5.6. Diffie-Hellman Encryption . . . . . . . . . . . . . . . . 14 - 5.7. Diffie-Hellman with Authentication Secret . . . . . . . . 14 - 6. Security Considerations . . . . . . . . . . . . . . . . . . . 15 - 6.1. Key and Nonce Reuse . . . . . . . . . . . . . . . . . . . 15 - 6.2. Data Encryption Limits . . . . . . . . . . . . . . . . . 16 - 6.3. Content Integrity . . . . . . . . . . . . . . . . . . . . 16 - 6.4. Leaking Information in Headers . . . . . . . . . . . . . 16 - 6.5. Poisoning Storage . . . . . . . . . . . . . . . . . . . . 17 - 6.6. Sizing and Timing Attacks . . . . . . . . . . . . . . . . 17 - 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 17 - 7.1. The "aesgcm" HTTP Content Encoding . . . . . . . . . . . 17 - 7.2. Encryption Header Fields . . . . . . . . . . . . . . . . 18 - 7.3. The HTTP Encryption Parameter Registry . . . . . . . . . 18 - 7.3.1. keyid . . . . . . . . . . . . . . . . . . . . . . . . 19 - 7.3.2. salt . . . . . . . . . . . . . . . . . . . . . . . . 19 - 7.3.3. rs . . . . . . . . . . . . . . . . . . . . . . . . . 19 - 7.4. The HTTP Crypto-Key Parameter Registry . . . . . . . . . 19 - 7.4.1. keyid . . . . . . . . . . . . . . . . . . . . . . . . 20 - 7.4.2. aesgcm . . . . . . . . . . . . . . . . . . . . . . . 20 - 7.4.3. dh . . . . . . . . . . . . . . . . . . . . . . . . . 20 - 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 20 - 8.1. Normative References . . . . . . . . . . . . . . . . . . 20 - 8.2. Informative References . . . . . . . . . . . . . . . . . 21 - Appendix A. JWE Mapping . . . . . . . . . . . . . . . . . . . . 22 - Appendix B. Intermediate Values for Encryption . . . . . . . . . 23 - Appendix C. Acknowledgements . . . . . . . . . . . . . . . . . . 24 - Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 24 + 5. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 9 + 5.1. Encryption of a Response . . . . . . . . . . . . . . . . 9 + 5.2. Encryption with Multiple Records . . . . . . . . . . . . 10 + 5.3. Encryption and Compression . . . . . . . . . . . . . . . 10 + 5.4. Encryption with More Than One Key . . . . . . . . . . . . 11 + 6. Security Considerations . . . . . . . . . . . . . . . . . . . 11 + 6.1. Key and Nonce Reuse . . . . . . . . . . . . . . . . . . . 11 + 6.2. Data Encryption Limits . . . . . . . . . . . . . . . . . 12 + 6.3. Content Integrity . . . . . . . . . . . . . . . . . . . . 12 + 6.4. Leaking Information in Headers . . . . . . . . . . . . . 12 + 6.5. Poisoning Storage . . . . . . . . . . . . . . . . . . . . 13 + 6.6. Sizing and Timing Attacks . . . . . . . . . . . . . . . . 13 + 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 + 7.1. The "aesgcm" HTTP Content Coding . . . . . . . . . . . . 13 + 7.2. Encryption Header Fields . . . . . . . . . . . . . . . . 14 + 7.3. The HTTP Encryption Parameter Registry . . . . . . . . . 14 + 7.3.1. keyid . . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.3.2. salt . . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.3.3. rs . . . . . . . . . . . . . . . . . . . . . . . . . 15 + 7.4. The HTTP Crypto-Key Parameter Registry . . . . . . . . . 15 + 7.4.1. keyid . . . . . . . . . . . . . . . . . . . . . . . . 16 + 7.4.2. aesgcm . . . . . . . . . . . . . . . . . . . . . . . 16 + 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 + 8.1. Normative References . . . . . . . . . . . . . . . . . . 16 + 8.2. Informative References . . . . . . . . . . . . . . . . . 17 + Appendix A. JWE Mapping . . . . . . . . . . . . . . . . . . . . 18 + Appendix B. Acknowledgements . . . . . . . . . . . . . . . . . . 19 + Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 19 1. Introduction 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 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 without exposing its contents to that server. Furthermore, that same file could be replicated to other servers (to make it more resistant to server or network failure), downloaded by clients (to make it available offline), etc. without exposing its contents. These uses are not met by the use of TLS [RFC5246], since it only 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. - 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], [RFC5652], [RFC7516], and [XMLENC] - which are not suited to stream processing, which is necessary for HTTP. The format described here cleaves more closely to the lower level constructs described in [RFC5116]. To the extent that message-based encryption formats use the same primitives, the format can be considered as sequence of encrypted messages with a particular profile. For instance, Appendix A explains how the format is congruent with a sequence of JSON Web @@ -139,40 +131,40 @@ Key header field that can be used to convey keying material. 1.1. Notational Conventions The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. Base64url encoding is defined in Section 2 of [RFC7515]. -2. The "aesgcm" HTTP Content Encoding +2. The "aesgcm" HTTP Content Coding - The "aesgcm" HTTP content-coding indicates that a payload has been + The "aesgcm" HTTP content coding indicates that a payload has been encrypted using Advanced Encryption Standard (AES) in Galois/Counter Mode (GCM) as identified as AEAD_AES_128_GCM in [RFC5116], Section 5.1. The AEAD_AES_128_GCM algorithm uses a 128 bit content encryption key. - When this content-coding is in use, the Encryption header field + When this content coding is in use, the Encryption header field (Section 3) describes how encryption has been applied. The Crypto- Key header field (Section 4) can be included to describe how the content encryption key is derived or retrieved. - The "aesgcm" content-coding uses a single fixed set of encryption + The "aesgcm" content coding uses a single fixed set of encryption 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 encryption. - The "aesgcm" content-coding uses a fixed record size. The resulting + The "aesgcm" content coding uses a fixed record size. The resulting encoding is either a single record, or a series of fixed-size records. The final record, or a lone record, MUST be shorter than the fixed record size. +-----------+ content is rs octets minus padding | data | of between 2 and 65537 octets; +-----------+ the last record is smaller | v +-----+-----------+ add padding to get rs octets; @@ -235,40 +228,40 @@ by arbitrary amounts cannot increase the record size beyond 65537 octets. Applications that don't depending on streaming, random access, or arbitrary padding can use larger records, or even a single record. A larger record size reduces the processing and data overheads. 3. The Encryption HTTP Header Field The "Encryption" HTTP header field describes the encrypted content - encoding(s) that have been applied to a payload body, and therefore - how those content encoding(s) can be removed. + coding(s) that have been applied to a payload body, and therefore how + those content coding(s) can be removed. The "Encryption" header field uses the extended ABNF syntax defined in Section 1.2 of [RFC7230] and the "parameter" and "OWS" rules from [RFC7231]. Encryption = #encryption_params encryption_params = [ parameter *( OWS ";" OWS parameter ) ] If the payload is encrypted more than once (as reflected by having - multiple content-codings that imply encryption), each application of - the content encoding is reflected in a separate Encryption header - field value in the order in which they were applied. + multiple content codings that imply encryption), each application of + the content coding is reflected in a separate Encryption header field + value in the order in which they were applied. Encryption header field values with multiple instances of the same parameter name are invalid. Servers processing PUT requests MUST persist the value of the - Encryption header field, unless they remove the content-coding by + Encryption header field, unless they remove the content coding by decrypting the payload. 3.1. Encryption Header Field Parameters The following parameters are used in determining the content encryption key that is used for encryption: keyid: The "keyid" parameter identifies the keying material that is used. When the Crypto-Key header field is used, the "keyid" identifies a matching value in that field. The "keyid" parameter @@ -276,26 +269,26 @@ field is needed to derive the content encryption key. The "keyid" parameter can also be used to identify keys in an application- specific fashion. salt: The "salt" parameter contains a base64url-encoded octets [RFC7515] that is used as salt in deriving a unique content encryption key (see Section 3.2). The "salt" parameter MUST be present, and MUST be exactly 16 octets long when decoded. The "salt" parameter MUST NOT be reused for two different payload bodies that have the same input keying material; generating a - random salt for every application of the content encoding ensures + random salt for every application of the content coding ensures that content encryption key reuse is highly unlikely. rs: The "rs" parameter contains a positive decimal integer that describes the record size in octets. This value MUST be greater - than 1. For the "aesgcm" content encoding, this value MUST NOT be + than 1. For the "aesgcm" content coding, this value MUST NOT be greater than 2^36-31 (see Section 6.2). The "rs" parameter is optional. If the "rs" parameter is absent, the record size defaults to 4096 octets. 3.2. Content Encryption Key Derivation In order to allow the reuse of keying material for multiple different HTTP messages, a content encryption key is derived for each message. The content encryption key is derived from the decoded value of the "salt" parameter using the HMAC-based key derivation function (HKDF) @@ -310,21 +303,21 @@ PRK = HMAC-SHA-256(salt, IKM) The info parameter to HKDF is set to the ASCII-encoded string "Content-Encoding: aesgcm", a single zero octet and an optional context string: cek_info = "Content-Encoding: aesgcm" || 0x00 || context Unless otherwise specified, the context is a zero length octet - sequence. Specifications that use this content encoding MAY specify + sequence. Specifications that use this content coding MAY specify the use of an expanded context to cover additional inputs in the key derivation. AEAD_AES_128_GCM requires a 16 octet (128 bit) content encryption key (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 HMAC: CEK = HMAC-SHA-256(PRK, cek_info || 0x01) @@ -337,22 +330,22 @@ The input keying material and salt values are input to HKDF with different info and length parameters. The length (L) parameter is 12 octets. The info parameter for the nonce is the ASCII-encoded string "Content-Encoding: nonce", a single zero octet and an context: nonce_info = "Content-Encoding: nonce" || 0x00 || context - The context for nonce derivation SHOULD be the same as is used for - content encryption key derivation. + The context for nonce derivation is the same as is used for content + encryption key derivation. The result is combined with the record sequence number - using exclusive or - to produce the nonce. The record sequence number (SEQ) is a 96-bit unsigned integer in network byte order that starts at zero. Thus, the final nonce for each record is a 12 octet value: NONCE = HMAC-SHA-256(PRK, nonce_info || 0x01) XOR SEQ @@ -370,308 +363,143 @@ [RFC7231]. Crypto-Key = #crypto_key_params crypto_key_params = [ parameter *( OWS ";" OWS parameter ) ] keyid: The "keyid" parameter corresponds to the "keyid" parameter in the Encryption header field. aesgcm: The "aesgcm" parameter contains the base64url-encoded octets [RFC7515] of the input keying material for the "aesgcm" content - encoding. - - dh: The "dh" parameter contains an ephemeral Diffie-Hellman share. - This form of the header field can be used to encrypt content for a - specific recipient. + coding. Crypto-Key header field values with multiple instances of the same parameter name are invalid. The input keying material used by the key derivation (see Section 3.2) can be determined based on the information in the - Crypto-Key header field. The method for key derivation depends on - the parameters that are present in the header field. + Crypto-Key header field. The value or values provided in the Crypto-Key header field is valid only for the current HTTP message unless additional information indicates a greater scope. - Note that different methods for determining input keying material - will produce different amounts of data. The HKDF process ensures - that the final content encryption key is the necessary size. - Alternative methods for determining input keying material MAY be - defined by specifications that use this content-encoding. - -4.1. Explicit Key - - The "aesgcm" parameter is decoded and used as the input keying - material for the "aesgcm" content encoding. The "aesgcm" parameter - MUST decode to at least 16 octets in order to be used as input keying - material for "aesgcm" content encoding. - - Other key determination parameters can be ignored if the "aesgcm" - parameter is present. - -4.2. Diffie-Hellman - - The "dh" parameter is included to describe a Diffie-Hellman share, - either modp (or finite field) Diffie-Hellman [DH] or elliptic curve - Diffie-Hellman (ECDH) [RFC4492]. - - This share is combined with other information at the recipient to - determine the HKDF input keying material. In order for the exchange - to be successful, the following information MUST be established out - of band: - - o Which Diffie-Hellman form is used. - - o The modp group or elliptic curve that will be used. - - o A label that uniquely identifies the group. This label will be - expressed as a sequence of octets and MUST NOT include a zero- - valued octet. - - o The format of the ephemeral public share that is included in the - "dh" parameter. This encoding MUST result in a single, canonical - sequence of octets. For instance, using ECDH both parties need to - agree whether this is an uncompressed or compressed point. - - In addition to identifying which content-encoding this input keying - material is used for, the "keyid" parameter is used to identify this - additional information at the receiver. - - The intended recipient recovers their private key and are then able - to generate a shared secret using the designated Diffie-Hellman - process. - - The context for content encryption key and nonce derivation (see - Section 3.2) is set to include the means by which the keys were - derived. The context is formed from the concatenation of group - label, a single zero octet, the length of the public key of the - recipient, the public key of the recipient, the length of the public - key of the sender, and the public key of the sender. The public keys - are encoded into octets as defined for the group when determining the - context string. - - context = label || 0x00 || - length(recipient_public) || recipient_public || - length(sender_public) || sender_public - - The two length fields are encoded as a two octet unsigned integer in - network byte order. - - Specifications that rely on an Diffie-Hellman exchange for - determining input keying material MUST either specify the parameters - for Diffie-Hellman (label, group parameters, or curves and point - format) that are used, or describe how those parameters are - negotiated between sender and receiver. - -4.3. Pre-shared Authentication Secrets + defined by specifications that use this content coding. This + document only defines the use of the "aesgcm" parameter which + describes an explicit key. - Key derivation MAY be extended to include an additional - authentication secret. Such a secret is shared between the sender - and receiver of a message using other means. + The "aesgcm" parameter MUST decode to at least 16 octets in order to + be used as input keying material for "aesgcm" content coding. - A pre-shared authentication secret is not explicitly signaled in - either the Encryption or Crypto-Key header fields. Use of this - additional step depends on prior agreement. +5. Examples - When a shared authentication secret is used, the keying material - produced by the key agreement method (e.g., Diffie-Hellman, explicit - key, or otherwise) is combined with the authentication secret using - HKDF. The output of HKDF is the input keying material used to derive - the content encryption key and nonce Section 3.2. + This section shows a few examples of the encrypted content coding. - The authentication secret is used as the "salt" parameter to HKDF, - the raw keying material (e.g., Diffie-Hellman output) is used as the - "IKM" parameter, the ASCII-encoded string "Content-Encoding: auth" - with a terminal zero octet is used as the "info" parameter, and the - length of the output is 32 octets (i.e., the entire output of the - underlying SHA-256 HMAC function): + Note: All binary values in the examples in this section use base64url + encoding [RFC7515]. This includes the bodies of requests. + Whitespace and line wrapping is added to fit formatting constraints. - auth_info = "Content-Encoding: auth" || 0x00 - IKM = HKDF(authentication, raw_key, auth_info, 32) +5.1. Encryption of a Response - This invocation of HKDF does not take the same context that is - provided to the final key derivation stages. Alternatively, this - phase can be viewed as always having a zero-length context. + Here, a successful HTTP GET response has been encrypted using input + keying material that is identified by a URI. - Note that in the absence of an authentication secret, the input - keying material is simply the raw keying material: + The encrypted data in this example is the UTF-8 encoded string "I am + the walrus". The input keying material is included in the Crypto-Key + header field. The content body contains a single record only and is + shown here using base64url encoding for presentation reasons. - IKM = raw_key + HTTP/1.1 200 OK + Content-Type: application/octet-stream + Content-Length: 33 + Content-Encoding: aesgcm + Encryption: keyid="a1"; salt="vr0o6Uq3w_KDWeatc27mUg" + Crypto-Key: keyid="a1"; aesgcm="csPJEXBYA5U-Tal9EdJi-w" -5. Examples + VDeU0XxaJkOJDAxPl7h9JD5V8N43RorP7PfpPdZZQuwF - This section shows a few examples of the content encoding. + Note that the media type has been changed to "application/octet- + stream" to avoid exposing information about the content. - Note: All binary values in the examples in this section use the URL - and filename safe variant of base64 [RFC4648]. This includes the - bodies of requests. Whitespace in these values is added to fit - formatting constraints. +5.2. Encryption with Multiple Records -5.1. Successful GET Response + This example shows the same encrypted message, but split into records + of 10 octets each. The first record includes a single additional + octet of padding, which causes the end of the content to align with a + record boundary, forcing the creation of a third record that contains + only padding. HTTP/1.1 200 OK - Content-Type: application/octet-stream + Content-Length: 70 Content-Encoding: aesgcm - Connection: close - Encryption: keyid="bob/keys/123"; - salt="XZwpw6o37R-6qoZjw6KwAw" - - [encrypted payload] - - Here, a successful HTTP GET response has been encrypted using input - keying material that is identified by a URI. + Encryption: keyid="a1"; salt="4pdat984KmT9BWsU3np0nw"; rs=10 + Crypto-Key: keyid="a1"; aesgcm="BO3ZVPxUlnLORbVGMpbT1Q" - Note that the media type has been changed to "application/octet- - stream" to avoid exposing information about the content. + uzLfrZ4cbMTC6hlUqHz4NvWZshFlTN3o2RLr6FrIuOKEfl2VrM_jYgoiIyEo + Zvc-ZGwV-RMJejG4M6ZfGysBAdhpPqrLzw -5.2. Encryption and Compression +5.3. Encryption and Compression In this example, a response is first compressed, then encrypted. Note that this particular encoding might compromise confidentiality - if the contents of the response could be influenced by an attacker. + if the contents could be influenced by an attacker. HTTP/1.1 200 OK Content-Type: text/html Content-Encoding: gzip, aesgcm Transfer-Encoding: chunked Encryption: keyid="me@example.com"; salt="m2hJ_NttRtFyUiMRPwfpHA" [encrypted payload] -5.3. Encryption with More Than One Key +5.4. Encryption with More Than One Key Here, a PUT request has been encrypted twice with different input keying material; decrypting twice is necessary to read the content. The outer layer of encryption uses a 1200 octet record size. PUT /thing HTTP/1.1 Host: storage.example.com Content-Type: application/http Content-Encoding: aesgcm, aesgcm Content-Length: 1235 Encryption: keyid="mailto:me@example.com"; salt="NfzOeuV5USPRA-n_9s1Lag", keyid="bob/keys/123"; salt="bDMSGoc2uobK_IhavSHsHA"; rs=1200 [encrypted payload] -5.4. Encryption with Explicit Key - - This example shows the UTF-8 encoded string "I am the walrus" - encrypted using an directly provided value for the input keying - material. The content body contains a single record only and is - shown here using base64url encoding for presentation reasons. - - HTTP/1.1 200 OK - Content-Length: 33 - Content-Encoding: aesgcm - Encryption: keyid="a1"; salt="vr0o6Uq3w_KDWeatc27mUg" - Crypto-Key: keyid="a1"; aesgcm="csPJEXBYA5U-Tal9EdJi-w" - - VDeU0XxaJkOJDAxPl7h9JD5V8N43RorP7PfpPdZZQuwF - -5.5. Encryption with Multiple Records - - This example shows the same encrypted message, but split into records - of 10 octets each. The first record includes a single additional - octet of padding, which causes the end of the content to align with a - record boundary, forcing the creation of a third record that contains - only padding. - - HTTP/1.1 200 OK - Content-Length: 70 - Content-Encoding: aesgcm - Encryption: keyid="a1"; salt="4pdat984KmT9BWsU3np0nw"; rs=10 - Crypto-Key: keyid="a1"; aesgcm="BO3ZVPxUlnLORbVGMpbT1Q" - - uzLfrZ4cbMTC6hlUqHz4NvWZshFlTN3o2RLr6FrIuOKEfl2VrM_jYgoiIyEo - Zvc-ZGwV-RMJejG4M6ZfGysBAdhpPqrLzw - -5.6. Diffie-Hellman Encryption - - HTTP/1.1 200 OK - Content-Length: 33 - Content-Encoding: aesgcm - Encryption: keyid="dhkey"; salt="Qg61ZJRva_XBE9IEUelU3A" - Crypto-Key: keyid="dhkey"; - dh="BDgpRKok2GZZDmS4r63vbJSUtcQx4Fq1V58-6-3NbZzS - TlZsQiCEDTQy3CZ0ZMsqeqsEb7qW2blQHA4S48fynTk" - - yqD2bapcx14XxUbtwjiGx69eHE3Yd6AqXcwBpT2Kd1uy - - This example shows the same string, "I am the walrus", encrypted - using ECDH over the P-256 curve [FIPS186], which is identified with - the label "P-256" encoded in ASCII. The content body is shown here - encoded in URL-safe base64url for presentation reasons only. - - The receiver (in this case, the HTTP client) uses a key pair that is - identified by the string "dhkey" and the sender (the server) uses a - key pair for which the public share is included in the "dh" parameter - above. The keys shown below use uncompressed points [X9.62] encoded - using base64url. Line wrapping is added for presentation purposes - only. - - Receiver: - private key: 9FWl15_QUQAWDaD3k3l50ZBZQJ4au27F1V4F0uLSD_M - public key: BCEkBjzL8Z3C-oi2Q7oE5t2Np-p7osjGLg93qUP0wvqR - T21EEWyf0cQDQcakQMqz4hQKYOQ3il2nNZct4HgAUQU - Sender: - private key: vG7TmzUX9NfVR4XUGBkLAFu8iDyQe-q_165JkkN0Vlw - public key: - -5.7. Diffie-Hellman with Authentication Secret - - This example shows the same receiver key pair from Section 5.6, but - with a shared authentication secret of "R29vIGdvbyBnJyBqb29iIQ". - - HTTP/1.1 200 OK - Content-Length: 33 - Content-Encoding: aesgcm - Encryption: keyid="dhkey"; salt="lngarbyKfMoi9Z75xYXmkg" - Crypto-Key: keyid="dhkey"; - dh="BNoRDbb84JGm8g5Z5CFxurSqsXWJ11ItfXEWYVLE85Y7 - CYkDjXsIEc4aqxYaQ1G8BqkXCJ6DPpDrWtdWj_mugHU" - - 6nqAQUME8hNqw5J3kl8cpVVJylXKYqZOeseZG8UueKpA - - The sender's private key used in this example is "nCScek-QpEjmOOlT- - rQ38nZzvdPlqa00Zy0i6m2OJvY". Intermediate values for this example - are included in Appendix B. - 6. Security Considerations This mechanism assumes the presence of a key management framework that is used to manage the distribution of keys between valid senders and receivers. Defining key management is part of composing this mechanism into a larger application, protocol, or framework. Implementation of cryptography - and key management in particular - can be difficult. For instance, implementations need to account for the potential for exposing keying material on side channels, such as might be exposed by the time it takes to perform a given operation. The requirements for a good implementation of cryptographic algorithms can change over time. 6.1. Key and Nonce Reuse Encrypting different plaintext with the same content encryption key and nonce in AES-GCM is not safe [RFC5116]. The scheme defined here uses a fixed progression of nonce values. Thus, a new content - encryption key is needed for every application of the content - encoding. Since input keying material can be reused, a unique "salt" - parameter is needed to ensure a content encryption key is not reused. + encryption key is needed for every application of the content coding. + Since input keying material can be reused, a unique "salt" parameter + is needed to ensure a content encryption key is not reused. If a content encryption key is reused - that is, if input keying material and salt are reused - this could expose the plaintext and the authentication key, nullifying the protection offered by encryption. Thus, if the same input keying material is reused, then the salt parameter MUST be unique each time. This ensures that the content encryption key is not reused. An implementation SHOULD generate a random salt parameter for every message; a counter could achieve the same result. @@ -753,27 +581,26 @@ so on, may leak sensitive information. This risk can be mitigated through the use of the padding that this mechanism provides. Alternatively, splitting up content into segments and storing the separately might reduce exposure. HTTP/2 [RFC7540] combined with TLS [RFC5246] might be used to hide the size of individual messages. 7. IANA Considerations -7.1. The "aesgcm" HTTP Content Encoding +7.1. The "aesgcm" HTTP Content Coding - This memo registers the "aesgcm" HTTP content-coding in the HTTP + This memo registers the "aesgcm" HTTP content coding in the HTTP Content Codings Registry, as detailed in Section 2. o Name: aesgcm - o Description: AES-GCM encryption with a 128-bit content encryption key o Reference: this specification 7.2. Encryption Header Fields This memo registers the "Encryption" HTTP header field in the Permanent Message Header Registry, as detailed in Section 3. @@ -871,62 +698,48 @@ o Purpose: Identify the key that is in use. o Reference: this document 7.4.2. aesgcm o Parameter Name: aesgcm o Purpose: Provide an explicit input keying material value for the - aesgcm content encoding. - - o Reference: this document - -7.4.3. dh - - o Parameter Name: dh - - o Purpose: Carry a modp or elliptic curve Diffie-Hellman share used - to derive input keying material. + aesgcm content coding. o Reference: this document 8. References 8.1. Normative References - [DH] Diffie, W. and M. Hellman, "New Directions in - Cryptography", IEEE Transactions on Information Theory, - V.IT-22 n.6 , June 1977. - [FIPS180-4] Department of Commerce, National., "NIST FIPS 180-4, Secure Hash Standard", March 2012, . [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . - [RFC4492] Blake-Wilson, S., Bolyard, N., Gupta, V., Hawk, C., and B. - Moeller, "Elliptic Curve Cryptography (ECC) Cipher Suites - for Transport Layer Security (TLS)", RFC 4492, - DOI 10.17487/RFC4492, May 2006, - . - [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, . + [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an + IANA Considerations Section in RFCs", BCP 26, RFC 5226, + DOI 10.17487/RFC5226, May 2008, + . + [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand Key Derivation Function (HKDF)", RFC 5869, DOI 10.17487/RFC5869, May 2010, . [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing", RFC 7230, DOI 10.17487/RFC7230, June 2014, . @@ -939,38 +752,25 @@ Signature (JWS)", RFC 7515, DOI 10.17487/RFC7515, May 2015, . 8.2. Informative References [AEBounds] Luykx, A. and K. Paterson, "Limits on Authenticated Encryption Use in TLS", March 2016, . - [FIPS186] National Institute of Standards and Technology (NIST), - "Digital Signature Standard (DSS)", NIST PUB 186-4 , July - 2013. - - [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data - Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, - . - [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. Thayer, "OpenPGP Message Format", RFC 4880, DOI 10.17487/RFC4880, November 2007, . - [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an - IANA Considerations Section in RFCs", BCP 26, RFC 5226, - DOI 10.17487/RFC5226, May 2008, - . - [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security (TLS) Protocol Version 1.2", RFC 5246, DOI 10.17487/RFC5246, August 2008, . [RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, RFC 5652, DOI 10.17487/RFC5652, September 2009, . [RFC7233] Fielding, R., Ed., Lafon, Y., Ed., and J. Reschke, Ed., @@ -985,120 +785,66 @@ [RFC7516] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)", RFC 7516, DOI 10.17487/RFC7516, May 2015, . [RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext Transfer Protocol Version 2 (HTTP/2)", RFC 7540, DOI 10.17487/RFC7540, May 2015, . - [X9.62] ANSI, "Public Key Cryptography For The Financial Services - Industry: The Elliptic Curve Digital Signature Algorithm - (ECDSA)", ANSI X9.62 , 1998. - [XMLENC] Eastlake, D., Reagle, J., Imamura, T., Dillaway, B., and E. Simon, "XML Encryption Syntax and Processing", W3C REC , December 2002, . Appendix A. JWE Mapping - The "aesgcm" content encoding can be considered as a sequence of JSON + The "aesgcm" content coding can be considered as a sequence of JSON Web Encryption (JWE) objects [RFC7516], each corresponding to a single fixed size record that includes leading padding. The following transformations are applied to a JWE object that might be expressed using the JWE Compact Serialization: - o The JWE Protected Header is fixed to a value { "alg": "dir", + o The JWE Protected Header is fixed to the value { "alg": "dir", "enc": "A128GCM" }, describing direct encryption using AES-GCM with a 128-bit content encryption key. This header is not transmitted, it is instead implied by the value of the Content- Encoding header field. o The JWE Encrypted Key is empty, as stipulated by the direct encryption algorithm. o The JWE Initialization Vector ("iv") for each record is set to the exclusive or of the 96-bit record sequence number, starting at zero, and a value derived from the input keying material (see Section 3.3). This value is also not transmitted. o The final value is the concatenated JWE Ciphertext and the JWE - Authentication Tag, both expressed without URL-safe Base 64 - encoding. The "." separator is omitted, since the length of these - fields is known. + Authentication Tag, both expressed without base64url encoding. + The "." separator is omitted, since the length of these fields is + known. - Thus, the example in Section 5.4 can be rendered using the JWE + Thus, the example in Section 5.1 can be rendered using the JWE Compact Serialization as: eyAiYWxnIjogImRpciIsICJlbmMiOiAiQTEyOEdDTSIgfQ..31iQYc1v4a36EgyJ. VDeU0XxaJkOJDAxPl7h9JD4.VfDeN0aKz-z36T3WWULsBQ Where the first line represents the fixed JWE Protected Header, an empty JWE Encrypted Key, and the algorithmically-determined JWE Initialization Vector. The second line contains the encoded body, split into JWE Ciphertext and JWE Authentication Tag. -Appendix B. Intermediate Values for Encryption - - The intermediate values calculated for the example in Section 5.7 are - shown here. The following are inputs to the calculation: - - Plaintext: SSBhbSB0aGUgd2FscnVz - - Sender public key: BNoRDbb84JGm8g5Z5CFxurSqsXWJ11ItfXEWYVLE85Y7 - CYkDjXsIEc4aqxYaQ1G8BqkXCJ6DPpDrWtdWj_mugHU - - Sender private key: nCScek-QpEjmOOlT-rQ38nZzvdPlqa00Zy0i6m2OJvY - - Receiver public key: BCEkBjzL8Z3C-oi2Q7oE5t2Np-p7osjGLg93qUP0wvqR - T21EEWyf0cQDQcakQMqz4hQKYOQ3il2nNZct4HgAUQU - - Receiver private key: 9FWl15_QUQAWDaD3k3l50ZBZQJ4au27F1V4F0uLSD_M - Salt: lngarbyKfMoi9Z75xYXmkg - - Note that knowledge of just one of the private keys is necessary. - The sender randomly generates the salt value, whereas salt is input - to the receiver. - - This produces the following intermediate values: - - Shared secret (raw_key): RNjC-NVW4BGJbxWPW7G2mowsLeDa53LYKYm4-NOQ6Y - - Input keying material (IKM): EhpZec37Ptm4IRD5-jtZ0q6r1iK5vYmY1tZwtN8 - fbZY - - Context for content encryption key derivation: - Q29udGVudC1FbmNvZGluZzogYWVzZ2NtAFAtMjU2AABB BCEkBjzL8Z3C- - oi2Q7oE5t2Np-p7osjGLg93qUP0wvqR - T21EEWyf0cQDQcakQMqz4hQKYOQ3il2nNZct4HgAUQUA - QQTaEQ22_OCRpvIOWeQhcbq0qrF1iddSLX1xFmFSxPOW - OwmJA417CBHOGqsWGkNRvAapFwiegz6Q61rXVo_5roB1 - - Content encryption key (CEK): AN2-xhvFWeYh5z0fcDu0Ww - - Context for nonce derivation: Q29udGVudC1FbmNvZGluZzogbm9uY2UAUC0yNT - YAAEEE ISQGPMvxncL6iLZDugTm3Y2n6nuiyMYuD3epQ_TC-pFP - bUQRbJ_RxANBxqRAyrPiFApg5DeKXac1ly3geABRBQBB - BNoRDbb84JGm8g5Z5CFxurSqsXWJ11ItfXEWYVLE85Y7 - CYkDjXsIEc4aqxYaQ1G8BqkXCJ6DPpDrWtdWj_mugHU - - Base nonce: JY1Okw5rw1Drkg9J - - When the CEK and nonce are used with AES GCM and the padded plaintext - of AABJIGFtIHRoZSB3YWxydXM, the final ciphertext is - 6nqAQUME8hNqw5J3kl8cpVVJylXKYqZOeseZG8UueKpA, as shown in the - example. - -Appendix C. Acknowledgements +Appendix B. Acknowledgements Mark Nottingham was an original author of this document. The following people provided valuable input: Richard Barnes, David Benjamin, Peter Beverloo, Mike Jones, Stephen Farrell, Adam Langley, John Mattsson, Eric Rescorla, and Jim Schaad. Author's Address + Martin Thomson Mozilla Email: martin.thomson@gmail.com