One document matched: draft-ietf-jose-json-web-encryption-10.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-10">
<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="25" month="April" year="2013" />
<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 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.
</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="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 represents this content using JavaScript Object Notation (JSON)
<xref target="RFC4627"/> based data structures.
The JWE cryptographic mechanisms encrypt and provide integrity protection for
arbitrary sequences of octets.
</t>
<t>
Cryptographic algorithms and identifiers for use with this
specification are described 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 title="Notational Conventions" anchor="NotationalConventions">
<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
Key words for use in RFCs to Indicate Requirement Levels <xref target='RFC2119' />.
</t>
</section>
</section>
<section title="Terminology" anchor="Terminology">
<t>
<list style="hanging">
<t hangText="JSON Web Encryption (JWE)">
A data structure representing an encrypted message.
The structure represents five values:
the JWE Header, the JWE Encrypted Key,
the JWE Initialization Vector, the JWE Ciphertext, and
the JWE Authentication Tag.
</t>
<t hangText="Authenticated Encryption">
An Authenticated Encryption algorithm is one that
provides an integrated content integrity check.
Authenticated Encryption algorithms accept two inputs, the Plaintext and the
Additional Authenticated Data value, and produce two outputs,
the Ciphertext and the Authentication Tag value.
AES Galois/Counter Mode (GCM) is one such algorithm.
</t>
<t hangText="Plaintext">
The sequence of octets to be encrypted -- a.k.a., the message.
The plaintext can contain an arbitrary sequence of octets.
</t>
<t hangText="Ciphertext">
An encrypted representation of the Plaintext.
</t>
<t hangText="Additional Associated Data (AAD)">
An input to an Authenticated Encryption operation that
is integrity protected but not encrypted.
</t>
<t hangText="Authentication Tag">
An output of an Authenticated Encryption operation that
ensures the integrity of the Ciphertext and the
Additional Associated Data.
</t>
<t hangText="Content Encryption Key (CEK)">
A symmetric key for the Authenticated Encryption algorithm
used to encrypt the Plaintext for the
recipient to produce the Ciphertext and the Authentication Tag.
</t>
<t hangText="JSON Text Object">
A UTF-8 <xref target="RFC3629"/>
encoded text string representing a JSON object;
the syntax of JSON objects is defined in
Section 2.2 of <xref target="RFC4627"/>.
</t>
<t hangText="JWE Header">
A JSON Text Object that describes the
encryption operations applied to create the JWE Encrypted
Key, the JWE Ciphertext, and the JWE Authentication Tag.
</t>
<t hangText="JWE Encrypted Key">
The result of encrypting the Content Encryption Key (CEK) with the
intended recipient's key using the specified algorithm.
Note that for some algorithms, the JWE Encrypted Key
value is specified as being the empty octet sequence.
</t>
<t hangText="JWE Initialization Vector">
A sequence of octets containing the Initialization Vector used
when encrypting the Plaintext.
Note that some algorithms may not use an Initialization Vector,
in which case this value is the empty octet sequence.
</t>
<t hangText="JWE Ciphertext">
A sequence of octets containing the Ciphertext for a JWE.
</t>
<t hangText="JWE Authentication Tag">
A sequence of octets containing the Authentication Tag for a JWE.
</t>
<t hangText="Base64url Encoding">
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 C of
<xref target="JWS" /> for notes on implementing base64url
encoding without padding.)
</t>
<t hangText="Encoded JWE Header">
Base64url encoding of the JWE Header.
</t>
<t hangText="Encoded JWE Encrypted Key">
Base64url encoding of the JWE Encrypted Key.
</t>
<t hangText="Encoded JWE Initialization Vector">
Base64url encoding of the JWE Initialization Vector.
</t>
<t hangText="Encoded JWE Ciphertext">
Base64url encoding of the JWE Ciphertext.
</t>
<t hangText="Encoded JWE Authentication Tag">
Base64url encoding of the JWE Authentication Tag.
</t>
<t hangText="Header Parameter Name">
The name of a member of the JWE Header.
</t>
<t hangText="Header Parameter Value">
The value of a member of 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 Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings being separated
by four period ('.') characters.
This results in a compact, URL-safe representation.
</t>
<t hangText="JWE JSON Serialization">
A representation of the JWE as a JSON structure containing
Encoded JWE Header,
Encoded JWE Encrypted Key,
Encoded JWE Initialization Vector,
Encoded JWE Ciphertext, and
Encoded JWE Authentication Tag values.
Unlike the JWE Compact Serialization,
the JWE JSON Serialization
enables the same content to be encrypted to multiple parties.
This representation is neither compact nor URL-safe.
</t>
<t hangText="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)
<xref target="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.
</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
<xref target="RFC3986"/>.
StringOrURI values are compared as case-sensitive strings
with no transformations or canonicalizations applied.
</t>
<t hangText="Key Management Mode">
A method of determining the Content Encryption Key (CEK) value to use.
Each algorithm used for determining the CEK value uses a specific Key Management Mode.
Key Management Modes employed by this specification are
Key Encryption,
Key Wrapping,
Direct Key Agreement,
Key Agreement with Key Wrapping, and
Direct Encryption.
</t>
<t hangText="Key Encryption">
A Key Management Mode in which the Content Encryption Key (CEK) value
is encrypted to the intended recipient using an asymmetric encryption algorithm.
</t>
<t hangText="Key Wrapping">
A Key Management Mode in which the Content Encryption Key (CEK) value
is encrypted to the intended recipient using a symmetric key wrapping algorithm.
</t>
<t hangText="Direct Key Agreement">
A Key Management Mode in which a key agreement algorithm is used to agree upon
the Content Encryption Key (CEK) value.
</t>
<t hangText="Key Agreement with Key Wrapping">
A Key Management Mode in which a key agreement algorithm is used to agree upon
a symmetric key used to encrypt the Content Encryption Key (CEK) value
to the intended recipient using a symmetric key wrapping algorithm.
</t>
<t hangText="Direct Encryption">
A Key Management Mode in which the Content Encryption Key (CEK) value
used is the secret symmetric key value shared between the parties.
</t>
</list>
</t>
</section>
<section title="JSON Web Encryption (JWE) Overview" anchor="Overview">
<t>
JWE represents encrypted content using JSON data
structures and base64url encoding.
Five values are represented in a JWE:
the JWE Header,
the JWE Encrypted Key,
the JWE Initialization Vector,
the JWE Ciphertext, and
the JWE Authentication Tag.
In the Compact Serialization, the five values are
base64url-encoded for transmission, and represented
as the concatenation of the encoded strings in that order,
with the five strings being separated by four period ('.') characters.
A JSON Serialization for this information is also defined in
<xref target="JSONSerialization"/>.
</t>
<t>
JWE utilizes authenticated encryption to ensure the confidentiality
and integrity of the Plaintext.
</t>
<section title="Example JWE using RSAES OAEP and AES GCM" anchor="OAEPGCMIntro">
<t>
This example encrypts the plaintext
"The true sign of intelligence is not knowledge but imagination."
to the recipient using RSAES OAEP and AES GCM.
</t>
<t>
The following example JWE Header declares that:
<list style="symbols">
<t>
the Content Encryption Key is encrypted to the recipient
using the RSAES OAEP algorithm to produce
the JWE Encrypted Key and
</t>
<t>
the Plaintext is encrypted using the AES GCM
algorithm with a 256 bit key to produce the Ciphertext.
</t>
</list>
</t>
<figure><artwork><![CDATA[
{"alg":"RSA-OAEP","enc":"A256GCM"}
]]></artwork></figure>
<t>
Base64url encoding the octets of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ
]]></artwork></figure>
<t>
The remaining steps to finish creating this JWE are:
<list style="symbols">
<t>
Generate a random Content Encryption Key (CEK)
</t>
<t>
Encrypt the CEK with the recipient's public key using the RSAES OAEP
algorithm to produce the JWE Encrypted Key
</t>
<t>
Base64url encode the JWE Encrypted Key to produce
the Encoded JWE Encrypted Key
</t>
<t>
Generate a random JWE Initialization Vector
</t>
<t>
Base64url encode the JWE Initialization Vector to produce the Encoded JWE Initialization Vector
</t>
<t>
Concatenate
the Encoded JWE Header value, a period ('.') character,
and the Encoded JWE Encrypted Key
to create the Additional Authenticated Data parameter
</t>
<t>
Encrypt the Plaintext with AES GCM
using the CEK as the encryption key,
the JWE Initialization Vector,
and the Additional Authenticated Data value,
requesting a 128 bit Authentication Tag output
</t>
<t>
Base64url encode the Ciphertext to create the Encoded JWE Ciphertext
</t>
<t>
Base64url encode the Authentication Tag to create
the Encoded JWE Authentication Tag
</t>
<t>
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 Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings
being separated by four period ('.') characters.
</t>
</list>
The final result in this example
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.
ApfOLCaDbqs_JXPYy2I937v_xmrzj-Iss1mG6NAHmeJViM6j2l0MHvfseIdHVyU2
BIoGVu9ohvkkWiRq5DL2jYZTPA9TAdwq3FUIVyoH-Pedf6elHIVFi2KGDEspYMtQ
ARMMSBcS7pslx6flh1Cfh3GBKysztVMEhZ_maFkm4PYVCsJsvq6Ct3fg2CJPOs0X
1DHuxZKoIGIqcbeK4XEO5a0h5TAuJObKdfO0dKwfNSSbpu5sFrpRFwV2FTTYoqF4
zI46N9-_hMIznlEpftRXhScEJuZ9HG8C8CHB1WRZ_J48PleqdhF4o7fB5J1wFqUX
BtbtuGJ_A2Xe6AEhrlzCOw.
48V1_ALb6US04U3b.
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6ji
SdiwkIr3ajwQzaBtQD_A.
ghEgxninkHEAMp4xZtB2mA
]]></artwork></figure>
<t>
See <xref target="OAEPGCMExample"/> for the complete details of computing this JWE.
</t>
</section>
<section title="Example JWE using RSAES-PKCS1-V1_5 and AES_128_CBC_HMAC_SHA_256" anchor="RSACBCIntro">
<t>
This example encrypts the plaintext
"Live long and prosper."
to the recipient using RSAES-PKCS1-V1_5 and AES_128_CBC_HMAC_SHA_256.
</t>
<t>
The following example JWE Header (with line breaks for display purposes only) declares that:
<list style="symbols">
<t>
the Content Encryption Key is encrypted to the recipient
using the RSAES-PKCS1-V1_5 algorithm to produce
the JWE Encrypted Key and
</t>
<t>
the Plaintext is encrypted using the AES_128_CBC_HMAC_SHA_256
algorithm to produce the Ciphertext.
</t>
</list>
</t>
<figure><artwork><![CDATA[
{"alg":"RSA1_5","enc":"A128CBC-HS256"}
]]></artwork></figure>
<t>
Base64url encoding the octets of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDK0hTMjU2In0
]]></artwork></figure>
<t>
The remaining steps to finish creating this JWE are the same
as for the previous example,
but using RSAES-PKCS1-v1_5 instead of RSAES OAEP and using
the AES_128_CBC_HMAC_SHA_256 algorithm
(which is specified in Sections 4.8 and 4.8.3 of JWA)
instead of AES GCM.
</t>
<t>
The final result in this example
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMkmOm
kkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZjDYENR
WiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfEJmNmfsx5f
cB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWyEHW6WzQ4iH9S
IcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_NSsx24LxtK6fIkej
RlMBmCfxv0Tg8CtxpURigg.
AxY8DCtDaGlsbGljb3RoZQ.
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY.
fY2U_Hx5VcfXmipEldHhMA
]]></artwork></figure>
<t>
See <xref target="RSACBCExample"/> for the complete details of computing this JWE.
</t>
</section>
</section>
<section title="JWE Header" anchor="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.
</t>
<t>
Implementations are required to understand
the specific header parameters defined by this specification
that are designated as "MUST be understood"
and process them in the manner defined in this specification.
All other header parameters defined by this specification that
are not so designated MUST be ignored when not understood.
Unless listed as a critical header parameter, per <xref target="critDef"/>,
all other header parameters MUST be ignored when not understood.
</t>
<t>
There are two ways of distinguishing whether a header is a
JWS Header or a JWE Header.
The first is by examining the <spanx style="verb">alg</spanx>
(algorithm) header parameter value.
If the value represents a digital signature or MAC algorithm,
or is the value <spanx style="verb">none</spanx>, it is for a JWS;
if it represents a Key Encryption, Key Wrapping, Direct Key Agreement,
Key Agreement with Key Wrapping, or Direct Encryption algorithm, it is for a JWE.
A second method is determining whether an
<spanx style="verb">enc</spanx> (encryption method) member exists.
If the <spanx style="verb">enc</spanx> member exists, it is a JWE;
otherwise, it is a JWS.
Both methods will yield the same result for all legal input values.
</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 this specification
is for the resulting representations
using the JWE Compact Serialization 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="JWS" />.
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' anchor="algDef">
<t>
The <spanx style="verb">alg</spanx> (algorithm) header
parameter identifies the cryptographic algorithm used to
encrypt or determine the value of the Content Encryption Key (CEK).
The algorithm specified by the <spanx style="verb">alg</spanx> 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.
<spanx style="verb">alg</spanx> values SHOULD either be
registered in the IANA
JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" /> or be
a value that contains a Collision Resistant Namespace.
The <spanx style="verb">alg</spanx> value is a case sensitive string
containing a StringOrURI value.
Use of this header parameter is REQUIRED.
This header parameter MUST be understood by implementations.
</t>
<t>
A list of defined <spanx style="verb">alg</spanx> values can be found
in the IANA JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" />;
the initial contents of this registry are the values defined in
Section 4.1 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
</t>
</section>
<section title='"enc" (Encryption Method) Header Parameter' anchor="encDef">
<t>
The <spanx style="verb">enc</spanx> (encryption method)
header parameter identifies the block
encryption algorithm used to encrypt the Plaintext to produce the Ciphertext.
This algorithm MUST be an Authenticated Encryption algorithm with a specified key length.
The algorithm specified by the <spanx style="verb">enc</spanx> value
MUST be supported by the implementation
or the JWE MUST be rejected.
<spanx style="verb">enc</spanx> values SHOULD either be
registered in the IANA
JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" /> or be
a value that contains a Collision Resistant Namespace.
The <spanx style="verb">enc</spanx> value is a case sensitive string
containing a StringOrURI value.
Use of this header parameter is REQUIRED.
This header parameter MUST be understood by implementations.
</t>
<t>
A list of defined <spanx style="verb">enc</spanx> values can be found
in the IANA JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" />;
the initial contents of this registry are the values defined in
Section 4.2 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
</t>
</section>
<section title='"epk" (Ephemeral Public Key) Header Parameter' anchor="epkDef">
<t>
The <spanx style="verb">epk</spanx> (ephemeral public key)
value created by the originator for the use in key agreement algorithms.
This key is represented as a JSON Web Key <xref target="JWK" /> value.
Use of this header parameter is OPTIONAL, although its use is
REQUIRED with some <spanx style="verb">alg</spanx> algorithms.
When its use is REQUIRED,
this header parameter MUST be understood by implementations.
</t>
</section>
<section title='"zip" (Compression Algorithm) Header Parameter' anchor="zipDef">
<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.
Use of this header parameter is OPTIONAL.
This header parameter MUST be understood by implementations.
</t>
</section>
<section title='"jku" (JWK Set URL) Header Parameter' anchor="jkuDef">
<t>
The <spanx style="verb">jku</spanx> (JWK Set URL)
header parameter is a URI <xref target="RFC3986"/> that refers to a
resource for a set of JSON-encoded public keys, one of which
is the key
to which the JWE was encrypted;
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) <xref target="JWK" />.
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"/> <xref target="RFC5246"/>;
the identity of the server MUST be validated, as per
Section 3.1 of HTTP Over TLS <xref target='RFC2818'/>.
Use of this header parameter is OPTIONAL.
</t>
</section>
<section title='"jwk" (JSON Web Key) Header Parameter' anchor="jwkDef">
<t>
The <spanx style="verb">jwk</spanx> (JSON Web Key)
header parameter is the public key
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
This key is represented as a JSON Web Key <xref target="JWK" />.
Use of this header parameter is OPTIONAL.
</t>
</section>
<section title='"x5u" (X.509 URL) Header Parameter' anchor="x5uDef">
<t>
The <spanx style="verb">x5u</spanx> (X.509 URL) header
parameter is a URI <xref target="RFC3986"/> that refers to a resource for
the X.509 public key certificate or certificate chain <xref target="RFC5280"/>
containing the key
to which the JWE was encrypted;
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
<xref target="RFC5280">RFC 5280</xref> in PEM encoded form
<xref target="RFC1421"/>.
The certificate containing the public key
to which the JWE was encrypted
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"/> <xref target="RFC5246"/>;
the identity of the server MUST be validated, as per
Section 3.1 of HTTP Over TLS <xref target='RFC2818'/>.
Use of this header parameter is OPTIONAL.
</t>
</section>
<section title='"x5t" (X.509 Certificate Thumbprint) Header Parameter' anchor="x5tDef">
<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 <xref target="RFC5280"/>
containing the key
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
Use of 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="JWS" />.
</t>
</section>
<section title='"x5c" (X.509 Certificate Chain) Header Parameter' anchor="x5cDef">
<t>
The <spanx style="verb">x5c</spanx> (X.509 Certificate Chain)
header parameter contains the X.509 public key
certificate or certificate chain <xref target="RFC5280"/>
containing the key
to which the JWE was encrypted;
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 value strings. Each string is a
base64 encoded (<xref target="RFC4648"/> Section 4 -- not base64url encoded)
DER <xref target="ITU.X690.1994"/> PKIX certificate value.
The certificate containing the public key
to which the JWE was encrypted
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.
Use of this header parameter is OPTIONAL.
</t>
<t>
See Appendix B of <xref target="JWS"/> for an example
<spanx style="verb">x5c</spanx> value.
</t>
</section>
<section title='"kid" (Key ID) Header Parameter' anchor="kidDef">
<t>
The <spanx style="verb">kid</spanx> (key ID) header
parameter is a hint indicating which key
to which the JWE was encrypted;
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 <spanx style="verb">kid</spanx>
value, they SHOULD treat that condition as an error.
The interpretation of the
<spanx style="verb">kid</spanx> value is unspecified.
Its value MUST be a string.
Use of this header parameter is OPTIONAL.
</t>
<t>
When used with a JWK, the <spanx style="verb">kid</spanx>
value can be used to match a JWK <spanx style="verb">kid</spanx>
parameter value.
</t>
</section>
<section title='"typ" (Type) Header Parameter' anchor="typDef">
<t>
The <spanx style="verb">typ</spanx> (type) header
parameter is used to declare the type of this object.
The type value <spanx style="verb">JWE</spanx> is used
to indicate that this object is a JWE using the JWE Compact Serialization.
The type value <spanx style="verb">JWE-JS</spanx> is used
to indicate that this object is a JWE using the JWE JSON Serialization.
The <spanx style="verb">typ</spanx> value is a case sensitive string.
Use of this header parameter is OPTIONAL.
</t>
<t>
MIME Media Type <xref target="RFC2046"/>
values MAY be used as <spanx style="verb">typ</spanx> values.
</t>
<t>
<spanx style="verb">typ</spanx> values SHOULD either be
registered in the IANA
JSON Web Signature and Encryption Type Values registry
<xref target="JWS" /> or be
a value that contains a Collision Resistant Namespace.
</t>
</section>
<section title='"cty" (Content Type) Header Parameter' anchor="ctyDef">
<t>
The <spanx style="verb">cty</spanx> (content type) header
parameter is used to declare the type of the encrypted
content (the Plaintext).
For example, the JSON Web Token (JWT) <xref target="JWT" />
specification uses the <spanx style="verb">cty</spanx> value
<spanx style="verb">JWT</spanx>
to indicate that the Plaintext is a JSON Web Token (JWT).
The <spanx style="verb">cty</spanx> value is a case sensitive string.
Use of this header parameter is OPTIONAL.
</t>
<t>
The values used for the <spanx style="verb">cty</spanx>
header parameter come from the same value space as the
<spanx style="verb">typ</spanx> header parameter,
with the same rules applying.
</t>
</section>
<section title='"apu" (Agreement PartyUInfo) Header Parameter' anchor="apuDef">
<t>
The <spanx style="verb">apu</spanx> (agreement PartyUInfo)
value for key agreement algorithms using it
(such as <spanx style="verb">ECDH-ES</spanx>),
represented as a base64url encoded string.
Use of this header parameter is OPTIONAL.
When the <spanx style="verb">alg</spanx> value used identifies
an algorithm for which <spanx style="verb">apu</spanx> is a parameter,
this header parameter MUST be understood by implementations.
</t>
</section>
<section title='"apv" (Agreement PartyVInfo) Header Parameter' anchor="apvDef">
<t>
The <spanx style="verb">apv</spanx> (agreement PartyVInfo)
value for key agreement algorithms using it
(such as <spanx style="verb">ECDH-ES</spanx>),
represented as a base64url encoded string.
Use of this header parameter is OPTIONAL.
When the <spanx style="verb">alg</spanx> value used identifies
an algorithm for which <spanx style="verb">apv</spanx> is a parameter,
this header parameter MUST be understood by implementations.
</t>
</section>
<section title='"crit" (Critical) Header Parameter' anchor="critDef">
<t>
The <spanx style="verb">crit</spanx> (critical) header
parameter is array listing the names of header parameters
that are present in the JWE Header
that MUST be understood and processed by the implementation or
if not understood, MUST cause the JWE to be rejected.
This list MUST NOT include header parameters
defined by this specification, duplicate names, or
names that do not occur as header parameters within the JWE.
Use of this header parameter is OPTIONAL.
This header parameter MUST be understood by implementations.
</t>
<t>
<figure>
<preamble>
An example use, along with a hypothetical
<spanx style="verb">exp</spanx> (expiration-time) field is:
</preamble>
<artwork><![CDATA[
{"alg":"RSA-OAEP",
"enc":"A256GCM",
"crit":["exp"],
"exp":1363284000
}
]]></artwork>
</figure>
</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 registered in the IANA
JSON Web Signature and Encryption Header Parameters registry
<xref target="JWS" /> or be a Public Name:
a value 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 use Header Parameter Names
that are Private Names: names that are
not Reserved Names <xref target="ReservedHeaderParameterName"></xref>
or Public Names <xref target="PublicHeaderParameterName"></xref>.
Unlike Public Names, Private Names are subject to collision and
should be used with caution.
</t>
</section>
</section>
<section title="Producing and Consuming JWEs" anchor="JWERules">
<section title="Message Encryption" anchor="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>
Determine the Key Management Mode employed by the algorithm
used to determine the Content Encryption Key (CEK) value.
(This is the algorithm recorded in the
<spanx style="verb">alg</spanx> (algorithm)
header parameter of the resulting JWE.)
</t>
<t>
When Key Wrapping, Key Encryption,
or Key Agreement with Key Wrapping are employed,
generate a random Content Encryption Key (CEK) value.
See <xref target="RFC4086">RFC 4086</xref> for
considerations on generating random values.
The CEK MUST have a length equal to that
required for the block encryption algorithm.
</t>
<t>
When Direct Key Agreement or Key Agreement with Key Wrapping
are employed, use the key agreement algorithm
to compute the value of the agreed upon key.
When Direct Key Agreement is employed,
let the Content Encryption Key (CEK) be the agreed upon key.
When Key Agreement with Key Wrapping is employed,
the agreed upon key will be used to wrap the CEK.
</t>
<t>
When Key Wrapping, Key Encryption,
or Key Agreement with Key Wrapping are employed,
encrypt the CEK to the recipient (see <xref
target="CEKEncryption"/>) and let the result be the
JWE Encrypted Key.
</t>
<t>
Otherwise, when Direct Key Agreement or Direct Encryption are employed,
let the JWE Encrypted Key be the empty octet sequence.
</t>
<t>
When Direct Encryption is employed,
let the Content Encryption Key (CEK) be the shared symmetric key.
</t>
<t>
Base64url encode the JWE Encrypted Key to create the
Encoded JWE Encrypted Key.
</t>
<t>
Generate a random JWE Initialization Vector of the correct size
for the block encryption algorithm (if required for the algorithm);
otherwise, let the JWE Initialization Vector be the empty octet sequence.
</t>
<t>
Base64url encode the JWE Initialization Vector to create the
Encoded JWE Initialization Vector.
</t>
<t>
Compress the Plaintext if a <spanx
style="verb">zip</spanx> parameter was included.
</t>
<t>
Serialize the (compressed) Plaintext into an octet sequence M.
</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 octets of the UTF-8 representation of
the JWE Header to create the Encoded JWE Header.
</t>
<t>
If the JWE JSON Serialization is being used, repeat this process
for each recipient.
</t>
<t>
Let the value X be the concatenation of the Encoded JWE Header values
computed above, with a tilde ('~') character between each Encoded JWE Header value.
(In the single recipient case, X is simply the single Encoded JWE Header value.)
</t>
<t>
Let the value Y be the concatenation of the Encoded JWE Encrypted Key values
computed above, with a tilde ('~') character between each Encoded JWE Encrypted Key value.
The order of the Encoded JWE Encrypted Key values MUST be the same as the order of
the corresponding Encoded JWE Header values in the previous step.
(In the single recipient case, Y is simply the single Encoded JWE Encrypted Key value.)
</t>
<t>
Let the Additional Authenticated Data value be the octets of the ASCII
representation of the concatenation of
X, a period ('.') character, and Y.
</t>
<t>
Encrypt M using the CEK, the JWE Initialization Vector, and
the Additional Authenticated Data value
using the specified block encryption algorithm
to create the JWE Ciphertext value and the JWE Authentication Tag
(which is the Authentication Tag output from the encryption operation).
</t>
<t>
Base64url encode the JWE Ciphertext to create the Encoded JWE Ciphertext.
</t>
<t>
Base64url encode the JWE Authentication Tag to create the
Encoded JWE Authentication Tag.
</t>
<t>
The five encoded parts are the result values used in both the
JWE Compact Serialization and the JWE JSON Serialization representations.
</t>
<t>
Create the desired serialized output.
The JWE Compact Serialization of this result is the
concatenation of
the Encoded JWE Header,
the Encoded JWE Encrypted Key,
the Encoded JWE Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings
being separated by four period ('.') characters.
The JWE JSON Serialization is described in <xref target="JSONSerialization"/>.
</t>
</list>
</t>
</section>
<section title="Message Decryption" anchor="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 serialized input to determine the values of
the Encoded JWE Header,
the Encoded JWE Encrypted Key,
the Encoded JWE Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag.
When using the JWE Compact Serialization, these five values
are represented as text strings in that order,
separated by four period ('.') characters.
The JWE JSON Serialization is described in <xref target="JSONSerialization"/>.
</t>
<t>
The Encoded JWE Header,
the Encoded JWE Encrypted Key,
the Encoded JWE Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
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
or that are specified as being ignored when not understood.
</t>
<t>
Determine the Key Management Mode employed by the algorithm
specified by the
<spanx style="verb">alg</spanx> (algorithm) header parameter.
</t>
<t>
Verify that the JWE uses a key known to the recipient.
</t>
<t>
When Direct Key Agreement or Key Agreement with Key Wrapping
are employed, use the key agreement algorithm
to compute the value of the agreed upon key.
When Direct Key Agreement is employed,
let the Content Encryption Key (CEK) 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.
</t>
<t>
When Key Wrapping, Key Encryption,
or Key Agreement with Key Wrapping are employed,
decrypt the JWE Encrypted Key to produce the Content Encryption Key (CEK).
The CEK MUST have a length equal to that
required for the block encryption algorithm.
Note that when there are multiple recipients,
each recipient will only be able decrypt any JWE Encrypted Key values
that were encrypted to a key in that recipient's possession.
It is therefore normal to only be able to decrypt one of the
per-recipient JWE Encrypted Key values to obtain the CEK value.
To mitigate against attacks described in <xref target="RFC3218">RFC 3218</xref>,
the recipient MUST NOT distinguish between format, padding, and
length errors of encrypted keys. It is strongly recommended,
in the event of receiving an improperly formatted key,
that the receiver substitute a randomly generated
CEK and proceed to the next step, to mitigate timing attacks.
</t>
<t>
Otherwise, when Direct Key Agreement or Direct Encryption are employed,
verify that the JWE Encrypted Key value is empty octet sequence.
</t>
<t>
When Direct Encryption is employed,
let the Content Encryption Key (CEK) be the shared symmetric key.
</t>
<t>
If the JWE JSON Serialization is being used, repeat this process
for each recipient contained in the representation.
</t>
<t>
Let the value X be the concatenation of the Encoded JWE Header values
identified above, with a tilde ('~') character between each Encoded JWE Header value.
(In the single recipient case, X is simply the single Encoded JWE Header value.)
</t>
<t>
Let the value Y be the concatenation of the Encoded JWE Encrypted Key values
identified above, with a tilde ('~') character between each Encoded JWE Encrypted Key value.
The order of the Encoded JWE Encrypted Key values MUST be the same as the order of
the corresponding Encoded JWE Header values in the previous step.
(In the single recipient case, Y is simply the single Encoded JWE Encrypted Key value.)
</t>
<t>
Let the Additional Authenticated Data value be the octets of the ASCII
representation of the concatenation of
X, a period ('.') character, and Y.
</t>
<t>
Decrypt the JWE Ciphertext using the CEK, the JWE Initialization Vector,
the Additional Authenticated Data value,
and the JWE Authentication Tag
(which is the Authentication Tag input to the calculation)
using the specified block encryption algorithm,
returning the decrypted plaintext and verifying the JWE Authentication Tag
in the manner specified for the algorithm,
rejecting the input without emitting any decrypted output
if the JWE Authentication Tag is incorrect.
</t>
<t>
Uncompress the decrypted plaintext
if a <spanx style="verb">zip</spanx> parameter was included.
</t>
<t>
Output the resulting Plaintext.
</t>
</list>
</t>
</section>
<section title="String Comparison Rules" anchor="StringComparison">
<t>
Processing a JWE inevitably requires comparing known strings
to values in JSON objects. For example, in checking what the
encryption method is, the Unicode string encoding
<spanx style="verb">enc</spanx> will be
checked against the member names in the JWE Header
to see if there is a matching Header Parameter Name.
</t>
<t>
Comparisons between JSON strings and other Unicode strings
MUST be performed by comparing Unicode code points without normalization
as specified in the String Comparison Rules in Section 5.3 of <xref target="JWS" />.
</t>
</section>
</section>
<section title="Encrypting JWEs with Cryptographic Algorithms" anchor="EncryptionAlgs">
<t>
JWE uses cryptographic algorithms to encrypt the Plaintext
and the Content Encryption Key (CEK) and to provide integrity
protection for the JWE Header, JWE Encrypted Key, and JWE Ciphertext.
The JSON Web Algorithms (JWA) <xref target="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
<spanx style="verb">alg</spanx> (algorithm) header parameter values and
Section 4.2 specifies a set of
<spanx style="verb">enc</spanx> (encryption method) header parameter values
intended for use this specification.
It also describes the semantics and operations that are
specific to these algorithms.
</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 title="CEK Encryption" anchor="CEKEncryption">
<t>
JWE supports three forms of Content Encryption Key (CEK) encryption:
<list style="symbols">
<t>
Asymmetric encryption under the recipient's public key.
</t>
<t>
Symmetric encryption under a key shared between the sender and receiver.
</t>
<t>
Symmetric encryption under a key agreed upon between the sender and receiver.
</t>
</list>
See the algorithms registered for <spanx style="verb">enc</spanx> usage in the IANA
JSON Web Signature and Encryption Algorithms registry <xref target="JWA" />
and Section 4.1 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification
for lists of encryption algorithms that can be used for CEK encryption.
</t>
</section>
</section>
<section title="JSON Serialization" anchor="JSONSerialization">
<t>
The JWE JSON Serialization represents encrypted
content as a JSON object with
a <spanx style="verb">recipients</spanx> member
containing an array of per-recipient information,
an <spanx style="verb">initialization_vector</spanx> member
containing a shared Encoded JWE Initialization Vector value,
a <spanx style="verb">ciphertext</spanx> member
containing a shared Encoded JWE Ciphertext value,
and an <spanx style="verb">authentication_tag</spanx> member
containing a shared Encoded JWE Authentication Tag value.
Each member of the <spanx style="verb">recipients</spanx> array is a JSON object with
a <spanx style="verb">header</spanx> member
containing an Encoded JWE Header value and
an <spanx style="verb">encrypted_key</spanx> member
containing an Encoded JWE Encrypted Key value.
</t>
<t>
Unlike the JWE Compact Serialization, content using
the JWE JSON Serialization MAY be encrypted to more than one
recipient. Each recipient requires:
<list style="symbols">
<t>
a JWE Header value specifying the cryptographic parameters
used to encrypt the JWE Encrypted Key to that recipient
and the parameters used to encrypt the plaintext to
produce the JWE Ciphertext;
this is represented as an Encoded JWE Header value
in the <spanx style="verb">header</spanx> member
of an object in the <spanx style="verb">recipients</spanx> array.
</t>
<t>
a JWE Encrypted Key value used to encrypt the ciphertext;
this is represented as an Encoded JWE Encrypted Key value
in the <spanx style="verb">encrypted_key</spanx> member
of the same object in the <spanx style="verb">recipients</spanx> array.
</t>
</list>
Therefore, the syntax is:
</t>
<figure><artwork><![CDATA[
{"recipients":[
{"header":"<header 1 contents>",
"encrypted_key":"<encrypted key 1 contents>"},
...
{"header":"<header N contents>",
"encrypted_key":"<encrypted key N contents>"}],
"initialization_vector":"<initialization vector contents>",
"ciphertext":"<ciphertext contents>",
"authentication_tag":"<authentication tag contents>"
}
]]></artwork></figure>
<t>
The contents of the
Encoded JWE Header,
Encoded JWE Encrypted Key,
Encoded JWE Initialization Vector,
Encoded JWE Ciphertext, and
Encoded JWE Authentication Tag
values are exactly as specified in the rest of this specification.
They are interpreted and validated in the same manner,
with each corresponding
<spanx style="verb">header</spanx> and
<spanx style="verb">encrypted_key</spanx>
value being created and validated together.
</t>
<t>
All recipients use the same JWE Ciphertext,
JWE Initialization Vector, and
JWE Authentication Tag values, resulting in
potentially significant space savings if the message is large.
Therefore, all header parameters that specify the treatment of
the JWE Ciphertext value MUST be the same for all recipients.
This primarily means that the <spanx
style="verb">enc</spanx> (encryption method) header parameter
value in the JWE Header for each recipient MUST be the same.
</t>
<section title="Example JWE-JS" anchor="JSONSerializationExample">
<t>
This section contains an example using the JWE JSON Serialization.
This example demonstrates the capability for
encrypting the same plaintext to multiple recipients.
</t>
<t>
Two recipients are present in this example: the first using the
RSAES-PKCS1-V1_5 algorithm to encrypt the Content Encryption Key (CEK)
and the second using RSAES OAEP to encrypt the CEK.
The Plaintext is encrypted using the AES_128_CBC_HMAC_SHA_256 algorithm
and the same block encryption parameters to produce
the common JWE Ciphertext value.
The two Decoded JWE Header Segments used are:
</t>
<figure><artwork><![CDATA[
{"alg":"RSA1_5","enc":"A128CBC-HS256"}
]]></artwork></figure>
<t>
and:
</t>
<figure><artwork><![CDATA[
{"alg":"RSA-OAEP","enc":"A128CBC-HS256"}
]]></artwork></figure>
<t>
The keys used for the first recipient are the same as those in
<xref target="RSACBCExample"/>, as is the Plaintext used.
The encryption key used for the second recipient
is the same as that used in <xref target="WrapExample"/>;
the block encryption keys and parameters for the second recipient
are the same as those for the first recipient
(which must be the case, since the Initialization Vector
and Ciphertext are shared).
Thus, the same two Encoded JWE Header and JWE Encoded Encrypted Key
values are used in this example as are used in those examples.
</t>
<t>
The value X used as part of the AAD value is the concatenation of
the Encoded JWE Header values, separated by a tilde ('~') character.
In this example, the value of X
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
~
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
]]></artwork></figure>
<t>
The value Y used as part of the AAD value is the concatenation of
the Encoded JWE Encrypted Key values, separated by a tilde ('~') character.
In this example, the value of Y
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMk
mOmkkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZ
jDYENRWiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfE
JmNmfsx5fcB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWy
EHW6WzQ4iH9SIcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_N
Ssx24LxtK6fIkejRlMBmCfxv0Tg8CtxpURigg
~
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ
]]></artwork></figure>
<t>
The AAD value used for the block encryption is
the octets of the ASCII
representation of the concatenation of
X, a period ('.') character, and Y.
This concatenation (with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
~
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
.
nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMk
mOmkkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZ
jDYENRWiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfE
JmNmfsx5fcB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWy
EHW6WzQ4iH9SIcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_N
Ssx24LxtK6fIkejRlMBmCfxv0Tg8CtxpURigg
~
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ
]]></artwork></figure>
<t>
The complete JSON Web Encryption JSON Serialization (JWE-JS)
for these values is as follows
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[
{"recipients":[
{"header":
"eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0",
"encrypted_key":
"nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMk
mOmkkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZ
jDYENRWiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfE
JmNmfsx5fcB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWy
EHW6WzQ4iH9SIcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_N
Ssx24LxtK6fIkejRlMBmCfxv0Tg8CtxpURigg"},
{"header":
"eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0",
"encrypted_key":
"6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ"}],
"initialization_vector":
"AxY8DCtDaGlsbGljb3RoZQ",
"ciphertext":
"KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY",
"authentication_tag":
"LlhRZFfphc2f5X3nTTJP6g"
}
]]></artwork></figure>
</section>
</section>
<section title="Implementation Considerations" anchor="ImplementationConsiderations">
<t>
The JWE Compact Serialization is mandatory to implement.
Implementation of the JWE JSON Serialization is OPTIONAL.
</t>
</section>
<section title="IANA Considerations" anchor="IANA">
<section title="Registration of JWE Header Parameter Names" anchor="HdrReg">
<t>
This specification registers the Header Parameter Names defined in
<xref target="ReservedHeaderParameterName"/> in the IANA
JSON Web Signature and Encryption Header Parameters registry
<xref target="JWS" />.
</t>
<section title="Registry Contents" anchor="HdrContents">
<t> <?rfc subcompact="yes"?>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">alg</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="algDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">enc</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="encDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">epk</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="epkDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">zip</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="zipDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">jku</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="jkuDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">jwk</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification document(s): <xref target="jwkDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">x5u</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="x5uDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">x5t</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="x5tDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">x5c</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="x5cDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">kid</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="kidDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">typ</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="typDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">cty</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="ctyDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">apu</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="apuDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">apv</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWE
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="apvDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
Header Parameter Name: <spanx style="verb">crit</spanx>
</t>
<t>
Header Parameter Usage Location(s): JWS
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="critDef"/> of [[ this document ]]
</t>
</list>
</t>
</section>
<?rfc subcompact="no"?>
</section>
<section title="JSON Web Signature and Encryption Type Values Registration" anchor="TypReg">
<section title="Registry Contents" anchor="TypContents">
<t>
This specification registers the <spanx style='verb'>JWE</spanx>
and <spanx style='verb'>JWE-JS</spanx>
type values in the
IANA JSON Web Signature and Encryption Type Values registry <xref target="JWS"/>:
</t>
<t> <?rfc subcompact="yes"?>
<list style='symbols'>
<t>
"typ" Header Parameter Value: <spanx style='verb'>JWE</spanx>
</t>
<t>
Abbreviation for MIME Type: application/jwe
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="typDef"/> of [[ this document ]]
</t>
</list>
</t>
<t>
<list style='symbols'>
<t>
"typ" Header Parameter Value: <spanx style='verb'>JWE-JS</spanx>
</t>
<t>
Abbreviation for MIME Type: application/jwe-js
</t>
<t>
Change Controller: IETF
</t>
<t>
Specification Document(s): <xref target="typDef"/> of [[ this document ]]
</t>
</list>
</t>
</section>
<?rfc subcompact="no"?>
</section>
<section title="Media Type Registration" anchor="MediaReg">
<section title="Registry Contents" anchor="MediaContents">
<t>
This specification registers the
<spanx style="verb">application/jwe</spanx> and
<spanx style="verb">application/jwe-js</spanx>
Media Types <xref target="RFC2046"/>
in the MIME Media Type registry <xref target="RFC4288"/>
to indicate, respectively, that the content is
a JWE using the JWE Compact Serialization or
a JWE using the JWE JSON Serialization.
</t>
<t> <?rfc subcompact="yes"?>
<list style="symbols">
<t>
Type Name: application
</t>
<t>
Subtype Name: jwe
</t>
<t>
Required Parameters: n/a
</t>
<t>
Optional Parameters: n/a
</t>
<t>
Encoding considerations: JWE values are encoded as a
series of base64url encoded values (some of which may be the
empty string) separated by period ('.') characters
</t>
<t>
Security Considerations: See the Security Considerations section of [[ this document ]]
</t>
<t>
Interoperability Considerations: n/a
</t>
<t>
Published Specification: [[ this document ]]
</t>
<t>
Applications that use this media type:
OpenID Connect and other applications using encrypted JWTs
</t>
<t>
Additional Information: Magic number(s): n/a,
File extension(s): n/a,
Macintosh file type code(s): n/a
</t>
<t>
Person & email address to contact for further information: Michael B. Jones, mbj@microsoft.com
</t>
<t>
Intended Usage: COMMON
</t>
<t>
Restrictions on Usage: none
</t>
<t>
Author: Michael B. Jones, mbj@microsoft.com
</t>
<t>
Change Controller: IETF
</t>
</list>
</t>
<t>
<list style="symbols">
<t>
Type Name: application
</t>
<t>
Subtype Name: jwe-js
</t>
<t>
Required Parameters: n/a
</t>
<t>
Optional Parameters: n/a
</t>
<t>
Encoding considerations:
JWE-JS values are represented as a JSON Object;
UTF-8 encoding SHOULD be employed for the JSON object.
</t>
<t>
Security Considerations: See the Security Considerations section of [[ this document ]]
</t>
<t>
Interoperability Considerations: n/a
</t>
<t>
Published Specification: [[ this document ]]
</t>
<t>
Applications that use this media type:
TBD
</t>
<t>
Additional Information: Magic number(s): n/a,
File extension(s): n/a,
Macintosh file type code(s): n/a
</t>
<t>
Person & email address to contact for further information: Michael B. Jones, mbj@microsoft.com
</t>
<t>
Intended Usage: COMMON
</t>
<t>
Restrictions on Usage: none
</t>
<t>
Author: Michael B. Jones, mbj@microsoft.com
</t>
<t>
Change Controller: IETF
</t>
</list>
</t>
</section>
<?rfc subcompact="no"?>
</section>
</section>
<section title="Security Considerations" anchor="Security">
<t>
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 and symmetric keys, 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.
</t>
<t>
All the security considerations in the JWS specification
also apply to this specification.
Likewise, all the security considerations in
<xref target="W3C.CR-xmlenc-core1-20120313">XML Encryption 1.1</xref>
also apply, other than those that are XML specific.
</t>
<t>
When decrypting, particular care must be taken not to allow
the JWE recipient to be used as an oracle for decrypting messages.
<xref target="RFC3218">RFC 3218</xref> should be consulted for specific
countermeasures to attacks on RSAES-PKCS1-V1_5.
An attacker might modify the contents of the <spanx style="verb">alg</spanx>
parameter from <spanx style="verb">RSA-OAEP</spanx> to
<spanx style="verb">RSA1_5</spanx> in order to generate a
formatting error that can be detected and used to recover the CEK
even if RSAES OAEP was used to encrypt the CEK.
It is therefore particularly important to report all
formatting errors to the CEK, Additional Authenticated Data,
or ciphertext as a single error when the JWE is rejected.
</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.2046.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.4288.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.5246.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5280.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml2/reference.ITU.X690.1994.xml' ?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml4/reference.W3C.CR-xmlenc-core1-20120313.xml" ?>
<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="25" month="April" year="2013" />
</front>
<seriesInfo value="draft-ietf-jose-json-web-signature" name="Internet-Draft"/>
<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="25" month="April" year="2013" />
</front>
<seriesInfo value="draft-ietf-jose-json-web-key" name="Internet-Draft"/>
<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="25" month="April" year="2013" />
</front>
<seriesInfo value="draft-ietf-jose-json-web-algorithms" name="Internet-Draft"/>
<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.3218.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.4122.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5652.xml' ?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-rescorla-jsms-00.xml" ?>
<?rfc include="http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-mcgrew-aead-aes-cbc-hmac-sha2-01.xml" ?>
<reference anchor="JWT">
<front>
<title>JSON Web Token (JWT)</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="23" month="April" year="2013" />
</front>
<seriesInfo value="draft-ietf-oauth-json-web-token" name="Internet-Draft"/>
<format target="http://tools.ietf.org/html/draft-ietf-oauth-json-web-token" 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 examples of JWE computations.
</t>
<section title="Example JWE using RSAES OAEP and AES GCM" anchor="OAEPGCMExample">
<t>
This example encrypts the plaintext
"The true sign of intelligence is not knowledge but imagination."
to the recipient using RSAES OAEP and AES GCM.
The representation of this plaintext is:
</t>
<t>
[84, 104, 101, 32, 116, 114, 117, 101, 32, 115, 105, 103, 110, 32, 111, 102,
32, 105, 110, 116, 101, 108, 108, 105, 103, 101, 110, 99, 101, 32, 105, 115,
32, 110, 111, 116, 32, 107, 110, 111, 119, 108, 101, 100, 103, 101, 32, 98,
117, 116, 32, 105, 109, 97, 103, 105, 110, 97, 116, 105, 111, 110, 46]
</t>
<section title="JWE Header" anchor="OAEPGCMHeader">
<t>
The following example JWE Header declares that:
<list style="symbols">
<t>
the Content Encryption Key is encrypted to the recipient
using the RSAES OAEP algorithm to produce
the JWE Encrypted Key and
</t>
<t>
the Plaintext is encrypted using the AES GCM
algorithm with a 256 bit key to produce the Ciphertext.
</t>
</list>
</t>
<figure><artwork><![CDATA[
{"alg":"RSA-OAEP","enc":"A256GCM"}
]]></artwork></figure>
</section>
<section title="Encoded JWE Header" anchor="OAEPGCMEncodedHeader">
<t>
Base64url encoding the octets of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ
]]></artwork></figure>
</section>
<section title="Content Encryption Key (CEK)" anchor="OAEPGCMCEK">
<t>
Generate a 256 bit random Content Encryption Key (CEK).
In this example, the value is:
</t>
<t>
[177, 161, 244, 128, 84, 143, 225, 115, 63, 180, 3, 255, 107, 154, 212, 246,
138, 7, 110, 91, 112, 46, 34, 105, 47, 130, 203, 46, 122, 234, 64, 252]
</t>
</section>
<section title="Key Encryption" anchor="OAEPGCEKeyEncryption">
<t>
Encrypt the CEK with the recipient's public key using the RSAES OAEP
algorithm to produce the JWE Encrypted Key.
In this example, the RSA key parameters are:
</t>
<texttable>
<ttcol align="left">Parameter Name</ttcol>
<ttcol align="left">Value</ttcol>
<c>Modulus</c>
<c>
[161, 168, 84, 34, 133, 176, 208, 173, 46, 176, 163, 110, 57, 30, 135, 227,
9, 31, 226, 128, 84, 92, 116, 241, 70, 248, 27, 227, 193, 62, 5, 91,
241, 145, 224, 205, 141, 176, 184, 133, 239, 43, 81, 103, 9, 161, 153, 157,
179, 104, 123, 51, 189, 34, 152, 69, 97, 69, 78, 93, 140, 131, 87, 182,
169, 101, 92, 142, 3, 22, 167, 8, 212, 56, 35, 79, 210, 222, 192, 208,
252, 49, 109, 138, 173, 253, 210, 166, 201, 63, 102, 74, 5, 158, 41, 90,
144, 108, 160, 79, 10, 89, 222, 231, 172, 31, 227, 197, 0, 19, 72, 81,
138, 78, 136, 221, 121, 118, 196, 17, 146, 10, 244, 188, 72, 113, 55, 221,
162, 217, 171, 27, 57, 233, 210, 101, 236, 154, 199, 56, 138, 239, 101, 48,
198, 186, 202, 160, 76, 111, 234, 71, 57, 183, 5, 211, 171, 136, 126, 64,
40, 75, 58, 89, 244, 254, 107, 84, 103, 7, 236, 69, 163, 18, 180, 251,
58, 153, 46, 151, 174, 12, 103, 197, 181, 161, 162, 55, 250, 235, 123, 110,
17, 11, 158, 24, 47, 133, 8, 199, 235, 107, 126, 130, 246, 73, 195, 20,
108, 202, 176, 214, 187, 45, 146, 182, 118, 54, 32, 200, 61, 201, 71, 243,
1, 255, 131, 84, 37, 111, 211, 168, 228, 45, 192, 118, 27, 197, 235, 232,
36, 10, 230, 248, 190, 82, 182, 140, 35, 204, 108, 190, 253, 186, 186, 27]
</c>
<c>Exponent</c>
<c>
[1, 0, 1]
</c>
<c>Private Exponent</c>
<c>
[144, 183, 109, 34, 62, 134, 108, 57, 44, 252, 10, 66, 73, 54, 16, 181,
233, 92, 54, 219, 101, 42, 35, 178, 63, 51, 43, 92, 119, 136, 251, 41,
53, 23, 191, 164, 164, 60, 88, 227, 229, 152, 228, 213, 149, 228, 169, 237,
104, 71, 151, 75, 88, 252, 216, 77, 251, 231, 28, 97, 88, 193, 215, 202,
248, 216, 121, 195, 211, 245, 250, 112, 71, 243, 61, 129, 95, 39, 244, 122,
225, 217, 169, 211, 165, 48, 253, 220, 59, 122, 219, 42, 86, 223, 32, 236,
39, 48, 103, 78, 122, 216, 187, 88, 176, 89, 24, 1, 42, 177, 24, 99,
142, 170, 1, 146, 43, 3, 108, 64, 194, 121, 182, 95, 187, 134, 71, 88,
96, 134, 74, 131, 167, 69, 106, 143, 121, 27, 72, 44, 245, 95, 39, 194,
179, 175, 203, 122, 16, 112, 183, 17, 200, 202, 31, 17, 138, 156, 184, 210,
157, 184, 154, 131, 128, 110, 12, 85, 195, 122, 241, 79, 251, 229, 183, 117,
21, 123, 133, 142, 220, 153, 9, 59, 57, 105, 81, 255, 138, 77, 82, 54,
62, 216, 38, 249, 208, 17, 197, 49, 45, 19, 232, 157, 251, 131, 137, 175,
72, 126, 43, 229, 69, 179, 117, 82, 157, 213, 83, 35, 57, 210, 197, 252,
171, 143, 194, 11, 47, 163, 6, 253, 75, 252, 96, 11, 187, 84, 130, 210,
7, 121, 78, 91, 79, 57, 251, 138, 132, 220, 60, 224, 173, 56, 224, 201]
</c>
</texttable>
<t>
The resulting JWE Encrypted Key value is:
</t>
<t>
[2, 151, 206, 44, 38, 131, 110, 171, 63, 37, 115, 216, 203, 98, 61, 223,
187, 255, 198, 106, 243, 143, 226, 44, 179, 89, 134, 232, 208, 7, 153, 226,
85, 136, 206, 163, 218, 93, 12, 30, 247, 236, 120, 135, 71, 87, 37, 54,
4, 138, 6, 86, 239, 104, 134, 249, 36, 90, 36, 106, 228, 50, 246, 141,
134, 83, 60, 15, 83, 1, 220, 42, 220, 85, 8, 87, 42, 7, 248, 247,
157, 127, 167, 165, 28, 133, 69, 139, 98, 134, 12, 75, 41, 96, 203, 80,
1, 19, 12, 72, 23, 18, 238, 155, 37, 199, 167, 229, 135, 80, 159, 135,
113, 129, 43, 43, 51, 181, 83, 4, 133, 159, 230, 104, 89, 38, 224, 246,
21, 10, 194, 108, 190, 174, 130, 183, 119, 224, 216, 34, 79, 58, 205, 23,
212, 49, 238, 197, 146, 168, 32, 98, 42, 113, 183, 138, 225, 113, 14, 229,
173, 33, 229, 48, 46, 36, 230, 202, 117, 243, 180, 116, 172, 31, 53, 36,
155, 166, 238, 108, 22, 186, 81, 23, 5, 118, 21, 52, 216, 162, 161, 120,
204, 142, 58, 55, 223, 191, 132, 194, 51, 158, 81, 41, 126, 212, 87, 133,
39, 4, 38, 230, 125, 28, 111, 2, 240, 33, 193, 213, 100, 89, 252, 158,
60, 62, 87, 170, 118, 17, 120, 163, 183, 193, 228, 157, 112, 22, 165, 23,
6, 214, 237, 184, 98, 127, 3, 101, 222, 232, 1, 33, 174, 92, 194, 59]
</t>
</section>
<section title="Encoded JWE Encrypted Key" anchor="OAEPGCMEncodedKey">
<t>
Base64url encode the JWE Encrypted Key to produce
the Encoded JWE Encrypted Key.
This result (with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
ApfOLCaDbqs_JXPYy2I937v_xmrzj-Iss1mG6NAHmeJViM6j2l0MHvfseIdHVyU2
BIoGVu9ohvkkWiRq5DL2jYZTPA9TAdwq3FUIVyoH-Pedf6elHIVFi2KGDEspYMtQ
ARMMSBcS7pslx6flh1Cfh3GBKysztVMEhZ_maFkm4PYVCsJsvq6Ct3fg2CJPOs0X
1DHuxZKoIGIqcbeK4XEO5a0h5TAuJObKdfO0dKwfNSSbpu5sFrpRFwV2FTTYoqF4
zI46N9-_hMIznlEpftRXhScEJuZ9HG8C8CHB1WRZ_J48PleqdhF4o7fB5J1wFqUX
BtbtuGJ_A2Xe6AEhrlzCOw
]]></artwork></figure>
</section>
<section title="Initialization Vector" anchor="OAEPGCMIV">
<t>
Generate a random 96 bit JWE Initialization Vector.
In this example, the value is:
</t>
<t>
[227, 197, 117, 252, 2, 219, 233, 68, 180, 225, 77, 219]
</t>
<t>
Base64url encoding this value yields the Encoded JWE Initialization Vector value:
</t>
<figure><artwork><![CDATA[
48V1_ALb6US04U3b
]]></artwork></figure>
</section>
<section title='Additional Authenticated Data Parameter' anchor="OAEPGCMAAD">
<t>
Concatenate
the Encoded JWE Header value, a period ('.') character,
and the Encoded JWE Encrypted Key
to create the Additional Authenticated Data parameter.
This result (with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.
ApfOLCaDbqs_JXPYy2I937v_xmrzj-Iss1mG6NAHmeJViM6j2l0MHvfseIdHVyU2
BIoGVu9ohvkkWiRq5DL2jYZTPA9TAdwq3FUIVyoH-Pedf6elHIVFi2KGDEspYMtQ
ARMMSBcS7pslx6flh1Cfh3GBKysztVMEhZ_maFkm4PYVCsJsvq6Ct3fg2CJPOs0X
1DHuxZKoIGIqcbeK4XEO5a0h5TAuJObKdfO0dKwfNSSbpu5sFrpRFwV2FTTYoqF4
zI46N9-_hMIznlEpftRXhScEJuZ9HG8C8CHB1WRZ_J48PleqdhF4o7fB5J1wFqUX
BtbtuGJ_A2Xe6AEhrlzCOw
]]></artwork></figure>
<t>
The representation of this value is:
</t>
<t>
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 48, 69, 116,
84, 48, 70, 70, 85, 67, 73, 115, 73, 109, 86, 117, 89, 121, 73, 54,
73, 107, 69, 121, 78, 84, 90, 72, 81, 48, 48, 105, 102, 81, 46, 65,
112, 102, 79, 76, 67, 97, 68, 98, 113, 115, 95, 74, 88, 80, 89, 121,
50, 73, 57, 51, 55, 118, 95, 120, 109, 114, 122, 106, 45, 73, 115, 115,
49, 109, 71, 54, 78, 65, 72, 109, 101, 74, 86, 105, 77, 54, 106, 50,
108, 48, 77, 72, 118, 102, 115, 101, 73, 100, 72, 86, 121, 85, 50, 66,
73, 111, 71, 86, 117, 57, 111, 104, 118, 107, 107, 87, 105, 82, 113, 53,
68, 76, 50, 106, 89, 90, 84, 80, 65, 57, 84, 65, 100, 119, 113, 51,
70, 85, 73, 86, 121, 111, 72, 45, 80, 101, 100, 102, 54, 101, 108, 72,
73, 86, 70, 105, 50, 75, 71, 68, 69, 115, 112, 89, 77, 116, 81, 65,
82, 77, 77, 83, 66, 99, 83, 55, 112, 115, 108, 120, 54, 102, 108, 104,
49, 67, 102, 104, 51, 71, 66, 75, 121, 115, 122, 116, 86, 77, 69, 104,
90, 95, 109, 97, 70, 107, 109, 52, 80, 89, 86, 67, 115, 74, 115, 118,
113, 54, 67, 116, 51, 102, 103, 50, 67, 74, 80, 79, 115, 48, 88, 49,
68, 72, 117, 120, 90, 75, 111, 73, 71, 73, 113, 99, 98, 101, 75, 52,
88, 69, 79, 53, 97, 48, 104, 53, 84, 65, 117, 74, 79, 98, 75, 100,
102, 79, 48, 100, 75, 119, 102, 78, 83, 83, 98, 112, 117, 53, 115, 70,
114, 112, 82, 70, 119, 86, 50, 70, 84, 84, 89, 111, 113, 70, 52, 122,
73, 52, 54, 78, 57, 45, 95, 104, 77, 73, 122, 110, 108, 69, 112, 102,
116, 82, 88, 104, 83, 99, 69, 74, 117, 90, 57, 72, 71, 56, 67, 56,
67, 72, 66, 49, 87, 82, 90, 95, 74, 52, 56, 80, 108, 101, 113, 100,
104, 70, 52, 111, 55, 102, 66, 53, 74, 49, 119, 70, 113, 85, 88, 66,
116, 98, 116, 117, 71, 74, 95, 65, 50, 88, 101, 54, 65, 69, 104, 114,
108, 122, 67, 79, 119]
</t>
</section>
<section title="Plaintext Encryption" anchor="OAEPGCMEncryption">
<t>
Encrypt the Plaintext with AES GCM
using the CEK as the encryption key,
the JWE Initialization Vector,
and the Additional Authenticated Data value above,
requesting a 128 bit Authentication Tag output.
The resulting Ciphertext is:
</t>
<t>
[229, 236, 166, 241, 53, 191, 115, 196, 174, 43, 73, 109, 39, 122, 233, 96,
140, 206, 120, 52, 51, 237, 48, 11, 190, 219, 186, 80, 111, 104, 50, 142,
47, 167, 59, 61, 181, 127, 196, 21, 40, 82, 242, 32, 123, 143, 168, 226,
73, 216, 176, 144, 138, 247, 106, 60, 16, 205, 160, 109, 64, 63, 192]
</t>
<t>
The resulting Authentication Tag value is:
</t>
<t>
[130, 17, 32, 198, 120, 167, 144, 113, 0, 50, 158, 49, 102, 208, 118, 152]
</t>
</section>
<section title="Encoded JWE Ciphertext" anchor="OAEPGCMEncodedCiphertext">
<t>
Base64url encode the Ciphertext to create the Encoded JWE Ciphertext.
This result (with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6ji
SdiwkIr3ajwQzaBtQD_A
]]></artwork></figure>
</section>
<section title="Encoded JWE Authentication Tag" anchor="OAEPGCMEncodedTag">
<t>
Base64url encode the Authentication Tag to create
the Encoded JWE Authentication Tag.
This result is:
</t>
<figure><artwork><![CDATA[
ghEgxninkHEAMp4xZtB2mA
]]></artwork></figure>
</section>
<section title="Complete Representation" anchor="OAEPGCMComplete">
<t>
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 Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings
being separated by four period ('.') characters.
</t>
<t>
The final result in this example
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.
ApfOLCaDbqs_JXPYy2I937v_xmrzj-Iss1mG6NAHmeJViM6j2l0MHvfseIdHVyU2
BIoGVu9ohvkkWiRq5DL2jYZTPA9TAdwq3FUIVyoH-Pedf6elHIVFi2KGDEspYMtQ
ARMMSBcS7pslx6flh1Cfh3GBKysztVMEhZ_maFkm4PYVCsJsvq6Ct3fg2CJPOs0X
1DHuxZKoIGIqcbeK4XEO5a0h5TAuJObKdfO0dKwfNSSbpu5sFrpRFwV2FTTYoqF4
zI46N9-_hMIznlEpftRXhScEJuZ9HG8C8CHB1WRZ_J48PleqdhF4o7fB5J1wFqUX
BtbtuGJ_A2Xe6AEhrlzCOw.
48V1_ALb6US04U3b.
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6ji
SdiwkIr3ajwQzaBtQD_A.
ghEgxninkHEAMp4xZtB2mA
]]></artwork></figure>
</section>
<section title="Validation" anchor="OAEPGCMValidation">
<t>
This example illustrates the process of creating a JWE with
RSA OAEP and AES GCM.
These results can be used to validate JWE decryption implementations for these algorithms.
Note that since the RSAES OAEP computation includes random values,
the encryption results above will not be completely reproducible.
However, since the AES GCM computation is deterministic, the JWE Encrypted Ciphertext
values will be the same for all encryptions performed using these inputs.
</t>
</section>
</section>
<section title="Example JWE using RSAES-PKCS1-V1_5 and AES_128_CBC_HMAC_SHA_256" anchor="RSACBCExample">
<t>
This example encrypts the plaintext
"Live long and prosper."
to the recipient using RSAES-PKCS1-V1_5 and AES_128_CBC_HMAC_SHA_256.
The representation of this plaintext is:
</t>
<t>
[76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114,
111, 115, 112, 101, 114, 46]
</t>
<section title="JWE Header" anchor="RSACBCHeader">
<t>
The following example JWE Header (with line breaks for display purposes only) declares that:
<list style="symbols">
<t>
the Content Encryption Key is encrypted to the recipient
using the RSAES-PKCS1-V1_5 algorithm to produce
the JWE Encrypted Key and
</t>
<t>
the Plaintext is encrypted using the AES_128_CBC_HMAC_SHA_256
algorithm to produce the Ciphertext.
</t>
</list>
</t>
<figure><artwork><![CDATA[
{"alg":"RSA1_5","enc":"A128CBC-HS256"}
]]></artwork></figure>
</section>
<section title="Encoded JWE Header" anchor="RSACBCEncodedHeader">
<t>
Base64url encoding the octets of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
]]></artwork></figure>
</section>
<section title="Content Encryption Key (CEK)" anchor="RSACBCCEK">
<t>
Generate a 256 bit random Content Encryption Key (CEK).
In this example, the key value is:
</t>
<t>
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106, 206,
107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156, 44, 207]
</t>
</section>
<section title="Key Encryption" anchor="RSACBCKeyEncryption">
<t>
Encrypt the CEK with the recipient's public key using the RSAES-PKCS1-V1_5
algorithm to produce the JWE Encrypted Key.
In this example, the RSA key parameters are:
</t>
<texttable>
<ttcol align="left">Parameter Name</ttcol>
<ttcol align="left">Value</ttcol>
<c>Modulus</c>
<c>
[177, 119, 33, 13, 164, 30, 108, 121, 207, 136, 107, 242, 12, 224, 19, 226,
198, 134, 17, 71, 173, 75, 42, 61, 48, 162, 206, 161, 97, 108, 185, 234,
226, 219, 118, 206, 118, 5, 169, 224, 60, 181, 90, 85, 51, 123, 6, 224,
4, 122, 29, 230, 151, 12, 244, 127, 121, 25, 4, 85, 220, 144, 215, 110,
130, 17, 68, 228, 129, 138, 7, 130, 231, 40, 212, 214, 17, 179, 28, 124,
151, 178, 207, 20, 14, 154, 222, 113, 176, 24, 198, 73, 211, 113, 9, 33,
178, 80, 13, 25, 21, 25, 153, 212, 206, 67, 154, 147, 70, 194, 192, 183,
160, 83, 98, 236, 175, 85, 23, 97, 75, 199, 177, 73, 145, 50, 253, 206,
32, 179, 254, 236, 190, 82, 73, 67, 129, 253, 252, 220, 108, 136, 138, 11,
192, 1, 36, 239, 228, 55, 81, 113, 17, 25, 140, 63, 239, 146, 3, 172,
96, 60, 227, 233, 64, 255, 224, 173, 225, 228, 229, 92, 112, 72, 99, 97,
26, 87, 187, 123, 46, 50, 90, 202, 117, 73, 10, 153, 47, 224, 178, 163,
77, 48, 46, 154, 33, 148, 34, 228, 33, 172, 216, 89, 46, 225, 127, 68,
146, 234, 30, 147, 54, 146, 5, 133, 45, 78, 254, 85, 55, 75, 213, 86,
194, 218, 215, 163, 189, 194, 54, 6, 83, 36, 18, 153, 53, 7, 48, 89,
35, 66, 144, 7, 65, 154, 13, 97, 75, 55, 230, 132, 3, 13, 239, 71]
</c>
<c>Exponent</c>
<c>
[1, 0, 1]
</c>
<c>Private Exponent</c>
<c>
[84, 80, 150, 58, 165, 235, 242, 123, 217, 55, 38, 154, 36, 181, 221, 156,
211, 215, 100, 164, 90, 88, 40, 228, 83, 148, 54, 122, 4, 16, 165, 48,
76, 194, 26, 107, 51, 53, 179, 165, 31, 18, 198, 173, 78, 61, 56, 97,
252, 158, 140, 80, 63, 25, 223, 156, 36, 203, 214, 252, 120, 67, 180, 167,
3, 82, 243, 25, 97, 214, 83, 133, 69, 16, 104, 54, 160, 200, 41, 83,
164, 187, 70, 153, 111, 234, 242, 158, 175, 28, 198, 48, 211, 45, 148, 58,
23, 62, 227, 74, 52, 117, 42, 90, 41, 249, 130, 154, 80, 119, 61, 26,
193, 40, 125, 10, 152, 174, 227, 225, 205, 32, 62, 66, 6, 163, 100, 99,
219, 19, 253, 25, 105, 80, 201, 29, 252, 157, 237, 69, 1, 80, 171, 167,
20, 196, 156, 109, 249, 88, 0, 3, 152, 38, 165, 72, 87, 6, 152, 71,
156, 214, 16, 71, 30, 82, 51, 103, 76, 218, 63, 9, 84, 163, 249, 91,
215, 44, 238, 85, 101, 240, 148, 1, 82, 224, 91, 135, 105, 127, 84, 171,
181, 152, 210, 183, 126, 24, 46, 196, 90, 173, 38, 245, 219, 186, 222, 27,
240, 212, 194, 15, 66, 135, 226, 178, 190, 52, 245, 74, 65, 224, 81, 100,
85, 25, 204, 165, 203, 187, 175, 84, 100, 82, 15, 11, 23, 202, 151, 107,
54, 41, 207, 3, 136, 229, 134, 131, 93, 139, 50, 182, 204, 93, 130, 89]
</c>
</texttable>
<t>
The resulting JWE Encrypted Key value is:
</t>
<t>
[156, 150, 191, 184, 77, 131, 211, 9, 74, 207, 227, 156, 193, 38, 202, 23,
56, 247, 211, 108, 88, 72, 143, 145, 44, 19, 58, 133, 181, 70, 152, 254,
26, 198, 210, 80, 60, 15, 82, 210, 154, 55, 179, 115, 76, 146, 99, 166,
146, 70, 176, 157, 252, 15, 54, 58, 92, 210, 103, 55, 207, 191, 92, 185,
5, 164, 64, 241, 80, 163, 233, 131, 198, 106, 32, 207, 199, 113, 5, 200,
94, 105, 53, 32, 221, 155, 233, 108, 96, 151, 197, 152, 195, 96, 67, 81,
90, 38, 121, 51, 208, 98, 47, 45, 61, 4, 129, 121, 152, 122, 124, 229,
2, 250, 92, 64, 245, 36, 70, 76, 58, 31, 181, 185, 61, 101, 168, 240,
220, 12, 62, 253, 169, 107, 107, 9, 241, 9, 152, 217, 159, 179, 30, 95,
112, 29, 143, 124, 7, 21, 181, 13, 45, 253, 137, 142, 95, 30, 127, 26,
237, 34, 183, 89, 200, 44, 165, 203, 71, 102, 39, 127, 217, 159, 46, 17,
28, 11, 146, 222, 110, 149, 178, 16, 117, 186, 91, 52, 56, 136, 127, 82,
33, 194, 46, 164, 245, 117, 136, 160, 179, 152, 151, 15, 172, 48, 73, 228,
87, 63, 40, 192, 92, 92, 24, 167, 105, 47, 255, 193, 251, 77, 203, 6,
134, 129, 248, 191, 53, 43, 49, 219, 130, 241, 180, 174, 159, 34, 71, 163,
70, 83, 1, 152, 39, 241, 191, 68, 224, 240, 43, 113, 165, 68, 98, 130]
</t>
</section>
<section title="Encoded JWE Encrypted Key" anchor="RSACBCEncodedKey">
<t>
Base64url encode the JWE Encrypted Key to produce
the Encoded JWE Encrypted Key.
This result (with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMkmOm
kkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZjDYENR
WiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfEJmNmfsx5f
cB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWyEHW6WzQ4iH9S
IcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_NSsx24LxtK6fIkej
RlMBmCfxv0Tg8CtxpURigg
]]></artwork></figure>
</section>
<section title="Initialization Vector" anchor="RSACBCIV">
<t>
Generate a random 128 bit JWE Initialization Vector.
In this example, the value is:
</t>
<t>
[3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101]
</t>
<t>
Base64url encoding this value yields the Encoded JWE Initialization Vector value:
</t>
<figure><artwork><![CDATA[
AxY8DCtDaGlsbGljb3RoZQ
]]></artwork></figure>
</section>
<section title='Additional Authenticated Data Parameter' anchor="RSACBCAAD">
<t>
Concatenate
the Encoded JWE Header value, a period ('.') character,
and the Encoded JWE Encrypted Key
to create the Additional Authenticated Data parameter.
This result (with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMkmOm
kkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZjDYENR
WiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfEJmNmfsx5f
cB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWyEHW6WzQ4iH9S
IcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_NSsx24LxtK6fIkej
RlMBmCfxv0Tg8CtxpURigg
]]></artwork></figure>
<t>
The representation of this value is:
</t>
<t>
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 48, 69, 120,
88, 122, 85, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66,
77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50,
73, 110, 48, 46, 110, 74, 97, 95, 117, 69, 50, 68, 48, 119, 108, 75,
122, 45, 79, 99, 119, 83, 98, 75, 70, 122, 106, 51, 48, 50, 120, 89,
83, 73, 45, 82, 76, 66, 77, 54, 104, 98, 86, 71, 109, 80, 52, 97,
120, 116, 74, 81, 80, 65, 57, 83, 48, 112, 111, 51, 115, 51, 78, 77,
107, 109, 79, 109, 107, 107, 97, 119, 110, 102, 119, 80, 78, 106, 112, 99,
48, 109, 99, 51, 122, 55, 57, 99, 117, 81, 87, 107, 81, 80, 70, 81,
111, 45, 109, 68, 120, 109, 111, 103, 122, 56, 100, 120, 66, 99, 104, 101,
97, 84, 85, 103, 51, 90, 118, 112, 98, 71, 67, 88, 120, 90, 106, 68,
89, 69, 78, 82, 87, 105, 90, 53, 77, 57, 66, 105, 76, 121, 48, 57,
66, 73, 70, 53, 109, 72, 112, 56, 53, 81, 76, 54, 88, 69, 68, 49,
74, 69, 90, 77, 79, 104, 45, 49, 117, 84, 49, 108, 113, 80, 68, 99,
68, 68, 55, 57, 113, 87, 116, 114, 67, 102, 69, 74, 109, 78, 109, 102,
115, 120, 53, 102, 99, 66, 50, 80, 102, 65, 99, 86, 116, 81, 48, 116,
95, 89, 109, 79, 88, 120, 53, 95, 71, 117, 48, 105, 116, 49, 110, 73,
76, 75, 88, 76, 82, 50, 89, 110, 102, 57, 109, 102, 76, 104, 69, 99,
67, 53, 76, 101, 98, 112, 87, 121, 69, 72, 87, 54, 87, 122, 81, 52,
105, 72, 57, 83, 73, 99, 73, 117, 112, 80, 86, 49, 105, 75, 67, 122,
109, 74, 99, 80, 114, 68, 66, 74, 53, 70, 99, 95, 75, 77, 66, 99,
88, 66, 105, 110, 97, 83, 95, 95, 119, 102, 116, 78, 121, 119, 97, 71,
103, 102, 105, 95, 78, 83, 115, 120, 50, 52, 76, 120, 116, 75, 54, 102,
73, 107, 101, 106, 82, 108, 77, 66, 109, 67, 102, 120, 118, 48, 84, 103,
56, 67, 116, 120, 112, 85, 82, 105, 103, 103]
</t>
</section>
<section title="Plaintext Encryption" anchor="RSACBCEncryption">
<t>
Encrypt the Plaintext with AES_128_CBC_HMAC_SHA_256
using the CEK as the encryption key,
the JWE Initialization Vector,
and the Additional Authenticated Data value above.
The steps for doing this using the values from <xref target="WrapExample"/>
are detailed in <xref target="CBC_HMAC_Example"/>.
The resulting Ciphertext is:
</t>
<t>
[40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6, 75,
129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143, 112, 56, 102]
</t>
<t>
The resulting Authentication Tag value is:
</t>
<t>
[125, 141, 148, 252, 124, 121, 85, 199, 215, 154, 42, 68, 149, 209, 225, 48]
</t>
</section>
<section title="Encoded JWE Ciphertext" anchor="RSACBCEncodedCiphertext">
<t>
Base64url encode the Ciphertext to create the Encoded JWE Ciphertext.
This result is:
</t>
<figure><artwork><![CDATA[
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY
]]></artwork></figure>
</section>
<section title="Encoded JWE Authentication Tag" anchor="RSACBCEncodedTag">
<t>
Base64url encode the Authentication Tag to create
the Encoded JWE Authentication Tag.
This result is:
</t>
<figure><artwork><![CDATA[
fY2U_Hx5VcfXmipEldHhMA
]]></artwork></figure>
</section>
<section title="Complete Representation" anchor="RSACBCComplete">
<t>
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 Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings
being separated by four period ('.') characters.
</t>
<t>
The final result in this example
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMkmOm
kkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZjDYENR
WiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfEJmNmfsx5f
cB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWyEHW6WzQ4iH9S
IcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_NSsx24LxtK6fIkej
RlMBmCfxv0Tg8CtxpURigg.
AxY8DCtDaGlsbGljb3RoZQ.
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY.
fY2U_Hx5VcfXmipEldHhMA
]]></artwork></figure>
</section>
<section title="Validation" anchor="RSACBCValidation">
<t>
This example illustrates the process of creating a JWE with
RSAES-PKCS1-V1_5 and AES_CBC_HMAC_SHA2.
These results can be used to validate JWE decryption implementations for these algorithms.
Note that since the RSAES-PKCS1-V1_5 computation includes random values,
the encryption results above will not be completely reproducible.
However, since the AES CBC computation is deterministic, the JWE Encrypted Ciphertext
values will be the same for all encryptions performed using these inputs.
</t>
</section>
</section>
<section title="Example JWE using AES Key Wrap and AES GCM" anchor="WrapExample">
<t>
This example encrypts the plaintext
"Live long and prosper."
to the recipient using AES Key Wrap and AES GCM.
The representation of this plaintext is:
</t>
<t>
[76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114,
111, 115, 112, 101, 114, 46]
</t>
<section title="JWE Header" anchor="WrapHeader">
<t>
The following example JWE Header declares that:
<list style="symbols">
<t>
the Content Encryption Key is encrypted to the recipient
using the AES Key Wrap algorithm with a 128 bit key to produce
the JWE Encrypted Key and
</t>
<t>
the Plaintext is encrypted using the AES_128_CBC_HMAC_SHA_256
algorithm to produce the Ciphertext.
</t>
</list>
</t>
<figure><artwork><![CDATA[
{"alg":"A128KW","enc":"A128CBC-HS256"}
]]></artwork></figure>
</section>
<section title="Encoded JWE Header" anchor="WrapEncodedHeader">
<t>
Base64url encoding the octets of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
]]></artwork></figure>
</section>
<section title="Content Encryption Key (CEK)" anchor="WrapCEK">
<t>
Generate a 256 bit random Content Encryption Key (CEK).
In this example, the value is:
</t>
<t>
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106, 206,
107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156, 44, 207]
</t>
</section>
<section title="Key Encryption" anchor="WrapKeyEncryption">
<t>
Encrypt the CEK with the shared symmetric key using the AES Key Wrap
algorithm to produce the JWE Encrypted Key.
In this example, the shared symmetric key value is:
</t>
<t>
[25, 172, 32, 130, 225, 114, 26, 181, 138, 106, 254, 192, 95, 133, 74, 82]
</t>
<t>
The resulting JWE Encrypted Key value is:
</t>
<t>
[232, 160, 123, 211, 183, 76, 245, 132, 200, 128, 123, 75, 190, 216, 22, 67,
201, 138, 193, 186, 9, 91, 122, 31, 246, 90, 28, 139, 57, 3, 76, 124,
193, 11, 98, 37, 173, 61, 104, 57]
</t>
</section>
<section title="Encoded JWE Encrypted Key" anchor="WrapEncodedKey">
<t>
Base64url encode the JWE Encrypted Key to produce
the Encoded JWE Encrypted Key.
This result is:
</t>
<figure><artwork><![CDATA[
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ
]]></artwork></figure>
</section>
<section title="Initialization Vector" anchor="WrapIV">
<t>
Generate a random 128 bit JWE Initialization Vector.
In this example, the value is:
</t>
<t>
[3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101]
</t>
<t>
Base64url encoding this value yields the Encoded JWE Initialization Vector value:
</t>
<figure><artwork><![CDATA[
AxY8DCtDaGlsbGljb3RoZQ
]]></artwork></figure>
</section>
<section title='Additional Authenticated Data Parameter' anchor="WrapAAD">
<t>
Concatenate
the Encoded JWE Header value, a period ('.') character,
and the Encoded JWE Encrypted Key
to create the Additional Authenticated Data parameter.
This result (with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ
]]></artwork></figure>
<t>
The representation of this value is:
</t>
<t>
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52,
83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66,
77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50,
73, 110, 48, 46, 54, 75, 66, 55, 48, 55, 100, 77, 57, 89, 84, 73,
103, 72, 116, 76, 118, 116, 103, 87, 81, 56, 109, 75, 119, 98, 111, 74,
87, 51, 111, 102, 57, 108, 111, 99, 105, 122, 107, 68, 84, 72, 122, 66,
67, 50, 73, 108, 114, 84, 49, 111, 79, 81]
</t>
</section>
<section title="Plaintext Encryption" anchor="WrapEncryption">
<t>
Encrypt the Plaintext with AES_128_CBC_HMAC_SHA_256
using the CEK as the encryption key,
the JWE Initialization Vector,
and the Additional Authenticated Data value above.
The steps for doing this using the values from this example
are detailed in <xref target="CBC_HMAC_Example"/>.
The resulting Ciphertext is:
</t>
<t>
[40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6, 75,
129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143, 112, 56, 102]
</t>
<t>
The resulting Authentication Tag value is:
</t>
<t>
[8, 65, 248, 101, 45, 185, 28, 218, 232, 112, 83, 79, 84, 221, 18, 172]
</t>
</section>
<section title="Encoded JWE Ciphertext" anchor="WrapEncodedCiphertext">
<t>
Base64url encode the Ciphertext to create the Encoded JWE Ciphertext.
This result is:
</t>
<figure><artwork><![CDATA[
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY
]]></artwork></figure>
</section>
<section title="Encoded JWE Authentication Tag" anchor="WrapEncodedTag">
<t>
Base64url encode the Authentication Tag to create
the Encoded JWE Authentication Tag.
This result is:
</t>
<figure><artwork><![CDATA[
CEH4ZS25HNrocFNPVN0SrA
]]></artwork></figure>
</section>
<section title="Complete Representation" anchor="WrapComplete">
<t>
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 Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings
being separated by four period ('.') characters.
</t>
<t>
The final result in this example
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ.
AxY8DCtDaGlsbGljb3RoZQ.
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY.
CEH4ZS25HNrocFNPVN0SrA
]]></artwork></figure>
</section>
<section title="Validation" anchor="WrapValidation">
<t>
This example illustrates the process of creating a JWE with
symmetric key wrap and AES_CBC_HMAC_SHA2.
These results can be used to validate JWE decryption implementations for these algorithms.
Also, since both the AES Key Wrap and AES GCM computations are deterministic,
the resulting JWE value will be the same for all encryptions performed using these inputs.
Since the computation is reproducible, these results can also be used to validate
JWE encryption implementations for these algorithms.
</t>
</section>
</section>
</section>
<section title="Example AES_128_CBC_HMAC_SHA_256 Computation"
anchor="CBC_HMAC_Example">
<t>
This example shows the steps in the AES_128_CBC_HMAC_SHA_256
authenticated encryption computation using the values from
the example in <xref target="WrapExample"/>.
As described where this algorithm is defined in
Sections 4.8 and 4.8.3 of JWA, the AES_CBC_HMAC_SHA2 family
of algorithms are implemented using
Advanced Encryption Standard (AES) in Cipher Block Chaining (CBC) mode with PKCS #5 padding
to perform the encryption and
an HMAC SHA-2 function to perform the integrity calculation
- in this case, HMAC SHA-256.
</t>
<section title="Extract MAC_KEY and ENC_KEY from Key" anchor="ExtractKeys">
<t>
The 256 bit AES_128_CBC_HMAC_SHA_256 key K used in this example is:
</t>
<t>
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106, 206,
107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156, 44, 207]
</t>
<t>
Use the first 128 bits of this key as the HMAC SHA-256 key MAC_KEY, which is:
</t>
<t>
[4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106, 206]
</t>
<t>
Use the last 128 bits of this key as the AES CBC key ENC_KEY, which is:
</t>
<t>
[107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156, 44, 207]
</t>
<t>
Note that the MAC key comes before the encryption key in the input key K;
this is in the opposite order of the algorithm names in
the identifiers "AES_128_CBC_HMAC_SHA_256" and
<spanx style="verb">A128CBC-HS256</spanx>.
</t>
</section>
<section title="Encrypt Plaintext to Create Ciphertext"
anchor="EncryptWithCBC">
<t>
Encrypt the Plaintext with
AES in Cipher Block Chaining (CBC) mode using PKCS #5 padding
using the ENC_KEY above.
The Plaintext in this example is:
</t>
<t>
[76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114,
111, 115, 112, 101, 114, 46]
</t>
<t>
The encryption result is as follows, which is the Ciphertext output:
</t>
<t>
[40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6, 75,
129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143, 112, 56, 102]
</t>
</section>
<section title="Create 64 Bit Big Endian Representation of AAD Length"
anchor="CreateAL">
<t>
The Additional Authenticated Data (AAD) in this example is:
</t>
<t>
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52,
83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66,
77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50,
73, 110, 48, 46, 54, 75, 66, 55, 48, 55, 100, 77, 57, 89, 84, 73,
103, 72, 116, 76, 118, 116, 103, 87, 81, 56, 109, 75, 119, 98, 111, 74,
87, 51, 111, 102, 57, 108, 111, 99, 105, 122, 107, 68, 84, 72, 122, 66,
67, 50, 73, 108, 114, 84, 49, 111, 79, 81]
</t>
<t>
This AAD is 106 bytes long, which is 848 bits long.
The octet string AL, which is the number of bits in AAD
expressed as a big endian 64 bit unsigned integer is:
</t>
<t>
[0, 0, 0, 0, 0, 0, 3, 80]
</t>
</section>
<section title="Initialization Vector Value" anchor="IVValue">
<t>
The Initialization Vector value used in this example is:
</t>
<t>
[3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101]
</t>
</section>
<section title="Create Input to HMAC Computation" anchor="HMACInput">
<t>
Concatenate
the AAD,
the Initialization Vector,
the Ciphertext,
and the AL value.
The result of this concatenation is:
</t>
<t>
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52,
83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66,
77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50,
73, 110, 48, 46, 54, 75, 66, 55, 48, 55, 100, 77, 57, 89, 84, 73,
103, 72, 116, 76, 118, 116, 103, 87, 81, 56, 109, 75, 119, 98, 111, 74,
87, 51, 111, 102, 57, 108, 111, 99, 105, 122, 107, 68, 84, 72, 122, 66,
67, 50, 73, 108, 114, 84, 49, 111, 79, 81, 3, 22, 60, 12, 43, 67,
104, 105, 108, 108, 105, 99, 111, 116, 104, 101, 40, 57, 83, 181, 119, 33,
133, 148, 198, 185, 243, 24, 152, 230, 6, 75, 129, 223, 127, 19, 210, 82,
183, 230, 168, 33, 215, 104, 143, 112, 56, 102, 0, 0, 0, 0, 0, 0,
3, 80]
</t>
</section>
<section title="Compute HMAC Value" anchor="DoHMAC">
<t>
Compute the HMAC SHA-256 of the concatenated value above. This result M is:
</t>
<t>
[8, 65, 248, 101, 45, 185, 28, 218, 232, 112, 83, 79, 84, 221, 18, 172,
50, 145, 207, 8, 14, 74, 44, 220, 100, 117, 32, 57, 239, 149, 173, 226]
</t>
</section>
<section title="Truncate HMAC Value to Create Authentication Tag"
anchor="DoTruncate">
<t>
Use the first half (128 bits) of the HMAC output M as
the Authentication Tag output T. This truncated value is:
</t>
<t>
[8, 65, 248, 101, 45, 185, 28, 218, 232, 112, 83, 79, 84, 221, 18, 172]
</t>
</section>
</section>
<section title="Possible Compact Serialization for Multiple Recipients" anchor="CompactMulti">
<t>
The JWE encryption process in <xref target="Encryption"/>,
and in particular in steps 15 and 16, <!-- TBD check these numbers -->
hint at a possible compact serialization when there are multiple recipients.
This possible compact serialization concatenates instances of the
per-recipient fields, separating them with tilde ('~') characters,
which are URL-safe.
</t>
<t>
The concatenation of the Encoded JWE Header values goes
before the first period ('.') character in the compact serialization.
The concatenation of the corresponding Encoded JWE Encoded Key values goes
between the first and second period ('.') characters in the compact serialization.
</t>
<t>
A complete compact serialization of the multi-recipient
JWE in <xref target="JSONSerializationExample"/>
(with line breaks for display purposes only) would be:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
~
eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0
.
nJa_uE2D0wlKz-OcwSbKFzj302xYSI-RLBM6hbVGmP4axtJQPA9S0po3s3NMk
mOmkkawnfwPNjpc0mc3z79cuQWkQPFQo-mDxmogz8dxBcheaTUg3ZvpbGCXxZ
jDYENRWiZ5M9BiLy09BIF5mHp85QL6XED1JEZMOh-1uT1lqPDcDD79qWtrCfE
JmNmfsx5fcB2PfAcVtQ0t_YmOXx5_Gu0it1nILKXLR2Ynf9mfLhEcC5LebpWy
EHW6WzQ4iH9SIcIupPV1iKCzmJcPrDBJ5Fc_KMBcXBinaS__wftNywaGgfi_N
Ssx24LxtK6fIkejRlMBmCfxv0Tg8CtxpURigg
~
6KB707dM9YTIgHtLvtgWQ8mKwboJW3of9locizkDTHzBC2IlrT1oOQ
.
AxY8DCtDaGlsbGljb3RoZQ
.
KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY
.
LlhRZFfphc2f5X3nTTJP6g
]]></artwork></figure>
<t>
Note that the octets of the UTF-8 representation of
the first two parts of this serialization,
including the period ('.') character separating them,
are used as the AAD value in step 17 <!-- TBD check this number -->
of the JWE encryption process in <xref target="Encryption"/>.
</t>
<t>
This representation is suggested for those who may desire or require
a compact, URL-safe serialization of JWEs with multiple recipients.
It is a suggestion to implementers for whom this functionality
would be valuable, and not a normative part of this specification.
</t>
</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>
<t>
Thanks to Axel Nennker, Emmanuel Raviart, Brian Campbell, and Edmund Jay
for validating the examples in this specification.
</t>
<t>
This specification is the work of the JOSE Working Group,
which includes dozens of active and dedicated participants.
In particular, the following individuals contributed ideas,
feedback, and wording that influenced this specification:
</t>
<t>
Richard Barnes,
John Bradley,
Brian Campbell,
Breno de Medeiros,
Dick Hardt,
Jeff Hodges,
Edmund Jay,
James Manger,
Tony Nadalin,
Axel Nennker,
Emmanuel Raviart,
Nat Sakimura,
Jim Schaad,
Hannes Tschofenig,
and Sean Turner.
</t>
<t>
Jim Schaad and Karen O'Donoghue chaired the JOSE working group and
Sean Turner and Stephen Farrell served as Security area directors
during the creation of this specification.
</t>
</section>
<section title="Document History" anchor="History">
<t>
[[ to be removed by the RFC editor before publication as an RFC ]]
</t>
<t>
-10
<list style='symbols'>
<t>
Changed the JWE processing rules for multiple recipients so that
a single AAD value contains the header parameters and encrypted key
values for all the recipients,
enabling AES GCM to be safely used for multiple recipients.
</t>
<t>
Added an appendix suggesting a possible compact serialization
for JWEs with multiple recipients.
</t>
</list>
</t>
<t>
-09
<list style='symbols'>
<t>
Added JWE JSON Serialization, as specified by
draft-jones-jose-jwe-json-serialization-04.
</t>
<t>
Registered <spanx style="verb">application/jwe-js</spanx> MIME type
and <spanx style="verb">JWE-JS</spanx> typ header parameter value.
</t>
<t>
Defined that the default action for header parameters that
are not understood is to ignore them unless specifically
designated as "MUST be understood" or included in the new
<spanx style="verb">crit</spanx> (critical) header parameter list.
This addressed issue #6.
</t>
<t>
Corrected <spanx style="verb">x5c</spanx> description.
This addressed issue #12.
</t>
<t>
Changed from using the term "byte" to "octet" when referring to 8 bit values.
</t>
<t>
Added Key Management Mode definitions to terminology section
and used the defined terms to provide clearer key management instructions.
This addressed issue #5.
</t>
<t>
Added text about preventing the recipient from behaving as an oracle
during decryption, especially when using RSAES-PKCS1-V1_5.
</t>
<t>
Changed from using the term "Integrity Value" to "Authentication Tag".
</t>
<t>
Changed member name from <spanx style="verb">integrity_value</spanx> to
<spanx style="verb">authentication_tag</spanx> in the JWE JSON Serialization.
</t>
<t>
Removed Initialization Vector from the AAD value since it is already
integrity protected by all of the authenticated encryption algorithms
specified in the JWA specification.
</t>
<t>
Replaced <spanx style="verb">A128CBC+HS256</spanx>
and <spanx style="verb">A256CBC+HS512</spanx>
with <spanx style="verb">A128CBC-HS256</spanx>
and <spanx style="verb">A256CBC-HS512</spanx>.
The new algorithms perform the same cryptographic computations as
<xref target="I-D.mcgrew-aead-aes-cbc-hmac-sha2"/>,
but with the Initialization Vector and Authentication Tag values remaining
separate from the Ciphertext value in the output representation.
Also deleted the header parameters
<spanx style="verb">epu</spanx> (encryption PartyUInfo) and
<spanx style="verb">epv</spanx> (encryption PartyVInfo),
since they are no longer used.
</t>
</list>
</t>
<t>
-08
<list style='symbols'>
<t>
Replaced uses of the term "AEAD" with "Authenticated Encryption", since
the term AEAD in the RFC 5116 sense implied the use of a particular
data representation, rather than just referring to the class of
algorithms that perform authenticated encryption with associated data.
</t>
<t>
Applied editorial improvements suggested by
Jeff Hodges and Hannes Tschofenig.
Many of these simplified the terminology used.
</t>
<t>
Clarified statements of the form "This header parameter is OPTIONAL"
to "Use of this header parameter is OPTIONAL".
</t>
<t>
Added a Header Parameter Usage Location(s) field to the
IANA JSON Web Signature and Encryption Header Parameters registry.
</t>
<t>
Added seriesInfo information to Internet Draft references.
</t>
</list>
</t>
<t>
-07
<list style='symbols'>
<t>
Added a data length prefix to PartyUInfo and PartyVInfo values.
</t>
<t>
Updated values for example AES CBC calculations.
</t>
<t>
Made several local editorial changes to clean up loose ends
left over from to the decision to only support
block encryption methods providing integrity.
One of these changes was to explicitly state that the
<spanx style="verb">enc</spanx> (encryption method) algorithm
must be an Authenticated Encryption algorithm with a specified key length.
</t>
</list>
</t>
<t>
-06
<list style='symbols'>
<t>
Removed the <spanx style="verb">int</spanx> and
<spanx style="verb">kdf</spanx> parameters and defined the new composite
Authenticated Encryption algorithms <spanx style="verb">A128CBC+HS256</spanx> and
<spanx style="verb">A256CBC+HS512</spanx> to replace the former
uses of AES CBC, which required the use of separate integrity
and key derivation functions.
</t>
<t>
Included additional values in the Concat KDF calculation -- the
desired output size and the algorithm value,
and optionally PartyUInfo and PartyVInfo values.
Added the optional header parameters
<spanx style="verb">apu</spanx> (agreement PartyUInfo),
<spanx style="verb">apv</spanx> (agreement PartyVInfo),
<spanx style="verb">epu</spanx> (encryption PartyUInfo), and
<spanx style="verb">epv</spanx> (encryption PartyVInfo).
Updated the KDF examples accordingly.
</t>
<t>
Promoted Initialization Vector from being a header parameter to being
a top-level JWE element.
This saves approximately 16 bytes in the compact serialization,
which is a significant savings for some use cases.
Promoting the Initialization Vector out of the header also avoids repeating
this shared value in the JSON serialization.
</t>
<t>
Changed <spanx style="verb">x5c</spanx> (X.509 Certificate Chain)
representation from being a single string to being an array of strings,
each containing a single base64 encoded DER certificate value,
representing elements of the certificate chain.
</t>
<t>
Added an AES Key Wrap example.
</t>
<t>
Reordered the encryption steps so CMK creation is first, when required.
</t>
<t>
Correct statements in examples about which algorithms produce
reproducible results.
</t>
</list>
</t>
<t>
-05
<list style='symbols'>
<t>
Support both direct encryption using a
shared or agreed upon symmetric key, and the use of a
shared or agreed upon symmetric key to key wrap the CMK.
</t>
<t>
Added statement that
"StringOrURI values are compared as case-sensitive strings
with no transformations or canonicalizations applied".
</t>
<t>
Updated open issues.
</t>
<t>
Indented artwork elements to better distinguish them from the body text.
</t>
</list>
</t>
<t>
-04
<list style='symbols'>
<t>
Refer to the registries as the primary sources of defined
values and then secondarily reference the sections
defining the initial contents of the registries.
</t>
<t>
Normatively reference
<xref target="W3C.CR-xmlenc-core1-20120313">XML Encryption 1.1</xref>
for its security considerations.
</t>
<t>
Reference draft-jones-jose-jwe-json-serialization
instead of draft-jones-json-web-encryption-json-serialization.
</t>
<t>
Described additional open issues.
</t>
<t>
Applied editorial suggestions.
</t>
</list>
</t>
<t>
-03
<list style='symbols'>
<t>
Added the <spanx style="verb">kdf</spanx> (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.
</t>
<t>
Reordered encryption steps so that the Encoded JWE Header
is always created before it is needed as an input to the Authenticated Encryption
"additional authenticated data" parameter.
</t>
<t>
Added the <spanx style="verb">cty</spanx> (content type) header parameter
for declaring type information about the secured content,
as opposed to the <spanx style="verb">typ</spanx> (type) header parameter,
which declares type information about this object.
</t>
<t>
Moved description of how to determine whether a header is
for a JWS or a JWE from the JWT spec to the JWE spec.
</t>
<t>
Added complete encryption examples for both Authenticated Encryption and non-Authenticated Encryption algorithms.
</t>
<t>
Added complete key derivation examples.
</t>
<t>
Added "Collision Resistant Namespace" to the terminology section.
</t>
<t>
Reference ITU.X690.1994 for DER encoding.
</t>
<t>
Added Registry Contents sections to populate registry values.
</t>
<t>
Numerous editorial improvements.
</t>
</list>
</t>
<t>
-02
<list style='symbols'>
<t>
When using Authenticated Encryption 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 Authentication Tag.
</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-Authenticated Encryption 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:43:54 |