idnits 2.17.1 draft-ietf-jose-json-web-encryption-01.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (March 12, 2012) is 4428 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'NIST-800-38D' is defined on line 892, but no explicit reference was found in the text -- Possible downref: Non-RFC (?) normative reference: ref. 'JWA' -- Possible downref: Non-RFC (?) normative reference: ref. 'JWK' -- Possible downref: Non-RFC (?) normative reference: ref. 'JWS' -- Possible downref: Non-RFC (?) normative reference: ref. 'NIST-800-38D' -- Possible downref: Non-RFC (?) normative reference: ref. 'NIST-800-56A' ** Downref: Normative reference to an Historic RFC: RFC 1421 ** Obsolete normative reference: RFC 1738 (Obsoleted by RFC 4248, RFC 4266) ** Downref: Normative reference to an Informational RFC: RFC 1952 ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 4627 (Obsoleted by RFC 7158, RFC 7159) ** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126) ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Downref: Normative reference to an Informational RFC: RFC 6090 ** Obsolete normative reference: RFC 6125 (Obsoleted by RFC 9525) Summary: 9 errors (**), 0 flaws (~~), 2 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 JOSE Working Group M. Jones 3 Internet-Draft Microsoft 4 Intended status: Standards Track E. Rescorla 5 Expires: September 13, 2012 RTFM, Inc. 6 J. Hildebrand 7 Cisco Systems, Inc. 8 March 12, 2012 10 JSON Web Encryption (JWE) 11 draft-ietf-jose-json-web-encryption-01 13 Abstract 15 JSON Web Encryption (JWE) is a means of representing encrypted 16 content using JSON data structures. Cryptographic algorithms and 17 identifiers used with this specification are enumerated in the 18 separate JSON Web Algorithms (JWA) specification. Related digital 19 signature and HMAC capabilities are described in the separate JSON 20 Web Signature (JWS) specification. 22 Requirements Language 24 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 25 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 26 document are to be interpreted as described in RFC 2119 [RFC2119]. 28 Status of this Memo 30 This Internet-Draft is submitted in full conformance with the 31 provisions of BCP 78 and BCP 79. 33 Internet-Drafts are working documents of the Internet Engineering 34 Task Force (IETF). Note that other groups may also distribute 35 working documents as Internet-Drafts. The list of current Internet- 36 Drafts is at http://datatracker.ietf.org/drafts/current/. 38 Internet-Drafts are draft documents valid for a maximum of six months 39 and may be updated, replaced, or obsoleted by other documents at any 40 time. It is inappropriate to use Internet-Drafts as reference 41 material or to cite them other than as "work in progress." 43 This Internet-Draft will expire on September 13, 2012. 45 Copyright Notice 47 Copyright (c) 2012 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents 52 (http://trustee.ietf.org/license-info) in effect on the date of 53 publication of this document. Please review these documents 54 carefully, as they describe your rights and restrictions with respect 55 to this document. Code Components extracted from this document must 56 include Simplified BSD License text as described in Section 4.e of 57 the Trust Legal Provisions and are provided without warranty as 58 described in the Simplified BSD License. 60 Table of Contents 62 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 63 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 64 3. JSON Web Encryption (JWE) Overview . . . . . . . . . . . . . . 4 65 3.1. Example JWE with an Integrated Integrity Check . . . . . . 5 66 3.2. Example JWE with a Separate Integrity Check . . . . . . . 6 67 4. JWE Header . . . . . . . . . . . . . . . . . . . . . . . . . . 7 68 4.1. Reserved Header Parameter Names . . . . . . . . . . . . . 7 69 4.2. Public Header Parameter Names . . . . . . . . . . . . . . 14 70 4.3. Private Header Parameter Names . . . . . . . . . . . . . . 14 71 5. Message Encryption . . . . . . . . . . . . . . . . . . . . . . 14 72 6. Message Decryption . . . . . . . . . . . . . . . . . . . . . . 16 73 7. Key Derivation . . . . . . . . . . . . . . . . . . . . . . . . 17 74 8. CMK Encryption . . . . . . . . . . . . . . . . . . . . . . . . 17 75 8.1. Asymmetric Encryption . . . . . . . . . . . . . . . . . . 17 76 8.2. Symmetric Encryption . . . . . . . . . . . . . . . . . . . 18 77 9. Integrity Value Calculation . . . . . . . . . . . . . . . . . 18 78 10. Encrypting JWEs with Cryptographic Algorithms . . . . . . . . 18 79 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 19 80 12. Security Considerations . . . . . . . . . . . . . . . . . . . 19 81 12.1. Unicode Comparison Security Issues . . . . . . . . . . . . 19 82 13. Open Issues and Things To Be Done (TBD) . . . . . . . . . . . 20 83 14. References . . . . . . . . . . . . . . . . . . . . . . . . . . 21 84 14.1. Normative References . . . . . . . . . . . . . . . . . . . 21 85 14.2. Informative References . . . . . . . . . . . . . . . . . . 22 86 Appendix A. JWE Examples . . . . . . . . . . . . . . . . . . . . 23 87 A.1. JWE Example using TBD Algorithm . . . . . . . . . . . . . 23 88 A.1.1. Encrypting . . . . . . . . . . . . . . . . . . . . . . 23 89 A.1.2. Decrypting . . . . . . . . . . . . . . . . . . . . . . 23 90 Appendix B. Acknowledgements . . . . . . . . . . . . . . . . . . 23 91 Appendix C. Document History . . . . . . . . . . . . . . . . . . 23 92 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 24 94 1. Introduction 96 JSON Web Encryption (JWE) is a compact encryption format intended for 97 space constrained environments such as HTTP Authorization headers and 98 URI query parameters. It provides a wrapper for encrypted content 99 using JSON RFC 4627 [RFC4627] data structures. The JWE encryption 100 mechanisms are independent of the type of content being encrypted. 101 Cryptographic algorithms and identifiers used with this specification 102 are enumerated in the separate JSON Web Algorithms (JWA) [JWA] 103 specification. Related digital signature and HMAC capabilities are 104 described in the separate JSON Web Signature (JWS) [JWS] 105 specification. 107 2. Terminology 109 JSON Web Encryption (JWE) A data structure representing an encrypted 110 version of a Plaintext. The structure consists of four parts: the 111 JWE Header, the JWE Encrypted Key, the JWE Ciphertext, and the JWE 112 Integrity Value. 114 Plaintext The bytes to be encrypted - a.k.a., the message. 116 Ciphertext The encrypted version of the Plaintext. 118 Content Encryption Key (CEK) A symmetric key used to encrypt the 119 Plaintext for the recipient to produce the Ciphertext. 121 Content Integrity Key (CIK) A key used with an HMAC function to 122 ensure the integrity of the Ciphertext and the parameters used to 123 create it. 125 Content Master Key (CMK) A randomly generated key from which the CEK 126 and CIK are derived, which is encrypted to the recipient as the 127 JWE Encrypted Key. 129 JWE Header A string representing a JSON object that describes the 130 encryption operations applied to create the JWE Encrypted Key and 131 the JWE Ciphertext. 133 JWE Encrypted Key The Content Encryption Key (CEK) is encrypted with 134 the intended recipient's key and the resulting encrypted content 135 is recorded as a byte array, which is referred to as the JWE 136 Encrypted Key. 138 JWE Ciphertext A byte array containing the Ciphertext. 140 JWE Integrity Value A byte array containing a HMAC value that 141 ensures the integrity of the Ciphertext and the parameters used to 142 create it. 144 Encoded JWE Header Base64url encoding of the bytes of the UTF-8 RFC 145 3629 [RFC3629] representation of the JWE Header. 147 Encoded JWE Encrypted Key Base64url encoding of the JWE Encrypted 148 Key. 150 Encoded JWE Ciphertext Base64url encoding of the JWE Ciphertext. 152 Encoded JWE Integrity Value Base64url encoding of the JWE Integrity 153 Value. 155 Header Parameter Names The names of the members within the JWE 156 Header. 158 Header Parameter Values The values of the members within the JWE 159 Header. 161 JWE Compact Serialization A representation of the JWE as the 162 concatenation of the Encoded JWE Header, the Encoded JWE Encrypted 163 Key, the Encoded JWE Ciphertext, and the Encoded JWE Integrity 164 Value in that order, with the four strings being separated by 165 period ('.') characters. 167 AEAD Algorithm An Authenticated Encryption with Associated Data 168 (AEAD) [RFC5116] encryption algorithm is one that provides an 169 integrated content integrity check. AES Galois/Counter Mode (GCM) 170 is one such algorithm. 172 Base64url Encoding For the purposes of this specification, this term 173 always refers to the URL- and filename-safe Base64 encoding 174 described in RFC 4648 [RFC4648], Section 5, with the (non URL- 175 safe) '=' padding characters omitted, as permitted by Section 3.2. 176 (See Appendix B of [JWS] for notes on implementing base64url 177 encoding without padding.) 179 3. JSON Web Encryption (JWE) Overview 181 JWE represents encrypted content using JSON data structures and 182 base64url encoding. The representation consists of four parts: the 183 JWE Header, the JWE Encrypted Key, the JWE Ciphertext, and the JWE 184 Integrity Value. In the Compact Serialization, the four parts are 185 base64url-encoded for transmission, and represented as the 186 concatenation of the encoded strings in that order, with the four 187 strings being separated by period ('.') characters. (A JSON 188 Serialization for this information is defined in the separate JSON 189 Web Encryption JSON Serialization (JWE-JS) [JWE-JS] specification.) 191 JWE utilizes encryption to ensure the confidentiality of the contents 192 of the Plaintext. JWE adds a content integrity check if not provided 193 by the underlying encryption algorithm. 195 3.1. Example JWE with an Integrated Integrity Check 197 The following example JWE Header declares that: 199 o the Content Master Key is encrypted to the recipient using the 200 RSA-PKCS1_1.5 algorithm to produce the JWE Encrypted Key, 202 o the Plaintext is encrypted using the AES-256-GCM algorithm to 203 produce the JWE Ciphertext, 205 o the specified 64-bit Initialization Vector with the base64url 206 encoding "__79_Pv6-fg" was used, and 208 o a JSON Web Key (JWK) representation of the public key used to 209 encrypt the JWE is located at 210 "https://example.com/public_key.jwk". 212 {"alg":"RSA1_5", 213 "enc":"A256GCM", 214 "iv":"__79_Pv6-fg", 215 "jku":"https://example.com/public_key.jwk"} 217 Base64url encoding the bytes of the UTF-8 representation of the JWE 218 Header yields this Encoded JWE Header value (with line breaks for 219 display purposes only): 220 eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2R0NNIiwNCiAiaXYiOiJfXzc5 221 X1B2Ni1mZyIsDQogImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vcHVibGljX2tl 222 eS5qd2sifQ 224 TBD: Finish this example by showing generation of a Content Master 225 Key (CMK), saying that the CMK is used as the CEK and there is no 226 separate integrity check since AES GCM is an AEAD algorithm, using 227 the CEK to encrypt the Plaintext to produce the Ciphertext, using the 228 recipient's key to encrypt the CMK to produce the JWE Encrypted Key, 229 base64url encoding these values, and assembling the result. 231 Concatenating these parts in the order 232 Header.EncryptedKey.Ciphertext.IntegrityValue with period characters 233 between the parts yields this complete JWE representation (with line 234 breaks for display purposes only): 235 eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2R0NNIiwNCiAiaXYiOiJfXzc5 236 X1B2Ni1mZyIsDQogImprdSI6Imh0dHBzOi8vZXhhbXBsZS5jb20vcHVibGljX2tl 237 eS5qd2sifQ 238 . 239 TBD_encrypted_key_value_TBD 240 . 241 TBD_ciphertext_value_TBD 242 . 244 3.2. Example JWE with a Separate Integrity Check 246 The following example JWE Header declares that: 248 o the Content Master Key is encrypted to the recipient using the 249 RSA-PKCS1_1.5 algorithm to produce the JWE Encrypted Key, 251 o the Plaintext is encrypted using the AES-256-CBC algorithm to 252 produce the JWE Ciphertext, 254 o the JWE Integrity Value safeguarding the integrity of the 255 Ciphertext and the parameters used to create it was computed with 256 the HMAC SHA-256 algorithm, 258 o the specified 64-bit Initialization Vector with the base64url 259 encoding "Mz-mW_4JHfg" was used, and 261 o the thumbprint of the X.509 certificate that corresponds to the 262 key used to encrypt the JWE has the base64url encoding 263 "7noOPq-hJ1_hCnvWh6IeYI2w9Q0". 265 {"alg":"RSA1_5", 266 "enc":"A256CBC", 267 "int":"HS256", 268 "iv":"Mz-mW_4JHfg", 269 "x5t":"7noOPq-hJ1_hCnvWh6IeYI2w9Q0"} 271 Because AES CBC is not an AEAD algorithm (and so provides no 272 integrated content integrity check), a separate integrity check value 273 is used. 275 Base64url encoding the bytes of the UTF-8 representation of the JWE 276 Header yields this Encoded JWE Header value (with line breaks for 277 display purposes only): 278 eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2Q0JDIiwNCiAiaW50IjoiSFMy 279 NTYiLA0KICJpdiI6Ik16LW1XXzRKSGZnIiwNCiAieDV0IjoiN25vT1BxLWhKMV9o 280 Q252V2g2SWVZSTJ3OVEwIn0 281 TBD: Finish this example by showing generation of a Content Master 282 Key (CMK), showing the derivation of the CEK and the CEK from the 283 CMK, using the CEK to encrypt the Plaintext to produce the 284 Ciphertext, using the recipient's key to encrypt the CMK to produce 285 the JWE Encrypted Key, showing the computation of the JWE Integrity 286 Value, base64url encoding these values, and assembling the result. 287 eyJhbGciOiJSU0ExXzUiLA0KICJlbmMiOiJBMjU2Q0JDIiwNCiAiaW50IjoiSFMy 288 NTYiLA0KICJpdiI6Ik16LW1XXzRKSGZnIiwNCiAieDV0IjoiN25vT1BxLWhKMV9o 289 Q252V2g2SWVZSTJ3OVEwIn0 290 . 291 TBD_encrypted_key_value_TBD 292 . 293 TBD_ciphertext_value_TBD 294 . 295 TBD_integrity_value_TBD 297 4. JWE Header 299 The members of the JSON object represented by the JWE Header describe 300 the encryption applied to the Plaintext and optionally additional 301 properties of the JWE. The Header Parameter Names within this object 302 MUST be unique. Implementations MUST understand the entire contents 303 of the header; otherwise, the JWE MUST be rejected. 305 4.1. Reserved Header Parameter Names 307 The following header parameter names are reserved. All the names are 308 short because a core goal of JWE is for the representations to be 309 compact. 311 +-----------+--------+----------------+-----------------------------+ 312 | Header | JSON | Header | Header Parameter Semantics | 313 | Parameter | Value | Parameter | | 314 | Name | Type | Syntax | | 315 +-----------+--------+----------------+-----------------------------+ 316 | alg | string | StringOrURI | The "alg" (algorithm) | 317 | | | | header parameter identifies | 318 | | | | the cryptographic algorithm | 319 | | | | used to secure the JWE | 320 | | | | Encrypted Key. A list of | 321 | | | | defined encryption "alg" | 322 | | | | values is presented in | 323 | | | | Section 4, Table 2 of the | 324 | | | | JSON Web Algorithms (JWA) | 325 | | | | [JWA] specification. The | 326 | | | | processing of the "alg" | 327 | | | | (algorithm) header | 328 | | | | parameter requires that the | 329 | | | | value MUST be one that is | 330 | | | | both supported and for | 331 | | | | which there exists a key | 332 | | | | for use with that algorithm | 333 | | | | associated with the | 334 | | | | intended recipient. The | 335 | | | | "alg" value is case | 336 | | | | sensitive. This header | 337 | | | | parameter is REQUIRED. | 338 | enc | string | StringOrURI | The "enc" (encryption | 339 | | | | method) header parameter | 340 | | | | identifies the symmetric | 341 | | | | encryption algorithm used | 342 | | | | to secure the Ciphertext. | 343 | | | | A list of defined "enc" | 344 | | | | values is presented in | 345 | | | | Section 4, Table 3 of the | 346 | | | | JSON Web Algorithms (JWA) | 347 | | | | [JWA] specification. The | 348 | | | | processing of the "enc" | 349 | | | | (encryption method) header | 350 | | | | parameter requires that the | 351 | | | | value MUST be one that is | 352 | | | | supported. The "enc" value | 353 | | | | is case sensitive. This | 354 | | | | header parameter is | 355 | | | | REQUIRED. | 356 | int | string | StringOrURI | The "int" (integrity | 357 | | | | algorithm) header parameter | 358 | | | | identifies the | 359 | | | | cryptographic algorithm | 360 | | | | used to safeguard the | 361 | | | | integrity of the Ciphertext | 362 | | | | and the parameters used to | 363 | | | | create it. The "int" | 364 | | | | parameter uses the same | 365 | | | | values as the JWS "alg" | 366 | | | | parameter; a list of | 367 | | | | defined JWS "alg" values is | 368 | | | | presented in Section 3, | 369 | | | | Table 1 of the JSON Web | 370 | | | | Algorithms (JWA) [JWA] | 371 | | | | specification. This header | 372 | | | | parameter is REQUIRED when | 373 | | | | an AEAD algorithm is not | 374 | | | | used to encrypt the | 375 | | | | Plaintext and MUST NOT be | 376 | | | | present when an AEAD | 377 | | | | algorithm is used. | 378 | iv | string | String | Initialization Vector | 379 | | | | ("iv") value for algorithms | 380 | | | | requiring it, represented | 381 | | | | as a base64url encoded | 382 | | | | string. This header | 383 | | | | parameter is OPTIONAL. | 384 | epk | object | JWK Key Object | Ephemeral Public Key | 385 | | | | ("epk") value created by | 386 | | | | the originator for the use | 387 | | | | in ECDH-ES RFC 6090 | 388 | | | | [RFC6090] encryption. This | 389 | | | | key is represented in the | 390 | | | | same manner as a JSON Web | 391 | | | | Key [JWK] JWK Key Object | 392 | | | | value, containing "crv" | 393 | | | | (curve), "x", and "y" | 394 | | | | members. The inclusion of | 395 | | | | the JWK Key Object "alg" | 396 | | | | (algorithm) member is | 397 | | | | OPTIONAL. This header | 398 | | | | parameter is OPTIONAL. | 399 | zip | string | String | Compression algorithm | 400 | | | | ("zip") applied to the | 401 | | | | Plaintext before | 402 | | | | encryption, if any. This | 403 | | | | specification defines the | 404 | | | | value "GZIP" to refer to | 405 | | | | the encoding format | 406 | | | | produced by the file | 407 | | | | compression program "gzip" | 408 | | | | (GNU zip) as described in | 409 | | | | [RFC1952]; this format is a | 410 | | | | Lempel-Ziv coding (LZ77) | 411 | | | | with a 32 bit CRC. If no | 412 | | | | "zip" parameter is present, | 413 | | | | or its value is "none", no | 414 | | | | compression is applied to | 415 | | | | the Plaintext before | 416 | | | | encryption. The "zip" | 417 | | | | value is case sensitive. | 418 | | | | This header parameter is | 419 | | | | OPTIONAL. | 420 | jku | string | URL | The "jku" (JSON Web Key | 421 | | | | URL) header parameter is an | 422 | | | | absolute URL that refers to | 423 | | | | a resource for a set of | 424 | | | | JSON-encoded public keys, | 425 | | | | one of which corresponds to | 426 | | | | the key that was used to | 427 | | | | encrypt the JWE. The keys | 428 | | | | MUST be encoded as | 429 | | | | described in the JSON Web | 430 | | | | Key (JWK) [JWK] | 431 | | | | specification. The | 432 | | | | protocol used to acquire | 433 | | | | the resource MUST provide | 434 | | | | integrity protection. An | 435 | | | | HTTP GET request to | 436 | | | | retrieve the certificate | 437 | | | | MUST use TLS RFC 2818 | 438 | | | | [RFC2818] RFC 5246 | 439 | | | | [RFC5246] with server | 440 | | | | authentication RFC 6125 | 441 | | | | [RFC6125]. This header | 442 | | | | parameter is OPTIONAL. | 443 | kid | string | String | The "kid" (key ID) header | 444 | | | | parameter is a hint | 445 | | | | indicating which key was | 446 | | | | used to encrypt the JWE. | 447 | | | | This allows originators to | 448 | | | | explicitly signal a change | 449 | | | | of key to recipients. The | 450 | | | | interpretation of the | 451 | | | | contents of the "kid" | 452 | | | | parameter is unspecified. | 453 | | | | This header parameter is | 454 | | | | OPTIONAL. | 455 | jpk | object | JWK Key Object | The "jpk" (JSON Public Key) | 456 | | | | header parameter is a | 457 | | | | public key that corresponds | 458 | | | | to the key that was used to | 459 | | | | encrypt the JWE. This key | 460 | | | | is represented in the same | 461 | | | | manner as a JSON Web Key | 462 | | | | [JWK] JWK Key Object value. | 463 | | | | This header parameter is | 464 | | | | OPTIONAL. | 465 | x5u | string | URL | The "x5u" (X.509 URL) | 466 | | | | header parameter is an | 467 | | | | absolute URL that refers to | 468 | | | | a resource for the X.509 | 469 | | | | public key certificate or | 470 | | | | certificate chain | 471 | | | | corresponding to the key | 472 | | | | used to encrypt the JWE. | 473 | | | | The identified resource | 474 | | | | MUST provide a | 475 | | | | representation of the | 476 | | | | certificate or certificate | 477 | | | | chain that conforms to RFC | 478 | | | | 5280 [RFC5280] in PEM | 479 | | | | encoded form RFC 1421 | 480 | | | | [RFC1421]. The certificate | 481 | | | | containing the public key | 482 | | | | of the entity encrypting | 483 | | | | the JWE MUST be the first | 484 | | | | certificate. This MAY be | 485 | | | | followed by additional | 486 | | | | certificates, with each | 487 | | | | subsequent certificate | 488 | | | | being the one used to | 489 | | | | certify the previous one. | 490 | | | | The protocol used to | 491 | | | | acquire the resource MUST | 492 | | | | provide integrity | 493 | | | | protection. An HTTP GET | 494 | | | | request to retrieve the | 495 | | | | certificate MUST use TLS | 496 | | | | RFC 2818 [RFC2818] RFC 5246 | 497 | | | | [RFC5246] with server | 498 | | | | authentication RFC 6125 | 499 | | | | [RFC6125]. This header | 500 | | | | parameter is OPTIONAL. | 501 | x5t | string | String | The "x5t" (x.509 | 502 | | | | certificate thumbprint) | 503 | | | | header parameter provides a | 504 | | | | base64url encoded SHA-1 | 505 | | | | thumbprint (a.k.a. digest) | 506 | | | | of the DER encoding of the | 507 | | | | X.509 certificate that | 508 | | | | corresponds to the key that | 509 | | | | was used to encrypt the | 510 | | | | JWE. This header parameter | 511 | | | | is OPTIONAL. | 512 | x5c | array | ArrayOfStrings | The "x5c" (x.509 | 513 | | | | certificate chain) header | 514 | | | | parameter contains the | 515 | | | | X.509 public key | 516 | | | | certificate or certificate | 517 | | | | chain corresponding to the | 518 | | | | key used to encrypt the | 519 | | | | JWE. The certificate or | 520 | | | | certificate chain is | 521 | | | | represented as an array of | 522 | | | | certificate values. Each | 523 | | | | value is a base64-encoded | 524 | | | | (not base64url encoded) | 525 | | | | DER/BER PKIX certificate | 526 | | | | value. The certificate | 527 | | | | containing the public key | 528 | | | | of the entity encrypting | 529 | | | | the JWE MUST be the first | 530 | | | | certificate. This MAY be | 531 | | | | followed by additional | 532 | | | | certificates, with each | 533 | | | | subsequent certificate | 534 | | | | being the one used to | 535 | | | | certify the previous one. | 536 | | | | The recipient MUST verify | 537 | | | | the certificate chain | 538 | | | | according to [RFC5280] and | 539 | | | | reject the JWE if any | 540 | | | | validation failure occurs. | 541 | | | | This header parameter is | 542 | | | | OPTIONAL. | 543 | typ | string | String | The "typ" (type) header | 544 | | | | parameter is used to | 545 | | | | declare the type of the | 546 | | | | encrypted content. The | 547 | | | | "typ" value is case | 548 | | | | sensitive. This header | 549 | | | | parameter is OPTIONAL. | 550 +-----------+--------+----------------+-----------------------------+ 552 Table 1: Reserved Header Parameter Definitions 554 Additional reserved header parameter names MAY be defined via the 555 IANA JSON Web Encryption Header Parameters registry, as per 556 Section 11. The syntax values used above are defined as follows: 558 +----------------+--------------------------------------------------+ 559 | Syntax Name | Syntax Definition | 560 +----------------+--------------------------------------------------+ 561 | String | Any string value MAY be used. | 562 | StringOrURI | Any string value MAY be used but a value | 563 | | containing a ":" character MUST be a URI as | 564 | | defined in RFC 3986 [RFC3986]. | 565 | URL | A URL as defined in RFC 1738 [RFC1738]. | 566 | ArrayOfStrings | An array of string values. | 567 +----------------+--------------------------------------------------+ 569 Table 2: Header Parameter Syntax Definitions 571 4.2. Public Header Parameter Names 573 Additional header parameter names can be defined by those using JWE. 574 However, in order to prevent collisions, any new header parameter 575 name or algorithm value SHOULD either be defined in the IANA JSON Web 576 Encryption Header Parameters registry or be defined as a URI that 577 contains a collision resistant namespace. In each case, the definer 578 of the name or value needs to take reasonable precautions to make 579 sure they are in control of the part of the namespace they use to 580 define the header parameter name. 582 New header parameters should be introduced sparingly since an 583 implementation that does not understand a parameter MUST reject the 584 JWE. 586 4.3. Private Header Parameter Names 588 A producer and consumer of a JWE may agree to any header parameter 589 name that is not a Reserved Name Section 4.1 or a Public Name 590 Section 4.2. Unlike Public Names, these private names are subject to 591 collision and should be used with caution. 593 New header parameters should be introduced sparingly, as they can 594 result in non-interoperable JWEs. 596 5. Message Encryption 598 The message encryption process is as follows. The order of the steps 599 is not significant in cases where there are no dependencies between 600 the inputs and outputs of the steps. 602 1. Generate a random Content Master Key (CMK). The CMK MUST have a 603 length at least equal to that of the larger of the required 604 encryption or integrity keys and MUST be generated randomly. 606 See RFC 4086 [RFC4086] for considerations on generating random 607 values. 609 2. Encrypt the CMK for the recipient (see Section 8) and let the 610 result be the JWE Encrypted Key. 612 3. Base64url encode the JWE Encrypted Key to create the Encoded JWE 613 Encrypted Key. 615 4. Generate a random Initialization Vector (IV) (if required for 616 the algorithm). 618 5. If not using an AEAD algorithm, run the key derivation algorithm 619 (see Section 7) to generate the Content Encryption Key (CEK) and 620 the Content Integrity Key (CIK); otherwise (when using an AEAD 621 algorithm), set the CEK to be the CMK. 623 6. Compress the Plaintext if a "zip" parameter was included. 625 7. Serialize the (compressed) Plaintext into a bitstring M. 627 8. Encrypt M using the CEK and IV to form the bitstring C. 629 9. Base64url encode C to create the Encoded JWE Ciphertext. 631 10. Create a JWE Header containing the encryption parameters used. 632 Note that white space is explicitly allowed in the 633 representation and no canonicalization need be performed before 634 encoding. 636 11. Base64url encode the bytes of the UTF-8 representation of the 637 JWE Header to create the Encoded JWE Header. 639 12. If not using an AEAD algorithm, run the integrity algorithm (see 640 Section 9) using the CIK to compute the JWE Integrity Value; 641 otherwise (when using an AEAD algorithm), set the JWE Integrity 642 Value to be the empty byte string. 644 13. Base64url encode the JWE Integrity Value to create the Encoded 645 JWE Integrity Value. 647 14. The four encoded parts, taken together, are the result. The 648 Compact Serialization of this result is the concatenation of the 649 Encoded JWE Header, the Encoded JWE Encrypted Key, the Encoded 650 JWE Ciphertext, and the Encoded JWE Integrity Value in that 651 order, with the four strings being separated by period ('.') 652 characters. 654 6. Message Decryption 656 The message decryption process is the reverse of the encryption 657 process. The order of the steps is not significant in cases where 658 there are no dependencies between the inputs and outputs of the 659 steps. If any of these steps fails, the JWE MUST be rejected. 661 1. Parse the four parts of the input (which are separated by period 662 characters when using the JWE Compact Serialization) into the 663 Encoded JWE Header, the Encoded JWE Encrypted Key, the Encoded 664 JWE Ciphertext, and the Encoded JWE Integrity Value. 666 2. The Encoded JWE Header, the Encoded JWE Encrypted Key, the 667 Encoded JWE Ciphertext, and the Encoded JWE Integrity Value MUST 668 be successfully base64url decoded following the restriction that 669 no padding characters have been used. 671 3. The resulting JWE Header MUST be completely valid JSON syntax 672 conforming to RFC 4627 [RFC4627]. 674 4. The resulting JWE Header MUST be validated to only include 675 parameters and values whose syntax and semantics are both 676 understood and supported. 678 5. Verify that the JWE Header references a key known to the 679 recipient. 681 6. Decrypt the JWE Encrypted Key to produce the Content Master Key 682 (CMK). 684 7. If not using an AEAD algorithm, run the key derivation algorithm 685 (see Section 7) to generate the Content Encryption Key (CEK) and 686 the Content Integrity Key (CIK); otherwise (when using an AEAD 687 algorithm), set the CEK to be the CMK. 689 8. If not using an AEAD algorithm, run the integrity algorithm (see 690 Section 9) using the CIK to compute an integrity value for the 691 input received. This computed value MUST match the received JWE 692 Integrity Value; otherwise (when using an AEAD algorithm), the 693 received JWE Integrity Value MUST be empty. 695 9. Decrypt the binary representation of the JWE Ciphertext using 696 the CEK. 698 10. Remove the Initialization Vector (IV) value from the decrypted 699 result (if an IV was used). 701 11. Uncompress the result of the previous step, if a "zip" parameter 702 was included. 704 12. Output the resulting Plaintext. 706 7. Key Derivation 708 The key derivation process converts the CMK into a CEK and a CIK. It 709 assumes as a primitive a Key Derivation Function (KDF) which 710 notionally takes three arguments: 712 MasterKey: The master key used to compute the individual use keys 714 Label: The use key label, used to differentiate individual use keys 716 Length: The length of the desired use key 718 The only KDF used in this document is the Concat KDF, as defined in 719 [NIST-800-56A], where the Digest Method is SHA-256, the SuppPubInfo 720 parameter is the Label, and the remaining OtherInfo parameters are 721 the empty bit string. 723 To compute the CEK from the CMK, the ASCII label "Encryption" is 724 used. 726 To compute the CIK from the CMK, the ASCII label "Integrity" is used. 728 When AEAD algorithms are used the KDF element MUST NOT be present. 729 When they are not used, it MUST be present. 731 8. CMK Encryption 733 JWE supports two forms of CMK encryption: 735 o Asymmetric encryption under the recipient's public key. 737 o Symmetric encryption under a shared key. 739 8.1. Asymmetric Encryption 741 In the asymmetric encryption mode, the CMK is encrypted under the 742 recipient's public key. The asymmetric encryption modes defined for 743 use with this in this specification are listed in Section 4, Table 2 744 of the JSON Web Algorithms (JWA) [JWA] specification. 746 8.2. Symmetric Encryption 748 In the symmetric encryption mode, the CMK is encrypted under a 749 symmetric key shared between the sender and receiver. The symmetric 750 encryption modes defined for use with this in this specification are 751 listed in Section 4, Table 2 of the JSON Web Algorithms (JWA) [JWA] 752 specification. For GCM, the random 64-bit IV is prepended to the 753 ciphertext. 755 9. Integrity Value Calculation 757 When a non-AEAD algorithm is used (an algorithm without an integrated 758 content check), JWE adds an explicit integrity check value to the 759 representation. This value is computed in the manner described in 760 the JSON Web Signature (JWS) [JWS] specification, with these 761 modifications: 763 o The algorithm used is taken from the "int" (integrity algorithm) 764 header parameter rather than the "alg" header parameter. 766 o The algorithm MUST be an HMAC algorithm (normally HMAC SHA-256). 768 o The JWS Secured Input used is the concatenation of the Encoded JWE 769 Header, a period ('.') character, the Encoded JWE Encrypted Key, a 770 period ('.') character, and the Encoded JWE Ciphertext. 772 o The CIK is used as the HMAC key. 774 The computed JWS Signature value is the resulting integrity value. 776 10. Encrypting JWEs with Cryptographic Algorithms 778 JWE uses cryptographic algorithms to encrypt the Content Encryption 779 Key (CMK) and the Plaintext. The JSON Web Algorithms (JWA) [JWA] 780 specification enumerates a set of cryptographic algorithms and 781 identifiers to be used with this specification. Specifically, 782 Section 4, Table 2 enumerates a set of "alg" (algorithm) header 783 parameter values and Section 4, Table 3 enumerates a set of "enc" 784 (encryption method) header parameter values intended for use this 785 specification. It also describes the semantics and operations that 786 are specific to these algorithms and algorithm families. 788 Public keys employed for encryption can be identified using the 789 Header Parameter methods described in Section 4.1 or can be 790 distributed using methods that are outside the scope of this 791 specification. 793 11. IANA Considerations 795 This specification calls for: 797 o A new IANA registry entitled "JSON Web Encryption Header 798 Parameters" for reserved header parameter names is defined in 799 Section 4.1. Inclusion in the registry is RFC Required in the RFC 800 5226 [RFC5226] sense for reserved JWE header parameter names that 801 are intended to be interoperable between implementations. The 802 registry will just record the reserved header parameter name and a 803 pointer to the RFC that defines it. This specification defines 804 inclusion of the header parameter names defined in Table 1. 806 12. Security Considerations 808 TBD: Lots of work to do here. We need to remember to look into any 809 issues relating to security and JSON parsing. One wonders just how 810 secure most JSON parsing libraries are. Were they ever hardened for 811 security scenarios? If not, what kind of holes does that open up? 812 Also, we need to walk through the JSON standard and see what kind of 813 issues we have especially around comparison of names. For instance, 814 comparisons of header parameter names and other parameters must occur 815 after they are unescaped. Need to also put in text about: Importance 816 of keeping secrets secret. Rotating keys. Strengths and weaknesses 817 of the different algorithms. 819 TBD: Need to put in text about why strict JSON validation is 820 necessary. Basically, that if malformed JSON is received then the 821 intent of the sender is impossible to reliably discern. One example 822 of malformed JSON that MUST be rejected is an object in which the 823 same member name occurs multiple times. 825 TBD: We need a section on generating randomness in browsers - it's 826 easy to screw up. 828 When utilizing TLS to retrieve information, the authority providing 829 the resource MUST be authenticated and the information retrieved MUST 830 be free from modification. 832 12.1. Unicode Comparison Security Issues 834 Header parameter names in JWEs are Unicode strings. For security 835 reasons, the representations of these names must be compared verbatim 836 after performing any escape processing (as per RFC 4627 [RFC4627], 837 Section 2.5). 839 This means, for instance, that these JSON strings must compare as 840 being equal ("enc", "\u0065nc"), whereas these must all compare as 841 being not equal to the first set or to each other ("ENC", "Enc", 842 "en\u0043"). 844 JSON strings MAY contain characters outside the Unicode Basic 845 Multilingual Plane. For instance, the G clef character (U+1D11E) may 846 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWE 847 implementations SHOULD ensure that characters outside the Basic 848 Multilingual Plane are preserved and compared correctly; 849 alternatively, if this is not possible due to these characters 850 exercising limitations present in the underlying JSON implementation, 851 then input containing them MUST be rejected. 853 13. Open Issues and Things To Be Done (TBD) 855 The following items remain to be done in this draft: 857 o EDITORIAL: Give each header parameter definition its own section. 858 This will let them appear in the index, will give space for 859 examples when needed, and will get rid of the way-too-cramped 860 tables. 862 o Consider adding the DEFLATE compression algorithm (which omits the 863 ZLIB header and checksum fields) and so produces smaller results 864 than "GZIP". 866 o Provide a more robust description of the use of the Initialization 867 Vector (IV), including listing which algorithms require an IV. 868 (This list may belong in the JWA spec.) The current statement 869 "For GCM, the random 64-bit IV is prepended to the ciphertext" in 870 the Symmetric Encryption section is almost certainly out of place 871 and insufficiently general. 873 o Finish the Security Considerations section. 875 o Consider which of the open issues from the JWS and JWT specs also 876 apply here. 878 o Should the JWE Encrypted Key be moved to the header (which would 879 add about 20 bytes to every JWE) or left in a separate period- 880 separated segment to prevent double base64 encoding? 882 14. References 883 14.1. Normative References 885 [JWA] Jones, M., "JSON Web Algorithms (JWA)", January 2012. 887 [JWK] Jones, M., "JSON Web Key (JWK)", March 2012. 889 [JWS] Jones, M., Bradley, J., and N. Sakimura, "JSON Web 890 Signature (JWS)", January 2012. 892 [NIST-800-38D] 893 National Institute of Standards and Technology (NIST), 894 "Recommendation for Block Cipher Modes of Operation: 895 Galois/Counter Mode (GCM) and GMAC", NIST PUB 800-38D, 896 December 2001. 898 [NIST-800-56A] 899 National Institute of Standards and Technology (NIST), 900 "Recommendation for Pair-Wise Key Establishment Schemes 901 Using Discrete Logarithm Cryptography (Revised)", NIST PUB 902 800-56A, March 2007. 904 [RFC1421] Linn, J., "Privacy Enhancement for Internet Electronic 905 Mail: Part I: Message Encryption and Authentication 906 Procedures", RFC 1421, February 1993. 908 [RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform 909 Resource Locators (URL)", RFC 1738, December 1994. 911 [RFC1952] Deutsch, P., Gailly, J-L., Adler, M., Deutsch, L., and G. 912 Randers-Pehrson, "GZIP file format specification version 913 4.3", RFC 1952, May 1996. 915 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 916 Requirement Levels", BCP 14, RFC 2119, March 1997. 918 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 920 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 921 10646", STD 63, RFC 3629, November 2003. 923 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 924 Resource Identifier (URI): Generic Syntax", STD 66, 925 RFC 3986, January 2005. 927 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 928 Requirements for Security", BCP 106, RFC 4086, June 2005. 930 [RFC4627] Crockford, D., "The application/json Media Type for 931 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 933 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 934 Encodings", RFC 4648, October 2006. 936 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 937 Encryption", RFC 5116, January 2008. 939 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 940 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 941 May 2008. 943 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 944 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 946 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 947 Housley, R., and W. Polk, "Internet X.509 Public Key 948 Infrastructure Certificate and Certificate Revocation List 949 (CRL) Profile", RFC 5280, May 2008. 951 [RFC6090] McGrew, D., Igoe, K., and M. Salter, "Fundamental Elliptic 952 Curve Cryptography Algorithms", RFC 6090, February 2011. 954 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 955 Verification of Domain-Based Application Service Identity 956 within Internet Public Key Infrastructure Using X.509 957 (PKIX) Certificates in the Context of Transport Layer 958 Security (TLS)", RFC 6125, March 2011. 960 14.2. Informative References 962 [I-D.rescorla-jsms] 963 Rescorla, E. and J. Hildebrand, "JavaScript Message 964 Security Format", draft-rescorla-jsms-00 (work in 965 progress), March 2011. 967 [JSE] Bradley, J. and N. Sakimura (editor), "JSON Simple 968 Encryption", September 2010. 970 [JWE-JS] Jones, M., "JSON Web Encryption JSON Serialization 971 (JWE-JS)", March 2012. 973 [RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, 974 RFC 5652, September 2009. 976 [W3C.CR-xmlenc-core1-20110303] 977 Hirsch, F., Roessler, T., Reagle, J., and D. Eastlake, 978 "XML Encryption Syntax and Processing Version 1.1", World 979 Wide Web Consortium CR CR-xmlenc-core1-20110303, 980 March 2011, 981 . 983 Appendix A. JWE Examples 985 This section provides several examples of JWEs. 987 A.1. JWE Example using TBD Algorithm 989 A.1.1. Encrypting 991 TBD: Demonstrate encryption steps with this algorithm 993 A.1.2. Decrypting 995 TBD: Demonstrate decryption steps with this algorithm 997 Appendix B. Acknowledgements 999 Solutions for encrypting JSON content were also explored by JSON 1000 Simple Encryption [JSE] and JavaScript Message Security Format 1001 [I-D.rescorla-jsms], both of which significantly influenced this 1002 draft. This draft attempts to explicitly reuse as many of the 1003 relevant concepts from XML Encryption 1.1 1004 [W3C.CR-xmlenc-core1-20110303] and RFC 5652 [RFC5652] as possible, 1005 while utilizing simple compact JSON-based data structures. 1007 Special thanks are due to John Bradley and Nat Sakimura for the 1008 discussions that helped inform the content of this specification and 1009 to Eric Rescorla and Joe Hildebrand for allowing the reuse of text 1010 from [I-D.rescorla-jsms] in this document. 1012 Appendix C. Document History 1014 -01 1016 o Added an integrity check for non-AEAD algorithms. 1018 o Added "jpk" and "x5c" header parameters for including JWK public 1019 keys and X.509 certificate chains directly in the header. 1021 o Clarified that this specification is defining the JWE Compact 1022 Serialization. Referenced the new JWE-JS spec, which defines the 1023 JWE JSON Serialization. 1025 o Added text "New header parameters should be introduced sparingly 1026 since an implementation that does not understand a parameter MUST 1027 reject the JWE". 1029 o Clarified that the order of the encryption and decryption steps is 1030 not significant in cases where there are no dependencies between 1031 the inputs and outputs of the steps. 1033 o Made other editorial improvements suggested by JOSE working group 1034 participants. 1036 -00 1038 o Created the initial IETF draft based upon 1039 draft-jones-json-web-encryption-02 with no normative changes. 1041 o Changed terminology to no longer call both digital signatures and 1042 HMACs "signatures". 1044 Authors' Addresses 1046 Michael B. Jones 1047 Microsoft 1049 Email: mbj@microsoft.com 1050 URI: http://self-issued.info/ 1052 Eric Rescorla 1053 RTFM, Inc. 1055 Email: ekr@rtfm.com 1057 Joe Hildebrand 1058 Cisco Systems, Inc. 1060 Email: jhildebr@cisco.com