JOSE Working Group M. Jones
Internet-Draft Microsoft
Intended status: Standards Track E. Rescorla
Expires: January 31, 2013 RTFM
J. Hildebrand
Cisco
July 30, 2012
JSON Web Encryption (JWE)draft-ietf-jose-json-web-encryption-05
Abstract
JSON Web Encryption (JWE) is a means of representing encrypted
content using JavaScript Object Notation (JSON) data structures.
Cryptographic algorithms and identifiers for use with this
specification are described in the separate JSON Web Algorithms (JWA)
specification. Related digital signature and MAC capabilities are
described in the separate JSON Web Signature (JWS) specification.
Status of this Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on January 31, 2013.
Copyright Notice
Copyright (c) 2012 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
Jones, et al. Expires January 31, 2013 [Page 1]

Internet-Draft JWE July 20121. Introduction
JSON Web Encryption (JWE) is a compact encryption format intended for
space constrained environments such as HTTP Authorization headers and
URI query parameters. It represents this content using JavaScript
Object Notation (JSON) [RFC4627] based data structures. The JWE
cryptographic mechanisms encrypt and provide integrity protection for
arbitrary sequences of bytes.
Cryptographic algorithms and identifiers for use with this
specification are described in the separate JSON Web Algorithms (JWA)
[JWA] specification. Related digital signature and MAC capabilities
are described in the separate JSON Web Signature (JWS) [JWS]
specification.
1.1. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in Key words for use in
RFCs to Indicate Requirement Levels [RFC2119].
2. Terminology
JSON Web Encryption (JWE) A data structure representing an encrypted
message. The structure consists of four parts: the JWE Header,
the JWE Encrypted Key, the JWE Ciphertext, and the JWE Integrity
Value.
Plaintext The bytes to be encrypted - a.k.a., the message. The
plaintext can contain an arbitrary sequence of bytes.
Ciphertext An encrypted representation of the Plaintext.
Content Encryption Key (CEK) A symmetric key used to encrypt the
Plaintext for the recipient to produce the Ciphertext.
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.
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 direct encryption with a shared symmetric
key is employed, the CMK is the shared key. When key agreement
without key wrapping is employed, the CMK is the result of the key
Jones, et al. Expires January 31, 2013 [Page 4]

Internet-Draft JWE July 2012
agreement algorithm.
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.
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 direct encryption with a shared or agreed upon
symmetric key is employed, the JWE Encrypted Key is the empty byte
array.
JWE Ciphertext A byte array containing the Ciphertext.
JWE Integrity Value A byte array containing a MAC value that ensures
the integrity of the Ciphertext and the parameters used to create
it.
Base64url Encoding The URL- and filename-safe Base64 encoding
described in RFC 4648[RFC4648], Section 5, with the (non URL-
safe) '=' padding characters omitted, as permitted by Section 3.2.
(See Appendix C of [JWS] for notes on implementing base64url
encoding without padding.)
Encoded JWE Header Base64url encoding of the bytes of the UTF-8
[RFC3629] representation of the JWE Header.
Encoded JWE Encrypted Key Base64url encoding of the JWE Encrypted
Key.
Encoded JWE Ciphertext Base64url encoding of the JWE Ciphertext.
Encoded JWE Integrity Value Base64url encoding of the JWE Integrity
Value.
Header Parameter Name The name of a member of the JSON object
representing a JWE Header.
Header Parameter Value The value of a member of the JSON object
representing a JWE Header.
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.
Jones, et al. Expires January 31, 2013 [Page 5]

Internet-Draft JWE July 2012
AEAD Algorithm An Authenticated Encryption with Associated Data
(AEAD) [RFC5116] encryption algorithm is one that provides an
integrated content integrity check. AES Galois/Counter Mode (GCM)
is one such algorithm.
Collision Resistant Namespace A namespace that allows names to be
allocated in a manner such that they are highly unlikely to
collide with other names. For instance, collision resistance can
be achieved through administrative delegation of portions of the
namespace or through use of collision-resistant name allocation
functions. Examples of Collision Resistant Namespaces include:
Domain Names, Object Identifiers (OIDs) as defined in the ITU-T
X.660 and X.670 Recommendation series, and Universally Unique
IDentifiers (UUIDs) [RFC4122]. When using an administratively
delegated namespace, the definer of a name needs to take
reasonable precautions to ensure they are in control of the
portion of the namespace they use to define the name.
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 [RFC3986]. StringOrURI
values are compared as case-sensitive strings with no
transformations or canonicalizations applied.
3. JSON Web Encryption (JWE) Overview
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) [JWE-JS] specification.)
JWE utilizes encryption to ensure the confidentiality of the
Plaintext. JWE adds a content integrity check if not provided by the
underlying encryption algorithm.
3.1. Example JWE with an Integrated Integrity Check
This example encrypts the plaintext "Live long and prosper." to the
recipient using RSAES OAEP and AES GCM. The AES GCM algorithm has an
integrated integrity check.
The following example JWE Header declares that:
Jones, et al. Expires January 31, 2013 [Page 6]

Internet-Draft JWE July 2012
o the Content Master Key is encrypted to the recipient using the
RSAES OAEP algorithm to produce the JWE Encrypted Key,
o the Plaintext is encrypted using the AES GCM algorithm with a 256
bit key to produce the Ciphertext, and
o the 96 bit Initialization Vector (IV) with the base64url encoding
"48V1_ALb6US04U3b" was used.
{"alg":"RSA-OAEP","enc":"A256GCM","iv":"48V1_ALb6US04U3b"}
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):
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00iLCJpdiI6IjQ4VjFfQUxi
NlVTMDRVM2IifQ
The remaining steps to finish creating this JWE are:
o Generate a random Content Master Key (CMK)
o Encrypt the CMK with the recipient's public key using the RSAES
OAEP algorithm to produce the JWE Encrypted Key
o Base64url encode the JWE Encrypted Key to produce the Encoded JWE
Encrypted Key
o Concatenate the Encoded JWE Header value, a period character
('.'), and the Encoded JWE Encrypted Key to create the "additional
authenticated data" parameter for the AES GCM algorithm.
o Encrypt the Plaintext with AES GCM, using the IV, the CMK as the
encryption key, and the "additional authenticated data" value
above, requesting a 128 bit "authentication tag" output
o Base64url encode the resulting Ciphertext to create the Encoded
JWE Ciphertext
o Base64url encode the resulting "authentication tag" to create the
Encoded JWE Integrity Value
o Assemble the final representation: 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 three period ('.') characters.
Jones, et al. Expires January 31, 2013 [Page 7]

Internet-Draft JWE July 2012
The final result in this example (with line breaks for display
purposes only) is:
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00iLCJpdiI6IjQ4VjFfQUxi
NlVTMDRVM2IifQ.
jvwoyhWxOMboB5cxX6ncAi7Wp3Q5FKRtlmIx35pfR9HpEa6Oy-iEpxEqM30W3YcR
Q8WU9ouRoO5jd6tfdcpX-2X-OteHw4dnMXdMLjHGGx86LMDeFRAN2KGz7EGPJiva
w0yM80fzT3zY0PKrIvU5ml1M5szqUnX4Jw0-PNcIM_j-L5YkLhv3Yk04XCwTJwxN
NmXCflYAQO9f00Aa213TJJr6dbHV6I642FwU-EWvtEfN3evgX3EFIVYSnT3HCHkA
AIdBQ9ykD-abRzVA_dGp_yJAZQcrZuNTqzThd_22YMPhIpzTygfC_4k7qqxI6t7L
e_l5_o-taUG7vaNAl5FjEQ.
_e21tGGhac_peEFkLXr2dMPUZiUkrw.
YbZSeHCNDZBqAdzpROlyiw
See Appendix A.1 for the complete details of computing this JWE.
3.2. Example JWE with a Separate Integrity Check
This example encrypts the plaintext "Now is the time for all good men
to come to the aid of their country." to the recipient using RSAES-
PKCS1-V1_5 and AES CBC. AES CBC does not have an integrated
integrity check, so a separate integrity check calculation is
performed using HMAC SHA-256, with separate encryption and integrity
keys being derived from a master key using the Concat KDF with the
SHA-256 digest function.
The following example JWE Header (with line breaks for display
purposes only) declares that:
o the Content Master Key is encrypted to the recipient using the
RSAES-PKCS1-V1_5 algorithm to produce the JWE Encrypted Key,
o the Plaintext is encrypted using the AES CBC algorithm with a 128
bit key to produce the Ciphertext,
o 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, and
o the 128 bit Initialization Vector (IV) with the base64url encoding
"AxY8DCtDaGlsbGljb3RoZQ" was used.
{"alg":"RSA1_5","enc":"A128CBC","int":"HS256","iv":"AxY8DCtDaGls
bGljb3RoZQ"}
Base64url encoding the bytes of the UTF-8 representation of the JWE
Header yields this Encoded JWE Header value (with line breaks for
Jones, et al. Expires January 31, 2013 [Page 8]

Internet-Draft JWE July 2012
display purposes only):
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDIiwiaW50IjoiSFMyNTYiLCJp
diI6IkF4WThEQ3REYUdsc2JHbGpiM1JvWlEifQ
The remaining steps to finish creating this JWE are like the previous
example, but with an additional step to compute the separate
integrity value:
o Generate a random Content Master Key (CMK)
o Encrypt the CMK with the recipient's public key using the RSAES-
PKCS1-V1_5 algorithm to produce the JWE Encrypted Key
o Base64url encode the JWE Encrypted Key to produce the Encoded JWE
Encrypted Key
o Use the Concat key derivation function to derive Content
Encryption Key (CEK) and Content Integrity Key (CIK) values from
the CMK
o Encrypt the Plaintext with AES CBC using the CEK and IV to produce
the Ciphertext
o Base64url encode the resulting Ciphertext to create the Encoded
JWE Ciphertext
o Concatenate the Encoded JWE Header value, a period character
('.'), the Encoded JWE Encrypted Key, a second period character,
and the Encoded JWE Ciphertext to create the value to integrity
protect
o Compute the HMAC SHA-256 of this value using the CIK to create the
JWE Integrity Value
o Base64url encode the resulting JWE Integrity Value to create the
Encoded JWE Integrity Value
o Assemble the final representation: 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 three period ('.') characters.
The final result in this example (with line breaks for display
purposes only) is:
Jones, et al. Expires January 31, 2013 [Page 9]

Internet-Draft JWE July 2012
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDIiwiaW50IjoiSFMyNTYiLCJp
diI6IkF4WThEQ3REYUdsc2JHbGpiM1JvWlEifQ.
IPI_z172hSWHMFgED8EG9DM6hIXU_6NaO1DImCn0vNeuoBq847Sl6qw_GHSYHJUQ
XtXJq7S_CxWVrI82wjrOyaQca5tLZRZc45BfKHeqByThKI261QevEK56SyAwwXfK
KZjSvkQ5dwTFSgfy76rMSUvVynHYEhdCatBF9HWTAiXPx7hgZixG1FeP_QCmOylz
2VClVyYFCbjKREOwBFf-puNYfO75S3LNlJUtTsGGQL2oTKpMsEiUTdefkje91VX9
h8g7908lFsggbjV7NicJsufuXxnTj1fcWIrRDeNIOmakiPEODi0gTSz0ou-W-LWK
-3T1zYlOIiIKBjsExQKZ-w.
_Z_djlIoC4MDSCKireWS2beti4Q6iSG2UjFujQvdz-_PQdUcFNkOulegD6BgjgdF
LjeB4HHOO7UHvP8PEDu0a0sA2a_-CI0w2YQQ2QQe35M.
c41k4T4eAgCCt63m8ZNmiOinMciFFypOFpvid7i6D0k
See Appendix A.2 for the complete details of computing this JWE.
4. JWE Header
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.
There are two ways of distinguishing whether a header is a JWS Header
or a JWE Header. The first is by examining the "alg" (algorithm)
header value. If the value represents a digital signature or MAC
algorithm, or is the value "none", it is for a JWS; if it represents
an encryption or key agreement algorithm, it is for a JWE. A second
method is determining whether an "enc" (encryption method) member
exists. If the "enc" member exists, it is a JWE; otherwise, it is a
JWS. Both methods will yield the same result for all legal input
values.
There are three classes of Header Parameter Names: Reserved Header
Parameter Names, Public Header Parameter Names, and Private Header
Parameter Names.
4.1. Reserved Header Parameter Names
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.
Additional reserved header parameter names MAY be defined via the
IANA JSON Web Signature and Encryption Header Parameters registry
[JWS]. As indicated by the common registry, JWSs and JWEs share a
common header parameter space; when a parameter is used by both
Jones, et al. Expires January 31, 2013 [Page 10]

Internet-Draft JWE July 2012
specifications, its usage must be compatible between the
specifications.
4.1.1. "alg" (Algorithm) Header Parameter
The "alg" (algorithm) header parameter identifies the cryptographic
algorithm used to encrypt or determine the value of the Content
Master Key (CMK). The algorithm specified by the "alg" value MUST be
supported by the implementation and there MUST be a key for use with
that algorithm associated with the intended recipient or the JWE MUST
be rejected. "alg" values SHOULD either be registered in the IANA
JSON Web Signature and Encryption Algorithms registry [JWA] or be a
URI that contains a Collision Resistant Namespace. The "alg" value
is a case sensitive string containing a StringOrURI value. This
header parameter is REQUIRED.
A list of defined "alg" values can be found in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA]; the initial
contents of this registry is the values defined in Section 4.1 of the
JSON Web Algorithms (JWA) [JWA] specification.
4.1.2. "enc" (Encryption Method) Header Parameter
The "enc" (encryption method) header parameter identifies the
symmetric encryption algorithm used to encrypt the Plaintext to
produce the Ciphertext. The algorithm specified by the "enc" value
MUST be supported by the implementation or the JWE MUST be rejected.
"enc" values SHOULD either be registered in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA] or be a URI that
contains a Collision Resistant Namespace. The "enc" value is a case
sensitive string containing a StringOrURI value. This header
parameter is REQUIRED.
A list of defined "enc" values can be found in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA]; the initial
contents of this registry is the values defined in Section 4.2 of the
JSON Web Algorithms (JWA) [JWA] specification.
4.1.3. "int" (Integrity Algorithm) Header Parameter
The "int" (integrity algorithm) header parameter identifies the
cryptographic algorithm used to safeguard the integrity of the
Ciphertext and the parameters used to create it. The "int" parameter
uses the MAC subset of the algorithm values used by the JWS "alg"
parameter. "int" values SHOULD either be registered in the IANA JSON
Web Signature and Encryption Algorithms registry [JWA] or be a URI
that contains a Collision Resistant Namespace. The "int" value is a
case sensitive string containing a StringOrURI value. This header
Jones, et al. Expires January 31, 2013 [Page 11]

Internet-Draft JWE July 2012
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.
A list of defined "int" values can be found in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA]; the initial
contents of this registry is the values defined in Section 4.3 of the
JSON Web Algorithms (JWA) [JWA] specification.
4.1.4. "kdf" (Key Derivation Function) Header Parameter
The "kdf" (key derivation function) header parameter identifies the
cryptographic algorithm used to derive the CEK and CIK from the CMK.
"kdf" values SHOULD either be registered in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA] or be a URI that
contains a Collision Resistant Namespace. The "kdf" value is a case
sensitive string containing a StringOrURI value. This header
parameter is OPTIONAL when an AEAD algorithm is not used to encrypt
the Plaintext and MUST NOT be present when an AEAD algorithm is used.
When an AEAD algorithm is not used and no "kdf" header parameter is
present, the "CS256" KDF [JWA] SHALL be used.
A list of defined "kdf" values can be found in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA]; the initial
contents of this registry is the values defined in Section 4.4 of the
JSON Web Algorithms (JWA) [JWA] specification.
4.1.5. "iv" (Initialization Vector) Header Parameter
The "iv" (initialization vector) value for algorithms requiring it,
represented as a base64url encoded string. This header parameter is
OPTIONAL, although its use is REQUIRED with some "enc" algorithms.
4.1.6. "epk" (Ephemeral Public Key) Header Parameter
The "epk" (ephemeral public key) value created by the originator for
the use in key agreement algorithms. This key is represented as a
JSON Web Key [JWK] value. This header parameter is OPTIONAL,
although its use is REQUIRED with some "alg" algorithms.
4.1.7. "zip" (Compression Algorithm) Header Parameter
The "zip" (compression algorithm) applied to the Plaintext before
encryption, if any. If present, the value of the "zip" header
parameter MUST be the case sensitive string "DEF". Compression is
performed with the DEFLATE [RFC1951] algorithm. If no "zip"
parameter is present, no compression is applied to the Plaintext
before encryption. This header parameter is OPTIONAL.
Jones, et al. Expires January 31, 2013 [Page 12]

Internet-Draft JWE July 20124.1.8. "jku" (JWK Set URL) Header Parameter
The "jku" (JWK Set URL) header parameter is a URI [RFC3986] 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; this can be
used to determine the private key needed to decrypt the JWE. The
keys MUST be encoded as a JSON Web Key Set (JWK Set) [JWK]. The
protocol used to acquire the resource MUST provide integrity
protection; an HTTP GET request to retrieve the certificate MUST use
TLS [RFC2818] [RFC5246]; the identity of the server MUST be
validated, as per Section 3.1 of HTTP Over TLS [RFC2818]. This
header parameter is OPTIONAL.
4.1.9. "jwk" (JSON Web Key) Header Parameter
The "jwk" (JSON Web Key) header parameter is a public key that
corresponds to the key used to encrypt the JWE; this can be used to
determine the private key needed to decrypt the JWE. This key is
represented as a JSON Web Key [JWK]. This header parameter is
OPTIONAL.
4.1.10. "x5u" (X.509 URL) Header Parameter
The "x5u" (X.509 URL) header parameter is a URI [RFC3986] that refers
to a resource for the X.509 public key certificate or certificate
chain [RFC5280] corresponding to the key used to encrypt the JWE;
this can be used to determine the private key needed to decrypt the
JWE. The identified resource MUST provide a representation of the
certificate or certificate chain that conforms to RFC 5280 [RFC5280]
in PEM encoded form [RFC1421]. 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 [RFC2818] [RFC5246]; the identity of the server MUST be
validated, as per Section 3.1 of HTTP Over TLS [RFC2818]. This
header parameter is OPTIONAL.
4.1.11. "x5t" (X.509 Certificate Thumbprint) Header Parameter
The "x5t" (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 [RFC5280] corresponding to the key
used to encrypt the JWE; this can be used to determine the private
key needed to decrypt the JWE. This header parameter is OPTIONAL.
If, in the future, certificate thumbprints need to be computed using
Jones, et al. Expires January 31, 2013 [Page 13]

Internet-Draft JWE July 2012
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 "x5t#S256" (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
[JWS].
4.1.12. "x5c" (X.509 Certificate Chain) Header Parameter
The "x5c" (X.509 Certificate Chain) header parameter contains the
X.509 public key certificate or certificate chain [RFC5280]
corresponding to the key used to encrypt the JWE; this can be used to
determine the private key needed to decrypt the JWE. The certificate
or certificate chain is represented as an array of certificate
values. Each value is a base64 encoded ([RFC4648] Section 4 - not
base64url encoded) DER [ITU.X690.1994] 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 [RFC5280] and reject the JWE if any
validation failure occurs. This header parameter is OPTIONAL.
See Appendix B of [JWS] for an example "x5c" value.
4.1.13. "kid" (Key ID) Header Parameter
The "kid" (key ID) header parameter is a hint indicating which key
was used to encrypt the JWE; this can be used to determine the
private key needed to decrypt the JWE. This parameter allows
originators to explicitly signal a change of key to recipients.
Should the recipient be unable to locate a key corresponding to the
"kid" value, they SHOULD treat that condition as an error. The
interpretation of the "kid" value is unspecified. Its value MUST be
a string. This header parameter is OPTIONAL.
When used with a JWK, the "kid" value MAY be used to match a JWK
"kid" parameter value.
4.1.14. "typ" (Type) Header Parameter
The "typ" (type) header parameter is used to declare the type of this
object. The type value "JWE" MAY be used to indicate that this
object is a JWE. The "typ" value is a case sensitive string. This
header parameter is OPTIONAL.
MIME Media Type [RFC2046] values MAY be used as "typ" values.
Jones, et al. Expires January 31, 2013 [Page 14]

Internet-Draft JWE July 2012
"typ" values SHOULD either be registered in the IANA JSON Web
Signature and Encryption Type Values registry [JWS] or be a URI that
contains a Collision Resistant Namespace.
4.1.15. "cty" (Content Type) Header Parameter
The "cty" (content type) header parameter is used to declare the type
of the encrypted content (the Plaintext). The "cty" value is a case
sensitive string. This header parameter is OPTIONAL.
The values used for the "cty" header parameter come from the same
value space as the "typ" header parameter, with the same rules
applying.
4.2. Public Header Parameter Names
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 registered in the IANA JSON Web Signature and
Encryption Header Parameters registry [JWS] 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.
New header parameters should be introduced sparingly, as they can
result in non-interoperable JWEs.
4.3. Private Header Parameter Names
A producer and consumer of a JWE may agree to any header parameter
name that is not a Reserved Name Section 4.1 or a Public Name
Section 4.2. Unlike Public Names, these private names are subject to
collision and should be used with caution.
5. Message Encryption
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.
1. When key agreement is employed, use the key agreement algorithm
to compute the value of the agreed upon key. When key agreement
without key wrapping is employed, let the Content Master Key
(CMK) be the agreed upon key. When key agreement with key
wrapping is employed, the agreed upon key will be used to wrap
the CMK.
Jones, et al. Expires January 31, 2013 [Page 15]

Internet-Draft JWE July 2012
2. When key wrapping, key encryption, or key agreement with key
wrapping are employed, generate a random Content Master Key
(CMK). See RFC 4086 [RFC4086] for considerations on generating
random values. The CMK MUST have a length equal to that of the
larger of the required encryption and integrity keys.
3. When key wrapping, key encryption, or key agreement with key
wrapping are employed, encrypt the CMK for the recipient (see
Section 7) and let the result be the JWE Encrypted Key.
Otherwise, when direct encryption with a shared or agreed upon
symmetric key is employed, let the JWE Encrypted Key be the
empty byte array.
4. When direct encryption with a shared symmetric key is employed,
let the Content Master Key (CMK) be the shared key.
5. Base64url encode the JWE Encrypted Key to create the Encoded JWE
Encrypted Key.
6. Generate a random Initialization Vector (IV) of the correct size
for the algorithm (if required for the algorithm).
7. If not using an AEAD algorithm, run the key derivation algorithm
specified by the "kdf" header parameter 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.
8. Compress the Plaintext if a "zip" parameter was included.
9. Serialize the (compressed) Plaintext into a byte sequence M.
10. 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.
11. Base64url encode the bytes of the UTF-8 representation of the
JWE Header to create the Encoded JWE Header.
12. Encrypt M using the CEK and IV to form the byte sequence C. If
an AEAD algorithm is used, use the bytes of the ASCII
representation of 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.
Jones, et al. Expires January 31, 2013 [Page 16]

Internet-Draft JWE July 2012
13. Base64url encode C to create the Encoded JWE Ciphertext.
14. If not using an AEAD algorithm, run the integrity algorithm (see
Section 8) 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.
15. Base64url encode the JWE Integrity Value to create the Encoded
JWE Integrity Value.
16. The four encoded parts, taken together, are the result.
17. 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.
6. Message Decryption
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.
1. Determine the Encoded JWE Header, the Encoded JWE Encrypted Key,
the Encoded JWE Ciphertext, and the Encoded JWE Integrity Value
values contained in the JWE. When using the Compact
Serialization, these four values are represented in that order,
separated by period characters.
2. 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.
3. The resulting JWE Header MUST be completely valid JSON syntax
conforming to RFC 4627 [RFC4627].
4. The resulting JWE Header MUST be validated to only include
parameters and values whose syntax and semantics are both
understood and supported.
5. Verify that the JWE uses a key known to the recipient.
Jones, et al. Expires January 31, 2013 [Page 17]

Internet-Draft JWE July 2012
6. When key agreement is employed, use the key agreement algorithm
to compute the value of the agreed upon key. When key agreement
without key wrapping is employed, let the Content Master Key
(CMK) be the agreed upon key. When key agreement with key
wrapping is employed, the agreed upon key will be used to
decrypt the JWE Encrypted Key.
7. When key wrapping, key encryption, or key agreement with key
wrapping are employed, decrypt the JWE Encrypted Key to produce
the Content Master Key (CMK). The CMK MUST have a length equal
to that of the larger of the required encryption and integrity
keys.
8. When direct encryption with a shared symmetric key is employed,
let the Content Master Key (CMK) be the shared key.
9. If not using an AEAD algorithm, run the key derivation algorithm
specified by the "kdf" header parameter 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.
10. Decrypt the binary representation of the JWE Ciphertext using
the CEK and IV. If an AEAD algorithm is used, use the bytes of
the ASCII representation of 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.
11. If not using an AEAD algorithm, run the integrity algorithm (see
Section 8) 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.
12. Uncompress the result of the previous step, if a "zip" parameter
was included.
13. Output the resulting Plaintext.
7. CMK Encryption
JWE supports three forms of Content Master Key (CMK) encryption:
o Asymmetric encryption under the recipient's public key.
Jones, et al. Expires January 31, 2013 [Page 18]

Internet-Draft JWE July 2012
o Symmetric encryption under a key shared between the sender and
receiver.
o Symmetric encryption under a key agreed upon between the sender
and receiver.
See the algorithms registered for "enc" usage in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA] and Section 4.1 of
the JSON Web Algorithms (JWA) [JWA] specification for lists of
encryption algorithms that can be used for CMK encryption.
8. Integrity Value Calculation
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) [JWS] specification, with these
modifications:
o The algorithm used is taken from the "int" (integrity algorithm)
header parameter rather than the "alg" header parameter.
o The algorithm MUST be a MAC algorithm (such as HMAC SHA-256).
o The JWS Secured Input used is the bytes of the ASCII
representation of the concatenation of the Encoded JWE Header, a
period ('.') character, the Encoded JWE Encrypted Key, a period
('.') character, and the Encoded JWE Ciphertext.
o The CIK is used as the MAC key.
The computed JWS Signature value is the resulting integrity value.
9. Encrypting JWEs with Cryptographic Algorithms
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) [JWA] specification specifies a set of cryptographic
algorithms and identifiers to be used with this specification and
defines registries for additional such algorithms. Specifically,
Section 4.1 specifies a set of "alg" (algorithm) header parameter
values, Section 4.2 specifies a set of "enc" (encryption method)
header parameter values, Section 4.3 specifies a set of "int"
(integrity algorithm) header parameter values, and Section 4.4
specifies a set of "kdf" (key derivation function) header parameter
Jones, et al. Expires January 31, 2013 [Page 19]

Internet-Draft JWE July 2012
o Security Considerations: See the Security Considerations section
of this document
o Interoperability Considerations: n/a
o Published Specification: [[ this document ]]
o Applications that use this media type: OpenID Connect and other
applications using encrypted JWTs
o Additional Information: Magic number(s): n/a, File extension(s):
n/a, Macintosh file type code(s): n/a
o Person & email address to contact for further information: Michael
B. Jones, mbj@microsoft.com
o Intended Usage: COMMON
o Restrictions on Usage: none
o Author: Michael B. Jones, mbj@microsoft.com
o Change Controller: IETF
11. Security Considerations
All of the security issues faced by any cryptographic application
must be faced by a JWS/JWE/JWK agent. Among these issues are
protecting the user's private key, preventing various attacks, and
helping the user avoid mistakes such as inadvertently encrypting a
message for the wrong recipient. The entire list of security
considerations is beyond the scope of this document, but some
significant concerns are listed here.
All the security considerations in the JWS specification also apply
to this specification. Likewise, all the security considerations in
XML Encryption 1.1 [W3C.CR-xmlenc-core1-20120313] also apply to JWE,
other than those that are XML specific.
12. Open Issues
[[ to be removed by the RFC editor before publication as an RFC ]]
The following items remain to be considered or done in this draft:
Jones, et al. Expires January 31, 2013 [Page 23]

Internet-Draft JWE July 2012
o Should we define an optional nonce and/or timestamp header
parameter? (Use of a nonce is an effective countermeasure to some
kinds of attacks.)
o Do we want to consolidate the combination of the "enc", "int", and
"kdf" parameters into a single new "enc" parameter defining
composite AEAD algorithms? For instance, we might define a
composite algorithm A128CBC with HS256 and CS256 and another
composite algorithm A256CBC with HS512 and CS512. A symmetry
argument for doing this is that the "int" and "kdf" parameters are
not used with AEAD algorithms. An argument against it is that in
some cases, integrity is not needed because it's provided by other
means, and so having the flexibility to not use an "int" algorithm
or key derivation with a non-AEAD "enc" algorithm could be useful.
o Do we want to represent the JWE IV as a separate dot-separated
element or continue to have it be in the header? An IV is always
required in practice for the block encryption algorithms we've
specified. This would save 15 and 17 characters, respectively,
for the current AES GCM and AES CBC examples.
13. References13.1. Normative References
[ITU.X690.1994]
International Telecommunications Union, "Information
Technology - ASN.1 encoding rules: Specification of Basic
Encoding Rules (BER), Canonical Encoding Rules (CER) and
Distinguished Encoding Rules (DER)", ITU-T Recommendation
X.690, 1994.
[JWA] Jones, M., "JSON Web Algorithms (JWA)", July 2012.
[JWK] Jones, M., "JSON Web Key (JWK)", July 2012.
[JWS] Jones, M., Bradley, J., and N. Sakimura, "JSON Web
Signature (JWS)", July 2012.
[RFC1421] Linn, J., "Privacy Enhancement for Internet Electronic
Mail: Part I: Message Encryption and Authentication
Procedures", RFC 1421, February 1993.
[RFC1951] Deutsch, P., "DEFLATE Compressed Data Format Specification
version 1.3", RFC 1951, May 1996.
[RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
Jones, et al. Expires January 31, 2013 [Page 24]

Internet-Draft JWE July 2012
key to key wrap the CMK.
o Added statement that "StringOrURI values are compared as case-
sensitive strings with no transformations or canonicalizations
applied".
o Updated open issues.
o Indented artwork elements to better distinguish them from the body
text.
-04
o Refer to the registries as the primary sources of defined values
and then secondarily reference the sections defining the initial
contents of the registries.
o Normatively reference XML Encryption 1.1
[W3C.CR-xmlenc-core1-20120313] for its security considerations.
o Reference draft-jones-jose-jwe-json-serialization instead of
draft-jones-json-web-encryption-json-serialization.
o Described additional open issues.
o Applied editorial suggestions.
-03
o Added the "kdf" (key derivation function) header parameter to
provide crypto agility for key derivation. The default KDF
remains the Concat KDF with the SHA-256 digest function.
o Reordered encryption steps so that the Encoded JWE Header is
always created before it is needed as an input to the AEAD
"additional authenticated data" parameter.
o Added the "cty" (content type) header parameter for declaring type
information about the secured content, as opposed to the "typ"
(type) header parameter, which declares type information about
this object.
o Moved description of how to determine whether a header is for a
JWS or a JWE from the JWT spec to the JWE spec.
o Added complete encryption examples for both AEAD and non-AEAD
algorithms.
Jones, et al. Expires January 31, 2013 [Page 43]

Internet-Draft JWE July 2012
o Added complete key derivation examples.
o Added "Collision Resistant Namespace" to the terminology section.
o Reference ITU.X690.1994 for DER encoding.
o Added Registry Contents sections to populate registry values.
o Numerous editorial improvements.
-02
o 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.
o Defined KDF output key sizes.
o Generalized text to allow key agreement to be employed as an
alternative to key wrapping or key encryption.
o Changed compression algorithm from gzip to DEFLATE.
o Clarified that it is an error when a "kid" value is included and
no matching key is found.
o Clarified that JWEs with duplicate Header Parameter Names MUST be
rejected.
o Clarified the relationship between "typ" header parameter values
and MIME types.
o Registered application/jwe MIME type and "JWE" typ header
parameter value.
o 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
"jpk" (JSON Public Key) to "jwk" (JSON Web Key).
o Added suggestion on defining additional header parameters such as
"x5t#S256" in the future for certificate thumbprints using hash
algorithms other than SHA-1.
Jones, et al. Expires January 31, 2013 [Page 44]

Internet-Draft JWE July 2012
o Specify RFC 2818 server identity validation, rather than RFC 6125
(paralleling the same decision in the OAuth specs).
o 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.
o Reformatted to give each header parameter its own section heading.
-01
o Added an integrity check for non-AEAD algorithms.
o Added "jpk" and "x5c" header parameters for including JWK public
keys and X.509 certificate chains directly in the header.
o Clarified that this specification is defining the JWE Compact
Serialization. Referenced the new JWE-JS spec, which defines the
JWE JSON Serialization.
o Added text "New header parameters should be introduced sparingly
since an implementation that does not understand a parameter MUST
reject the JWE".
o 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.
o Made other editorial improvements suggested by JOSE working group
participants.
-00
o Created the initial IETF draft based upon
draft-jones-json-web-encryption-02 with no normative changes.
o Changed terminology to no longer call both digital signatures and
HMACs "signatures".
Authors' Addresses
Michael B. Jones
Microsoft
Email: mbj@microsoft.com
URI: http://self-issued.info/Jones, et al. Expires January 31, 2013 [Page 45]