One document matched: draft-ietf-jose-json-web-encryption-02.xml
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='http://xml.resource.org/authoring/rfc2629.xslt' ?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" ipr="trust200902" docName="draft-ietf-jose-json-web-encryption-02">
<front>
<title abbrev="JWE">JSON Web Encryption (JWE)</title>
<author fullname="Michael B. Jones" initials="M.B." surname="Jones">
<organization>Microsoft</organization>
<address>
<email>mbj@microsoft.com</email>
<uri>http://self-issued.info/</uri>
</address>
</author>
<author fullname="Eric Rescorla" initials="E." surname="Rescorla">
<organization abbrev="RTFM">RTFM, Inc.</organization>
<address>
<email>ekr@rtfm.com</email>
</address>
</author>
<author fullname="Joe Hildebrand" initials="J." surname="Hildebrand">
<organization abbrev="Cisco">Cisco Systems, Inc.</organization>
<address>
<email>jhildebr@cisco.com</email>
</address>
</author>
<date day="12" month="May" year="2012" />
<area>Security</area>
<workgroup>JOSE Working Group</workgroup>
<keyword>RFC</keyword>
<keyword>Request for Comments</keyword>
<keyword>I-D</keyword>
<keyword>Internet-Draft</keyword>
<keyword>JavaScript Object Notation</keyword>
<keyword>JSON</keyword>
<keyword>JSON Web Token</keyword>
<keyword>JWT</keyword>
<keyword>JSON Web Signature</keyword>
<keyword>JWS</keyword>
<keyword>JSON Web Encryption</keyword>
<keyword>JWE</keyword>
<keyword>JSON Web Key</keyword>
<keyword>JWK</keyword>
<keyword>JSON Web Algorithms</keyword>
<keyword>JWA</keyword>
<abstract>
<t>
JSON Web Encryption (JWE) is a means of representing encrypted
content using JSON data structures.
Cryptographic algorithms and identifiers used with this
specification are enumerated in the separate
JSON Web Algorithms (JWA) specification.
Related digital signature and MAC capabilities are described
in the separate JSON Web Signature (JWS) specification.
</t>
</abstract>
<note title="Requirements Language">
<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">RFC 2119</xref>.
</t>
</note>
</front>
<middle>
<section title="Introduction">
<t>
JSON Web Encryption (JWE) is a compact encryption format
intended for space constrained environments such as HTTP
Authorization headers and URI query parameters. It provides a
wrapper for encrypted content using JSON <xref
target="RFC4627">RFC 4627</xref> data structures. The JWE
encryption mechanisms are independent of the type of content
being encrypted.
Cryptographic algorithms and identifiers used with this
specification are enumerated in the separate
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
Related digital signature and MAC capabilities are described
in the separate JSON Web Signature (JWS) <xref target="JWS" />
specification.
</t>
</section>
<section title="Terminology">
<t>
<list style="hanging">
<t hangText="JSON Web Encryption (JWE)">
A data structure representing an encrypted version of a
Plaintext. The structure consists of four parts: the JWE
Header, the JWE Encrypted Key, the JWE Ciphertext, and
the JWE Integrity Value.
</t>
<t hangText="Plaintext">
The bytes to be encrypted - a.k.a., the message.
The plaintext can contain an arbitrary sequence of bytes.
</t>
<t hangText="Ciphertext">
The encrypted version of the Plaintext.
</t>
<t hangText="Content Encryption Key (CEK)">
A symmetric key used to encrypt the Plaintext for the
recipient to produce the Ciphertext.
</t>
<t hangText="Content Integrity Key (CIK)">
A key used with a MAC function to ensure the integrity
of the Ciphertext and the parameters used to create it.
</t>
<t hangText="Content Master Key (CMK)">
A key from which the CEK and CIK are derived.
When key wrapping or key encryption are employed, the CMK
is randomly generated and encrypted to the recipient as
the JWE Encrypted Key.
When key agreement is employed, the CMK is the result of
the key agreement algorithm.
</t>
<t hangText="JWE Header">
A string representing a JSON object that describes the
encryption operations applied to create the JWE Encrypted
Key, the JWE Ciphertext, and the JWE Integrity Value.
</t>
<t hangText="JWE Encrypted Key">
When key wrapping or key encryption are employed,
the Content Master Key (CMK) is encrypted with the
intended recipient's key and the resulting encrypted
content is recorded as a byte array, which is referred to
as the JWE Encrypted Key.
Otherwise, when key agreement is employed,
the JWE Encrypted Key is the empty byte array.
</t>
<t hangText="JWE Ciphertext">
A byte array containing the Ciphertext.
</t>
<t hangText="JWE Integrity Value">
A byte array containing a MAC value that ensures the
integrity of the Ciphertext and the parameters used to
create it.
</t>
<t hangText="Encoded JWE Header">
Base64url encoding of the bytes of the
UTF-8 <xref target="RFC3629">RFC 3629</xref>
representation of the JWE Header.
</t>
<t hangText="Encoded JWE Encrypted Key">
Base64url encoding of the JWE Encrypted Key.
</t>
<t hangText="Encoded JWE Ciphertext">
Base64url encoding of the JWE Ciphertext.
</t>
<t hangText="Encoded JWE Integrity Value">
Base64url encoding of the JWE Integrity Value.
</t>
<t hangText="Header Parameter Names">
The names of the members within the JWE Header.
</t>
<t hangText="Header Parameter Values">
The values of the members within the JWE Header.
</t>
<t hangText="JWE Compact Serialization">
A representation of the JWE as the concatenation of the
Encoded JWE Header, the Encoded JWE Encrypted Key, the
Encoded JWE Ciphertext, and the Encoded JWE Integrity
Value in that order, with the four strings being separated
by period ('.') characters.
</t>
<t hangText="AEAD Algorithm">
An Authenticated Encryption with Associated Data (AEAD)
<xref target="RFC5116"/> encryption algorithm is one that
provides an integrated content integrity check. AES
Galois/Counter Mode (GCM) is one such algorithm.
</t>
<t hangText="Base64url Encoding">
For the purposes of this specification, this term always
refers to the URL- and filename-safe Base64 encoding
described in <xref target="RFC4648">RFC 4648</xref>,
Section 5, with the (non URL-safe) '=' padding characters
omitted, as permitted by Section 3.2. (See Appendix B of
<xref target="JWS" /> for notes on implementing base64url
encoding without padding.)
</t>
<t hangText="StringOrURI">
A JSON string value, with the additional requirement that
while arbitrary string values MAY be used, any value
containing a ":" character MUST be a URI as defined in
<xref target="RFC3986">RFC 3986</xref>.
</t>
</list>
</t>
</section>
<section title="JSON Web Encryption (JWE) Overview">
<t>
JWE represents encrypted content using JSON data
structures and base64url encoding. The representation
consists of four parts: the JWE Header, the JWE Encrypted Key,
the JWE Ciphertext, and the JWE Integrity Value.
In the Compact Serialization, the four parts are
base64url-encoded for transmission, and represented
as the concatenation of the encoded strings in that order,
with the four strings being separated by period ('.')
characters.
(A JSON Serialization for this information is defined in the separate
JSON Web Encryption JSON Serialization (JWE-JS) <xref target="JWE-JS" />
specification.)
</t>
<t>
JWE utilizes encryption to ensure the confidentiality of the
contents of the Plaintext. JWE adds a content
integrity check if not provided by the underlying encryption
algorithm.
</t>
<section title="Example JWE with an Integrated Integrity Check" anchor="ExampleAEADJWE">
<t>
The following example JWE Header declares that:
<list style="symbols">
<t>
the Content Master Key is encrypted to the recipient
using the RSA-PKCS1_1.5 algorithm to produce the JWE
Encrypted Key,
</t>
<t>
the Plaintext is encrypted using the AES-256-GCM
algorithm to produce the JWE Ciphertext,
</t>
<t>
the specified 96 bit Initialization Vector with the
base64url encoding <spanx
style="verb">__79_Pv6-fj39vX0</spanx> was used, and
</t>
<t>
a JSON Web Key Set (JWK Set) representation of the public key
used to encrypt the JWE is located at <spanx
style="verb">https://example.com/public_key.jwk</spanx>.
</t>
</list>
</t>
<figure><artwork><![CDATA[{"alg":"RSA1_5",
"enc":"A256GCM",
"iv":"__79_Pv6-fj39vX0",
"jku":"https://example.com/public_key.jwk"}]]></artwork></figure>
<t>
Base64url encoding the bytes of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2R0NNIiwNCiAiaXYiOiJfXzc5
X1B2Ni1mZyIsDQogImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vcHVibGljX2tl
eS5qd2sifQ]]></artwork></figure>
<t>
TBD: Finish this example by showing generation of a Content Master Key (CMK),
saying that the CMK is used as the CEK and there is no
separate integrity check since AES GCM is an AEAD algorithm,
using the recipient's key to encrypt the CMK to produce the JWE Encrypted Key,
using the CEK, IV, Encoded JWE Header, and Encoded JWE Encrypted Key
to encrypt the Plaintext to produce the Ciphertext and "authentication tag" value,
base64url encoding these values, and assembling the result.
</t>
<t>
Concatenating these parts in the order
Header.EncryptedKey.Ciphertext.IntegrityValue with period
characters between the parts yields this complete JWE
representation (with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2R0NNIiwNCiAiaXYiOiJfXzc5
X1B2Ni1mZyIsDQogImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vcHVibGljX2tl
eS5qd2sifQ
.
TBD_encrypted_key_value_TBD
.
TBD_ciphertext_value_TBD
.
TBD_integrity_value_TBD]]></artwork></figure>
</section>
<section title="Example JWE with a Separate Integrity Check" anchor="ExampleNonAEADJWE">
<t>
The following example JWE Header declares that:
<list style="symbols">
<t>
the Content Master Key is encrypted to the recipient
using the RSA-PKCS1_1.5 algorithm to produce the JWE
Encrypted Key,
</t>
<t>
the Plaintext is encrypted using the AES-256-CBC
algorithm to produce the JWE Ciphertext,
</t>
<t>
the JWE Integrity Value safeguarding the integrity of the
Ciphertext and the parameters used to create it was
computed with the HMAC SHA-256 algorithm,
</t>
<t>
the specified 128 bit Initialization Vector with the
base64url encoding <spanx
style="verb">AxY8DCtDaGlsbGljb3RoZQ</spanx> was used, and
</t>
<t>
the thumbprint of the X.509 certificate that corresponds
to the key used to encrypt the JWE has the base64url
encoding <spanx
style="verb">7noOPq-hJ1_hCnvWh6IeYI2w9Q0</spanx>.
</t>
</list>
</t>
<figure><artwork><![CDATA[{"alg":"RSA1_5",
"enc":"A256CBC",
"int":"HS256",
"iv":"AxY8DCtDaGlsbGljb3RoZQ",
"x5t":"7noOPq-hJ1_hCnvWh6IeYI2w9Q0"}]]></artwork></figure>
<t>
Because AES CBC is not an AEAD algorithm (and so provides
no integrated content integrity check), a separate integrity
check value is used.
</t>
<t>
Base64url encoding the bytes of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2Q0JDIiwNCiAiaW50IjoiSFMy
NTYiLA0KICJpdiI6Ik16LW1XXzRKSGZnIiwNCiAieDV0IjoiN25vT1BxLWhKMV9o
Q252V2g2SWVZSTJ3OVEwIn0]]></artwork></figure>
<t>
TBD: Finish this example by showing generation of a Content Master Key (CMK),
showing the derivation of the CEK and the CIK from the CMK,
using the recipient's key to encrypt the CMK to produce the JWE Encrypted Key,
using the CEK and IV to encrypt the Plaintext to produce the Ciphertext,
showing the computation of the JWE Integrity Value,
base64url encoding these values, and assembling the result.
</t>
<figure><artwork><![CDATA[eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2Q0JDIiwNCiAiaW50IjoiSFMy
NTYiLA0KICJpdiI6Ik16LW1XXzRKSGZnIiwNCiAieDV0IjoiN25vT1BxLWhKMV9o
Q252V2g2SWVZSTJ3OVEwIn0
.
TBD_encrypted_key_value_TBD
.
TBD_ciphertext_value_TBD
.
TBD_integrity_value_TBD]]></artwork></figure>
</section>
</section>
<section title="JWE Header">
<t>
The members of the JSON object represented by the JWE Header
describe the encryption applied to the Plaintext and optionally
additional properties of the JWE.
The Header Parameter Names within this object MUST be unique;
JWEs with duplicate Header Parameter Names MUST be rejected.
Implementations MUST understand the entire contents of the
header; otherwise, the JWE MUST be rejected.
</t>
<t>
There are three classes of Header Parameter Names:
Reserved Header Parameter Names, Public Header Parameter Names,
and Private Header Parameter Names.
</t>
<section title="Reserved Header Parameter Names" anchor="ReservedHeaderParameterName">
<t>
The following header parameter names are reserved
with meanings as defined below. All the
names are short because a core goal of JWE is for the
representations to be compact.
</t>
<t>
Additional reserved header parameter names MAY be defined
via the IANA
JSON Web Signature and Encryption Header Parameters registry
<xref target="JWA" />.
As indicated by the common registry, JWSs and JWEs share a
common header parameter space; when a parameter is used by
both specifications, its usage must be compatible
between the specifications.
</t>
<section title='"alg" (Algorithm) Header Parameter'>
<t>
The <spanx style="verb">alg</spanx> (algorithm) header
parameter identifies the cryptographic algorithm used to
secure the JWE Encrypted Key.
A list of defined <spanx style="verb">alg</spanx> values for use with
JWE is presented in Section 4.1 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
The processing of the <spanx style="verb">alg</spanx>
header parameter requires that the value MUST
be one that is both supported and for which there exists a
key for use with that algorithm associated with the
intended recipient.
The <spanx style="verb">alg</spanx> value is case sensitive.
Its value MUST be a string containing a StringOrURI value.
This header parameter is REQUIRED.
</t>
<t>
<spanx style="verb">alg</spanx> values SHOULD either be
defined in the IANA
JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" /> or be
a URI that contains a collision resistant namespace.
</t>
</section>
<section title='"enc" (Encryption Method) Header Parameter'>
<t>
The <spanx style="verb">enc</spanx> (encryption method)
header parameter identifies the symmetric
encryption algorithm used to secure the Ciphertext.
A list of defined <spanx style="verb">enc</spanx> values
is presented in Section 4.2 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
The processing of the <spanx style="verb">enc</spanx>
(encryption method) header parameter requires that the
value MUST be one that is supported.
The <spanx style="verb">enc</spanx> value is case sensitive.
Its value MUST be a string containing a StringOrURI value.
This header parameter is REQUIRED.
</t>
<t>
<spanx style="verb">enc</spanx> values SHOULD either be
defined in the IANA
JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" /> or be
a URI that contains a collision resistant namespace.
</t>
</section>
<section title='"int" (Integrity Algorithm) Header Parameter'>
<t>
The <spanx style="verb">int</spanx> (integrity algorithm) header
parameter identifies the cryptographic algorithm used to
safeguard the integrity of the Ciphertext and the
parameters used to create it.
A list of defined <spanx style="verb">int</spanx> values
is presented in Section 4.3 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
The <spanx style="verb">int</spanx> parameter uses the
MAC subset of the algorithm values used by the JWS
<spanx style="verb">alg</spanx> parameter.
The <spanx style="verb">int</spanx> value is case sensitive.
Its value MUST be a string containing a StringOrURI value.
This header parameter is REQUIRED when an AEAD algorithm
is not used to encrypt the Plaintext and MUST NOT be
present when an AEAD algorithm is used.
</t>
<t>
<spanx style="verb">int</spanx> values SHOULD either be
defined in the IANA
JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" /> or be
a URI that contains a collision resistant namespace.
</t>
</section>
<section title='"iv" (Initialization Vector) Header Parameter'>
<t>
The <spanx style="verb">iv</spanx> (initialization vector)
value for algorithms requiring it, represented as a
base64url encoded string.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"epk" (Ephemeral Public Key) Header Parameter'>
<t>
The <spanx style="verb">epk</spanx> (ephemeral public key)
value created by the originator for the use in ECDH-ES
<xref target="RFC6090">RFC 6090</xref>
encryption. This key is represented as
a JSON Web Key <xref target="JWK" /> value,
containing <spanx style="verb">crv</spanx> (curve), <spanx
style="verb">x</spanx>, and <spanx style="verb">y</spanx>
members. The inclusion of the JWK <spanx
style="verb">alg</spanx> (algorithm) member is OPTIONAL.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"zip" (Compression Algorithm) Header Parameter'>
<t>
The <spanx style="verb">zip</spanx> (compression algorithm)
applied to the Plaintext before encryption, if any.
If present, the value of the <spanx style="verb">zip</spanx>
header parameter MUST be the case sensitive string "DEF".
Compression is performed with the
DEFLATE <xref target="RFC1951" /> algorithm.
If no <spanx style="verb">zip</spanx> parameter is present,
no compression is applied to the Plaintext before encryption.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"jku" (JWK Set URL) Header Parameter'>
<t>
The <spanx style="verb">jku</spanx> (JWK Set URL)
header parameter is an absolute URL that refers to a
resource for a set of JSON-encoded public keys, one of
which corresponds to the key used to
encrypt the JWE.
The keys MUST be encoded as a JSON Web Key Set (JWK Set)
as defined in the JSON Web Key (JWK) <xref target="JWK" /> specification.
The protocol used to acquire the resource MUST provide
integrity protection; an HTTP GET request to retrieve the
certificate MUST use TLS <xref target="RFC2818">RFC
2818</xref> <xref target="RFC5246">RFC 5246</xref>;
the identity of the server MUST be validated, as per
Section 3.1 of HTTP Over TLS <xref target='RFC2818' />.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"jwk" (JSON Web Key) Header Parameter'>
<t>
The <spanx style="verb">jwk</spanx> (JSON Web Key)
header parameter is a public key that corresponds to the
key used to encrypt the JWE.
This key is represented as a JSON Web Key <xref target="JWK" />.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"x5u" (X.509 URL) Header Parameter'>
<t>
The <spanx style="verb">x5u</spanx> (X.509 URL) header
parameter is an absolute URL that refers to a resource for
the X.509 public key certificate or certificate chain
corresponding to the key used to encrypt the JWE.
The identified resource MUST provide a representation of
the certificate or certificate chain that conforms to
<xref target="RFC5280">RFC 5280</xref> in PEM encoded form
<xref target="RFC1421">RFC 1421</xref>.
The certificate containing the public key of the entity
that encrypted the JWE MUST be the first certificate. This
MAY be followed by additional certificates, with each
subsequent certificate being the one used to certify the
previous one.
The protocol used to acquire the resource MUST provide
integrity protection; an HTTP GET request to retrieve the
certificate MUST use TLS <xref target="RFC2818">RFC
2818</xref> <xref target="RFC5246">RFC 5246</xref>;
the identity of the server MUST be validated, as per
Section 3.1 of HTTP Over TLS <xref target='RFC2818' />.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"x5t" (X.509 Certificate Thumbprint) Header Parameter'>
<t>
The <spanx style="verb">x5t</spanx> (X.509 Certificate Thumbprint)
header parameter provides a base64url encoded
SHA-1 thumbprint (a.k.a. digest) of the DER encoding of
the X.509 certificate corresponding to the key used to
encrypt the JWE.
This header parameter is OPTIONAL.
</t>
<t>
If, in the future, certificate thumbprints need to be
computed using hash functions other than SHA-1, it is
suggested that additional related header parameters be
defined for that purpose. For example, it is suggested
that a new <spanx style="verb">x5t#S256</spanx> (X.509
Certificate Thumbprint using SHA-256) header parameter
could be defined by registering it in the IANA
JSON Web Signature and Encryption Header Parameters
registry <xref target="JWA" />.
</t>
</section>
<section title='"x5c" (X.509 Certificate Chain) Header Parameter'>
<t>
The <spanx style="verb">x5c</spanx> (X.509 Certificate Chain)
header parameter contains the X.509 public key
certificate or certificate chain corresponding to the key used to
encrypt the JWE.
The certificate or certificate chain is represented as an
array of certificate values. Each value is a
base64-encoded (not base64url encoded) DER/BER PKIX
certificate value.
The certificate containing the public key of the entity
that encrypted the JWE MUST be the first certificate. This
MAY be followed by additional certificates, with each
subsequent certificate being the one used to certify the
previous one.
The recipient MUST verify the certificate chain according
to <xref target="RFC5280"/> and reject the JWE if any
validation failure occurs.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"kid" (Key ID) Header Parameter'>
<t>
The <spanx style="verb">kid</spanx> (key ID) header
parameter is a hint indicating which key was used to
encrypt the JWE.
This allows originators to explicitly signal a change of
key to recipients.
Should the recipient be unable to locate a key
corresponding to the <spanx style="verb">kid</spanx>
value, they SHOULD treat that condition as an error.
The interpretation of the contents of the
<spanx style="verb">kid</spanx> parameter is unspecified.
Its value MUST be a string.
This header parameter is OPTIONAL.
</t>
</section>
<section title='"typ" (Type) Header Parameter'>
<t>
The <spanx style="verb">typ</spanx> (type) header
parameter is used to declare the type of the encrypted
content.
The type value <spanx style="verb">JWE</spanx> MAY be used
to indicate that the encrypted content is a JWE.
The <spanx style="verb">typ</spanx> value is case sensitive.
Its value MUST be a string.
This header parameter is OPTIONAL.
</t>
<t>
MIME Media Type <xref target="RFC2045">RFC 2045</xref>
values MAY be used as <spanx style="verb">typ</spanx> values.
</t>
<t>
<spanx style="verb">typ</spanx> values SHOULD either be
defined in the IANA
JSON Web Signature and Encryption "typ" Values registry
<xref target="JWA" /> or be
a URI that contains a collision resistant namespace.
</t>
</section>
</section>
<section title="Public Header Parameter Names" anchor="PublicHeaderParameterName">
<t>
Additional header parameter names can be defined by those
using JWEs. However, in order to prevent collisions, any new
header parameter name SHOULD either be defined in the IANA
JSON Web Signature and Encryption Header Parameters registry
<xref target="JWA" /> or be
a URI that contains a collision resistant namespace.
In each case, the definer of the name
or value needs to take reasonable precautions to make sure they
are in control of the part of the namespace they use to
define the header parameter name.
</t>
<t>
New header parameters should be introduced sparingly, as
they can result in non-interoperable JWEs.
</t>
</section>
<section title="Private Header Parameter Names" anchor="PrivateHeaderParameterName">
<t>
A producer and consumer of a JWE may agree to any header
parameter name that is not a Reserved Name <xref
target="ReservedHeaderParameterName"></xref> or a Public
Name <xref
target="PublicHeaderParameterName"></xref>. Unlike Public
Names, these private names are subject to collision and
should be used with caution.
</t>
</section>
</section>
<section anchor="sec.encryption" title="Message Encryption">
<t>
The message encryption process is as follows. The order of
the steps is not significant in cases where there are no
dependencies between the inputs and outputs of the steps.
</t>
<t><list style="numbers">
<t>
When key wrapping or key encryption are employed,
generate a random Content Master Key (CMK).
See <xref target="RFC4086">RFC 4086</xref> for
considerations on generating random values.
Otherwise, when key agreement is employed, use the
key agreement algorithm to compute the value of the
Content Master Key (CMK).
The CMK MUST have a length equal to that of the
larger of the required encryption and integrity keys.
</t>
<t>
When key wrapping or key encryption are employed,
encrypt the CMK for the recipient (see <xref
target="sec.encrypt_cmk"/>) and let the result be the
JWE Encrypted Key.
Otherwise, when key agreement is employed, let the
JWE Encrypted Key be an empty byte array.
</t>
<t>
Base64url encode the JWE Encrypted Key to create the
Encoded JWE Encrypted Key.
</t>
<t>
Generate a random Initialization Vector (IV) of the
correct size for the algorithm (if required for the
algorithm).
</t>
<t>
If not using an AEAD algorithm, run the key derivation
algorithm (see <xref target="sec.key_derivation"/>) to
generate the Content Encryption Key (CEK) and the Content
Integrity Key (CIK); otherwise (when using an AEAD
algorithm), set the CEK to be the CMK.
</t>
<t>
Compress the Plaintext if a <spanx
style="verb">zip</spanx> parameter was included.
</t>
<t>
Serialize the (compressed) Plaintext into a byte sequence M.
</t>
<t>
Encrypt M using the CEK and IV to form the byte sequence C.
If an AEAD algorithm is used, use the concatenation of the
Encoded JWE Header, a period ('.') character, and the
Encoded JWE Encrypted Key as the "additional authenticated data"
parameter value for the encryption.
</t>
<t>
Base64url encode C to create the Encoded JWE Ciphertext.
</t>
<t>
Create a JWE Header containing the encryption
parameters used.
Note that white space is explicitly allowed
in the representation and no canonicalization need be performed
before encoding.
</t>
<t>
Base64url encode the bytes of the UTF-8 representation of
the JWE Header to create the Encoded JWE Header.
</t>
<t>
If not using an AEAD algorithm, run the integrity
algorithm (see <xref target="sec.integrity"/>) using the
CIK to compute the JWE Integrity Value; otherwise (when
using an AEAD algorithm), set the JWE Integrity Value to
be the "authentication tag" value produced by the AEAD algorithm.
</t>
<t>
Base64url encode the JWE Integrity Value to create the
Encoded JWE Integrity Value.
</t>
<t>
The four encoded parts, taken together, are the result.
The Compact Serialization of this result is the
concatenation of the Encoded JWE Header, the Encoded JWE
Encrypted Key, the Encoded JWE Ciphertext, and the Encoded
JWE Integrity Value in that order, with the four strings
being separated by period ('.') characters.
</t>
</list></t>
</section>
<section anchor="sec.decryption" title="Message Decryption">
<t>
The message decryption process is the reverse of the
encryption process. The order of the steps is not significant
in cases where there are no dependencies between the inputs
and outputs of the steps. If any of these steps fails, the
JWE MUST be rejected.
</t>
<t>
<list style="numbers">
<t>
Parse the four parts of the input (which are separated by
period characters when using the JWE Compact
Serialization) into the Encoded JWE Header, the Encoded
JWE Encrypted Key, the Encoded JWE Ciphertext, and the
Encoded JWE Integrity Value.
</t>
<t>
The Encoded JWE Header, the Encoded JWE Encrypted Key, the
Encoded JWE Ciphertext, and the Encoded JWE Integrity
Value MUST be successfully base64url decoded following the
restriction that no padding characters have been used.
</t>
<t>
The resulting JWE Header MUST be completely valid
JSON syntax conforming to <xref target="RFC4627">RFC
4627</xref>.
</t>
<t>
The resulting JWE Header MUST be validated to only include
parameters and values whose syntax and semantics are both
understood and supported.
</t>
<t>
Verify that the JWE Header references a key known to the
recipient.
</t>
<t>
When key wrapping or key encryption are employed,
decrypt the JWE Encrypted Key to produce the Content
Master Key (CMK).
Otherwise, when key agreement is employed, use the
key agreement algorithm to compute the value of the
Content Master Key (CMK).
The CMK MUST have a length equal to that of the
larger of the required encryption and integrity keys.
</t>
<t>
If not using an AEAD algorithm, run the key derivation
algorithm (see <xref target="sec.key_derivation"/>) to
generate the Content Encryption Key (CEK) and the Content
Integrity Key (CIK); otherwise (when using an AEAD
algorithm), set the CEK to be the CMK.
</t>
<t>
Decrypt the binary representation of the JWE Ciphertext
using the CEK and IV.
If an AEAD algorithm is used, use the concatenation of the
Encoded JWE Header, a period ('.') character, and the
Encoded JWE Encrypted Key as the "additional authenticated data"
parameter value for the decryption.
</t>
<t>
If not using an AEAD algorithm, run the integrity
algorithm (see <xref target="sec.integrity"/>) using the
CIK to compute an integrity value for the input received.
This computed value MUST match the received JWE
Integrity Value; otherwise (when using an AEAD algorithm),
the received JWE Integrity Value MUST match the
"authentication tag" value produced by the AEAD algorithm.
</t>
<t>
Uncompress the result of the previous step, if a <spanx
style="verb">zip</spanx> parameter was included.
</t>
<t>
Output the resulting Plaintext.
</t>
</list>
</t>
</section>
<section anchor="sec.key_derivation" title="Key Derivation">
<t>
The key derivation process converts the CMK into a CEK and a
CIK. It assumes as a primitive a Key Derivation Function (KDF)
which notionally takes three arguments:
<list style="hanging">
<t hangText="MasterKey:">The master key used to compute the
individual use keys</t>
<t hangText="Label:">The use key label, used to differentiate
individual use keys</t>
<t hangText="Length:">The desired length of the use key</t>
</list>
The only KDF used in this document is the Concat KDF, as
defined in Section 5.8.1 of <xref target="NIST.800-56A" />, where the Digest
Method is SHA-256, the SuppPubInfo parameter is the Label, and
the remaining OtherInfo parameters are the empty bit string.
</t>
<t>
To compute the CEK from the CMK, the ASCII label "Encryption"
([69, 110, 99, 114, 121, 112, 116, 105, 111, 110])
is used.
Use the key size for the <spanx style="verb">enc</spanx>
algorithm as the CEK desired key length.
</t>
<t>
To compute the CIK from the CMK, the ASCII label "Integrity"
([73, 110, 116, 101, 103, 114, 105, 116, 121])
is used.
Use the minimum key size for the <spanx style="verb">int</spanx>
algorithm (for instance, 256 bits for <spanx style="verb">HS256</spanx>)
as the CIK desired key length.
</t>
</section>
<section anchor="sec.encrypt_cmk" title="CMK Encryption">
<t>
JWE supports two forms of CMK encryption:
</t>
<t>
<list style="symbols">
<t>
Asymmetric encryption under the recipient's public key.
</t>
<t>
Symmetric encryption under a shared key.
</t>
</list>
</t>
<section anchor="sec.asymmetric_encryption"
title="Asymmetric Encryption">
<t>
In the asymmetric encryption mode, the CMK is encrypted
under the recipient's public key. The asymmetric encryption
modes defined for use with this in this specification are
listed in
Section 4.1 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
</t>
</section>
<section anchor="sec.symmetric_encryption"
title="Symmetric Encryption">
<t>
In the symmetric encryption mode, the CMK is encrypted under
a symmetric key shared between the sender and receiver.
The symmetric encryption modes defined for use with this in
this specification are listed in
Section 4.1 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
</t>
</section>
</section>
<section anchor="sec.integrity" title="Integrity Value Calculation">
<t>
When a non-AEAD algorithm is used (an algorithm without an
integrated content check), JWE adds an explicit integrity
check value to the representation. This value is computed in
the manner described in the JSON Web Signature (JWS) <xref
target="JWS" /> specification, with these modifications:
<list style="symbols">
<t>
The algorithm used is taken from the <spanx
style="verb">int</spanx> (integrity algorithm) header
parameter rather than the <spanx style="verb">alg</spanx>
header parameter.
</t>
<t>
The algorithm MUST be a MAC algorithm (normally HMAC SHA-256).
</t>
<t>
The JWS Secured Input used is the concatenation of the
Encoded JWE Header, a period ('.') character, the Encoded
JWE Encrypted Key, a period ('.') character, and the
Encoded JWE Ciphertext.
</t>
<t>
The CIK is used as the MAC key.
</t>
</list>
The computed JWS Signature value is the resulting integrity value.
</t>
</section>
<section title="Encrypting JWEs with Cryptographic Algorithms" anchor="Encrypting">
<t>
JWE uses cryptographic algorithms to encrypt the Plaintext
and the Content Encryption Key (CMK) and to provide integrity
protection for the JWE Header, JWE Encrypted Key, and JWE Ciphertext.
The JSON Web Algorithms (JWA) <xref target="JWA" />
specification enumerates a set of cryptographic algorithms and
identifiers to be used with this specification.
Specifically, Section 4.1 enumerates a set of
<spanx style="verb">alg</spanx> (algorithm) header parameter values,
Section 4.2 enumerates a set of
<spanx style="verb">enc</spanx> (encryption method) header parameter values,
and Section 4.3 enumerates a set of
<spanx style="verb">int</spanx> (integrity algorithm) header parameter values
intended for use this specification.
It also describes the semantics and operations that are
specific to these algorithms and algorithm families.
</t>
<t>
Public keys employed for encryption can be identified using the
Header Parameter methods described in <xref
target="ReservedHeaderParameterName" /> or can be distributed
using methods that are outside the scope of this
specification.
</t>
</section>
<section title="IANA Considerations" anchor="IANA">
<section title="Registration of application/jwe MIME Media Type" anchor="JWEMIMEType">
<t>
This specification registers the <spanx
style="verb">application/jwe</spanx> MIME Media Type
<xref target="RFC2045">RFC 2045</xref>.
<list style="hanging">
<t hangText='Type name:'>
<vspace />
application
</t>
<t hangText='Subtype name:'>
<vspace />
jwe
</t>
<t hangText='Required parameters:'>
<vspace />
n/a
</t>
<t hangText='Optional parameters:'>
<vspace />
n/a
</t>
<t hangText='Encoding considerations:'>
<vspace />
n/a
</t>
<t hangText='Security considerations:'>
<vspace />
See the Security Considerations section of this document
</t>
<t hangText='Interoperability considerations:'>
<vspace />
n/a
</t>
<t hangText='Published specification:'>
<vspace />
[[ this document ]]
</t>
<t hangText='Applications that use this media type:'>
<vspace />
OpenID Connect
</t>
<t hangText='Additional information:'>
<vspace />
Magic number(s): n/a
<vspace />
File extension(s): n/a
<vspace />
Macintosh file type code(s): n/a
</t>
<t hangText='Person & email address to contact for further information:'>
<vspace />
Michael B. Jones
<vspace />
mbj@microsoft.com
</t>
<t hangText='Intended usage:'>
<vspace />
COMMON
</t>
<t hangText='Restrictions on usage:'>
<vspace />
none
</t>
<t hangText='Author:'>
<vspace />
Michael B. Jones
<vspace />
mbj@microsoft.com
</t>
<t hangText='Change controller:'>
<vspace />
IETF
</t>
</list>
</t>
</section>
<section title='Registration of "JWE" Type Value' anchor="JWETypReg">
<t>
This specification registers the following <spanx style="verb">typ</spanx>
header parameter value in the
JSON Web Signature and Encryption "typ" Values registry established by the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification:
<list style='hanging'>
<t hangText='"typ" header parameter value:'>
<vspace />
"JWE"
</t>
<t hangText='Abbreviation for MIME type:'>
<vspace />
application/jwe
</t>
<t hangText='Change controller:'>
<vspace />
IETF
</t>
<t hangText='Description:'>
<vspace />
[[ this document ]]
</t>
</list>
</t>
</section>
</section>
<section title="Security Considerations" anchor="Security">
<t>
All the security considerations in the JWS specification
also apply to this specification, other than those that are signature specific.
Likewise, all the security considerations in
<xref target="W3C.CR-xmlenc-core1-20120313">XML Encryption 1.1</xref>
also apply to JWE, other than those that are XML specific.
</t>
</section>
<section title="Open Issues and Things To Be Done (TBD)" anchor="TBD">
<t>
The following items remain to be done in this draft:
<list style="symbols">
<t>
Add examples, including a KDF and a key agreement example.
</t>
</list>
</t>
</section>
</middle>
<back>
<references title="Normative References">
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.1421.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.1951.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2045.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2818.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.3629.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.4086.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.4627.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.4648.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5116.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5280.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.6090.xml' ?>
<reference anchor="NIST.800-56A">
<front>
<title>Recommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryptography (Revised)</title>
<author>
<organization>National Institute of Standards and Technology (NIST)
</organization>
</author>
<date month="March" year="2007" />
</front>
<seriesInfo name="NIST" value="PUB 800-56A" />
<format target="http://csrc.nist.gov/publications/nistpubs/800-56A/SP800-56A_Revision1_Mar08-2007.pdf" type="PDF" />
</reference>
<reference anchor="JWS">
<front>
<title>JSON Web Signature (JWS)</title>
<author fullname="Michael B. Jones" initials="M.B." surname="Jones">
<organization>Microsoft</organization>
<address>
<email>mbj@microsoft.com</email>
<uri>http://self-issued.info/</uri>
</address>
</author>
<author fullname="John Bradley" initials="J." surname="Bradley">
<organization abbrev="Ping Identity">Ping Identity</organization>
<address>
<email>ve7jtb@ve7jtb.com</email>
</address>
</author>
<author fullname="Nat Sakimura" initials="N." surname="Sakimura">
<organization abbrev="NRI">Nomura Research Institute</organization>
<address>
<email>n-sakimura@nri.co.jp</email>
</address>
</author>
<date day="12" month="May" year="2012" />
</front>
<format target="http://tools.ietf.org/html/draft-ietf-jose-json-web-signature" type="HTML" />
</reference>
<reference anchor="JWK">
<front>
<title>JSON Web Key (JWK)</title>
<author fullname="Michael B. Jones" initials="M.B." surname="Jones">
<organization>Microsoft</organization>
<address>
<email>mbj@microsoft.com</email>
<uri>http://self-issued.info/</uri>
</address>
</author>
<date day="12" month="May" year="2012" />
</front>
<format target="http://tools.ietf.org/html/draft-ietf-jose-json-web-key" type="HTML" />
</reference>
<reference anchor="JWA">
<front>
<title>JSON Web Algorithms (JWA)</title>
<author fullname="Michael B. Jones" initials="M.B." surname="Jones">
<organization>Microsoft</organization>
<address>
<email>mbj@microsoft.com</email>
<uri>http://self-issued.info/</uri>
</address>
</author>
<date day="12" month="May" year="2012" />
</front>
<format target="http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms" type="HTML" />
</reference>
</references>
<references title="Informative References">
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5652.xml' ?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml4/reference.W3C.CR-xmlenc-core1-20120313.xml" ?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-rescorla-jsms-00.xml" ?>
<reference anchor="JWE-JS">
<front>
<title abbrev="JWE JSON Serialization (JWE-JS)">JSON Web Encryption JSON Serialization (JWE-JS)</title>
<author fullname="Michael B. Jones" initials="M.B." surname="Jones">
<organization>Microsoft</organization>
<address>
<email>mbj@microsoft.com</email>
<uri>http://self-issued.info/</uri>
</address>
</author>
<date day="12" month="March" year="2012" />
</front>
<format target="http://tools.ietf.org/html/draft-jones-json-web-encryption-json-serialization" type="HTML" />
</reference>
<reference anchor="JSE">
<front>
<title>JSON Simple Encryption</title>
<author fullname="John Bradley" initials="J." surname="Bradley">
<organization>independent</organization>
</author>
<author fullname="Nat Sakimura (editor)" initials="N. " surname="Sakimura (editor)">
<organization abbrev="NRI">Nomura Research Institute</organization>
</author>
<date month="September" year="2010" />
</front>
<format target="http://jsonenc.info/enc/1.0/" type="HTML" />
</reference>
</references>
<section title="JWE Examples" anchor="JWEExamples">
<t>
This section provides several examples of JWEs.
</t>
<section title="JWE Example using TBD Algorithm" anchor="TBDExample">
<section title="Encrypting">
<t>
TBD: Demonstrate encryption steps with this algorithm
</t>
</section>
<section title="Decrypting">
<t>
TBD: Demonstrate decryption steps with this algorithm
</t>
</section>
</section>
</section>
<section title="Acknowledgements" anchor="Acknowledgements">
<t>
Solutions for encrypting JSON content were also explored by
<xref target="JSE">JSON Simple Encryption</xref> and
<xref target="I-D.rescorla-jsms">JavaScript Message Security
Format</xref>, both of which significantly influenced this draft.
This draft attempts to explicitly reuse as many of the relevant concepts from
<xref target="W3C.CR-xmlenc-core1-20120313">XML Encryption 1.1</xref>
and <xref target="RFC5652">RFC 5652</xref> as possible,
while utilizing simple compact JSON-based data structures.
</t>
<t>
Special thanks are due to John Bradley and Nat Sakimura for
the discussions that helped inform the content of this
specification and to Eric Rescorla and Joe Hildebrand for
allowing the reuse of text from <xref
target="I-D.rescorla-jsms"/> in this document.
</t>
</section>
<section title='Document History'>
<t>
-02
<list style='symbols'>
<t>
When using AEAD algorithms (such as AES GCM),
use the "additional authenticated data" parameter
to provide integrity for the header, encrypted key, and
ciphertext and use the resulting "authentication tag"
value as the JWE Integrity Value.
</t>
<t>
Defined KDF output key sizes.
</t>
<t>
Generalized text to allow key agreement to be employed
as an alternative to key wrapping or key encryption.
</t>
<t>
Changed compression algorithm from gzip to DEFLATE.
</t>
<t>
Clarified that it is an error when a <spanx style="verb">kid</spanx>
value is included and no matching key is found.
</t>
<t>
Clarified that JWEs with duplicate Header Parameter Names
MUST be rejected.
</t>
<t>
Clarified the relationship between
<spanx style="verb">typ</spanx> header parameter values
and MIME types.
</t>
<t>
Registered application/jwe MIME type and "JWE" typ header parameter value.
</t>
<t>
Simplified JWK terminology to get replace the "JWK Key Object" and
"JWK Container Object" terms with simply "JSON Web Key (JWK)"
and "JSON Web Key Set (JWK Set)" and to eliminate potential
confusion between single keys and sets of keys.
As part of this change, the header parameter name for a
public key value was changed from
<spanx style="verb">jpk</spanx> (JSON Public Key) to
<spanx style="verb">jwk</spanx> (JSON Web Key).
</t>
<t>
Added suggestion on defining additional header parameters
such as <spanx style="verb">x5t#S256</spanx> in the future
for certificate thumbprints using hash algorithms other
than SHA-1.
</t>
<t>
Specify RFC 2818 server identity validation, rather than
RFC 6125 (paralleling the same decision in the OAuth specs).
</t>
<t>
Generalized language to refer to Message Authentication Codes (MACs)
rather than Hash-based Message Authentication Codes (HMACs)
unless in a context specific to HMAC algorithms.
</t>
<t>
Reformatted to give each header parameter its own section heading.
</t>
</list>
</t>
<t>
-01
<list style='symbols'>
<t>
Added an integrity check for non-AEAD algorithms.
</t>
<t>
Added <spanx style="verb">jpk</spanx> and <spanx
style="verb">x5c</spanx> header parameters for including
JWK public keys and X.509 certificate chains directly in
the header.
</t>
<t>
Clarified that this specification is defining the JWE
Compact Serialization. Referenced the new JWE-JS spec,
which defines the JWE JSON Serialization.
</t>
<t>
Added text "New header parameters should be introduced
sparingly since an implementation that does not understand
a parameter MUST reject the JWE".
</t>
<t>
Clarified that the order of the encryption and decryption
steps is not significant in cases where there are no
dependencies between the inputs and outputs of the steps.
</t>
<t>
Made other editorial improvements suggested by JOSE
working group participants.
</t>
</list>
</t>
<t>
-00
<list style='symbols'>
<t>
Created the initial IETF draft based upon
draft-jones-json-web-encryption-02 with no normative
changes.
</t>
<t>
Changed terminology to no longer call both digital
signatures and HMACs "signatures".
</t>
</list>
</t>
</section>
</back>
</rfc>
| PAFTECH AB 2003-2026 | 2026-04-22 20:44:47 |