<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.0.30 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>

<?rfc toc="yes"?>
<?rfc tocindent="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc strict="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc docmapping="yes"?>

<rfc ipr="trust200902" docName="draft-ietf-httpbis-encryption-encoding-01" category="std">

  <feedback xmlns='https://umn7fc98gj7rc.julianrbryant.com/net/xml2rfc/ext' template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22&amp;body=%3c{ref}%3e:"/><front>
    <title abbrev="HTTP encryption coding">Encrypted Content-Encoding for HTTP</title>

    <author initials="M." surname="Thomson" fullname="Martin Thomson">
      <organization>Mozilla</organization>
      <address>
        <email>martin.thomson@gmail.com</email>
      </address>
    </author>

    <date year="2016" month="3" day="20"/>

    <area>Applications and Real-Time</area>
    <workgroup>HTTP</workgroup>
    <keyword>Internet-Draft</keyword>

    <abstract>


<t>This memo introduces a content-coding for HTTP that allows message payloads to
be encrypted.</t>



    </abstract>


    <note title="Note to Readers">


<t>Discussion of this draft takes place on the HTTP working group mailing list
(ietf-http-wg@w3.org), which is archived at <eref target="https://un5xruhmgkj46tygt32g.julianrbryant.com/Archives/Public/ietf-http-wg/">https://un5xruhmgkj46tygt32g.julianrbryant.com/Archives/Public/ietf-http-wg/</eref>.</t>

<t>Working Group information can be found at <eref target="https://umn5j91xuvj8cem5tqpfy4k4ym.julianrbryant.com/">https://umn5j91xuvj8cem5tqpfy4k4ym.julianrbryant.com/</eref>; source
code and issues list for this draft can be found at <eref target="https://github.com/httpwg/http-extensions/labels/encryption">https://github.com/httpwg/http-extensions/labels/encryption</eref>.</t>


    </note>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>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.</t>

<t>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.</t>

<t>These uses are not met by the use of TLS <xref target="RFC5246"></xref>, since it only encrypts the
channel between the client and server.</t>

<t>This document specifies a content-coding (Section 3.1.2 of <xref target="RFC7231"></xref>) for HTTP
to serve these and other use cases.</t>

<t>This content-coding is not a direct adaptation of message-based encryption
formats - such as those that are described by <xref target="RFC4880"></xref>, <xref target="RFC5652"></xref>, <xref target="RFC7516"></xref>,
and <xref target="XMLENC"></xref> - 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 <xref target="RFC5116"></xref>.</t>

<t>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, <xref target="jwe"/> explains how the format is congruent with a
sequence of JSON Web Encryption <xref target="RFC7516"></xref> values with a fixed header.</t>

<t>This mechanism is likely only a small part of a larger design that uses content
encryption.  How clients and servers acquire and identify keys will depend on
the use case.  Though a complete key management system is not described, this
document defines an Crypto-Key header field that can be used to convey keying
material.</t>

<section anchor="notational-conventions" title="Notational Conventions">

<t>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 <xref target="RFC2119"></xref>.</t>

<t>Base64url encoding is defined in Section 2 of <xref target="RFC7515"></xref>.</t>

</section>
</section>
<section anchor="aesgcm" title="The “aesgcm” HTTP Content Encoding">

<t>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 <xref target="RFC5116"></xref>, Section 5.1.  The AEAD_AES_128_GCM
algorithm uses a 128 bit content encryption key.</t>

<t>When this content-coding is in use, the Encryption header field (<xref target="encryption"/>)
describes how encryption has been applied.  The Crypto-Key header field
(<xref target="crypto-key"/>) can be included to describe how the content encryption key is
derived or retrieved.</t>

<t>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-Encoding header field is
necessary to negotiate the use of encryption.</t>

<t>The “aesgcm” content-coding uses a fixed record size.  The resulting encoding is
a series of fixed-size records, with a final record that is one or more octets
shorter than a fixed sized record.</t>

<figure><artwork type="drawing"><![CDATA[
       +------+         input of between rs-65537
       | data |            and rs-2 octets
       +------+      (one fewer for the last record)
           |
           v
+-----+-----------+
| pad |   data    |     add padding to form plaintext
+-----+-----------+
         |
         v
+--------------------+
|    ciphertext      |  encrypt with AEAD_AES_128_GCM
+--------------------+     expands by 16 octets
]]></artwork></figure>

<t>The record size determines the length of each portion of plaintext that is
enciphered, with the exception of the final record, which is necessarily
smaller.  The record size defaults to 4096 octets, but can be changed using the
“rs” parameter on the Encryption header field.</t>

<t>AEAD_AES_128_GCM expands ciphertext to be 16 octets longer than its input
plaintext.  Therefore, the length of each enciphered record other than the last
is equal to the value of the “rs” parameter plus 16 octets.  A receiver MUST
fail to decrypt if the final record ciphertext is 16 octets or less in size.
Valid records always contain at least one byte of padding and a 16 octet
authentication tag.</t>

<t>Each record contains between 2 and 65537 octets of padding, inserted into a
record before the enciphered content. Padding consists of a two octet unsigned
integer in network byte order, followed that number of zero-valued octets. A
receiver MUST fail to decrypt if any padding octet other than the first two are
non-zero, or a record has more padding than the record size can accommodate.</t>

<t>The nonce for each record is a 96-bit value constructed from the record sequence
number and the input keying material.  Nonce derivation is covered in <xref target="nonce"/>.</t>

<t>The additional data passed to each invocation of AEAD_AES_128_GCM is a
zero-length octet sequence.</t>

<t>A sequence of full-sized records can be truncated to produce a shorter sequence
of records with valid authentication tags.  To prevent an attacker from
truncating a stream, an encoder MUST append a record that contains only padding
and is smaller than the full record size if the final record ends on a record
boundary.  A receiver MUST treat the stream as failed due to truncation if the
final record is the full record size.</t>

<t>A consequence of this record structure is that range requests <xref target="RFC7233"></xref> and
random access to encrypted payload bodies are possible at the granularity of the
record size.  However, without data from adjacent ranges, partial records cannot
be used.  Thus, it is best if records start and end on multiples of the record
size, plus the 16 octet authentication tag size.</t>

</section>
<section anchor="encryption" title="The Encryption HTTP Header Field">

<t>The <spanx style="verb">Encryption</spanx> 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.</t>

<t>The <spanx style="verb">Encryption</spanx> header field uses the extended ABNF syntax defined in
Section 1.2 of <xref target="RFC7230"></xref> and the <spanx style="verb">parameter</spanx> rule from <xref target="RFC7231"></xref></t>

<figure><artwork type="abnf7230"><![CDATA[
  Encryption = #encryption_params
  encryption_params = [ parameter *( ";" parameter ) ]
]]></artwork></figure>

<t>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 the Encryption header field, in the order in which they were
applied.</t>

<t>Encryption header field values with multiple instances of the same parameter
name are invalid.</t>

<t>The Encryption header MAY be omitted if the sender does not intend for the
immediate recipient to be able to decrypt the payload body.  Alternatively,
the Encryption header field MAY be omitted if the sender intends for the
recipient to acquire the header field by other means.</t>

<t>Servers processing PUT requests MUST persist the value of the Encryption header
field, unless they remove the content-coding by decrypting the payload.</t>

<section anchor="encryption-header-field-parameters" title="Encryption Header Field Parameters">

<t>The following parameters are used in determining the content encryption key that
is used for encryption:</t>

<t><list style="hanging">
  <t hangText='keyid:'>
  The “keyid” parameter contains a string that identifies the keying material
that is used.  The “keyid” parameter SHOULD be included, unless key
identification is guaranteed by other means.  The “keyid” parameter MUST be
used if keying material included in an Crypto-Key header field is needed to
derive the content encryption key.</t>
  <t hangText='salt:'>
  The “salt” parameter contains a base64url-encoded octets <xref target="RFC7515"></xref> that is
used as salt in deriving a unique content encryption key (see <xref target="derivation"/>).
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 that content encryption key
reuse is highly unlikely.</t>
  <t hangText='rs:'>
  The “rs” parameter contains a positive decimal integer that describes the
record size in octets.  This value MUST be greater than 1.  If the “rs”
parameter is absent, the record size defaults to 4096 octets.</t>
</list></t>

</section>
<section anchor="derivation" title="Content Encryption Key Derivation">

<t>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) described in <xref target="RFC5869"></xref> using the
SHA-256 hash algorithm <xref target="FIPS180-4"></xref>.</t>

<t>The decoded value of the “salt” parameter is the salt input to HKDF function.
The keying material identified by the “keyid” parameter is the input keying
material (IKM) to HKDF.  Input keying material can either be prearranged, or can
be described using the Crypto-Key header field (<xref target="crypto-key"/>).  The first step
of HKDF is therefore:</t>

<figure><artwork type="inline"><![CDATA[
   PRK = HMAC-SHA-256(salt, IKM)
]]></artwork></figure>

<t>The info parameter to HKDF is set to the ASCII-encoded string “Content-Encoding:
aesgcm”, a single zero octet and an optional context string:</t>

<figure><artwork type="inline"><![CDATA[
   cek_info = "Content-Encoding: aesgcm" || 0x00 || context
]]></artwork></figure>

<t>Unless otherwise specified, the context is a zero length octet sequence.
Specifications that use this content encoding MAY specify the use of an expanded
context to cover additional inputs in the key derivation.</t>

<t>AEAD_AES_128_GCM requires a 16 octet (128 bit) content encryption key, 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:</t>

<figure><artwork type="inline"><![CDATA[
   CEK = HMAC-SHA-256(PRK, cek_info || 0x01)
]]></artwork></figure>

</section>
<section anchor="nonce" title="Nonce Derivation">

<t>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 is produced from the record
sequence number and a value derived from the input keying material.</t>

<t>The input keying material and salt values are input to HKDF with different info
and length parameters.</t>

<t>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:</t>

<figure><artwork type="inline"><![CDATA[
   nonce_info = "Content-Encoding: nonce" || 0x00 || context
]]></artwork></figure>

<t>The context for nonce derivation SHOULD be the same as is used for content
encryption key derivation.</t>

<t>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.</t>

<t>Thus, the final nonce for each record is a 12 octet value:</t>

<figure><artwork type="inline"><![CDATA[
   NONCE = HMAC-SHA-256(PRK, nonce_info || 0x01) XOR SEQ
]]></artwork></figure>

</section>
</section>
<section anchor="crypto-key" title="Crypto-Key Header Field">

<t>An Crypto-Key header field can be used to describe the input keying material
used in the Encryption header field.</t>

<t>The Crypto-Key header field uses the extended ABNF syntax defined in Section 1.2
of <xref target="RFC7230"></xref> and the <spanx style="verb">parameter</spanx> rule from <xref target="RFC7231"></xref>.</t>

<figure><artwork type="abnf7230"><![CDATA[
  Crypto-Key = #crypto_key_params
  crypto_key_params = [ parameter *( ";" parameter ) ]
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='keyid:'>
  The “keyid” parameter corresponds to the “keyid” parameter in the Encryption
header field.</t>
  <t hangText='aesgcm:'>
  The “aesgcm” parameter contains the base64url-encoded octets <xref target="RFC7515"></xref> of the
input keying material.</t>
  <t hangText='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.</t>
</list></t>

<t>Crypto-Key header field values with multiple instances of the same parameter
name are invalid.</t>

<t>The input keying material used by the key derivation (see <xref target="derivation"/>) 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.</t>

<t>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.</t>

<t>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.</t>

<t>Alternative methods for determining input keying material MAY be defined by
specifications that use this content-encoding.</t>

<section anchor="explicit-key" title="Explicit Key">

<t>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.</t>

<t>Other key determination parameters can be ignored if the “aesgcm” parameter is
present.</t>

</section>
<section anchor="diffie-hellman" title="Diffie-Hellman">

<t>The “dh” parameter is included to describe a Diffie-Hellman share, either modp
(or finite field) Diffie-Hellman <xref target="DH"></xref> or elliptic curve Diffie-Hellman (ECDH)
<xref target="RFC4492"></xref>.</t>

<t>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:</t>

<t><list style="symbols">
  <t>Which Diffie-Hellman form is used.</t>
  <t>The modp group or elliptic curve that will be used.</t>
  <t>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.</t>
  <t>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.</t>
</list></t>

<t>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.</t>

<t>The intended recipient recovers their private key and are then able to generate
a shared secret using the designated Diffie-Hellman process.</t>

<t>The context for content encryption key and nonce derivation (see <xref target="derivation"/>)
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.</t>

<figure><artwork type="inline"><![CDATA[
   context = label || 0x00 ||
               length(recipient_public) || recipient_public ||
               length(sender_public) || sender_public
]]></artwork></figure>

<t>The two length fields are encoded as a two octet unsigned integer in network
byte order.</t>

<t>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.</t>

</section>
<section anchor="auth" title="Pre-shared Authentication Secrets">

<t>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.</t>

<t>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.</t>

<t>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
<xref target="derivation"/>.</t>

<t>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):</t>

<figure><artwork type="inline"><![CDATA[
   auth_info = "Content-Encoding: auth" || 0x00
   IKM = HKDF(authentication, raw_key, auth_info, 32)
]]></artwork></figure>

<t>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.</t>

<t>Note that in the absence of an authentication secret, the input keying material
is simply the raw keying material:</t>

<figure><artwork type="inline"><![CDATA[
   IKM = raw_key
]]></artwork></figure>

</section>
</section>
<section anchor="examples" title="Examples">

<t>This section shows a few examples of the content encoding.</t>

<t>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.</t>

<section anchor="successful-get-response" title="Successful GET Response">

<figure><artwork type="example"><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Encoding: aesgcm
Connection: close
Encryption: keyid="https://umn4kq9urycymemmv4.julianrbryant.com/bob/keys/123";
            salt="XZwpw6o37R-6qoZjw6KwAw"

[encrypted payload]
]]></artwork></figure>

<t>Here, a successful HTTP GET response has been encrypted using input keying
material that is identified by a URI.</t>

<t>Note that the media type has been changed to “application/octet-stream” to avoid
exposing information about the content.</t>

</section>
<section anchor="encryption-and-compression" title="Encryption and Compression">

<t>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.</t>

<figure><artwork type="example"><![CDATA[
HTTP/1.1 200 OK
Content-Type: text/html
Content-Encoding: gzip, aesgcm
Transfer-Encoding: chunked
Encryption: keyid="mailto:me@example.com";
            salt="m2hJ_NttRtFyUiMRPwfpHA"

[encrypted payload]
]]></artwork></figure>

</section>
<section anchor="encryption-with-more-than-one-key" title="Encryption with More Than One Key">

<t>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.</t>

<figure><artwork type="example"><![CDATA[
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="https://umn4kq9urycymemmv4.julianrbryant.com/bob/keys/123";
            salt="bDMSGoc2uobK_IhavSHsHA"; rs=1200

[encrypted payload]
]]></artwork></figure>

</section>
<section anchor="explicit" title="Encryption with Explicit Key">

<t>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.</t>

<figure><artwork type="example"><![CDATA[
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
]]></artwork></figure>

</section>
<section anchor="encryption-with-multiple-records" title="Encryption with Multiple Records">

<t>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.</t>

<figure><artwork type="example"><![CDATA[
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
]]></artwork></figure>

</section>
<section anchor="ex-dh" title="Diffie-Hellman Encryption">

<figure><artwork type="example"><![CDATA[
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
]]></artwork></figure>

<t>This example shows the same string, “I am the walrus”, encrypted using ECDH over
the P-256 curve <xref target="FIPS186"></xref>, 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.</t>

<t>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 <xref target="X9.62"></xref> encoded using base64url. Line wrapping is added for
presentation purposes only.</t>

<figure><artwork type="example"><![CDATA[
   Receiver:
      private key: 9FWl15_QUQAWDaD3k3l50ZBZQJ4au27F1V4F0uLSD_M
      public key: BCEkBjzL8Z3C-oi2Q7oE5t2Np-p7osjGLg93qUP0wvqR
                  T21EEWyf0cQDQcakQMqz4hQKYOQ3il2nNZct4HgAUQU
   Sender:
      private key: vG7TmzUX9NfVR4XUGBkLAFu8iDyQe-q_165JkkN0Vlw
      public key: <the value of the "dh" parameter>
]]></artwork></figure>

</section>
<section anchor="ex-authSecret" title="Diffie-Hellman with Authentication Secret">

<t>This example shows the same receiver key pair from <xref target="ex-dh"/>, but with a shared
authentication secret of “R29vIGdvbyBnJyBqb29iIQ”.</t>

<figure><artwork><![CDATA[
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
]]></artwork></figure>

<t>The sender’s private key used in this example is
“nCScek-QpEjmOOlT-rQ38nZzvdPlqa00Zy0i6m2OJvY”.  Intermediate values for this
example are included in <xref target="ex-intermediate"/>.</t>

</section>
</section>
<section anchor="security-considerations" title="Security Considerations">

<t>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.</t>

<t>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.</t>

<section anchor="key-and-nonce-reuse" title="Key and Nonce Reuse">

<t>Encrypting different plaintext with the same content encryption key and nonce in
AES-GCM is not safe <xref target="RFC5116"></xref>.  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.</t>

<t>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.</t>

</section>
<section anchor="content-integrity" title="Content Integrity">

<t>This mechanism only provides content origin authentication.  The authentication
tag only ensures that an entity with access to the content encryption key
produced the encrypted data.</t>

<t>Any entity with the content encryption key can therefore produce content that
will be accepted as valid.  This includes all recipients of the same HTTP
message.</t>

<t>Furthermore, any entity that is able to modify both the Encryption header field
and the HTTP message body can replace the contents.  Without the content
encryption key or the input keying material, modifications to or replacement of
parts of a payload body are not possible.</t>

</section>
<section anchor="leaking-information-in-headers" title="Leaking Information in Headers">

<t>Because only the payload body is encrypted, information exposed in header fields
is visible to anyone who can read the HTTP message.  This could expose
side-channel information.</t>

<t>For example, the Content-Type header field can leak information about the
payload body.</t>

<t>There are a number of strategies available to mitigate this threat, depending
upon the application’s threat model and the users’ tolerance for leaked
information:</t>

<t><list style="numbers">
  <t>Determine that it is not an issue. For example, if it is expected that all
content stored will be “application/json”, or another very common media type,
exposing the Content-Type header field could be an acceptable risk.</t>
  <t>If it is considered sensitive information and it is possible to determine it
through other means (e.g., out of band, using hints in other representations,
etc.), omit the relevant headers, and/or normalize them. In the case of
Content-Type, this could be accomplished by always sending Content-Type:
application/octet-stream (the most generic media type), or no Content-Type at
all.</t>
  <t>If it is considered sensitive information and it is not possible to convey it
elsewhere, encapsulate the HTTP message using the application/http media type
(Section 8.3.2 of <xref target="RFC7230"></xref>), encrypting that as the payload of the “outer”
message.</t>
</list></t>

</section>
<section anchor="poisoning-storage" title="Poisoning Storage">

<t>This mechanism only offers encryption of content; it does not perform
authentication or authorization, which still needs to be performed (e.g., by
HTTP authentication <xref target="RFC7235"></xref>).</t>

<t>This is especially relevant when a HTTP PUT request is accepted by a server; if
the request is unauthenticated, it becomes possible for a third party to deny
service and/or poison the store.</t>

</section>
<section anchor="sizing-and-timing-attacks" title="Sizing and Timing Attacks">

<t>Applications using this mechanism need to be aware that the size of encrypted
messages, as well as their timing, HTTP methods, URIs and so on, may leak
sensitive information.</t>

<t>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 <xref target="RFC7540"></xref> combined with TLS <xref target="RFC5246"></xref>
might be used to hide the size of individual messages.</t>

</section>
</section>
<section anchor="iana" title="IANA Considerations">

<section anchor="the-aesgcm-http-content-encoding" title="The “aesgcm” HTTP Content Encoding">

<t>This memo registers the “encrypted” HTTP content-coding in the HTTP Content
Codings Registry, as detailed in <xref target="aesgcm"/>.</t>

<t><list style="symbols">
  <t>Name: aesgcm</t>
  <t>Description: AES-GCM encryption with a 128-bit content encryption key</t>
  <t>Reference: this specification</t>
</list></t>

</section>
<section anchor="encryption-header-fields" title="Encryption Header Fields">

<t>This memo registers the “Encryption” HTTP header field in the Permanent Message
Header Registry, as detailed in <xref target="encryption"/>.</t>

<t><list style="symbols">
  <t>Field name: Encryption</t>
  <t>Protocol: HTTP</t>
  <t>Status: Standard</t>
  <t>Reference: this specification</t>
  <t>Notes:</t>
</list></t>

<t>This memo registers the “Crypto-Key” HTTP header field in the Permanent
Message Header Registry, as detailed in <xref target="crypto-key"/>.</t>

<t><list style="symbols">
  <t>Field name: Crypto-Key</t>
  <t>Protocol: HTTP</t>
  <t>Status: Standard</t>
  <t>Reference: this specification</t>
  <t>Notes:</t>
</list></t>

</section>
<section anchor="encryption-registry" title="The HTTP Encryption Parameter Registry">

<t>This memo establishes a registry for parameters used by the “Encryption” header
field under the “Hypertext Transfer Protocol (HTTP) Parameters” grouping.  The
“Hypertext Transfer Protocol (HTTP) Encryption Parameters” registry operates
under an “Specification Required” policy <xref target="RFC5226"></xref>.</t>

<t>Entries in this registry are expected to include the following information:</t>

<t><list style="symbols">
  <t>Parameter Name: The name of the parameter.</t>
  <t>Purpose: A brief description of the purpose of the parameter.</t>
  <t>Reference: A reference to a specification that defines the semantics of the parameter.</t>
</list></t>

<t>The initial contents of this registry are:</t>

<section anchor="keyid" title="keyid">

<t><list style="symbols">
  <t>Parameter Name: keyid</t>
  <t>Purpose: Identify the key that is in use.</t>
  <t>Reference: this document</t>
</list></t>

</section>
<section anchor="salt" title="salt">

<t><list style="symbols">
  <t>Parameter Name: salt</t>
  <t>Purpose: Provide a source of entropy for derivation of a content encryption key. This value is mandatory.</t>
  <t>Reference: this document</t>
</list></t>

</section>
<section anchor="rs" title="rs">

<t><list style="symbols">
  <t>Parameter Name: rs</t>
  <t>Purpose: The size of the encrypted records.</t>
  <t>Reference: this document</t>
</list></t>

</section>
</section>
<section anchor="crypto-key-registry" title="The HTTP Crypto-Key Parameter Registry">

<t>This memo establishes a registry for parameters used by the “Crypto-Key” header
field under the “Hypertext Transfer Protocol (HTTP) Parameters” grouping.  The
“Hypertext Transfer Protocol (HTTP) Crypto-Key Parameters” operates under an
“Specification Required” policy <xref target="RFC5226"></xref>.</t>

<t>Entries in this registry are expected to include the following information:</t>

<t><list style="symbols">
  <t>Parameter Name: The name of the parameter.</t>
  <t>Purpose: A brief description of the purpose of the parameter.</t>
  <t>Reference: A reference to a specification that defines the semantics of the parameter.</t>
</list></t>

<t>The initial contents of this registry are:</t>

<section anchor="keyid-1" title="keyid">

<t><list style="symbols">
  <t>Parameter Name: keyid</t>
  <t>Purpose: Identify the key that is in use.</t>
  <t>Reference: this document</t>
</list></t>

</section>
<section anchor="iana-ekey-aesgcm" title="aesgcm">

<t><list style="symbols">
  <t>Parameter Name: aesgcm</t>
  <t>Purpose: Provide an explicit input keying material value for the aesgcm content encoding.</t>
  <t>Reference: this document</t>
</list></t>

</section>
<section anchor="dh" title="dh">

<t><list style="symbols">
  <t>Parameter Name: dh</t>
  <t>Purpose: Carry a modp or elliptic curve Diffie-Hellman share used to derive input keying material.</t>
  <t>Reference: this document</t>
</list></t>

</section>
</section>
</section>


  </middle>

  <back>

    <references title='Normative References'>





<reference  anchor='RFC2119' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc2119'>
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials='S.' surname='Bradner' fullname='S. Bradner'><organization /></author>
<date year='1997' month='March' />
<abstract><t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract>
</front>
<seriesInfo name='BCP' value='14'/>
<seriesInfo name='RFC' value='2119'/>
<seriesInfo name='DOI' value='10.17487/RFC2119'/>
</reference>



<reference  anchor='RFC4492' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc4492'>
<front>
<title>Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS)</title>
<author initials='S.' surname='Blake-Wilson' fullname='S. Blake-Wilson'><organization /></author>
<author initials='N.' surname='Bolyard' fullname='N. Bolyard'><organization /></author>
<author initials='V.' surname='Gupta' fullname='V. Gupta'><organization /></author>
<author initials='C.' surname='Hawk' fullname='C. Hawk'><organization /></author>
<author initials='B.' surname='Moeller' fullname='B. Moeller'><organization /></author>
<date year='2006' month='May' />
<abstract><t>This document describes new key exchange algorithms based on Elliptic Curve Cryptography (ECC) for the Transport Layer Security (TLS) protocol.  In particular, it specifies the use of Elliptic Curve Diffie-Hellman (ECDH) key agreement in a TLS handshake and the use of Elliptic Curve Digital Signature Algorithm (ECDSA) as a new authentication mechanism.  This memo provides information for the Internet community.</t></abstract>
</front>
<seriesInfo name='RFC' value='4492'/>
<seriesInfo name='DOI' value='10.17487/RFC4492'/>
</reference>



<reference  anchor='RFC7230' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc7230'>
<front>
<title>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</title>
<author initials='R.' surname='Fielding' fullname='R. Fielding' role='editor'><organization /></author>
<author initials='J.' surname='Reschke' fullname='J. Reschke' role='editor'><organization /></author>
<date year='2014' month='June' />
<abstract><t>The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol for distributed, collaborative, hypertext information systems.  This document provides an overview of HTTP architecture and its associated terminology, defines the &quot;http&quot; and &quot;https&quot; Uniform Resource Identifier (URI) schemes, defines the HTTP/1.1 message syntax and parsing requirements, and describes related security concerns for implementations.</t></abstract>
</front>
<seriesInfo name='RFC' value='7230'/>
<seriesInfo name='DOI' value='10.17487/RFC7230'/>
</reference>



<reference  anchor='RFC7231' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc7231'>
<front>
<title>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</title>
<author initials='R.' surname='Fielding' fullname='R. Fielding' role='editor'><organization /></author>
<author initials='J.' surname='Reschke' fullname='J. Reschke' role='editor'><organization /></author>
<date year='2014' month='June' />
<abstract><t>The Hypertext Transfer Protocol (HTTP) is a stateless \%application- level protocol for distributed, collaborative, hypertext information systems.  This document defines the semantics of HTTP/1.1 messages, as expressed by request methods, request header fields, response status codes, and response header fields, along with the payload of messages (metadata and body content) and mechanisms for content negotiation.</t></abstract>
</front>
<seriesInfo name='RFC' value='7231'/>
<seriesInfo name='DOI' value='10.17487/RFC7231'/>
</reference>



<reference  anchor='RFC7515' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc7515'>
<front>
<title>JSON Web Signature (JWS)</title>
<author initials='M.' surname='Jones' fullname='M. Jones'><organization /></author>
<author initials='J.' surname='Bradley' fullname='J. Bradley'><organization /></author>
<author initials='N.' surname='Sakimura' fullname='N. Sakimura'><organization /></author>
<date year='2015' month='May' />
<abstract><t>JSON Web Signature (JWS) represents content secured with digital signatures or Message Authentication Codes (MACs) using JSON-based data structures.  Cryptographic algorithms and identifiers for use with this specification are described in the separate JSON Web Algorithms (JWA) specification and an IANA registry defined by that specification.  Related encryption capabilities are described in the separate JSON Web Encryption (JWE) specification.</t></abstract>
</front>
<seriesInfo name='RFC' value='7515'/>
<seriesInfo name='DOI' value='10.17487/RFC7515'/>
</reference>



<reference  anchor='RFC5116' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc5116'>
<front>
<title>An Interface and Algorithms for Authenticated Encryption</title>
<author initials='D.' surname='McGrew' fullname='D. McGrew'><organization /></author>
<date year='2008' month='January' />
<abstract><t>This document defines algorithms for Authenticated Encryption with Associated Data (AEAD), and defines a uniform interface and a registry for such algorithms.  The interface and registry can be used as an application-independent set of cryptoalgorithm suites.  This approach provides advantages in efficiency and security, and promotes the reuse of crypto implementations.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='RFC' value='5116'/>
<seriesInfo name='DOI' value='10.17487/RFC5116'/>
</reference>



<reference  anchor='RFC5869' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc5869'>
<front>
<title>HMAC-based Extract-and-Expand Key Derivation Function (HKDF)</title>
<author initials='H.' surname='Krawczyk' fullname='H. Krawczyk'><organization /></author>
<author initials='P.' surname='Eronen' fullname='P. Eronen'><organization /></author>
<date year='2010' month='May' />
<abstract><t>This document specifies a simple Hashed Message Authentication Code (HMAC)-based key derivation function (HKDF), which can be used as a building block in various protocols and applications.  The key derivation function (KDF) is intended to support a wide range of applications and requirements, and is conservative in its use of cryptographic hash functions.  This document is not an Internet  Standards Track specification; it is published for informational  purposes.</t></abstract>
</front>
<seriesInfo name='RFC' value='5869'/>
<seriesInfo name='DOI' value='10.17487/RFC5869'/>
</reference>


<reference anchor="FIPS180-4" target="https://umn5eb9jyv5v8wdxhk2xy98.julianrbryant.com/publications/fips/fips180-4/fips-180-4.pdf">
  <front>
    <title>NIST FIPS 180-4, Secure Hash Standard</title>
    <author initials="National Institute of Standards and Technology, U.S." surname="Department of Commerce" fullname="NIST">
      <organization></organization>
    </author>
    <date year="2012" month="March"/>
  </front>
</reference>
<reference anchor="DH" >
  <front>
    <title>New Directions in Cryptography</title>
    <author initials="W." surname="Diffie">
      <organization></organization>
    </author>
    <author initials="M." surname="Hellman">
      <organization></organization>
    </author>
    <date year="1977" month="June"/>
  </front>
  <seriesInfo name="IEEE Transactions on Information Theory, V.IT-22 n.6" value=""/>
</reference>


    </references>

    <references title='Informative References'>





<reference  anchor='RFC4880' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc4880'>
<front>
<title>OpenPGP Message Format</title>
<author initials='J.' surname='Callas' fullname='J. Callas'><organization /></author>
<author initials='L.' surname='Donnerhacke' fullname='L. Donnerhacke'><organization /></author>
<author initials='H.' surname='Finney' fullname='H. Finney'><organization /></author>
<author initials='D.' surname='Shaw' fullname='D. Shaw'><organization /></author>
<author initials='R.' surname='Thayer' fullname='R. Thayer'><organization /></author>
<date year='2007' month='November' />
<abstract><t>This document is maintained in order to publish all necessary information needed to develop interoperable applications based on the OpenPGP format.  It is not a step-by-step cookbook for writing an application.  It describes only the format and methods needed to read, check, generate, and write conforming packets crossing any network.  It does not deal with storage and implementation questions. It does, however, discuss implementation issues necessary to avoid security flaws.</t><t>OpenPGP software uses a combination of strong public-key and symmetric cryptography to provide security services for electronic communications and data storage.  These services include confidentiality, key management, authentication, and digital signatures.  This document specifies the message formats used in OpenPGP.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='RFC' value='4880'/>
<seriesInfo name='DOI' value='10.17487/RFC4880'/>
</reference>



<reference  anchor='RFC5226' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc5226'>
<front>
<title>Guidelines for Writing an IANA Considerations Section in RFCs</title>
<author initials='T.' surname='Narten' fullname='T. Narten'><organization /></author>
<author initials='H.' surname='Alvestrand' fullname='H. Alvestrand'><organization /></author>
<date year='2008' month='May' />
<abstract><t>Many protocols make use of identifiers consisting of constants and other well-known values.  Even after a protocol has been defined and deployment has begun, new values may need to be assigned (e.g., for a new option type in DHCP, or a new encryption or authentication transform for IPsec).  To ensure that such quantities have consistent values and interpretations across all implementations, their assignment must be administered by a central authority.  For IETF protocols, that role is provided by the Internet Assigned Numbers Authority (IANA).</t><t>In order for IANA to manage a given namespace prudently, it needs guidelines describing the conditions under which new values can be assigned or when modifications to existing values can be made.  If IANA is expected to play a role in the management of a namespace, IANA must be given clear and concise instructions describing that role.  This document discusses issues that should be considered in formulating a policy for assigning values to a namespace and provides guidelines for authors on the specific text that must be included in documents that place demands on IANA.</t><t>This document obsoletes RFC 2434.  This document specifies an Internet Best  Current Practices for the Internet Community, and requests discussion and  suggestions for improvements.</t></abstract>
</front>
<seriesInfo name='BCP' value='26'/>
<seriesInfo name='RFC' value='5226'/>
<seriesInfo name='DOI' value='10.17487/RFC5226'/>
</reference>



<reference  anchor='RFC5246' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc5246'>
<front>
<title>The Transport Layer Security (TLS) Protocol Version 1.2</title>
<author initials='T.' surname='Dierks' fullname='T. Dierks'><organization /></author>
<author initials='E.' surname='Rescorla' fullname='E. Rescorla'><organization /></author>
<date year='2008' month='August' />
<abstract><t>This document specifies Version 1.2 of the Transport Layer Security (TLS) protocol.  The TLS protocol provides communications security over the Internet.  The protocol allows client/server applications to communicate in a way that is designed to prevent eavesdropping, tampering, or message forgery.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='RFC' value='5246'/>
<seriesInfo name='DOI' value='10.17487/RFC5246'/>
</reference>



<reference  anchor='RFC5652' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc5652'>
<front>
<title>Cryptographic Message Syntax (CMS)</title>
<author initials='R.' surname='Housley' fullname='R. Housley'><organization /></author>
<date year='2009' month='September' />
<abstract><t>This document describes the Cryptographic Message Syntax (CMS).  This syntax is used to digitally sign, digest, authenticate, or encrypt arbitrary message content.  [STANDARDS-TRACK]</t></abstract>
</front>
<seriesInfo name='STD' value='70'/>
<seriesInfo name='RFC' value='5652'/>
<seriesInfo name='DOI' value='10.17487/RFC5652'/>
</reference>



<reference  anchor='RFC7233' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc7233'>
<front>
<title>Hypertext Transfer Protocol (HTTP/1.1): Range Requests</title>
<author initials='R.' surname='Fielding' fullname='R. Fielding' role='editor'><organization /></author>
<author initials='Y.' surname='Lafon' fullname='Y. Lafon' role='editor'><organization /></author>
<author initials='J.' surname='Reschke' fullname='J. Reschke' role='editor'><organization /></author>
<date year='2014' month='June' />
<abstract><t>The Hypertext Transfer Protocol (HTTP) is a stateless application- level protocol for distributed, collaborative, hypertext information systems.  This document defines range requests and the rules for constructing and combining responses to those requests.</t></abstract>
</front>
<seriesInfo name='RFC' value='7233'/>
<seriesInfo name='DOI' value='10.17487/RFC7233'/>
</reference>



<reference  anchor='RFC7235' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc7235'>
<front>
<title>Hypertext Transfer Protocol (HTTP/1.1): Authentication</title>
<author initials='R.' surname='Fielding' fullname='R. Fielding' role='editor'><organization /></author>
<author initials='J.' surname='Reschke' fullname='J. Reschke' role='editor'><organization /></author>
<date year='2014' month='June' />
<abstract><t>The Hypertext Transfer Protocol (HTTP) is a stateless application- level protocol for distributed, collaborative, hypermedia information systems.  This document defines the HTTP Authentication framework.</t></abstract>
</front>
<seriesInfo name='RFC' value='7235'/>
<seriesInfo name='DOI' value='10.17487/RFC7235'/>
</reference>



<reference  anchor='RFC7516' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc7516'>
<front>
<title>JSON Web Encryption (JWE)</title>
<author initials='M.' surname='Jones' fullname='M. Jones'><organization /></author>
<author initials='J.' surname='Hildebrand' fullname='J. Hildebrand'><organization /></author>
<date year='2015' month='May' />
<abstract><t>JSON Web Encryption (JWE) represents encrypted content using JSON-based data structures.  Cryptographic algorithms and identifiers for use with this specification are described in the separate JSON Web Algorithms (JWA) specification and IANA registries defined by that specification.  Related digital signature and Message Authentication Code (MAC) capabilities are described in the separate JSON Web Signature (JWS) specification.</t></abstract>
</front>
<seriesInfo name='RFC' value='7516'/>
<seriesInfo name='DOI' value='10.17487/RFC7516'/>
</reference>



<reference  anchor='RFC7540' target='https://umn0mtkzgjmt2j3jm38z69h0br.julianrbryant.com/info/rfc7540'>
<front>
<title>Hypertext Transfer Protocol Version 2 (HTTP/2)</title>
<author initials='M.' surname='Belshe' fullname='M. Belshe'><organization /></author>
<author initials='R.' surname='Peon' fullname='R. Peon'><organization /></author>
<author initials='M.' surname='Thomson' fullname='M. Thomson' role='editor'><organization /></author>
<date year='2015' month='May' />
<abstract><t>This specification describes an optimized expression of the semantics of the Hypertext Transfer Protocol (HTTP), referred to as HTTP version 2 (HTTP/2).  HTTP/2 enables a more efficient use of network resources and a reduced perception of latency by introducing header field compression and allowing multiple concurrent exchanges on the same connection.  It also introduces unsolicited push of representations from servers to clients.</t><t>This specification is an alternative to, but does not obsolete, the HTTP/1.1 message syntax.  HTTP's existing semantics remain unchanged.</t></abstract>
</front>
<seriesInfo name='RFC' value='7540'/>
<seriesInfo name='DOI' value='10.17487/RFC7540'/>
</reference>


<reference anchor="FIPS186" >
  <front>
    <title>Digital Signature Standard (DSS)</title>
    <author >
      <organization>National Institute of Standards and Technology (NIST)</organization>
    </author>
    <date year="2013" month="July"/>
  </front>
  <seriesInfo name="NIST PUB 186-4" value=""/>
</reference>
<reference anchor="X9.62" >
  <front>
    <title>Public Key Cryptography For The Financial Services Industry: The Elliptic Curve Digital Signature Algorithm (ECDSA)</title>
    <author >
      <organization>ANSI</organization>
    </author>
    <date year="1998"/>
  </front>
  <seriesInfo name="ANSI X9.62" value=""/>
</reference>
<reference anchor="XMLENC" target="https://umn0mtkzgkj46tygt32g.julianrbryant.com/TR/xmlenc-core/">
  <front>
    <title>XML Encryption Syntax and Processing</title>
    <author initials="D." surname="Eastlake">
      <organization></organization>
    </author>
    <author initials="J." surname="Reagle">
      <organization></organization>
    </author>
    <author initials="T." surname="Imamura">
      <organization></organization>
    </author>
    <author initials="B." surname="Dillaway">
      <organization></organization>
    </author>
    <author initials="E." surname="Simon">
      <organization></organization>
    </author>
    <date year="2002" month="December"/>
  </front>
  <seriesInfo name="W3C REC" value=""/>
</reference>


    </references>


<section anchor="jwe" title="JWE Mapping">

<t>The “aesgcm” content encoding can be considered as a sequence of JSON Web
Encryption (JWE) objects <xref target="RFC7516"></xref>, 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:</t>

<t><list style="symbols">
  <t>The JWE Protected Header is fixed to a 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.</t>
  <t>The JWE Encrypted Key is empty, as stipulated by the direct encryption algorithm.</t>
  <t>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 <xref target="nonce"/>).  This value is also not
transmitted.</t>
  <t>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.</t>
</list></t>

<t>Thus, the example in <xref target="explicit"/> can be rendered using the JWE Compact
Serialization as:</t>

<figure><artwork type="example"><![CDATA[
eyAiYWxnIjogImRpciIsICJlbmMiOiAiQTEyOEdDTSIgfQ..31iQYc1v4a36EgyJ.
VDeU0XxaJkOJDAxPl7h9JD4.VfDeN0aKz-z36T3WWULsBQ
]]></artwork></figure>

<t>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.</t>

</section>
<section anchor="ex-intermediate" title="Intermediate Values for Encryption">

<t>The intermediate values calculated for the example in <xref target="ex-authSecret"/> are
shown here.  The following are inputs to the calculation:</t>

<t><list style="hanging">
  <t hangText='Plaintext:'>
  SSBhbSB0aGUgd2FscnVz</t>
  <t hangText='Sender public key:'>
  BNoRDbb84JGm8g5Z5CFxurSqsXWJ11ItfXEWYVLE85Y7
CYkDjXsIEc4aqxYaQ1G8BqkXCJ6DPpDrWtdWj_mugHU</t>
  <t hangText='Sender private key:'>
  nCScek-QpEjmOOlT-rQ38nZzvdPlqa00Zy0i6m2OJvY</t>
  <t hangText='Receiver public key:'>
  BCEkBjzL8Z3C-oi2Q7oE5t2Np-p7osjGLg93qUP0wvqR
T21EEWyf0cQDQcakQMqz4hQKYOQ3il2nNZct4HgAUQU</t>
  <t hangText='Receiver private key:'>
  9FWl15_QUQAWDaD3k3l50ZBZQJ4au27F1V4F0uLSD_M</t>
  <t hangText='Salt:'>
  lngarbyKfMoi9Z75xYXmkg</t>
</list></t>

<t>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.</t>

<t>This produces the following intermediate values:</t>

<t><list style="hanging">
  <t hangText='Shared secret (raw_key):'>
  RNjC-NVW4BGJbxWPW7G2mowsLeDa53LYKYm4–NOQ6Y</t>
  <t hangText='Input keying material (IKM):'>
  EhpZec37Ptm4IRD5-jtZ0q6r1iK5vYmY1tZwtN8fbZY</t>
  <t hangText='Context for content encryption key derivation:'>
  Q29udGVudC1FbmNvZGluZzogYWVzZ2NtAFAtMjU2AABB
BCEkBjzL8Z3C-oi2Q7oE5t2Np-p7osjGLg93qUP0wvqR
T21EEWyf0cQDQcakQMqz4hQKYOQ3il2nNZct4HgAUQUA
QQTaEQ22_OCRpvIOWeQhcbq0qrF1iddSLX1xFmFSxPOW
OwmJA417CBHOGqsWGkNRvAapFwiegz6Q61rXVo_5roB1</t>
  <t hangText='Content encryption key (CEK):'>
  AN2-xhvFWeYh5z0fcDu0Ww</t>
  <t hangText='Context for nonce derivation:'>
  Q29udGVudC1FbmNvZGluZzogbm9uY2UAUC0yNTYAAEEE
ISQGPMvxncL6iLZDugTm3Y2n6nuiyMYuD3epQ_TC-pFP
bUQRbJ_RxANBxqRAyrPiFApg5DeKXac1ly3geABRBQBB
BNoRDbb84JGm8g5Z5CFxurSqsXWJ11ItfXEWYVLE85Y7
CYkDjXsIEc4aqxYaQ1G8BqkXCJ6DPpDrWtdWj_mugHU</t>
  <t hangText='Base nonce:'>
  JY1Okw5rw1Drkg9J</t>
</list></t>

<t>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.</t>

</section>
<section anchor="acknowledgements" title="Acknowledgements">

<t>Mark Nottingham was an original author of this document.</t>

<t>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.</t>

</section>


  </back>
</rfc>

