idnits 2.17.1 draft-ietf-jose-json-web-signature-18.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 == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: Senders MUST not use the empty list "[]" as the "crit" value. Recipients MAY reject the JWS if the critical list contains any Header Parameter names defined by the initial RFC versions of [[ this specification ]] or [JWA] for use with JWS, or any other constraints on its use are violated. This Header Parameter MUST be integrity protected, and therefore MUST occur only within the JWS Protected Header, when used. Use of this Header Parameter is OPTIONAL. This Header Parameter MUST be understood and processed by implementations. -- The document date (November 12, 2013) is 3816 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '123' on line 1654 -- Looks like a reference, but probably isn't: '34' on line 1654 -- Looks like a reference, but probably isn't: '97' on line 1664 -- Looks like a reference, but probably isn't: '108' on line 1664 -- Looks like a reference, but probably isn't: '103' on line 1654 -- Looks like a reference, but probably isn't: '58' on line 1654 -- Looks like a reference, but probably isn't: '82' on line 1418 -- Looks like a reference, but probably isn't: '83' on line 1654 -- Looks like a reference, but probably isn't: '50' on line 1654 -- Looks like a reference, but probably isn't: '53' on line 1654 -- Looks like a reference, but probably isn't: '54' on line 1546 -- Looks like a reference, but probably isn't: '125' on line 1654 -- Looks like a reference, but probably isn't: '69' on line 1654 -- Looks like a reference, but probably isn't: '49' on line 1654 -- Looks like a reference, but probably isn't: '80' on line 1664 -- Looks like a reference, but probably isn't: '121' on line 1664 -- Looks like a reference, but probably isn't: '111' on line 1664 -- Looks like a reference, but probably isn't: '100' on line 1664 -- Looks like a reference, but probably isn't: '0' on line 1972 -- Possible downref: Non-RFC (?) normative reference: ref. 'ECMAScript' == Outdated reference: A later version (-10) exists of draft-ietf-json-rfc4627bis-07 -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.X690.1994' ** Downref: Normative reference to an Historic RFC: RFC 1421 ** Obsolete normative reference: RFC 2246 (Obsoleted by RFC 4346) ** 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) ** Obsolete normative reference: RFC 6125 (Obsoleted by RFC 9525) -- Possible downref: Non-RFC (?) normative reference: ref. 'USASCII' Summary: 7 errors (**), 0 flaws (~~), 3 warnings (==), 24 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 J. Bradley 5 Expires: May 16, 2014 Ping Identity 6 N. Sakimura 7 NRI 8 November 12, 2013 10 JSON Web Signature (JWS) 11 draft-ietf-jose-json-web-signature-18 13 Abstract 15 JSON Web Signature (JWS) represents content secured with digital 16 signatures or Message Authentication Codes (MACs) using JavaScript 17 Object Notation (JSON) based data structures. Cryptographic 18 algorithms and identifiers for use with this specification are 19 described in the separate JSON Web Algorithms (JWA) specification and 20 an IANA registry defined by that specification. Related encryption 21 capabilities are described in the separate JSON Web Encryption (JWE) 22 specification. 24 Status of this Memo 26 This Internet-Draft is submitted in full conformance with the 27 provisions of BCP 78 and BCP 79. 29 Internet-Drafts are working documents of the Internet Engineering 30 Task Force (IETF). Note that other groups may also distribute 31 working documents as Internet-Drafts. The list of current Internet- 32 Drafts is at http://datatracker.ietf.org/drafts/current/. 34 Internet-Drafts are draft documents valid for a maximum of six months 35 and may be updated, replaced, or obsoleted by other documents at any 36 time. It is inappropriate to use Internet-Drafts as reference 37 material or to cite them other than as "work in progress." 39 This Internet-Draft will expire on May 16, 2014. 41 Copyright Notice 43 Copyright (c) 2013 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (http://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 59 1.1. Notational Conventions . . . . . . . . . . . . . . . . . . 4 60 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 5 61 3. JSON Web Signature (JWS) Overview . . . . . . . . . . . . . . 6 62 3.1. Example JWS . . . . . . . . . . . . . . . . . . . . . . . 7 63 4. JWS Header . . . . . . . . . . . . . . . . . . . . . . . . . . 8 64 4.1. Registered Header Parameter Names . . . . . . . . . . . . 9 65 4.1.1. "alg" (Algorithm) Header Parameter . . . . . . . . . . 9 66 4.1.2. "jku" (JWK Set URL) Header Parameter . . . . . . . . . 10 67 4.1.3. "jwk" (JSON Web Key) Header Parameter . . . . . . . . 10 68 4.1.4. "x5u" (X.509 URL) Header Parameter . . . . . . . . . . 10 69 4.1.5. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header 70 Parameter . . . . . . . . . . . . . . . . . . . . . . 10 71 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter . . . 11 72 4.1.7. "kid" (Key ID) Header Parameter . . . . . . . . . . . 11 73 4.1.8. "typ" (Type) Header Parameter . . . . . . . . . . . . 11 74 4.1.9. "cty" (Content Type) Header Parameter . . . . . . . . 12 75 4.1.10. "crit" (Critical) Header Parameter . . . . . . . . . . 12 76 4.2. Public Header Parameter Names . . . . . . . . . . . . . . 13 77 4.3. Private Header Parameter Names . . . . . . . . . . . . . . 13 78 5. Producing and Consuming JWSs . . . . . . . . . . . . . . . . . 13 79 5.1. Message Signature or MAC Computation . . . . . . . . . . . 13 80 5.2. Message Signature or MAC Validation . . . . . . . . . . . 14 81 5.3. String Comparison Rules . . . . . . . . . . . . . . . . . 16 82 6. Key Identification . . . . . . . . . . . . . . . . . . . . . . 16 83 7. Serializations . . . . . . . . . . . . . . . . . . . . . . . . 16 84 7.1. JWS Compact Serialization . . . . . . . . . . . . . . . . 17 85 7.2. JWS JSON Serialization . . . . . . . . . . . . . . . . . . 17 86 8. TLS Requirements . . . . . . . . . . . . . . . . . . . . . . . 19 87 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 19 88 9.1. JSON Web Signature and Encryption Header Parameters 89 Registry . . . . . . . . . . . . . . . . . . . . . . . . . 20 90 9.1.1. Registration Template . . . . . . . . . . . . . . . . 20 91 9.1.2. Initial Registry Contents . . . . . . . . . . . . . . 21 92 9.2. Media Type Registration . . . . . . . . . . . . . . . . . 22 93 9.2.1. Registry Contents . . . . . . . . . . . . . . . . . . 22 94 10. Security Considerations . . . . . . . . . . . . . . . . . . . 23 95 10.1. Cryptographic Security Considerations . . . . . . . . . . 23 96 10.2. JSON Security Considerations . . . . . . . . . . . . . . . 25 97 10.3. Unicode Comparison Security Considerations . . . . . . . . 25 98 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 26 99 11.1. Normative References . . . . . . . . . . . . . . . . . . . 26 100 11.2. Informative References . . . . . . . . . . . . . . . . . . 27 101 Appendix A. JWS Examples . . . . . . . . . . . . . . . . . . . . 28 102 A.1. Example JWS using HMAC SHA-256 . . . . . . . . . . . . . . 28 103 A.1.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 28 104 A.1.2. Validating . . . . . . . . . . . . . . . . . . . . . . 30 105 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 . . . . . . . . 31 106 A.2.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 31 107 A.2.2. Validating . . . . . . . . . . . . . . . . . . . . . . 33 108 A.3. Example JWS using ECDSA P-256 SHA-256 . . . . . . . . . . 33 109 A.3.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 33 110 A.3.2. Validating . . . . . . . . . . . . . . . . . . . . . . 35 111 A.4. Example JWS using ECDSA P-521 SHA-512 . . . . . . . . . . 36 112 A.4.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 36 113 A.4.2. Validating . . . . . . . . . . . . . . . . . . . . . . 38 114 A.5. Example Plaintext JWS . . . . . . . . . . . . . . . . . . 38 115 A.6. Example JWS Using JWS JSON Serialization . . . . . . . . . 39 116 A.6.1. JWS Per-Signature Protected Headers . . . . . . . . . 39 117 A.6.2. JWS Per-Signature Unprotected Headers . . . . . . . . 40 118 A.6.3. Complete JWS Header Values . . . . . . . . . . . . . . 40 119 A.6.4. Complete JWS JSON Serialization Representation . . . . 40 120 Appendix B. "x5c" (X.509 Certificate Chain) Example . . . . . . . 41 121 Appendix C. Notes on implementing base64url encoding without 122 padding . . . . . . . . . . . . . . . . . . . . . . . 43 123 Appendix D. Negative Test Case for "crit" Header Parameter . . . 44 124 Appendix E. Detached Content . . . . . . . . . . . . . . . . . . 44 125 Appendix F. Acknowledgements . . . . . . . . . . . . . . . . . . 45 126 Appendix G. Document History . . . . . . . . . . . . . . . . . . 45 127 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 52 129 1. Introduction 131 JSON Web Signature (JWS) represents content secured with digital 132 signatures or Message Authentication Codes (MACs) using JavaScript 133 Object Notation (JSON) [RFC4627] based data structures. The JWS 134 cryptographic mechanisms provide integrity protection for an 135 arbitrary sequence of octets. 137 Two closely related serializations for JWS objects are defined. The 138 JWS Compact Serialization is a compact, URL-safe representation 139 intended for space constrained environments such as HTTP 140 Authorization headers and URI query parameters. The JWS JSON 141 Serialization represents JWS objects as JSON objects and enables 142 multiple signatures and/or MACs to be applied to the same content. 143 Both share the same cryptographic underpinnings. 145 Cryptographic algorithms and identifiers for use with this 146 specification are described in the separate JSON Web Algorithms (JWA) 147 [JWA] specification and an IANA registry defined by that 148 specification. Related encryption capabilities are described in the 149 separate JSON Web Encryption (JWE) [JWE] specification. 151 Names defined by this specification are short because a core goal is 152 for the resulting representations to be compact. 154 1.1. Notational Conventions 156 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 157 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 158 document are to be interpreted as described in Key words for use in 159 RFCs to Indicate Requirement Levels [RFC2119]. If these words are 160 used without being spelled in uppercase then they are to be 161 interpreted with their normal natural language meanings. 163 BASE64URL(OCTETS) denotes the base64url encoding of OCTETS, per 164 Section 2. 166 UTF8(STRING) denotes the octets of the UTF-8 [RFC3629] representation 167 of STRING. 169 ASCII(STRING) denotes the octets of the ASCII [USASCII] 170 representation of STRING. 172 The concatenation of two values A and B is denoted as A || B. 174 2. Terminology 176 JSON Web Signature (JWS) A data structure representing a digitally 177 signed or MACed message. 179 JWS Header A JSON object (or JSON objects, when using the JWS JSON 180 Serialization) that describes the digital signature or MAC 181 operation applied to create the JWS Signature value. The members 182 of the JWS Header object(s) are Header Parameters. 184 JWS Payload The sequence of octets to be secured -- a.k.a., the 185 message. The payload can contain an arbitrary sequence of octets. 187 JWS Signature A sequence of octets containing the cryptographic 188 material that ensures the integrity of the JWS Protected Header 189 and the JWS Payload. The JWS Signature value is a digital 190 signature or MAC value calculated over the JWS Signing Input using 191 the parameters specified in the JWS Header. 193 JWS Protected Header A JSON object that contains the portion of the 194 JWS Header that is integrity protected. For the JWS Compact 195 Serialization, this comprises the entire JWS Header. For the JWS 196 JSON Serialization, this is one component of the JWS Header. 198 Header Parameter A name/value pair that is member of the JWS Header. 200 Base64url Encoding Base64 encoding using the URL- and filename-safe 201 character set defined in Section 5 of RFC 4648 [RFC4648], with all 202 trailing '=' characters omitted (as permitted by Section 3.2). 203 (See Appendix C for notes on implementing base64url encoding 204 without padding.) 206 JWS Signing Input The input to the digital signature or MAC 207 computation. Its value is ASCII(BASE64URL(UTF8(JWS Protected 208 Header)) || '.' || BASE64URL(JWS Payload)). 210 JWS Compact Serialization A representation of the JWS as a compact, 211 URL-safe string. 213 JWS JSON Serialization A representation of the JWS as a JSON object. 214 Unlike the JWS Compact Serialization, the JWS JSON Serialization 215 enables multiple digital signatures and/or MACs to be applied to 216 the same content. This representation is neither compact nor URL- 217 safe. 219 Collision-Resistant Name A name in a namespace that enables names to 220 be allocated in a manner such that they are highly unlikely to 221 collide with other names. Examples of collision-resistant 222 namespaces include: Domain Names, Object Identifiers (OIDs) as 223 defined in the ITU-T X.660 and X.670 Recommendation series, and 224 Universally Unique IDentifiers (UUIDs) [RFC4122]. When using an 225 administratively delegated namespace, the definer of a name needs 226 to take reasonable precautions to ensure they are in control of 227 the portion of the namespace they use to define the name. 229 StringOrURI A JSON string value, with the additional requirement 230 that while arbitrary string values MAY be used, any value 231 containing a ":" character MUST be a URI [RFC3986]. StringOrURI 232 values are compared as case-sensitive strings with no 233 transformations or canonicalizations applied. 235 3. JSON Web Signature (JWS) Overview 237 JWS represents digitally signed or MACed content using JSON data 238 structures and base64url encoding. A JWS represents these logical 239 values: 241 JWS Header JSON object containing the parameters describing the 242 cryptographic operations and parameters employed. The JWE Header 243 members are the union of the members of the JWS Protected Header 244 and the JWS Unprotected Header, as described below. 246 JWS Payload Message content to be secured. 248 JWS Signature Digital signature or MAC over the JWS Protected Header 249 and the JWS Payload. 251 The JWS Header represents the combination of these logical values: 253 JWS Protected Header JSON object containing some of the parameters 254 describing the cryptographic operations and parameters employed. 255 This value is integrity protected in the digital signature or MAC 256 calculation of the JWS Signature. 258 JWS Unprotected Header JSON object containing some of the parameters 259 describing the cryptographic operations and parameters employed. 260 This value is not integrity protected in the digital signature or 261 MAC calculation of the JWS Signature. 263 This document defines two serializations for JWS objects: a compact, 264 URL-safe serialization called the JWS Compact Serialization and a 265 JSON serialization called the JWS JSON Serialization. In both 266 serializations, the JWS Protected Header, JWS Payload, and JWS 267 Signature are base64url encoded for transmission, since JSON lacks a 268 way to directly represent octet sequences. 270 In the JWS Compact Serialization, no JWS Unprotected Header is used. 271 In this case, the JWS Header and the JWS Protected Header are the 272 same. 274 In the JWS Compact Serialization, a JWS object is represented as the 275 combination of these three string values, 276 BASE64URL(UTF8(JWS Protected Header)), 277 BASE64URL(JWS Payload), and 278 BASE64URL(JWS Signature), 279 concatenated in that order, with the three strings being separated by 280 two period ('.') characters. 282 In the JWS JSON Serialization, one or both of the JWS Protected 283 Header and JWS Unprotected Header MUST be present. In this case, the 284 members of the JWS Header are the combination of the members of the 285 JWS Protected Header and the JWS Unprotected Header values that are 286 present. 288 In the JWS JSON Serialization, a JWS object is represented as the 289 combination of these four values, 290 BASE64URL(UTF8(JWS Protected Header)), 291 JWS Unprotected Header, 292 BASE64URL(JWS Payload), and 293 BASE64URL(JWS Signature), 294 with the three base64url encoding result strings and the JWS 295 Unprotected Header value being represented as members within a JSON 296 object. The inclusion of some of these values is OPTIONAL. The JWS 297 JSON Serialization can also represent multiple signature and/or MAC 298 values, rather than just one. See Section 7.2 for more information 299 about the JWS JSON Serialization. 301 3.1. Example JWS 303 This section provides an example of a JWS. Its computation is 304 described in more detail in Appendix A.1, including specifying the 305 exact octet sequences representing the JSON values used and the key 306 value used. 308 The following example JWS Protected Header declares that the encoded 309 object is a JSON Web Token (JWT) [JWT] and the JWS Protected Header 310 and the JWS Payload are secured using the HMAC SHA-256 algorithm: 312 {"typ":"JWT", 313 "alg":"HS256"} 315 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 316 Header)) gives this value: 318 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 320 The UTF-8 representation of following JSON object is used as the JWS 321 Payload. (Note that the payload can be any content, and need not be 322 a representation of a JSON object.) 324 {"iss":"joe", 325 "exp":1300819380, 326 "http://example.com/is_root":true} 328 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value 329 (with line breaks for display purposes only): 331 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 332 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 334 Computing the HMAC of the JWS Signing Input ASCII(BASE64URL(UTF8(JWS 335 Protected Header)) || '.' || BASE64URL(JWS Payload)) with the HMAC 336 SHA-256 algorithm using the key specified in Appendix A.1 and 337 base64url encoding the result yields this BASE64URL(JWS Signature) 338 value: 340 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 342 Concatenating these values in the order Header.Payload.Signature with 343 period ('.') characters between the parts yields this complete JWS 344 representation using the JWS Compact Serialization (with line breaks 345 for display purposes only): 347 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 348 . 349 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 350 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 351 . 352 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 354 See Appendix A for additional examples. 356 4. JWS Header 358 The members of the JSON object(s) representing the JWS Header 359 describe the digital signature or MAC applied to the JWS Protected 360 Header and the JWS Payload and optionally additional properties of 361 the JWS. The Header Parameter names within the JWS Header MUST be 362 unique; recipients MUST either reject JWSs with duplicate Header 363 Parameter names or use a JSON parser that returns only the lexically 364 last duplicate member name, as specified in Section 15.12 (The JSON 365 Object) of ECMAScript 5.1 [ECMAScript]. 367 Implementations are required to understand the specific Header 368 Parameters defined by this specification that are designated as "MUST 369 be understood" and process them in the manner defined in this 370 specification. All other Header Parameters defined by this 371 specification that are not so designated MUST be ignored when not 372 understood. Unless listed as a critical Header Parameter, per 373 Section 4.1.10, all Header Parameters not defined by this 374 specification MUST be ignored when not understood. 376 There are three classes of Header Parameter names: Registered Header 377 Parameter names, Public Header Parameter names, and Private Header 378 Parameter names. 380 4.1. Registered Header Parameter Names 382 The following Header Parameter names are registered in the IANA JSON 383 Web Signature and Encryption Header Parameters registry defined in 384 Section 9.1, with meanings as defined below. 386 As indicated by the common registry, JWSs and JWEs share a common 387 Header Parameter space; when a parameter is used by both 388 specifications, its usage must be compatible between the 389 specifications. 391 4.1.1. "alg" (Algorithm) Header Parameter 393 The "alg" (algorithm) Header Parameter identifies the cryptographic 394 algorithm used to secure the JWS. The signature, MAC, or plaintext 395 value is not valid if the "alg" value does not represent a supported 396 algorithm, or if there is not a key for use with that algorithm 397 associated with the party that digitally signed or MACed the content. 398 "alg" values should either be registered in the IANA JSON Web 399 Signature and Encryption Algorithms registry defined in [JWA] or be a 400 value that contains a Collision-Resistant Name. The "alg" value is a 401 case-sensitive string containing a StringOrURI value. This Header 402 Parameter MUST be present and MUST be understood and processed by 403 implementations. 405 A list of defined "alg" values for this use can be found in the IANA 406 JSON Web Signature and Encryption Algorithms registry defined in 407 [JWA]; the initial contents of this registry are the values defined 408 in Section 3.1 of the JSON Web Algorithms (JWA) [JWA] specification. 410 4.1.2. "jku" (JWK Set URL) Header Parameter 412 The "jku" (JWK Set URL) Header Parameter is a URI [RFC3986] that 413 refers to a resource for a set of JSON-encoded public keys, one of 414 which corresponds to the key used to digitally sign the JWS. The 415 keys MUST be encoded as a JSON Web Key Set (JWK Set) [JWK]. The 416 protocol used to acquire the resource MUST provide integrity 417 protection; an HTTP GET request to retrieve the JWK Set MUST use TLS 418 [RFC2818] [RFC5246]; the identity of the server MUST be validated, as 419 per Section 3.1 of HTTP Over TLS [RFC2818]. Use of this Header 420 Parameter is OPTIONAL. 422 4.1.3. "jwk" (JSON Web Key) Header Parameter 424 The "jwk" (JSON Web Key) Header Parameter is the public key that 425 corresponds to the key used to digitally sign the JWS. This key is 426 represented as a JSON Web Key [JWK]. Use of this Header Parameter is 427 OPTIONAL. 429 4.1.4. "x5u" (X.509 URL) Header Parameter 431 The "x5u" (X.509 URL) Header Parameter is a URI [RFC3986] that refers 432 to a resource for the X.509 public key certificate or certificate 433 chain [RFC5280] corresponding to the key used to digitally sign the 434 JWS. The identified resource MUST provide a representation of the 435 certificate or certificate chain that conforms to RFC 5280 [RFC5280] 436 in PEM encoded form [RFC1421]. The certificate containing the public 437 key corresponding to the key used to digitally sign the JWS MUST be 438 the first certificate. This MAY be followed by additional 439 certificates, with each subsequent certificate being the one used to 440 certify the previous one. The protocol used to acquire the resource 441 MUST provide integrity protection; an HTTP GET request to retrieve 442 the certificate MUST use TLS [RFC2818] [RFC5246]; the identity of the 443 server MUST be validated, as per Section 3.1 of HTTP Over TLS 444 [RFC2818]. Use of this Header Parameter is OPTIONAL. 446 4.1.5. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter 448 The "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter is a 449 base64url encoded SHA-1 thumbprint (a.k.a. digest) of the DER 450 encoding of the X.509 certificate [RFC5280] corresponding to the key 451 used to digitally sign the JWS. Use of this Header Parameter is 452 OPTIONAL. 454 If, in the future, certificate thumbprints need to be computed using 455 hash functions other than SHA-1, it is suggested that additional 456 related Header Parameters be defined for that purpose. For example, 457 it is suggested that a new "x5t#S256" (X.509 Certificate Thumbprint 458 using SHA-256) Header Parameter could be defined by registering it in 459 the IANA JSON Web Signature and Encryption Header Parameters registry 460 defined in Section 9.1. 462 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter 464 The "x5c" (X.509 Certificate Chain) Header Parameter contains the 465 X.509 public key certificate or certificate chain [RFC5280] 466 corresponding to the key used to digitally sign the JWS. The 467 certificate or certificate chain is represented as a JSON array of 468 certificate value strings. Each string in the array is a base64 469 encoded ([RFC4648] Section 4 -- not base64url encoded) DER 470 [ITU.X690.1994] PKIX certificate value. The certificate containing 471 the public key corresponding to the key used to digitally sign the 472 JWS MUST be the first certificate. This MAY be followed by 473 additional certificates, with each subsequent certificate being the 474 one used to certify the previous one. The recipient MUST verify the 475 certificate chain according to [RFC5280] and reject the signature if 476 any validation failure occurs. Use of this Header Parameter is 477 OPTIONAL. 479 See Appendix B for an example "x5c" value. 481 4.1.7. "kid" (Key ID) Header Parameter 483 The "kid" (key ID) Header Parameter is a hint indicating which key 484 was used to secure the JWS. This parameter allows originators to 485 explicitly signal a change of key to recipients. The structure of 486 the "kid" value is unspecified. Its value MUST be a string. Use of 487 this Header Parameter is OPTIONAL. 489 When used with a JWK, the "kid" value is used to match a JWK "kid" 490 parameter value. 492 4.1.8. "typ" (Type) Header Parameter 494 The "typ" (type) Header Parameter is used to declare the MIME Media 495 Type [IANA.MediaTypes] of this complete JWS object in contexts where 496 this is useful to the application. This parameter has no effect upon 497 the JWS processing. Use of this Header Parameter is OPTIONAL. 499 Per [RFC2045], all media type values, subtype values, and parameter 500 names are case-insensitive. However, parameter values are case- 501 sensitive unless otherwise specified for the specific parameter. 503 To keep messages compact in common situations, it is RECOMMENDED that 504 senders omit an "application/" prefix of a media type value in a 505 "typ" Header Parameter when no other '/' appears in the media type 506 value. A recipient using the media type value MUST treat it as if 507 "application/" were prepended to any "typ" value not containing a 508 '/'. For instance, a "typ" value of "example" SHOULD be used to 509 represent the "application/example" media type; whereas, the media 510 type "application/example;part="1/2"" cannot be shortened to 511 "example;part="1/2"". 513 The "typ" value "JOSE" can be used by applications to indicate that 514 this object is a JWS or JWE using the JWS Compact Serialization or 515 the JWE Compact Serialization. The "typ" value "JOSE+JSON" can be 516 used by applications to indicate that this object is a JWS or JWE 517 using the JWS JSON Serialization or the JWE JSON Serialization. 518 Other type values can also be used by applications. 520 4.1.9. "cty" (Content Type) Header Parameter 522 The "cty" (content type) Header Parameter is used to declare the MIME 523 Media Type [IANA.MediaTypes] of the secured content (the payload) in 524 contexts where this is useful to the application. This parameter has 525 no effect upon the JWS processing. Use of this Header Parameter is 526 OPTIONAL. 528 Per [RFC2045], all media type values, subtype values, and parameter 529 names are case-insensitive. However, parameter values are case- 530 sensitive unless otherwise specified for the specific parameter. 532 To keep messages compact in common situations, it is RECOMMENDED that 533 senders omit an "application/" prefix of a media type value in a 534 "cty" Header Parameter when no other '/' appears in the media type 535 value. A recipient using the media type value MUST treat it as if 536 "application/" were prepended to any "cty" value not containing a 537 '/'. For instance, a "cty" value of "example" SHOULD be used to 538 represent the "application/example" media type; whereas, the media 539 type "application/example;part="1/2"" cannot be shortened to 540 "example;part="1/2"". 542 4.1.10. "crit" (Critical) Header Parameter 544 The "crit" (critical) Header Parameter indicates that extensions to 545 the initial RFC versions of [[ this specification ]] and [JWA] are 546 being used that MUST be understood and processed. Its value is an 547 array listing the Header Parameter names present in the JWS Header 548 that use those extensions. If any of the listed extension Header 549 Parameters are not understood and supported by the receiver, it MUST 550 reject the JWS. Senders must not include Header Parameter names 551 defined by the initial RFC versions of [[ this specification ]] or 552 [JWA] for use with JWS, duplicate names, or names that do not occur 553 as Header Parameter names within the JWS Header in the "crit" list. 555 Senders MUST not use the empty list "[]" as the "crit" value. 556 Recipients MAY reject the JWS if the critical list contains any 557 Header Parameter names defined by the initial RFC versions of [[ this 558 specification ]] or [JWA] for use with JWS, or any other constraints 559 on its use are violated. This Header Parameter MUST be integrity 560 protected, and therefore MUST occur only within the JWS Protected 561 Header, when used. Use of this Header Parameter is OPTIONAL. This 562 Header Parameter MUST be understood and processed by implementations. 564 An example use, along with a hypothetical "exp" (expiration-time) 565 field is: 567 {"alg":"ES256", 568 "crit":["exp"], 569 "exp":1363284000 570 } 572 4.2. Public Header Parameter Names 574 Additional Header Parameter names can be defined by those using JWSs. 575 However, in order to prevent collisions, any new Header Parameter 576 name should either be registered in the IANA JSON Web Signature and 577 Encryption Header Parameters registry defined in Section 9.1 or be a 578 Public Name: a value that contains a Collision-Resistant Name. In 579 each case, the definer of the name or value needs to take reasonable 580 precautions to make sure they are in control of the part of the 581 namespace they use to define the Header Parameter name. 583 New Header Parameters should be introduced sparingly, as they can 584 result in non-interoperable JWSs. 586 4.3. Private Header Parameter Names 588 A producer and consumer of a JWS may agree to use Header Parameter 589 names that are Private Names: names that are not Registered Header 590 Parameter names Section 4.1 or Public Header Parameter names 591 Section 4.2. Unlike Public Header Parameter names, Private Header 592 Parameter names are subject to collision and should be used with 593 caution. 595 5. Producing and Consuming JWSs 597 5.1. Message Signature or MAC Computation 599 To create a JWS, one MUST perform these steps. The order of the 600 steps is not significant in cases where there are no dependencies 601 between the inputs and outputs of the steps. 603 1. Create the content to be used as the JWS Payload. 604 2. Compute the encoded payload value BASE64URL(JWS Payload). 605 3. Create the JSON object(s) containing the desired set of Header 606 Parameters, which together comprise the JWS Header: the JWS 607 Protected Header, and if the JWS JSON Serialization is being 608 used, the JWS Unprotected Header. 609 4. Compute the encoded header value BASE64URL(UTF8(JWS Protected 610 Header)). If the JWS Protected Header is not present (which can 611 only happen when using the JWS JSON Serialization and no 612 "protected" member is present), let this value be the empty 613 string. 614 5. Compute the JWS Signature in the manner defined for the 615 particular algorithm being used over the JWS Signing Input 616 ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 617 BASE64URL(JWS Payload)). The "alg" (algorithm) Header Parameter 618 MUST be present in the JWS Header, with the algorithm value 619 accurately representing the algorithm used to construct the JWS 620 Signature. 621 6. Compute the encoded signature value BASE64URL(JWS Signature). 622 7. These three encoded values are used in both the JWS Compact 623 Serialization and the JWS JSON Serialization representations. 624 8. If the JWS JSON Serialization is being used, repeat this process 625 (steps 1-7) for each digital signature or MAC value being 626 applied. 627 9. Create the desired serialized output. The JWS Compact 628 Serialization of this result is BASE64URL(UTF8(JWS Protected 629 Header)) || '.' || BASE64URL(JWS Payload) || '.' || BASE64URL(JWS 630 Signature). The JWS JSON Serialization is described in 631 Section 7.2. 633 5.2. Message Signature or MAC Validation 635 When validating a JWS, the following steps MUST be taken. The order 636 of the steps is not significant in cases where there are no 637 dependencies between the inputs and outputs of the steps. If any of 638 the listed steps fails, then the signature or MAC cannot be 639 validated. 641 It is an application decision which signatures, MACs, or plaintext 642 values must successfully validate for the JWS to be accepted. In 643 some cases, all must successfully validate or the JWS will be 644 rejected. In other cases, only a specific signature, MAC, or 645 plaintext value needs to be successfully validated. However, in all 646 cases, at least one signature, MAC, or plaintext value MUST 647 successfully validate or the JWS MUST be rejected. 649 1. Parse the JWS representation to extract the serialized values 650 for the components of the JWS -- when using the JWS Compact 651 Serialization, the base64url encoded representations of the JWS 652 Protected Header, the JWS Payload, and the JWS Signature, and 653 when using the JWS JSON Serialization, also the unencoded JWS 654 Unprotected Header value. When using the JWS Compact 655 Serialization, the JWS Protected Header, the JWS Payload, and 656 the JWS Signature are represented as base64url encoded values in 657 that order, separated by two period ('.') characters. The JWS 658 JSON Serialization is described in Section 7.2. 659 2. The encoded representation of the JWS Protected Header MUST be 660 successfully base64url decoded following the restriction that no 661 padding characters have been used. 662 3. The resulting octet sequence MUST be a UTF-8 encoded 663 representation of a completely valid JSON object conforming to 664 RFC 4627 [RFC4627], which is the JWS Protected Header. 665 4. If using the JWS Compact Serialization, let the JWS Header be 666 the JWS Protected Header; otherwise, when using the JWS JSON 667 Serialization, let the JWS Header be the union of the members of 668 the corresponding JWS Protected Header and JWS Unprotected 669 Header, all of which must be completely valid JSON objects. 670 5. The resulting JWS Header MUST NOT contain duplicate Header 671 Parameter names. When using the JWS JSON Serialization, this 672 restriction includes that the same Header Parameter name also 673 MUST NOT occur in distinct JSON object values that together 674 comprise the JWS Header. 675 6. Verify that the implementation understands and can process all 676 fields that it is required to support, whether required by this 677 specification, by the algorithm being used, or by the "crit" 678 Header Parameter value, and that the values of those parameters 679 are also understood and supported. 680 7. The encoded representation of the JWS Payload MUST be 681 successfully base64url decoded following the restriction that no 682 padding characters have been used. 683 8. The encoded representation of the JWS Signature MUST be 684 successfully base64url decoded following the restriction that no 685 padding characters have been used. 686 9. The JWS Signature MUST be successfully validated against the JWS 687 Signing Input ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' 688 || BASE64URL(JWS Payload)) in the manner defined for the 689 algorithm being used, which MUST be accurately represented by 690 the value of the "alg" (algorithm) Header Parameter, which MUST 691 be present. 692 10. If the JWS JSON Serialization is being used, repeat this process 693 (steps 1-9) for each digital signature or MAC value contained in 694 the representation. 696 5.3. String Comparison Rules 698 Processing a JWS inevitably requires comparing known strings to 699 members and values in a JSON object. For example, in checking what 700 the algorithm is, the Unicode string "alg" will be checked against 701 the member names in the JWS Header to see if there is a matching 702 Header Parameter name. The same process is then used to determine if 703 the value of the "alg" Header Parameter represents a supported 704 algorithm. 706 Since the only string comparision operations that are performed are 707 equality and inequality, the same rules can be used for comparing 708 both member names and member values against known strings. The JSON 709 rules for doing member name comparison are described in Section 8.3 710 of [I-D.ietf-json-rfc4627bis]. 712 Also, see the JSON security considerations in Section 10.2 and the 713 Unicode security considerations in Section 10.3. 715 6. Key Identification 717 It is necessary for the recipient of a JWS to be able to determine 718 the key that was employed for the digital signature or MAC operation. 719 The key employed can be identified using the Header Parameter methods 720 described in Section 4.1 or can be identified using methods that are 721 outside the scope of this specification. Specifically, the Header 722 Parameters "jku", "jwk", "x5u", "x5t", "x5c", and "kid" can be used 723 to identify the key used. These Header Parameters MUST be integrity 724 protected if the information that they convey is to be utilized in a 725 trust decision. 727 The sender SHOULD include sufficient information in the Header 728 Parameters to identify the key used, unless the application uses 729 another means or convention to determine the key used. Validation of 730 the signature or MAC fails when the algorithm used requires a key 731 (which is true of all algorithms except for "none") and the key used 732 cannot be determined. 734 The means of exchanging any shared symmetric keys used is outside the 735 scope of this specification. 737 7. Serializations 739 JWS objects use one of two serializations, the JWS Compact 740 Serialization or the JWS JSON Serialization. Applications using this 741 specification need to specify what serialization and serialization 742 features are used for that application. For instance, applications 743 might specify that only the JWS JSON Serialization is used, that only 744 JWS JSON Serialization support for a single signature or MAC value is 745 used, or that support for multiple signatures and/or MAC values is 746 used. JWS implementations only need to implement the features needed 747 for the applications they are designed to support. 749 7.1. JWS Compact Serialization 751 The JWS Compact Serialization represents digitally signed or MACed 752 content as a compact URL-safe string. This string is 753 BASE64URL(UTF8(JWS Protected Header)) || '.' || BASE64URL(JWS 754 Payload) || '.' || BASE64URL(JWS Signature). Only one signature/MAC 755 is supported by the JWS Compact Serialization and it provides no 756 syntax to represent a JWS Unprotected Header value. 758 7.2. JWS JSON Serialization 760 The JWS JSON Serialization represents digitally signed or MACed 761 content as a JSON object. Unlike the JWS Compact Serialization, 762 content using the JWS JSON Serialization can be secured with more 763 than one digital signature and/or MAC value. 765 The representation is closely related to that used in the JWS Compact 766 Serialization, with the following differences for the JWS JSON 767 Serialization: 768 o Values in the JWS JSON Serialization are represented as members of 769 a JSON object, rather than as base64url encoded strings separated 770 by period ('.') characters. (However binary values and values 771 that are integrity protected are still base64url encoded.) 772 o The value BASE64URL(JWS Payload) is stored in the "payload" 773 member. 774 o There can be multiple signature and/or MAC values, rather than 775 just one. A JSON array in the "signatures" member is used to hold 776 values that are specific to a particular signature or MAC 777 computation, with one array element per signature/MAC represented. 778 These array elements are JSON objects. 779 o Each value BASE64URL(JWS Signature), if non-empty, is stored in 780 the "signature" member of a JSON object that is an element of the 781 "signatures" array. 782 o Each value BASE64URL(UTF8(JWS Protected Header)), if non-empty, is 783 stored in the "protected" member of the corresponding element of 784 the "signatures" array. 785 o Each JWS Unprotected Header value, if non-empty, is stored in the 786 "header" member of the corresponding element of the "signatures" 787 array. If present, a JWS Unprotected Header value is represented 788 as an unencoded JSON object, rather than as a string. 790 o The Header Parameter values used when creating or validating 791 individual signature or MAC values are the union of the two sets 792 of Header Parameter values that may be present: (1) the JWS 793 Protected Header values represented in the "protected" member of 794 the signature/MAC's array element, and (2) the JWS Unprotected 795 Header values in the "header" member of the signature/MAC's array 796 element. The union of these sets of Header Parameters comprises 797 the JWS Header. The Header Parameter names in the two locations 798 MUST be disjoint. 800 The syntax of a JWS using the JWS JSON Serialization is as follows: 802 { 803 "payload":"" 804 "signatures":[ 805 {"protected":", 806 "header":"", 807 "signature":""}, 808 ... 809 {"protected":", 810 "header":"", 811 "signature":""}], 812 } 814 Of these members, only the "payload", "signatures", and "signature" 815 members MUST be present. At least one of the "protected" and 816 "header" members MUST be present for each signature/MAC computation 817 so that an "alg" Header Parameter value is conveyed. 819 The contents of the JWS Payload and JWS Signature values are exactly 820 as defined in the rest of this specification. They are interpreted 821 and validated in the same manner, with each corresponding JWS 822 Signature and set of Header Parameter values being created and 823 validated together. The JWS Header values used are the union of the 824 Header Parameters in the corresponding JWS Protected Header and JWS 825 Unprotected Header values, as described earlier. 827 Each JWS Signature value is computed on the JWS Signing Input using 828 the parameters of the corresponding JWS Header value in the same 829 manner as for the JWS Compact Serialization. This has the desirable 830 property that each JWS Signature value represented in the 831 "signatures" array is identical to the value that would have been 832 computed for the same parameter in the JWS Compact Serialization, 833 provided that the JWS Protected Header value for that signature/MAC 834 computation (which represents the integrity-protected Header 835 Parameter values) matches that used in the JWS Compact Serialization. 837 See Appendix A.6 for an example of computing a JWS using the JWS JSON 838 Serialization. 840 8. TLS Requirements 842 Implementations MUST support TLS. Which version(s) ought to be 843 implemented will vary over time, and depend on the widespread 844 deployment and known security vulnerabilities at the time of 845 implementation. At the time of this writing, TLS version 1.2 846 [RFC5246] is the most recent version, but has very limited actual 847 deployment, and might not be readily available in implementation 848 toolkits. TLS version 1.0 [RFC2246] is the most widely deployed 849 version, and will give the broadest interoperability. 851 To protect against information disclosure and tampering, 852 confidentiality protection MUST be applied using TLS with a 853 ciphersuite that provides confidentiality and integrity protection. 855 Whenever TLS is used, a TLS server certificate check MUST be 856 performed, per RFC 6125 [RFC6125]. 858 9. IANA Considerations 860 The following registration procedure is used for all the registries 861 established by this specification. 863 Values are registered with a Specification Required [RFC5226] after a 864 two-week review period on the [TBD]@ietf.org mailing list, on the 865 advice of one or more Designated Experts. However, to allow for the 866 allocation of values prior to publication, the Designated Expert(s) 867 may approve registration once they are satisfied that such a 868 specification will be published. 870 Registration requests must be sent to the [TBD]@ietf.org mailing list 871 for review and comment, with an appropriate subject (e.g., "Request 872 for access token type: example"). [[ Note to the RFC Editor: The name 873 of the mailing list should be determined in consultation with the 874 IESG and IANA. Suggested name: jose-reg-review. ]] 876 Within the review period, the Designated Expert(s) will either 877 approve or deny the registration request, communicating this decision 878 to the review list and IANA. Denials should include an explanation 879 and, if applicable, suggestions as to how to make the request 880 successful. Registration requests that are undetermined for a period 881 longer than 21 days can be brought to the IESG's attention (using the 882 iesg@iesg.org mailing list) for resolution. 884 Criteria that should be applied by the Designated Expert(s) includes 885 determining whether the proposed registration duplicates existing 886 functionality, determining whether it is likely to be of general 887 applicability or whether it is useful only for a single application, 888 and whether the registration makes sense. 890 IANA must only accept registry updates from the Designated Expert(s) 891 and should direct all requests for registration to the review mailing 892 list. 894 It is suggested that multiple Designated Experts be appointed who are 895 able to represent the perspectives of different applications using 896 this specification, in order to enable broadly-informed review of 897 registration decisions. In cases where a registration decision could 898 be perceived as creating a conflict of interest for a particular 899 Expert, that Expert should defer to the judgment of the other 900 Expert(s). 902 9.1. JSON Web Signature and Encryption Header Parameters Registry 904 This specification establishes the IANA JSON Web Signature and 905 Encryption Header Parameters registry for JWS and JWE Header 906 Parameter names. The registry records the Header Parameter name and 907 a reference to the specification that defines it. The same Header 908 Parameter name can be registered multiple times, provided that the 909 parameter usage is compatible between the specifications. Different 910 registrations of the same Header Parameter name will typically use 911 different Header Parameter Usage Location(s) values. 913 9.1.1. Registration Template 915 Header Parameter Name: 916 The name requested (e.g., "example"). Because a core goal of this 917 specification is for the resulting representations to be compact, 918 it is RECOMMENDED that the name be short -- not to exceed 8 919 characters without a compelling reason to do so. This name is 920 case-sensitive. Names may not match other registered names in a 921 case-insensitive manner unless the Designated Expert(s) state that 922 there is a compelling reason to allow an exception in this 923 particular case. 924 Header Parameter Description: 925 Brief description of the Header Parameter (e.g., "Example 926 description"). 927 Header Parameter Usage Location(s): 928 The Header Parameter usage locations, which should be one or more 929 of the values "JWS" or "JWE". 931 Change Controller: 932 For Standards Track RFCs, state "IESG". For others, give the name 933 of the responsible party. Other details (e.g., postal address, 934 email address, home page URI) may also be included. 935 Specification Document(s): 936 Reference to the document(s) that specify the parameter, 937 preferably including URI(s) that can be used to retrieve copies of 938 the document(s). An indication of the relevant sections may also 939 be included but is not required. 941 9.1.2. Initial Registry Contents 943 This specification registers the Header Parameter names defined in 944 Section 4.1 in this registry. 946 o Header Parameter Name: "alg" 947 o Header Parameter Description: Algorithm 948 o Header Parameter Usage Location(s): JWS 949 o Change Controller: IESG 950 o Specification Document(s): Section 4.1.1 of [[ this document ]] 952 o Header Parameter Name: "jku" 953 o Header Parameter Description: JWK Set URL 954 o Header Parameter Usage Location(s): JWS 955 o Change Controller: IESG 956 o Specification Document(s): Section 4.1.2 of [[ this document ]] 958 o Header Parameter Name: "jwk" 959 o Header Parameter Description: JSON Web Key 960 o Header Parameter Usage Location(s): JWS 961 o Change Controller: IESG 962 o Specification document(s): Section 4.1.3 of [[ this document ]] 964 o Header Parameter Name: "x5u" 965 o Header Parameter Description: X.509 URL 966 o Header Parameter Usage Location(s): JWS 967 o Change Controller: IESG 968 o Specification Document(s): Section 4.1.4 of [[ this document ]] 970 o Header Parameter Name: "x5t" 971 o Header Parameter Description: X.509 Certificate SHA-1 Thumbprint 972 o Header Parameter Usage Location(s): JWS 973 o Change Controller: IESG 974 o Specification Document(s): Section 4.1.5 of [[ this document ]] 976 o Header Parameter Name: "x5c" 977 o Header Parameter Description: X.509 Certificate Chain 978 o Header Parameter Usage Location(s): JWS 979 o Change Controller: IESG 980 o Specification Document(s): Section 4.1.6 of [[ this document ]] 982 o Header Parameter Name: "kid" 983 o Header Parameter Description: Key ID 984 o Header Parameter Usage Location(s): JWS 985 o Change Controller: IESG 986 o Specification Document(s): Section 4.1.7 of [[ this document ]] 988 o Header Parameter Name: "typ" 989 o Header Parameter Description: Type 990 o Header Parameter Usage Location(s): JWS 991 o Change Controller: IESG 992 o Specification Document(s): Section 4.1.8 of [[ this document ]] 994 o Header Parameter Name: "cty" 995 o Header Parameter Description: Content Type 996 o Header Parameter Usage Location(s): JWS 997 o Change Controller: IESG 998 o Specification Document(s): Section 4.1.9 of [[ this document ]] 1000 o Header Parameter Name: "crit" 1001 o Header Parameter Description: Critical 1002 o Header Parameter Usage Location(s): JWS 1003 o Change Controller: IESG 1004 o Specification Document(s): Section 4.1.10 of [[ this document ]] 1006 9.2. Media Type Registration 1008 9.2.1. Registry Contents 1010 This specification registers the "application/jose" Media Type 1011 [RFC2046] in the MIME Media Types registry [IANA.MediaTypes], which 1012 can be used to indicate that the content is a JWS or JWE object using 1013 the JWS Compact Serialization or the JWE Compact Serialization and 1014 the "application/jose+json" Media Type in the MIME Media Types 1015 registry, which can be used to indicate that the content is a JWS or 1016 JWE object using the JWS JSON Serialization or the JWE JSON 1017 Serialization. 1019 o Type name: application 1020 o Subtype name: jose 1021 o Required parameters: n/a 1022 o Optional parameters: n/a 1023 o Encoding considerations: 8bit; application/jose values are encoded 1024 as a series of base64url encoded values (some of which may be the 1025 empty string) separated by period ('.') characters. 1026 o Security considerations: See the Security Considerations section 1027 of [[ this document ]] 1028 o Interoperability considerations: n/a 1029 o Published specification: [[ this document ]] 1030 o Applications that use this media type: OpenID Connect, Mozilla 1031 Persona, Salesforce, Google, numerous others that use signed JWTs 1032 o Additional information: Magic number(s): n/a, File extension(s): 1033 n/a, Macintosh file type code(s): n/a 1034 o Person & email address to contact for further information: Michael 1035 B. Jones, mbj@microsoft.com 1036 o Intended usage: COMMON 1037 o Restrictions on usage: none 1038 o Author: Michael B. Jones, mbj@microsoft.com 1039 o Change Controller: IESG 1041 o Type name: application 1042 o Subtype name: jose+json 1043 o Required parameters: n/a 1044 o Optional parameters: n/a 1045 o Encoding considerations: 8bit; application/jose+json values are 1046 represented as a JSON Object; UTF-8 encoding SHOULD be employed 1047 for the JSON object. 1048 o Security considerations: See the Security Considerations section 1049 of [[ this document ]] 1050 o Interoperability considerations: n/a 1051 o Published specification: [[ this document ]] 1052 o Applications that use this media type: TBD 1053 o Additional information: Magic number(s): n/a, File extension(s): 1054 n/a, Macintosh file type code(s): n/a 1055 o Person & email address to contact for further information: Michael 1056 B. Jones, mbj@microsoft.com 1057 o Intended usage: COMMON 1058 o Restrictions on usage: none 1059 o Author: Michael B. Jones, mbj@microsoft.com 1060 o Change Controller: IESG 1062 10. Security Considerations 1064 10.1. Cryptographic Security Considerations 1066 All of the security issues faced by any cryptographic application 1067 must be faced by a JWS/JWE/JWK agent. Among these issues are 1068 protecting the user's private and symmetric keys, preventing various 1069 attacks, and helping the user avoid mistakes such as inadvertently 1070 encrypting a message for the wrong recipient. The entire list of 1071 security considerations is beyond the scope of this document, but 1072 some significant concerns are listed here. 1074 All the security considerations in XML DSIG 2.0 1075 [W3C.CR-xmldsig-core2-20120124], also apply to this specification, 1076 other than those that are XML specific. Likewise, many of the best 1077 practices documented in XML Signature Best Practices 1078 [W3C.WD-xmldsig-bestpractices-20110809] also apply to this 1079 specification, other than those that are XML specific. 1081 Keys are only as strong as the amount of entropy used to generate 1082 them. A minimum of 128 bits of entropy should be used for all keys, 1083 and depending upon the application context, more may be required. In 1084 particular, it may be difficult to generate sufficiently random 1085 values in some browsers and application environments. 1087 Creators of JWSs should not allow third parties to insert arbitrary 1088 content into the message without adding entropy not controlled by the 1089 third party. 1091 When utilizing TLS to retrieve information, the authority providing 1092 the resource MUST be authenticated and the information retrieved MUST 1093 be free from modification. 1095 When cryptographic algorithms are implemented in such a way that 1096 successful operations take a different amount of time than 1097 unsuccessful operations, attackers may be able to use the time 1098 difference to obtain information about the keys employed. Therefore, 1099 such timing differences must be avoided. 1101 A SHA-1 hash is used when computing "x5t" (x.509 certificate 1102 thumbprint) values, for compatibility reasons. Should an effective 1103 means of producing SHA-1 hash collisions be developed, and should an 1104 attacker wish to interfere with the use of a known certificate on a 1105 given system, this could be accomplished by creating another 1106 certificate whose SHA-1 hash value is the same and adding it to the 1107 certificate store used by the intended victim. A prerequisite to 1108 this attack succeeding is the attacker having write access to the 1109 intended victim's certificate store. 1111 If, in the future, certificate thumbprints need to be computed using 1112 hash functions other than SHA-1, it is suggested that additional 1113 related Header Parameters be defined for that purpose. For example, 1114 it is suggested that a new "x5t#S256" (X.509 Certificate Thumbprint 1115 using SHA-256) Header Parameter could be defined and used. 1117 10.2. JSON Security Considerations 1119 Strict JSON validation is a security requirement. If malformed JSON 1120 is received, then the intent of the sender is impossible to reliably 1121 discern. Ambiguous and potentially exploitable situations could 1122 arise if the JSON parser used does not reject malformed JSON syntax. 1124 Section 2.2 of the JavaScript Object Notation (JSON) specification 1125 [RFC4627] states "The names within an object SHOULD be unique", 1126 whereas this specification states that "Header Parameter names within 1127 this object MUST be unique; recipients MUST either reject JWSs with 1128 duplicate Header Parameter names or use a JSON parser that returns 1129 only the lexically last duplicate member name, as specified in 1130 Section 15.12 (The JSON Object) of ECMAScript 5.1 [ECMAScript]". 1131 Thus, this specification requires that the Section 2.2 "SHOULD" be 1132 treated as a "MUST" by senders and that it be either treated as a 1133 "MUST" or in the manner specified in ECMAScript 5.1 by receivers. 1134 Ambiguous and potentially exploitable situations could arise if the 1135 JSON parser used does not enforce the uniqueness of member names or 1136 returns an unpredictable value for duplicate member names. 1138 Some JSON parsers might not reject input that contains extra 1139 significant characters after a valid input. For instance, the input 1140 "{"tag":"value"}ABCD" contains a valid JSON object followed by the 1141 extra characters "ABCD". Such input MUST be rejected in its 1142 entirety. 1144 10.3. Unicode Comparison Security Considerations 1146 Header Parameter names and algorithm names are Unicode strings. For 1147 security reasons, the representations of these names must be compared 1148 verbatim after performing any escape processing (as per RFC 4627 1149 [RFC4627], Section 2.5). This means, for instance, that these JSON 1150 strings must compare as being equal ("sig", "\u0073ig"), whereas 1151 these must all compare as being not equal to the first set or to each 1152 other ("SIG", "Sig", "si\u0047"). 1154 JSON strings can contain characters outside the Unicode Basic 1155 Multilingual Plane. For instance, the G clef character (U+1D11E) may 1156 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWS 1157 implementations SHOULD ensure that characters outside the Basic 1158 Multilingual Plane are preserved and compared correctly; 1159 alternatively, if this is not possible due to these characters 1160 exercising limitations present in the underlying JSON implementation, 1161 then input containing them MUST be rejected. 1163 11. References 1164 11.1. Normative References 1166 [ECMAScript] 1167 Ecma International, "ECMAScript Language Specification, 1168 5.1 Edition", ECMA 262, June 2011. 1170 [I-D.ietf-json-rfc4627bis] 1171 Bray, T., "The JSON Data Interchange Format", 1172 draft-ietf-json-rfc4627bis-07 (work in progress), 1173 November 2013. 1175 [IANA.MediaTypes] 1176 Internet Assigned Numbers Authority (IANA), "MIME Media 1177 Types", 2005. 1179 [ITU.X690.1994] 1180 International Telecommunications Union, "Information 1181 Technology - ASN.1 encoding rules: Specification of Basic 1182 Encoding Rules (BER), Canonical Encoding Rules (CER) and 1183 Distinguished Encoding Rules (DER)", ITU-T Recommendation 1184 X.690, 1994. 1186 [JWA] Jones, M., "JSON Web Algorithms (JWA)", 1187 draft-ietf-jose-json-web-algorithms (work in progress), 1188 November 2013. 1190 [JWK] Jones, M., "JSON Web Key (JWK)", 1191 draft-ietf-jose-json-web-key (work in progress), 1192 November 2013. 1194 [RFC1421] Linn, J., "Privacy Enhancement for Internet Electronic 1195 Mail: Part I: Message Encryption and Authentication 1196 Procedures", RFC 1421, February 1993. 1198 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1199 Extensions (MIME) Part One: Format of Internet Message 1200 Bodies", RFC 2045, November 1996. 1202 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1203 Extensions (MIME) Part Two: Media Types", RFC 2046, 1204 November 1996. 1206 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1207 Requirement Levels", BCP 14, RFC 2119, March 1997. 1209 [RFC2246] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", 1210 RFC 2246, January 1999. 1212 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 1214 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 1215 10646", STD 63, RFC 3629, November 2003. 1217 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1218 Resource Identifier (URI): Generic Syntax", STD 66, 1219 RFC 3986, January 2005. 1221 [RFC4627] Crockford, D., "The application/json Media Type for 1222 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 1224 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 1225 Encodings", RFC 4648, October 2006. 1227 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 1228 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 1229 May 2008. 1231 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1232 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 1234 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1235 Housley, R., and W. Polk, "Internet X.509 Public Key 1236 Infrastructure Certificate and Certificate Revocation List 1237 (CRL) Profile", RFC 5280, May 2008. 1239 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 1240 Verification of Domain-Based Application Service Identity 1241 within Internet Public Key Infrastructure Using X.509 1242 (PKIX) Certificates in the Context of Transport Layer 1243 Security (TLS)", RFC 6125, March 2011. 1245 [USASCII] American National Standards Institute, "Coded Character 1246 Set -- 7-bit American Standard Code for Information 1247 Interchange", ANSI X3.4, 1986. 1249 [W3C.WD-xmldsig-bestpractices-20110809] 1250 Datta, P. and F. Hirsch, "XML Signature Best Practices", 1251 World Wide Web Consortium WD WD-xmldsig-bestpractices- 1252 20110809, August 2011, . 1255 11.2. Informative References 1257 [CanvasApp] 1258 Facebook, "Canvas Applications", 2010. 1260 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 1261 September 2010. 1263 [JWE] Jones, M., Rescorla, E., and J. Hildebrand, "JSON Web 1264 Encryption (JWE)", draft-ietf-jose-json-web-encryption 1265 (work in progress), November 2013. 1267 [JWT] Jones, M., Bradley, J., and N. Sakimura, "JSON Web Token 1268 (JWT)", draft-ietf-oauth-json-web-token (work in 1269 progress), November 2013. 1271 [MagicSignatures] 1272 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 1273 Signatures", January 2011. 1275 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 1276 Unique IDentifier (UUID) URN Namespace", RFC 4122, 1277 July 2005. 1279 [W3C.CR-xmldsig-core2-20120124] 1280 Eastlake, D., Reagle, J., Yiu, K., Solo, D., Datta, P., 1281 Hirsch, F., Cantor, S., and T. Roessler, "XML Signature 1282 Syntax and Processing Version 2.0", World Wide Web 1283 Consortium CR CR-xmldsig-core2-20120124, January 2012, 1284 . 1286 Appendix A. JWS Examples 1288 This section provides several examples of JWSs. While the first 1289 three examples all represent JSON Web Tokens (JWTs) [JWT], the 1290 payload can be any octet sequence, as shown in Appendix A.4. 1292 A.1. Example JWS using HMAC SHA-256 1294 A.1.1. Encoding 1296 The following example JWS Protected Header declares that the data 1297 structure is a JSON Web Token (JWT) [JWT] and the JWS Signing Input 1298 is secured using the HMAC SHA-256 algorithm. 1300 {"typ":"JWT", 1301 "alg":"HS256"} 1303 The octets representing UTF8(JWS Protected Header) in this case are: 1305 [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 1306 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] 1307 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1308 Header)) gives this value: 1310 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1312 The JWS Payload used in this example is the octets of the UTF-8 1313 representation of the JSON object below. (Note that the payload can 1314 be any base64url encoded octet sequence, and need not be a base64url 1315 encoded JSON object.) 1317 {"iss":"joe", 1318 "exp":1300819380, 1319 "http://example.com/is_root":true} 1321 The following octet sequence, which is the UTF-8 representation of 1322 the JSON object above, is the JWS Payload: 1324 [123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, 1325 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, 1326 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, 1327 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, 1328 111, 116, 34, 58, 116, 114, 117, 101, 125] 1330 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1331 Header)) gives this value (with line breaks for display purposes 1332 only): 1334 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1335 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1337 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1338 BASE64URL(JWS Payload) gives this string (with line breaks for 1339 display purposes only): 1341 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1342 . 1343 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1344 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1346 The resulting JWS Signing Input value, which is the ASCII 1347 representation of above string, is the following octet sequence: 1349 [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, 1350 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, 1351 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 1352 77, 105, 79, 105, 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 1353 74, 108, 101, 72, 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 1354 107, 122, 79, 68, 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 1355 72, 65, 54, 76, 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 1356 109, 78, 118, 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 1357 106, 112, 48, 99, 110, 86, 108, 102, 81] 1359 HMACs are generated using keys. This example uses the symmetric key 1360 represented in JSON Web Key [JWK] format below (with line breaks for 1361 display purposes only): 1363 {"kty":"oct", 1364 "k":"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75 1365 aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow" 1366 } 1368 Running the HMAC SHA-256 algorithm on the JWS Signing Input with this 1369 key yields this JWS Signature octet sequence: 1371 [116, 24, 223, 180, 151, 153, 224, 37, 79, 250, 96, 125, 216, 173, 1372 187, 186, 22, 212, 37, 77, 105, 214, 191, 240, 91, 88, 5, 88, 83, 1373 132, 141, 121] 1375 Encoding this JWS Signature as BASE64URL(JWS Signature) gives this 1376 value: 1378 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1380 Concatenating these values in the order Header.Payload.Signature with 1381 period ('.') characters between the parts yields this complete JWS 1382 representation using the JWS Compact Serialization (with line breaks 1383 for display purposes only): 1385 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1386 . 1387 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1388 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1389 . 1390 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1392 A.1.2. Validating 1394 Since the "alg" Header Parameter is "HS256", we validate the HMAC 1395 SHA-256 value contained in the JWS Signature. 1397 To validate the HMAC value, we repeat the previous process of using 1398 the correct key and the JWS Signing Input as input to the HMAC SHA- 1399 256 function and then taking the output and determining if it matches 1400 the JWS Signature. If it matches exactly, the HMAC has been 1401 validated. 1403 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 1405 A.2.1. Encoding 1407 The JWS Protected Header in this example is different from the 1408 previous example in two ways: First, because a different algorithm is 1409 being used, the "alg" value is different. Second, for illustration 1410 purposes only, the optional "typ" parameter is not used. (This 1411 difference is not related to the algorithm employed.) The JWS 1412 Protected Header used is: 1414 {"alg":"RS256"} 1416 The octets representing UTF8(JWS Protected Header) in this case are: 1418 [123, 34, 97, 108, 103, 34, 58, 34, 82, 83, 50, 53, 54, 34, 125] 1420 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1421 Header)) gives this value: 1423 eyJhbGciOiJSUzI1NiJ9 1425 The JWS Payload used in this example, which follows, is the same as 1426 in the previous example. Since the BASE64URL(JWS Payload) value will 1427 therefore be the same, its computation is not repeated here. 1429 {"iss":"joe", 1430 "exp":1300819380, 1431 "http://example.com/is_root":true} 1433 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1434 BASE64URL(JWS Payload) gives this string (with line breaks for 1435 display purposes only): 1437 eyJhbGciOiJSUzI1NiJ9 1438 . 1439 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1440 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1442 The resulting JWS Signing Input value, which is the ASCII 1443 representation of above string, is the following octet sequence: 1445 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73, 1446 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1447 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1448 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1449 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1450 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1451 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1452 99, 110, 86, 108, 102, 81] 1454 This example uses the RSA key represented in JSON Web Key [JWK] 1455 format below (with line breaks for display purposes only): 1457 {"kty":"RSA", 1458 "n":"ofgWCuLjybRlzo0tZWJjNiuSfb4p4fAkd_wWJcyQoTbji9k0l8W26mPddx 1459 HmfHQp-Vaw-4qPCJrcS2mJPMEzP1Pt0Bm4d4QlL-yRT-SFd2lZS-pCgNMs 1460 D1W_YpRPEwOWvG6b32690r2jZ47soMZo9wGzjb_7OMg0LOL-bSf63kpaSH 1461 SXndS5z5rexMdbBYUsLA9e-KXBdQOS-UTo7WTBEMa2R2CapHg665xsmtdV 1462 MTBQY4uDZlxvb3qCo5ZwKh9kG4LT6_I5IhlJH7aGhyxXFvUK-DWNmoudF8 1463 NAco9_h9iaGNj8q2ethFkMLs91kzk2PAcDTW9gb54h4FRWyuXpoQ", 1464 "e":"AQAB", 1465 "d":"Eq5xpGnNCivDflJsRQBXHx1hdR1k6Ulwe2JZD50LpXyWPEAeP88vLNO97I 1466 jlA7_GQ5sLKMgvfTeXZx9SE-7YwVol2NXOoAJe46sui395IW_GO-pWJ1O0 1467 BkTGoVEn2bKVRUCgu-GjBVaYLU6f3l9kJfFNS3E0QbVdxzubSu3Mkqzjkn 1468 439X0M_V51gfpRLI9JYanrC4D4qAdGcopV_0ZHHzQlBjudU2QvXt4ehNYT 1469 CBr6XCLQUShb1juUO1ZdiYoFaFQT5Tw8bGUl_x_jTj3ccPDVZFD9pIuhLh 1470 BOneufuBiB4cS98l2SR_RQyGWSeWjnczT0QU91p1DhOVRuOopznQ" 1471 } 1473 The RSA private key is then passed to the RSA signing function, which 1474 also takes the hash type, SHA-256, and the JWS Signing Input as 1475 inputs. The result of the digital signature is an octet sequence, 1476 which represents a big endian integer. In this example, it is: 1478 [112, 46, 33, 137, 67, 232, 143, 209, 30, 181, 216, 45, 191, 120, 69, 1479 243, 65, 6, 174, 27, 129, 255, 247, 115, 17, 22, 173, 209, 113, 125, 1480 131, 101, 109, 66, 10, 253, 60, 150, 238, 221, 115, 162, 102, 62, 81, 1481 102, 104, 123, 0, 11, 135, 34, 110, 1, 135, 237, 16, 115, 249, 69, 1482 229, 130, 173, 252, 239, 22, 216, 90, 121, 142, 232, 198, 109, 219, 1483 61, 184, 151, 91, 23, 208, 148, 2, 190, 237, 213, 217, 217, 112, 7, 1484 16, 141, 178, 129, 96, 213, 248, 4, 12, 167, 68, 87, 98, 184, 31, 1485 190, 127, 249, 217, 46, 10, 231, 111, 36, 242, 91, 51, 187, 230, 244, 1486 74, 230, 30, 177, 4, 10, 203, 32, 4, 77, 62, 249, 18, 142, 212, 1, 1487 48, 121, 91, 212, 189, 59, 65, 238, 202, 208, 102, 171, 101, 25, 129, 1488 253, 228, 141, 247, 127, 55, 45, 195, 139, 159, 175, 221, 59, 239, 1489 177, 139, 93, 163, 204, 60, 46, 176, 47, 158, 58, 65, 214, 18, 202, 1490 173, 21, 145, 18, 115, 160, 95, 35, 185, 232, 56, 250, 175, 132, 157, 1491 105, 132, 41, 239, 90, 30, 136, 121, 130, 54, 195, 212, 14, 96, 69, 1492 34, 165, 68, 200, 242, 122, 122, 45, 184, 6, 99, 209, 108, 247, 202, 1493 234, 86, 222, 64, 92, 178, 33, 90, 69, 178, 194, 85, 102, 181, 90, 1494 193, 167, 72, 160, 112, 223, 200, 163, 42, 70, 149, 67, 208, 25, 238, 1495 251, 71] 1497 Encoding the signature as BASE64URL(JWS Signature) produces this 1498 value (with line breaks for display purposes only): 1500 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1501 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1502 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1503 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1504 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1505 p0igcN_IoypGlUPQGe77Rw 1507 Concatenating these values in the order Header.Payload.Signature with 1508 period ('.') characters between the parts yields this complete JWS 1509 representation using the JWS Compact Serialization (with line breaks 1510 for display purposes only): 1512 eyJhbGciOiJSUzI1NiJ9 1513 . 1514 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1515 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1516 . 1517 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1518 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1519 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1520 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1521 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1522 p0igcN_IoypGlUPQGe77Rw 1524 A.2.2. Validating 1526 Since the "alg" Header Parameter is "RS256", we validate the RSASSA- 1527 PKCS-v1_5 SHA-256 digital signature contained in the JWS Signature. 1529 Validating the JWS Signature is a little different from the previous 1530 example. We pass (n, e), JWS Signature, and the JWS Signing Input to 1531 an RSASSA-PKCS-v1_5 signature verifier that has been configured to 1532 use the SHA-256 hash function. 1534 A.3. Example JWS using ECDSA P-256 SHA-256 1536 A.3.1. Encoding 1538 The JWS Protected Header for this example differs from the previous 1539 example because a different algorithm is being used. The JWS 1540 Protected Header used is: 1542 {"alg":"ES256"} 1544 The octets representing UTF8(JWS Protected Header) in this case are: 1546 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 50, 53, 54, 34, 125] 1547 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1548 Header)) gives this value: 1550 eyJhbGciOiJFUzI1NiJ9 1552 The JWS Payload used in this example, which follows, is the same as 1553 in the previous examples. Since the BASE64URL(JWS Payload) value 1554 will therefore be the same, its computation is not repeated here. 1556 {"iss":"joe", 1557 "exp":1300819380, 1558 "http://example.com/is_root":true} 1560 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1561 BASE64URL(JWS Payload) gives this string (with line breaks for 1562 display purposes only): 1564 eyJhbGciOiJFUzI1NiJ9 1565 . 1566 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1567 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1569 The resulting JWS Signing Input value, which is the ASCII 1570 representation of above string, is the following octet sequence: 1572 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 73, 1573 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1574 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1575 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1576 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1577 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1578 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1579 99, 110, 86, 108, 102, 81] 1581 This example uses the elliptic curve key represented in JSON Web Key 1582 [JWK] format below: 1584 {"kty":"EC", 1585 "crv":"P-256", 1586 "x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU", 1587 "y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0", 1588 "d":"jpsQnnGQmL-YBIffH1136cspYG6-0iY7X1fCE9-E9LI" 1589 } 1591 The ECDSA private part d is then passed to an ECDSA signing function, 1592 which also takes the curve type, P-256, the hash type, SHA-256, and 1593 the JWS Signing Input as inputs. The result of the digital signature 1594 is the EC point (R, S), where R and S are unsigned integers. In this 1595 example, the R and S values, given as octet sequences representing 1596 big endian integers are: 1598 +--------+----------------------------------------------------------+ 1599 | Result | Value | 1600 | Name | | 1601 +--------+----------------------------------------------------------+ 1602 | R | [14, 209, 33, 83, 121, 99, 108, 72, 60, 47, 127, 21, 88, | 1603 | | 7, 212, 2, 163, 178, 40, 3, 58, 249, 124, 126, 23, 129, | 1604 | | 154, 195, 22, 158, 166, 101] | 1605 | S | [197, 10, 7, 211, 140, 60, 112, 229, 216, 241, 45, 175, | 1606 | | 8, 74, 84, 128, 166, 101, 144, 197, 242, 147, 80, 154, | 1607 | | 143, 63, 127, 138, 131, 163, 84, 213] | 1608 +--------+----------------------------------------------------------+ 1610 The JWS Signature is the value R || S. Encoding the signature as 1611 BASE64URL(JWS Signature) produces this value (with line breaks for 1612 display purposes only): 1614 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 1615 pmWQxfKTUJqPP3-Kg6NU1Q 1617 Concatenating these values in the order Header.Payload.Signature with 1618 period ('.') characters between the parts yields this complete JWS 1619 representation using the JWS Compact Serialization (with line breaks 1620 for display purposes only): 1622 eyJhbGciOiJFUzI1NiJ9 1623 . 1624 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1625 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1626 . 1627 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 1628 pmWQxfKTUJqPP3-Kg6NU1Q 1630 A.3.2. Validating 1632 Since the "alg" Header Parameter is "ES256", we validate the ECDSA 1633 P-256 SHA-256 digital signature contained in the JWS Signature. 1635 Validating the JWS Signature is a little different from the first 1636 example. We need to split the 64 member octet sequence of the JWS 1637 Signature into two 32 octet sequences, the first R and the second S. 1638 We then pass (x, y), (R, S) and the JWS Signing Input to an ECDSA 1639 signature verifier that has been configured to use the P-256 curve 1640 with the SHA-256 hash function. 1642 A.4. Example JWS using ECDSA P-521 SHA-512 1644 A.4.1. Encoding 1646 The JWS Protected Header for this example differs from the previous 1647 example because different ECDSA curves and hash functions are used. 1648 The JWS Protected Header used is: 1650 {"alg":"ES512"} 1652 The octets representing UTF8(JWS Protected Header) in this case are: 1654 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 53, 49, 50, 34, 125] 1656 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1657 Header)) gives this value: 1659 eyJhbGciOiJFUzUxMiJ9 1661 The JWS Payload used in this example, is the ASCII string "Payload". 1662 The representation of this string is the octet sequence: 1664 [80, 97, 121, 108, 111, 97, 100] 1666 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value: 1668 UGF5bG9hZA 1670 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1671 BASE64URL(JWS Payload) gives this string (with line breaks for 1672 display purposes only): 1674 eyJhbGciOiJFUzUxMiJ9.UGF5bG9hZA 1676 The resulting JWS Signing Input value, which is the ASCII 1677 representation of above string, is the following octet sequence: 1679 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 85, 1680 120, 77, 105, 74, 57, 46, 85, 71, 70, 53, 98, 71, 57, 104, 90, 65] 1682 This example uses the elliptic curve key represented in JSON Web Key 1683 [JWK] format below (with line breaks for display purposes only): 1685 {"kty":"EC", 1686 "crv":"P-521", 1687 "x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_ 1688 NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk", 1689 "y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDl 1690 y79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2", 1691 "d":"AY5pb7A0UFiB3RELSD64fTLOSV_jazdF7fLYyuTw8lOfRhWg6Y6rUrPA 1692 xerEzgdRhajnu0ferB0d53vM9mE15j2C" 1693 } 1695 The ECDSA private part d is then passed to an ECDSA signing function, 1696 which also takes the curve type, P-521, the hash type, SHA-512, and 1697 the JWS Signing Input as inputs. The result of the digital signature 1698 is the EC point (R, S), where R and S are unsigned integers. In this 1699 example, the R and S values, given as octet sequences representing 1700 big endian integers are: 1702 +--------+----------------------------------------------------------+ 1703 | Result | Value | 1704 | Name | | 1705 +--------+----------------------------------------------------------+ 1706 | R | [1, 220, 12, 129, 231, 171, 194, 209, 232, 135, 233, | 1707 | | 117, 247, 105, 122, 210, 26, 125, 192, 1, 217, 21, 82, | 1708 | | 91, 45, 240, 255, 83, 19, 34, 239, 71, 48, 157, 147, | 1709 | | 152, 105, 18, 53, 108, 163, 214, 68, 231, 62, 153, 150, | 1710 | | 106, 194, 164, 246, 72, 143, 138, 24, 50, 129, 223, 133, | 1711 | | 206, 209, 172, 63, 237, 119, 109] | 1712 | S | [0, 111, 6, 105, 44, 5, 41, 208, 128, 61, 152, 40, 92, | 1713 | | 61, 152, 4, 150, 66, 60, 69, 247, 196, 170, 81, 193, | 1714 | | 199, 78, 59, 194, 169, 16, 124, 9, 143, 42, 142, 131, | 1715 | | 48, 206, 238, 34, 175, 83, 203, 220, 159, 3, 107, 155, | 1716 | | 22, 27, 73, 111, 68, 68, 21, 238, 144, 229, 232, 148, | 1717 | | 188, 222, 59, 242, 103] | 1718 +--------+----------------------------------------------------------+ 1720 The JWS Signature is the value R || S. Encoding the signature as 1721 BASE64URL(JWS Signature) produces this value (with line breaks for 1722 display purposes only): 1724 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 1725 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 1726 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 1728 Concatenating these values in the order Header.Payload.Signature with 1729 period ('.') characters between the parts yields this complete JWS 1730 representation using the JWS Compact Serialization (with line breaks 1731 for display purposes only): 1733 eyJhbGciOiJFUzUxMiJ9 1734 . 1735 UGF5bG9hZA 1736 . 1737 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 1738 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 1739 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 1741 A.4.2. Validating 1743 Since the "alg" Header Parameter is "ES512", we validate the ECDSA 1744 P-521 SHA-512 digital signature contained in the JWS Signature. 1746 Validating the JWS Signature is similar to the previous example. We 1747 need to split the 132 member octet sequence of the JWS Signature into 1748 two 66 octet sequences, the first R and the second S. We then pass 1749 (x, y), (R, S) and the JWS Signing Input to an ECDSA signature 1750 verifier that has been configured to use the P-521 curve with the 1751 SHA-512 hash function. 1753 A.5. Example Plaintext JWS 1755 The following example JWS Protected Header declares that the encoded 1756 object is a Plaintext JWS: 1758 {"alg":"none"} 1760 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1761 Header)) gives this value: 1763 eyJhbGciOiJub25lIn0 1765 The JWS Payload used in this example, which follows, is the same as 1766 in the previous examples. Since the BASE64URL(JWS Payload) value 1767 will therefore be the same, its computation is not repeated here. 1769 {"iss":"joe", 1770 "exp":1300819380, 1771 "http://example.com/is_root":true} 1773 The JWS Signature is the empty octet string and BASE64URL(JWS 1774 Signature) is the empty string. 1776 Concatenating these parts in the order Header.Payload.Signature with 1777 period ('.') characters between the parts yields this complete JWS 1778 (with line breaks for display purposes only): 1780 eyJhbGciOiJub25lIn0 1781 . 1782 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1783 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1784 . 1786 A.6. Example JWS Using JWS JSON Serialization 1788 This section contains an example using the JWS JSON Serialization. 1789 This example demonstrates the capability for conveying multiple 1790 digital signatures and/or MACs for the same payload. 1792 The JWS Payload used in this example is the same as that used in the 1793 examples in Appendix A.2 and Appendix A.3 (with line breaks for 1794 display purposes only): 1796 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1797 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1799 Two digital signatures are used in this example: the first using 1800 RSASSA-PKCS-v1_5 SHA-256 and the second using ECDSA P-256 SHA-256. 1801 For the first, the JWS Protected Header and key are the same as in 1802 Appendix A.2, resulting in the same JWS Signature value; therefore, 1803 its computation is not repeated here. For the second, the JWS 1804 Protected Header and key are the same as in Appendix A.3, resulting 1805 in the same JWS Signature value; therefore, its computation is not 1806 repeated here. 1808 A.6.1. JWS Per-Signature Protected Headers 1810 The JWS Protected Header value used for the first signature is: 1812 {"alg":"RS256"} 1814 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1815 Header)) gives this value: 1817 eyJhbGciOiJSUzI1NiJ9 1819 The JWS Protected Header value used for the second signature is: 1821 {"alg":"ES256"} 1823 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1824 Header)) gives this value: 1826 eyJhbGciOiJFUzI1NiJ9 1828 A.6.2. JWS Per-Signature Unprotected Headers 1830 Key ID values are supplied for both keys using per-signature Header 1831 Parameters. The two values used to represent these Key IDs are: 1833 {"kid":"2010-12-29"} 1835 and 1837 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 1839 A.6.3. Complete JWS Header Values 1841 Combining the protected and unprotected header values supplied, the 1842 JWS Header values used for the first and second signatures 1843 respectively are: 1845 {"alg":"RS256", 1846 "kid":"2010-12-29"} 1848 and 1850 {"alg":"ES256", 1851 "kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 1853 A.6.4. Complete JWS JSON Serialization Representation 1855 The complete JSON Web Signature JSON Serialization for these values 1856 is as follows (with line breaks for display purposes only): 1858 {"payload": 1859 "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGF 1860 tcGxlLmNvbS9pc19yb290Ijp0cnVlfQ", 1861 "signatures":[ 1862 {"protected":"eyJhbGciOiJSUzI1NiJ9", 1863 "header": 1864 {"kid":"2010-12-29"}, 1865 "signature": 1866 "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZ 1867 mh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjb 1868 KBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHl 1869 b1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZES 1870 c6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AX 1871 LIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw"}, 1872 {"protected":"eyJhbGciOiJFUzI1NiJ9", 1873 "header": 1874 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"}, 1875 "signature": 1876 "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8IS 1877 lSApmWQxfKTUJqPP3-Kg6NU1Q"}] 1878 } 1880 Appendix B. "x5c" (X.509 Certificate Chain) Example 1882 The JSON array below is an example of a certificate chain that could 1883 be used as the value of an "x5c" (X.509 Certificate Chain) Header 1884 Parameter, per Section 4.1.6. Note that since these strings contain 1885 base64 encoded (not base64url encoded) values, they are allowed to 1886 contain white space and line breaks. 1888 ["MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVM 1889 xITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR2 1890 8gRGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExM 1891 TYwMTU0MzdaFw0yNjExMTYwMTU0MzdaMIHKMQswCQYDVQQGEwJVUzEQMA4GA1UE 1892 CBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEaMBgGA1UEChMRR29EYWR 1893 keS5jb20sIEluYy4xMzAxBgNVBAsTKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYW 1894 RkeS5jb20vcmVwb3NpdG9yeTEwMC4GA1UEAxMnR28gRGFkZHkgU2VjdXJlIENlc 1895 nRpZmljYXRpb24gQXV0aG9yaXR5MREwDwYDVQQFEwgwNzk2OTI4NzCCASIwDQYJ 1896 KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMQt1RWMnCZM7DI161+4WQFapmGBWTt 1897 wY6vj3D3HKrjJM9N55DrtPDAjhI6zMBS2sofDPZVUBJ7fmd0LJR4h3mUpfjWoqV 1898 Tr9vcyOdQmVZWt7/v+WIbXnvQAjYwqDL1CBM6nPwT27oDyqu9SoWlm2r4arV3aL 1899 GbqGmu75RpRSgAvSMeYddi5Kcju+GZtCpyz8/x4fKL4o/K1w/O5epHBp+YlLpyo 1900 7RJlbmr2EkRTcDCVw5wrWCs9CHRK8r5RsL+H0EwnWGu1NcWdrxcx+AuP7q2BNgW 1901 JCJjPOq8lh8BJ6qf9Z/dFjpfMFDniNoW1fho3/Rb2cRGadDAW/hOUoz+EDU8CAw 1902 EAAaOCATIwggEuMB0GA1UdDgQWBBT9rGEyk2xF1uLuhV+auud2mWjM5zAfBgNVH 1903 SMEGDAWgBTSxLDSkdRMEXGzYcs9of7dqGrU4zASBgNVHRMBAf8ECDAGAQH/AgEA 1904 MDMGCCsGAQUFBwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZ29kYWR 1905 keS5jb20wRgYDVR0fBD8wPTA7oDmgN4Y1aHR0cDovL2NlcnRpZmljYXRlcy5nb2 1906 RhZGR5LmNvbS9yZXBvc2l0b3J5L2dkcm9vdC5jcmwwSwYDVR0gBEQwQjBABgRVH 1907 SAAMDgwNgYIKwYBBQUHAgEWKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5j 1908 b20vcmVwb3NpdG9yeTAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggE 1909 BANKGwOy9+aG2Z+5mC6IGOgRQjhVyrEp0lVPLN8tESe8HkGsz2ZbwlFalEzAFPI 1910 UyIXvJxwqoJKSQ3kbTJSMUA2fCENZvD117esyfxVgqwcSeIaha86ykRvOe5GPLL 1911 5CkKSkB2XIsKd83ASe8T+5o0yGPwLPk9Qnt0hCqU7S+8MxZC9Y7lhyVJEnfzuz9 1912 p0iRFEUOOjZv2kWzRaJBydTXRE4+uXR21aITVSzGh6O1mawGhId/dQb8vxRMDsx 1913 uxN89txJx9OjxUUAiKEngHUuHqDTMBqLdElrRhjZkAzVvb3du6/KFUJheqwNTrZ 1914 EjYx8WnM25sgVjOuH0aBsXBTWVU+4=", 1915 "MIIE+zCCBGSgAwIBAgICAQ0wDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1Z 1916 hbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIE 1917 luYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb 1918 24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8x 1919 IDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTA0MDYyOTE3MDY 1920 yMFoXDTI0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRoZS 1921 BHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3MgM 1922 iBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN 1923 ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XC 1924 APVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux 1925 6wwdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLO 1926 tXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWo 1927 riMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZ 1928 Eewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjggHhMIIB3TAdBgNVHQ 1929 4EFgQU0sSw0pHUTBFxs2HLPaH+3ahq1OMwgdIGA1UdIwSByjCBx6GBwaSBvjCBu 1930 zEkMCIGA1UEBxMbVmFsaUNlcnQgVmFsaWRhdGlvbiBOZXR3b3JrMRcwFQYDVQQK 1931 Ew5WYWxpQ2VydCwgSW5jLjE1MDMGA1UECxMsVmFsaUNlcnQgQ2xhc3MgMiBQb2x 1932 pY3kgVmFsaWRhdGlvbiBBdXRob3JpdHkxITAfBgNVBAMTGGh0dHA6Ly93d3cudm 1933 FsaWNlcnQuY29tLzEgMB4GCSqGSIb3DQEJARYRaW5mb0B2YWxpY2VydC5jb22CA 1934 QEwDwYDVR0TAQH/BAUwAwEB/zAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGG 1935 F2h0dHA6Ly9vY3NwLmdvZGFkZHkuY29tMEQGA1UdHwQ9MDswOaA3oDWGM2h0dHA 1936 6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5jb20vcmVwb3NpdG9yeS9yb290LmNybD 1937 BLBgNVHSAERDBCMEAGBFUdIAAwODA2BggrBgEFBQcCARYqaHR0cDovL2NlcnRpZ 1938 mljYXRlcy5nb2RhZGR5LmNvbS9yZXBvc2l0b3J5MA4GA1UdDwEB/wQEAwIBBjAN 1939 BgkqhkiG9w0BAQUFAAOBgQC1QPmnHfbq/qQaQlpE9xXUhUaJwL6e4+PrxeNYiY+ 1940 Sn1eocSxI0YGyeR+sBjUZsE4OWBsUs5iB0QQeyAfJg594RAoYC5jcdnplDQ1tgM 1941 QLARzLrUc+cb53S8wGd9D0VmsfSxOaFIqII6hR8INMqzW/Rn453HWkrugp++85j 1942 09VZw==", 1943 "MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ 1944 0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNT 1945 AzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0a 1946 G9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkq 1947 hkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE 1948 5MDYyNjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTm 1949 V0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZ 1950 XJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQD 1951 ExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9 1952 AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5a 1953 vIWZJV16vYdA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zf 1954 N1SLUzm1NZ9WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwb 1955 P7RfZHM047QSv4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQU 1956 AA4GBADt/UG9vUJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQ 1957 C1u+mNr0HZDzTuIYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMM 1958 j4QssxsodyamEwCW/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd"] 1960 Appendix C. Notes on implementing base64url encoding without padding 1962 This appendix describes how to implement base64url encoding and 1963 decoding functions without padding based upon standard base64 1964 encoding and decoding functions that do use padding. 1966 To be concrete, example C# code implementing these functions is shown 1967 below. Similar code could be used in other languages. 1969 static string base64urlencode(byte [] arg) 1970 { 1971 string s = Convert.ToBase64String(arg); // Regular base64 encoder 1972 s = s.Split('=')[0]; // Remove any trailing '='s 1973 s = s.Replace('+', '-'); // 62nd char of encoding 1974 s = s.Replace('/', '_'); // 63rd char of encoding 1975 return s; 1976 } 1978 static byte [] base64urldecode(string arg) 1979 { 1980 string s = arg; 1981 s = s.Replace('-', '+'); // 62nd char of encoding 1982 s = s.Replace('_', '/'); // 63rd char of encoding 1983 switch (s.Length % 4) // Pad with trailing '='s 1984 { 1985 case 0: break; // No pad chars in this case 1986 case 2: s += "=="; break; // Two pad chars 1987 case 3: s += "="; break; // One pad char 1988 default: throw new System.Exception( 1989 "Illegal base64url string!"); 1990 } 1991 return Convert.FromBase64String(s); // Standard base64 decoder 1992 } 1994 As per the example code above, the number of '=' padding characters 1995 that needs to be added to the end of a base64url encoded string 1996 without padding to turn it into one with padding is a deterministic 1997 function of the length of the encoded string. Specifically, if the 1998 length mod 4 is 0, no padding is added; if the length mod 4 is 2, two 1999 '=' padding characters are added; if the length mod 4 is 3, one '=' 2000 padding character is added; if the length mod 4 is 1, the input is 2001 malformed. 2003 An example correspondence between unencoded and encoded values 2004 follows. The octet sequence below encodes into the string below, 2005 which when decoded, reproduces the octet sequence. 2006 3 236 255 224 193 2007 A-z_4ME 2009 Appendix D. Negative Test Case for "crit" Header Parameter 2011 Conforming implementations must reject input containing critical 2012 extensions that are not understood or cannot be processed. The 2013 following JWS must be rejected by all implementations, because it 2014 uses an extension Header Parameter name 2015 "http://example.invalid/UNDEFINED" that they do not understand. Any 2016 other similar input, in which the use of the value 2017 "http://example.invalid/UNDEFINED" is substituted for any other 2018 Header Parameter name not understood by the implementation, must also 2019 be rejected. 2021 The JWS Protected Header value for this JWS is: 2023 {"alg":"none", 2024 "crit":["http://example.invalid/UNDEFINED"], 2025 "http://example.invalid/UNDEFINED":true 2026 } 2028 The complete JWS that must be rejected is as follows (with line 2029 breaks for display purposes only): 2031 eyJhbGciOiJub25lIiwNCiAiY3JpdCI6WyJodHRwOi8vZXhhbXBsZS5jb20vVU5ERU 2032 ZJTkVEIl0sDQogImh0dHA6Ly9leGFtcGxlLmNvbS9VTkRFRklORUQiOnRydWUNCn0. 2033 RkFJTA. 2035 Appendix E. Detached Content 2037 In some contexts, it is useful integrity protect content that is not 2038 itself contained in a JWS object. One way to do this is create a JWS 2039 object in the normal fashion using a representation of the content as 2040 the payload, but then delete the payload representation from the JWS, 2041 and send this modified object to the recipient, rather than the JWS. 2042 When using the JWS Compact Serialization, the deletion is 2043 accomplished by replacing the second field (which contains 2044 BASE64URL(JWS Payload)) value with the empty string; when using the 2045 JWS JSON Serialization, the deletion is accomplished by deleting the 2046 "payload" member. This method assumes that the recipient can 2047 reconstruct the exact payload used in the JWS. To use the modified 2048 object, the recipient reconstructs the JWS by re-inserting the 2049 payload representation into the modified object, and uses the 2050 resulting JWS in the usual manner. Note that this method needs no 2051 support from JWS libraries, as applications can use this method by 2052 modifying the inputs and outputs of standard JWS libraries. 2054 Appendix F. Acknowledgements 2056 Solutions for signing JSON content were previously explored by Magic 2057 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 2058 Applications [CanvasApp], all of which influenced this draft. 2060 Thanks to Axel Nennker for his early implementation and feedback on 2061 the JWS and JWE specifications. 2063 This specification is the work of the JOSE Working Group, which 2064 includes dozens of active and dedicated participants. In particular, 2065 the following individuals contributed ideas, feedback, and wording 2066 that influenced this specification: 2068 Dirk Balfanz, Richard Barnes, Brian Campbell, Breno de Medeiros, Dick 2069 Hardt, Joe Hildebrand, Jeff Hodges, Edmund Jay, Yaron Y. Goland, Ben 2070 Laurie, James Manger, Matt Miller, Tony Nadalin, Axel Nennker, John 2071 Panzer, Emmanuel Raviart, Eric Rescorla, Jim Schaad, Paul Tarjan, 2072 Hannes Tschofenig, and Sean Turner. 2074 Jim Schaad and Karen O'Donoghue chaired the JOSE working group and 2075 Sean Turner and Stephen Farrell served as Security area directors 2076 during the creation of this specification. 2078 Appendix G. Document History 2080 [[ to be removed by the RFC Editor before publication as an RFC ]] 2082 -18 2084 o Updated the mandatory-to-implement (MTI) language to say that 2085 applications using this specification need to specify what 2086 serialization and serialization features are used for that 2087 application, addressing issue #119. 2089 o Changes to address editorial and minor issues #25, #89, #97, #110, 2090 #114, #115, #116, #117, #120, and #184. 2092 o Added and used Header Parameter Description registry field. 2094 -17 2096 o Refined the "typ" and "cty" definitions to always be MIME Media 2097 Types, with the omission of "application/" prefixes recommended 2098 for brevity, addressing issue #50. 2100 o Updated the mandatory-to-implement (MTI) language to say that 2101 general-purpose implementations must implement the single 2102 signature/MAC value case for both serializations whereas special- 2103 purpose implementations can implement just one serialization if 2104 that meets the needs of the use cases the implementation is 2105 designed for, addressing issue #119. 2107 o Explicitly named all the logical components of a JWS and defined 2108 the processing rules and serializations in terms of those 2109 components, addressing issues #60, #61, and #62. 2111 o Replaced verbose repetitive phases such as "base64url encode the 2112 octets of the UTF-8 representation of X" with mathematical 2113 notation such as "BASE64URL(UTF8(X))". 2115 o Terms used in multiple documents are now defined in one place and 2116 incorporated by reference. Some lightly used or obvious terms 2117 were also removed. This addresses issue #58. 2119 -16 2121 o Changes to address editorial and minor issues #50, #98, #99, #102, 2122 #104, #106, #107, #111, and #112. 2124 -15 2126 o Clarified that it is an application decision which signatures, 2127 MACs, or plaintext values must successfully validate for the JWS 2128 to be accepted, addressing issue #35. 2130 o Corrected editorial error in "ES512" example. 2132 o Changes to address editorial and minor issues #34, #96, #100, 2133 #101, #104, #105, and #106. 2135 -14 2137 o Stated that the "signature" parameter is to be omitted in the JWS 2138 JSON Serialization when its value would be empty (which is only 2139 the case for a Plaintext JWS). 2141 -13 2143 o Made all header parameter values be per-signature/MAC, addressing 2144 issue #24. 2146 -12 2148 o Clarified that the "typ" and "cty" header parameters are used in 2149 an application-specific manner and have no effect upon the JWS 2150 processing. 2152 o Replaced the MIME types "application/jws+json" and 2153 "application/jws" with "application/jose+json" and 2154 "application/jose". 2156 o Stated that recipients MUST either reject JWSs with duplicate 2157 Header Parameter Names or use a JSON parser that returns only the 2158 lexically last duplicate member name. 2160 o Added a Serializations section with parallel treatment of the JWS 2161 Compact Serialization and the JWS JSON Serialization and also 2162 moved the former Implementation Considerations content there. 2164 -11 2166 o Added Key Identification section. 2168 o For the JWS JSON Serialization, enable header parameter values to 2169 be specified in any of three parameters: the "protected" member 2170 that is integrity protected and shared among all recipients, the 2171 "unprotected" member that is not integrity protected and shared 2172 among all recipients, and the "header" member that is not 2173 integrity protected and specific to a particular recipient. (This 2174 does not affect the JWS Compact Serialization, in which all header 2175 parameter values are in a single integrity protected JWE Header 2176 value.) 2178 o Removed suggested compact serialization for multiple digital 2179 signatures and/or MACs. 2181 o Changed the MIME type name "application/jws-js" to 2182 "application/jws+json", addressing issue #22. 2184 o Tightened the description of the "crit" (critical) header 2185 parameter. 2187 o Added a negative test case for the "crit" header parameter 2188 -10 2190 o Added an appendix suggesting a possible compact serialization for 2191 JWSs with multiple digital signatures and/or MACs. 2193 -09 2195 o Added JWS JSON Serialization, as specified by 2196 draft-jones-jose-jws-json-serialization-04. 2198 o Registered "application/jws-js" MIME type and "JWS-JS" typ header 2199 parameter value. 2201 o Defined that the default action for header parameters that are not 2202 understood is to ignore them unless specifically designated as 2203 "MUST be understood" or included in the new "crit" (critical) 2204 header parameter list. This addressed issue #6. 2206 o Changed term "JWS Secured Input" to "JWS Signing Input". 2208 o Changed from using the term "byte" to "octet" when referring to 8 2209 bit values. 2211 o Changed member name from "recipients" to "signatures" in the JWS 2212 JSON Serialization. 2214 o Added complete values using the JWS Compact Serialization for all 2215 examples. 2217 -08 2219 o Applied editorial improvements suggested by Jeff Hodges and Hannes 2220 Tschofenig. Many of these simplified the terminology used. 2222 o Clarified statements of the form "This header parameter is 2223 OPTIONAL" to "Use of this header parameter is OPTIONAL". 2225 o Added a Header Parameter Usage Location(s) field to the IANA JSON 2226 Web Signature and Encryption Header Parameters registry. 2228 o Added seriesInfo information to Internet Draft references. 2230 -07 2232 o Updated references. 2234 -06 2235 o Changed "x5c" (X.509 Certificate Chain) representation from being 2236 a single string to being an array of strings, each containing a 2237 single base64 encoded DER certificate value, representing elements 2238 of the certificate chain. 2240 o Applied changes made by the RFC Editor to RFC 6749's registry 2241 language to this specification. 2243 -05 2245 o Added statement that "StringOrURI values are compared as case- 2246 sensitive strings with no transformations or canonicalizations 2247 applied". 2249 o Indented artwork elements to better distinguish them from the body 2250 text. 2252 -04 2254 o Completed JSON Security Considerations section, including 2255 considerations about rejecting input with duplicate member names. 2257 o Completed security considerations on the use of a SHA-1 hash when 2258 computing "x5t" (x.509 certificate thumbprint) values. 2260 o Refer to the registries as the primary sources of defined values 2261 and then secondarily reference the sections defining the initial 2262 contents of the registries. 2264 o Normatively reference XML DSIG 2.0 [W3C.CR-xmldsig-core2-20120124] 2265 for its security considerations. 2267 o Added this language to Registration Templates: "This name is case 2268 sensitive. Names that match other registered names in a case 2269 insensitive manner SHOULD NOT be accepted." 2271 o Reference draft-jones-jose-jws-json-serialization instead of 2272 draft-jones-json-web-signature-json-serialization. 2274 o Described additional open issues. 2276 o Applied editorial suggestions. 2278 -03 2280 o Added the "cty" (content type) header parameter for declaring type 2281 information about the secured content, as opposed to the "typ" 2282 (type) header parameter, which declares type information about 2283 this object. 2285 o Added "Collision Resistant Namespace" to the terminology section. 2287 o Reference ITU.X690.1994 for DER encoding. 2289 o Added an example JWS using ECDSA P-521 SHA-512. This has 2290 particular illustrative value because of the use of the 521 bit 2291 integers in the key and signature values. This is also an example 2292 in which the payload is not a base64url encoded JSON object. 2294 o Added an example "x5c" value. 2296 o No longer say "the UTF-8 representation of the JWS Secured Input 2297 (which is the same as the ASCII representation)". Just call it 2298 "the ASCII representation of the JWS Secured Input". 2300 o Added Registration Template sections for defined registries. 2302 o Added Registry Contents sections to populate registry values. 2304 o Changed name of the JSON Web Signature and Encryption "typ" Values 2305 registry to be the JSON Web Signature and Encryption Type Values 2306 registry, since it is used for more than just values of the "typ" 2307 parameter. 2309 o Moved registries JSON Web Signature and Encryption Header 2310 Parameters and JSON Web Signature and Encryption Type Values to 2311 the JWS specification. 2313 o Numerous editorial improvements. 2315 -02 2317 o Clarified that it is an error when a "kid" value is included and 2318 no matching key is found. 2320 o Removed assumption that "kid" (key ID) can only refer to an 2321 asymmetric key. 2323 o Clarified that JWSs with duplicate Header Parameter Names MUST be 2324 rejected. 2326 o Clarified the relationship between "typ" header parameter values 2327 and MIME types. 2329 o Registered application/jws MIME type and "JWS" typ header 2330 parameter value. 2332 o Simplified JWK terminology to get replace the "JWK Key Object" and 2333 "JWK Container Object" terms with simply "JSON Web Key (JWK)" and 2334 "JSON Web Key Set (JWK Set)" and to eliminate potential confusion 2335 between single keys and sets of keys. As part of this change, the 2336 Header Parameter Name for a public key value was changed from 2337 "jpk" (JSON Public Key) to "jwk" (JSON Web Key). 2339 o Added suggestion on defining additional header parameters such as 2340 "x5t#S256" in the future for certificate thumbprints using hash 2341 algorithms other than SHA-1. 2343 o Specify RFC 2818 server identity validation, rather than RFC 6125 2344 (paralleling the same decision in the OAuth specs). 2346 o Generalized language to refer to Message Authentication Codes 2347 (MACs) rather than Hash-based Message Authentication Codes (HMACs) 2348 unless in a context specific to HMAC algorithms. 2350 o Reformatted to give each header parameter its own section heading. 2352 -01 2354 o Moved definition of Plaintext JWSs (using "alg":"none") here from 2355 the JWT specification since this functionality is likely to be 2356 useful in more contexts that just for JWTs. 2358 o Added "jpk" and "x5c" header parameters for including JWK public 2359 keys and X.509 certificate chains directly in the header. 2361 o Clarified that this specification is defining the JWS Compact 2362 Serialization. Referenced the new JWS-JS spec, which defines the 2363 JWS JSON Serialization. 2365 o Added text "New header parameters should be introduced sparingly 2366 since an implementation that does not understand a parameter MUST 2367 reject the JWS". 2369 o Clarified that the order of the creation and validation steps is 2370 not significant in cases where there are no dependencies between 2371 the inputs and outputs of the steps. 2373 o Changed "no canonicalization is performed" to "no canonicalization 2374 need be performed". 2376 o Corrected the Magic Signatures reference. 2378 o Made other editorial improvements suggested by JOSE working group 2379 participants. 2381 -00 2383 o Created the initial IETF draft based upon 2384 draft-jones-json-web-signature-04 with no normative changes. 2386 o Changed terminology to no longer call both digital signatures and 2387 HMACs "signatures". 2389 Authors' Addresses 2391 Michael B. Jones 2392 Microsoft 2394 Email: mbj@microsoft.com 2395 URI: http://self-issued.info/ 2397 John Bradley 2398 Ping Identity 2400 Email: ve7jtb@ve7jtb.com 2401 URI: http://www.thread-safe.com/ 2403 Nat Sakimura 2404 Nomura Research Institute 2406 Email: n-sakimura@nri.co.jp 2407 URI: http://nat.sakimura.org/