JOSE Working Group | M.B. Jones |
Internet-Draft | Microsoft |
Intended status: Standards Track | E. Rescorla |
Expires: September 11, 2012 | RTFM, Inc. |
J. Hildebrand | |
Cisco Systems, Inc. | |
March 12, 2012 |
JSON Web Encryption (JWE)
draft-ietf-jose-json-web-encryption-01
JSON Web Encryption (JWE) is a means of representing encrypted content using JSON data structures. Cryptographic algorithms and identifiers used with this specification are enumerated in the separate JSON Web Algorithms (JWA) specification. Related digital signature and HMAC capabilities are described in the separate JSON Web Signature (JWS) specification.
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 RFC 2119 [RFC2119].
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on September 11, 2012.
Copyright (c) 2012 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
JSON Web Encryption (JWE) is a compact encryption format intended for space constrained environments such as HTTP Authorization headers and URI query parameters. It provides a wrapper for encrypted content using JSON RFC 4627 [RFC4627] data structures. The JWE encryption mechanisms are independent of the type of content being encrypted. Cryptographic algorithms and identifiers used with this specification are enumerated in the separate JSON Web Algorithms (JWA) [JWA] specification. Related digital signature and HMAC capabilities are described in the separate JSON Web Signature (JWS) [JWS] specification.
JWE represents encrypted content using JSON data structures and base64url encoding. The representation consists of four parts: the JWE Header, the JWE Encrypted Key, the JWE Ciphertext, and the JWE Integrity Value. In the Compact Serialization, the four parts are base64url-encoded for transmission, and represented as the concatenation of the encoded strings in that order, with the four strings being separated by period ('.') characters. (A JSON Serialization for this information is defined in the separate JSON Web Encryption JSON Serialization (JWE-JS) [JWE-JS] specification.)
JWE utilizes encryption to ensure the confidentiality of the contents of the Plaintext. JWE adds a content integrity check if not provided by the underlying encryption algorithm.
The following example JWE Header declares that:
{"alg":"RSA1_5", "enc":"A256GCM", "iv":"__79_Pv6-fg", "jku":"https://example.com/public_key.jwk"}
Base64url encoding the bytes of the UTF-8 representation of the JWE Header yields this Encoded JWE Header value (with line breaks for display purposes only):
eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2R0NNIiwNCiAiaXYiOiJfXzc5 X1B2Ni1mZyIsDQogImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vcHVibGljX2tl eS5qd2sifQ
TBD: Finish this example by showing generation of a Content Master Key (CMK), saying that the CMK is used as the CEK and there is no separate integrity check since AES GCM is an AEAD algorithm, using the CEK to encrypt the Plaintext to produce the Ciphertext, using the recipient's key to encrypt the CMK to produce the JWE Encrypted Key, base64url encoding these values, and assembling the result.
Concatenating these parts in the order Header.EncryptedKey.Ciphertext.IntegrityValue with period characters between the parts yields this complete JWE representation (with line breaks for display purposes only):
eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2R0NNIiwNCiAiaXYiOiJfXzc5 X1B2Ni1mZyIsDQogImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vcHVibGljX2tl eS5qd2sifQ . TBD_encrypted_key_value_TBD . TBD_ciphertext_value_TBD .
The following example JWE Header declares that:
{"alg":"RSA1_5", "enc":"A256CBC", "int":"HS256", "iv":"Mz-mW_4JHfg", "x5t":"7noOPq-hJ1_hCnvWh6IeYI2w9Q0"}
Because AES CBC is not an AEAD algorithm (and so provides no integrated content integrity check), a separate integrity check value is used.
Base64url encoding the bytes of the UTF-8 representation of the JWE Header yields this Encoded JWE Header value (with line breaks for display purposes only):
eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2Q0JDIiwNCiAiaW50IjoiSFMy NTYiLA0KICJpdiI6Ik16LW1XXzRKSGZnIiwNCiAieDV0IjoiN25vT1BxLWhKMV9o Q252V2g2SWVZSTJ3OVEwIn0
TBD: Finish this example by showing generation of a Content Master Key (CMK), showing the derivation of the CEK and the CEK from the CMK, using the CEK to encrypt the Plaintext to produce the Ciphertext, using the recipient's key to encrypt the CMK to produce the JWE Encrypted Key, showing the computation of the JWE Integrity Value, base64url encoding these values, and assembling the result.
eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2Q0JDIiwNCiAiaW50IjoiSFMy NTYiLA0KICJpdiI6Ik16LW1XXzRKSGZnIiwNCiAieDV0IjoiN25vT1BxLWhKMV9o Q252V2g2SWVZSTJ3OVEwIn0 . TBD_encrypted_key_value_TBD . TBD_ciphertext_value_TBD . TBD_integrity_value_TBD
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. Implementations MUST understand the entire contents of the header; otherwise, the JWE MUST be rejected.
The following header parameter names are reserved. All the names are short because a core goal of JWE is for the representations to be compact.
Header Parameter Name | JSON Value Type | Header Parameter Syntax | Header Parameter Semantics |
---|---|---|---|
alg | string | StringOrURI | The alg (algorithm) header parameter identifies the cryptographic algorithm used to secure the JWE Encrypted Key. A list of defined encryption alg values is presented in Section 4, Table 2 of the JSON Web Algorithms (JWA) [JWA] specification. The processing of the alg (algorithm) header parameter requires that the value MUST be one that is both supported and for which there exists a key for use with that algorithm associated with the intended recipient. The alg value is case sensitive. This header parameter is REQUIRED. |
enc | string | StringOrURI | The enc (encryption method) header parameter identifies the symmetric encryption algorithm used to secure the Ciphertext. A list of defined enc values is presented in Section 4, Table 3 of the JSON Web Algorithms (JWA) [JWA] specification. The processing of the enc (encryption method) header parameter requires that the value MUST be one that is supported. The enc value is case sensitive. This header parameter is REQUIRED. |
int | string | StringOrURI | The int (integrity algorithm) header parameter identifies the cryptographic algorithm used to safeguard the integrity of the Ciphertext and the parameters used to create it. The int parameter uses the same values as the JWS alg parameter; a list of defined JWS alg values is presented in Section 3, Table 1 of the JSON Web Algorithms (JWA) [JWA] specification. This header parameter is REQUIRED when an AEAD algorithm is not used to encrypt the Plaintext and MUST NOT be present when an AEAD algorithm is used. |
iv | string | String | Initialization Vector (iv) value for algorithms requiring it, represented as a base64url encoded string. This header parameter is OPTIONAL. |
epk | object | JWK Key Object | Ephemeral Public Key (epk) value created by the originator for the use in ECDH-ES RFC 6090 [RFC6090] encryption. This key is represented in the same manner as a JSON Web Key [JWK] JWK Key Object value, containing crv (curve), x, and y members. The inclusion of the JWK Key Object alg (algorithm) member is OPTIONAL. This header parameter is OPTIONAL. |
zip | string | String | Compression algorithm (zip) applied to the Plaintext before encryption, if any. This specification defines the value GZIP to refer to the encoding format produced by the file compression program "gzip" (GNU zip) as described in [RFC1952]; this format is a Lempel-Ziv coding (LZ77) with a 32 bit CRC. If no zip parameter is present, or its value is none, no compression is applied to the Plaintext before encryption. The zip value is case sensitive. This header parameter is OPTIONAL. |
jku | string | URL | The jku (JSON Web Key URL) header parameter is an absolute URL that refers to a resource for a set of JSON-encoded public keys, one of which corresponds to the key that was used to encrypt the JWE. The keys MUST be encoded as described in the JSON Web Key (JWK) [JWK] specification. The protocol used to acquire the resource MUST provide integrity protection. An HTTP GET request to retrieve the certificate MUST use TLS RFC 2818 [RFC2818] RFC 5246 [RFC5246] with server authentication RFC 6125 [RFC6125]. This header parameter is OPTIONAL. |
kid | string | String | The kid (key ID) header parameter is a hint indicating which key was used to encrypt the JWE. This allows originators to explicitly signal a change of key to recipients. The interpretation of the contents of the kid parameter is unspecified. This header parameter is OPTIONAL. |
jpk | object | JWK Key Object | The jpk (JSON Public Key) header parameter is a public key that corresponds to the key that was used to encrypt the JWE. This key is represented in the same manner as a JSON Web Key [JWK] JWK Key Object value. This header parameter is OPTIONAL. |
x5u | string | URL | The x5u (X.509 URL) header parameter is an absolute URL that refers to a resource for the X.509 public key certificate or certificate chain corresponding to the key used to encrypt the JWE. The identified resource MUST provide a representation of the certificate or certificate chain that conforms to RFC 5280 [RFC5280] in PEM encoded form RFC 1421 [RFC1421]. The certificate containing the public key of the entity encrypting the JWE MUST be the first certificate. This MAY be followed by additional certificates, with each subsequent certificate being the one used to certify the previous one. The protocol used to acquire the resource MUST provide integrity protection. An HTTP GET request to retrieve the certificate MUST use TLS RFC 2818 [RFC2818] RFC 5246 [RFC5246] with server authentication RFC 6125 [RFC6125]. This header parameter is OPTIONAL. |
x5t | string | String | The x5t (x.509 certificate thumbprint) header parameter provides a base64url encoded SHA-1 thumbprint (a.k.a. digest) of the DER encoding of the X.509 certificate that corresponds to the key that was used to encrypt the JWE. This header parameter is OPTIONAL. |
x5c | array | ArrayOfStrings | The x5c (x.509 certificate chain) header parameter contains the X.509 public key certificate or certificate chain corresponding to the key used to encrypt the JWE. The certificate or certificate chain is represented as an array of certificate values. Each value is a base64-encoded (not base64url encoded) DER/BER PKIX certificate value. The certificate containing the public key of the entity encrypting the JWE MUST be the first certificate. This MAY be followed by additional certificates, with each subsequent certificate being the one used to certify the previous one. The recipient MUST verify the certificate chain according to [RFC5280] and reject the JWE if any validation failure occurs. This header parameter is OPTIONAL. |
typ | string | String | The typ (type) header parameter is used to declare the type of the encrypted content. The typ value is case sensitive. This header parameter is OPTIONAL. |
Additional reserved header parameter names MAY be defined via the IANA JSON Web Encryption Header Parameters registry, as per Section 11. The syntax values used above are defined as follows:
Syntax Name | Syntax Definition |
---|---|
String | Any string value MAY be used. |
StringOrURI | Any string value MAY be used but a value containing a ":" character MUST be a URI as defined in RFC 3986 [RFC3986]. |
URL | A URL as defined in RFC 1738 [RFC1738]. |
ArrayOfStrings | An array of string values. |
Additional header parameter names can be defined by those using JWE. However, in order to prevent collisions, any new header parameter name or algorithm value SHOULD either be defined in the IANA JSON Web Encryption Header Parameters registry or be defined as a URI that contains a collision resistant namespace. In each case, the definer of the name or value needs to take reasonable precautions to make sure they are in control of the part of the namespace they use to define the header parameter name.
New header parameters should be introduced sparingly since an implementation that does not understand a parameter MUST reject the JWE.
A producer and consumer of a JWE may agree to any header parameter name that is not a Reserved Name Section 4.1 or a Public Name Section 4.2. Unlike Public Names, these private names are subject to collision and should be used with caution.
New header parameters should be introduced sparingly, as they can result in non-interoperable JWEs.
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.
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.
The key derivation process converts the CMK into a CEK and a CIK. It assumes as a primitive a Key Derivation Function (KDF) which notionally takes three arguments: [NIST-800-56A], where the Digest Method is SHA-256, the SuppPubInfo parameter is the Label, and the remaining OtherInfo parameters are the empty bit string.
The only KDF used in this document is the Concat KDF, as defined in
To compute the CEK from the CMK, the ASCII label "Encryption" is used.
To compute the CIK from the CMK, the ASCII label "Integrity" is used.
When AEAD algorithms are used the KDF element MUST NOT be present. When they are not used, it MUST be present.
JWE supports two forms of CMK encryption:
In the asymmetric encryption mode, the CMK is encrypted under the recipient's public key. The asymmetric encryption modes defined for use with this in this specification are listed in Section 4, Table 2 of the JSON Web Algorithms (JWA) [JWA] specification.
In the symmetric encryption mode, the CMK is encrypted under a symmetric key shared between the sender and receiver. The symmetric encryption modes defined for use with this in this specification are listed in Section 4, Table 2 of the JSON Web Algorithms (JWA) [JWA] specification. For GCM, the random 64-bit IV is prepended to the ciphertext.
When a non-AEAD algorithm is used (an algorithm without an integrated content check), JWE adds an explicit integrity check value to the representation. This value is computed in the manner described in the JSON Web Signature (JWS) [JWS] specification, with these modifications:
The computed JWS Signature value is the resulting integrity value.
JWE uses cryptographic algorithms to encrypt the Content Encryption Key (CMK) and the Plaintext. The JSON Web Algorithms (JWA) [JWA] specification enumerates a set of cryptographic algorithms and identifiers to be used with this specification. Specifically, Section 4, Table 2 enumerates a set of alg (algorithm) header parameter values and Section 4, Table 3 enumerates a set of enc (encryption method) header parameter values intended for use this specification. It also describes the semantics and operations that are specific to these algorithms and algorithm families.
Public keys employed for encryption can be identified using the Header Parameter methods described in Section 4.1 or can be distributed using methods that are outside the scope of this specification.
This specification calls for:
TBD: Lots of work to do here. We need to remember to look into any issues relating to security and JSON parsing. One wonders just how secure most JSON parsing libraries are. Were they ever hardened for security scenarios? If not, what kind of holes does that open up? Also, we need to walk through the JSON standard and see what kind of issues we have especially around comparison of names. For instance, comparisons of header parameter names and other parameters must occur after they are unescaped. Need to also put in text about: Importance of keeping secrets secret. Rotating keys. Strengths and weaknesses of the different algorithms.
TBD: Need to put in text about why strict JSON validation is necessary. Basically, that if malformed JSON is received then the intent of the sender is impossible to reliably discern. One example of malformed JSON that MUST be rejected is an object in which the same member name occurs multiple times.
TBD: We need a section on generating randomness in browsers - it's easy to screw up.
When utilizing TLS to retrieve information, the authority providing the resource MUST be authenticated and the information retrieved MUST be free from modification.
Header parameter names in JWEs are Unicode strings. For security reasons, the representations of these names must be compared verbatim after performing any escape processing (as per RFC 4627 [RFC4627], Section 2.5).
This means, for instance, that these JSON strings must compare as being equal ("enc", "\u0065nc"), whereas these must all compare as being not equal to the first set or to each other ("ENC", "Enc", "en\u0043").
JSON strings MAY contain characters outside the Unicode Basic Multilingual Plane. For instance, the G clef character (U+1D11E) may be represented in a JSON string as "\uD834\uDD1E". Ideally, JWE implementations SHOULD ensure that characters outside the Basic Multilingual Plane are preserved and compared correctly; alternatively, if this is not possible due to these characters exercising limitations present in the underlying JSON implementation, then input containing them MUST be rejected.
The following items remain to be done in this draft:
[RFC5652] | Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, RFC 5652, September 2009. |
[W3C.CR-xmlenc-core1-20110303] | Hirsch, F., Roessler, T., Reagle, J. and D. Eastlake, "XML Encryption Syntax and Processing Version 1.1", World Wide Web Consortium CR CR-xmlenc-core1-20110303, March 2011. |
[I-D.rescorla-jsms] | Rescorla, E and J Hildebrand, "JavaScript Message Security Format", Internet-Draft draft-rescorla-jsms-00, March 2011. |
[JWE-JS] | Jones, M.B., "JSON Web Encryption JSON Serialization (JWE-JS)", March 2012. |
[JSE] | Bradley, J. and N. Sakimura (editor), "JSON Simple Encryption", September 2010. |
This section provides several examples of JWEs.
TBD: Demonstrate encryption steps with this algorithm
TBD: Demonstrate decryption steps with this algorithm
Solutions for encrypting JSON content were also explored by JSON Simple Encryption [JSE] and JavaScript Message Security Format [I-D.rescorla-jsms], both of which significantly influenced this draft. This draft attempts to explicitly reuse as many of the relevant concepts from XML Encryption 1.1 [W3C.CR-xmlenc-core1-20110303] and RFC 5652 [RFC5652] as possible, while utilizing simple compact JSON-based data structures.
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 [I-D.rescorla-jsms] in this document.
-01
-00