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