idnits 2.17.1 draft-ietf-jose-json-web-signature-35.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 17, 2014) is 3479 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 1969 -- Looks like a reference, but probably isn't: '34' on line 1969 -- Looks like a reference, but probably isn't: '97' on line 1979 -- Looks like a reference, but probably isn't: '108' on line 1979 -- Looks like a reference, but probably isn't: '103' on line 1969 -- Looks like a reference, but probably isn't: '58' on line 1969 -- Looks like a reference, but probably isn't: '82' on line 1722 -- Looks like a reference, but probably isn't: '83' on line 1969 -- Looks like a reference, but probably isn't: '50' on line 1969 -- Looks like a reference, but probably isn't: '53' on line 1969 -- Looks like a reference, but probably isn't: '54' on line 1855 -- Looks like a reference, but probably isn't: '125' on line 1969 -- Looks like a reference, but probably isn't: '69' on line 1969 -- Looks like a reference, but probably isn't: '49' on line 1969 -- Looks like a reference, but probably isn't: '80' on line 1979 -- Looks like a reference, but probably isn't: '121' on line 1979 -- Looks like a reference, but probably isn't: '111' on line 1979 -- Looks like a reference, but probably isn't: '100' on line 1979 -- Looks like a reference, but probably isn't: '0' on line 2290 -- Possible downref: Non-RFC (?) normative reference: ref. 'ECMAScript' -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.X690.1994' ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** Downref: Normative reference to an Informational RFC: RFC 4949 ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 6125 (Obsoleted by RFC 9525) ** Obsolete normative reference: RFC 7159 (Obsoleted by RFC 8259) == Outdated reference: A later version (-11) exists of draft-ietf-uta-tls-bcp-05 -- Obsolete informational reference (is this intentional?): RFC 3447 (Obsoleted by RFC 8017) -- Obsolete informational reference (is this intentional?): RFC 5226 (Obsoleted by RFC 8126) Summary: 5 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 20, 2015 Ping Identity 6 N. Sakimura 7 NRI 8 October 17, 2014 10 JSON Web Signature (JWS) 11 draft-ietf-jose-json-web-signature-35 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 20, 2015. 41 Copyright Notice 43 Copyright (c) 2014 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. JWS Compact Serialization Overview . . . . . . . . . . . 7 63 3.2. JWS JSON Serialization Overview . . . . . . . . . . . . . 7 64 3.3. Example JWS . . . . . . . . . . . . . . . . . . . . . . . 8 65 4. JOSE Header . . . . . . . . . . . . . . . . . . . . . . . . . 9 66 4.1. Registered Header Parameter Names . . . . . . . . . . . . 9 67 4.1.1. "alg" (Algorithm) Header Parameter . . . . . . . . . . 10 68 4.1.2. "jku" (JWK Set URL) Header Parameter . . . . . . . . . 10 69 4.1.3. "jwk" (JSON Web Key) Header Parameter . . . . . . . . 10 70 4.1.4. "kid" (Key ID) Header Parameter . . . . . . . . . . . 10 71 4.1.5. "x5u" (X.509 URL) Header Parameter . . . . . . . . . . 11 72 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter . . . 11 73 4.1.7. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header 74 Parameter . . . . . . . . . . . . . . . . . . . . . . 11 75 4.1.8. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) 76 Header Parameter . . . . . . . . . . . . . . . . . . . 12 77 4.1.9. "typ" (Type) Header Parameter . . . . . . . . . . . . 12 78 4.1.10. "cty" (Content Type) Header Parameter . . . . . . . . 13 79 4.1.11. "crit" (Critical) Header Parameter . . . . . . . . . . 13 80 4.2. Public Header Parameter Names . . . . . . . . . . . . . . 14 81 4.3. Private Header Parameter Names . . . . . . . . . . . . . 14 82 5. Producing and Consuming JWSs . . . . . . . . . . . . . . . . . 14 83 5.1. Message Signature or MAC Computation . . . . . . . . . . 14 84 5.2. Message Signature or MAC Validation . . . . . . . . . . . 15 85 5.3. String Comparison Rules . . . . . . . . . . . . . . . . . 17 86 6. Key Identification . . . . . . . . . . . . . . . . . . . . . . 18 87 7. Serializations . . . . . . . . . . . . . . . . . . . . . . . . 18 88 7.1. JWS Compact Serialization . . . . . . . . . . . . . . . . 19 89 7.2. JWS JSON Serialization . . . . . . . . . . . . . . . . . 19 90 8. TLS Requirements . . . . . . . . . . . . . . . . . . . . . . . 21 91 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 21 92 9.1. JSON Web Signature and Encryption Header Parameters 93 Registry . . . . . . . . . . . . . . . . . . . . . . . . 22 94 9.1.1. Registration Template . . . . . . . . . . . . . . . . 23 95 9.1.2. Initial Registry Contents . . . . . . . . . . . . . . 23 97 9.2. Media Type Registration . . . . . . . . . . . . . . . . . 25 98 9.2.1. Registry Contents . . . . . . . . . . . . . . . . . . 25 99 10. Security Considerations . . . . . . . . . . . . . . . . . . . 26 100 10.1. Key Entropy and Random Values . . . . . . . . . . . . . . 26 101 10.2. Key Protection . . . . . . . . . . . . . . . . . . . . . 27 102 10.3. Key Origin Authentication . . . . . . . . . . . . . . . . 27 103 10.4. Cryptographic Agility . . . . . . . . . . . . . . . . . . 27 104 10.5. Differences between Digital Signatures and MACs . . . . . 27 105 10.6. Algorithm Validation . . . . . . . . . . . . . . . . . . 28 106 10.7. Algorithm Protection . . . . . . . . . . . . . . . . . . 28 107 10.8. Chosen Plaintext Attacks . . . . . . . . . . . . . . . . 29 108 10.9. Timing Attacks . . . . . . . . . . . . . . . . . . . . . 29 109 10.10. Replay Protection . . . . . . . . . . . . . . . . . . . . 29 110 10.11. SHA-1 Certificate Thumbprints . . . . . . . . . . . . . . 29 111 10.12. JSON Security Considerations . . . . . . . . . . . . . . 30 112 10.13. Unicode Comparison Security Considerations . . . . . . . 30 113 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 31 114 11.1. Normative References . . . . . . . . . . . . . . . . . . 31 115 11.2. Informative References . . . . . . . . . . . . . . . . . 32 116 Appendix A. JWS Examples . . . . . . . . . . . . . . . . . . . . 34 117 A.1. Example JWS using HMAC SHA-256 . . . . . . . . . . . . . 34 118 A.1.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 34 119 A.1.2. Validating . . . . . . . . . . . . . . . . . . . . . . 36 120 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 . . . . . . . 36 121 A.2.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 37 122 A.2.2. Validating . . . . . . . . . . . . . . . . . . . . . . 39 123 A.3. Example JWS using ECDSA P-256 SHA-256 . . . . . . . . . . 39 124 A.3.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 39 125 A.3.2. Validating . . . . . . . . . . . . . . . . . . . . . . 41 126 A.4. Example JWS using ECDSA P-521 SHA-512 . . . . . . . . . . 42 127 A.4.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 42 128 A.4.2. Validating . . . . . . . . . . . . . . . . . . . . . . 44 129 A.5. Example Unsecured JWS . . . . . . . . . . . . . . . . . . 44 130 A.6. Example JWS Using JWS JSON Serialization . . . . . . . . 45 131 A.6.1. JWS Per-Signature Protected Headers . . . . . . . . . 45 132 A.6.2. JWS Per-Signature Unprotected Headers . . . . . . . . 46 133 A.6.3. Complete JOSE Header Values . . . . . . . . . . . . . 46 134 A.6.4. Complete JWS JSON Serialization Representation . . . . 46 135 Appendix B. "x5c" (X.509 Certificate Chain) Example . . . . . . . 47 136 Appendix C. Notes on implementing base64url encoding without 137 padding . . . . . . . . . . . . . . . . . . . . . . . 49 138 Appendix D. Notes on Key Selection . . . . . . . . . . . . . . . 50 139 Appendix E. Negative Test Case for "crit" Header Parameter . . . 51 140 Appendix F. Detached Content . . . . . . . . . . . . . . . . . . 52 141 Appendix G. Acknowledgements . . . . . . . . . . . . . . . . . . 52 142 Appendix H. Document History . . . . . . . . . . . . . . . . . . 53 143 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 63 145 1. Introduction 147 JSON Web Signature (JWS) represents content secured with digital 148 signatures or Message Authentication Codes (MACs) using JavaScript 149 Object Notation (JSON) [RFC7159] based data structures. The JWS 150 cryptographic mechanisms provide integrity protection for an 151 arbitrary sequence of octets. See Section 10.5 for a discussion on 152 the differences between Digital Signatures and MACs. 154 Two closely related serializations for JWS objects are defined. The 155 JWS Compact Serialization is a compact, URL-safe representation 156 intended for space constrained environments such as HTTP 157 Authorization headers and URI query parameters. The JWS JSON 158 Serialization represents JWS objects as JSON objects and enables 159 multiple signatures and/or MACs to be applied to the same content. 160 Both share the same cryptographic underpinnings. 162 Cryptographic algorithms and identifiers for use with this 163 specification are described in the separate JSON Web Algorithms (JWA) 164 [JWA] specification and an IANA registry defined by that 165 specification. Related encryption capabilities are described in the 166 separate JSON Web Encryption (JWE) [JWE] specification. 168 Names defined by this specification are short because a core goal is 169 for the resulting representations to be compact. 171 1.1. Notational Conventions 173 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 174 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 175 "OPTIONAL" in this document are to be interpreted as described in Key 176 words for use in RFCs to Indicate Requirement Levels [RFC2119]. If 177 these words are used without being spelled in uppercase then they are 178 to be interpreted with their normal natural language meanings. 180 BASE64URL(OCTETS) denotes the base64url encoding of OCTETS, per 181 Section 2. 183 UTF8(STRING) denotes the octets of the UTF-8 [RFC3629] representation 184 of STRING. 186 ASCII(STRING) denotes the octets of the ASCII [RFC20] representation 187 of STRING. 189 The concatenation of two values A and B is denoted as A || B. 191 2. Terminology 193 These terms are defined by this specification: 195 JSON Web Signature (JWS) 196 A data structure representing a digitally signed or MACed message. 198 JOSE Header 199 JSON object containing the parameters describing the cryptographic 200 operations and parameters employed. The JOSE Header is comprised 201 of a set of Header Parameters. 203 JWS Payload 204 The sequence of octets to be secured -- a.k.a., the message. The 205 payload can contain an arbitrary sequence of octets. 207 JWS Signature 208 Digital signature or MAC over the JWS Protected Header and the JWS 209 Payload. 211 Header Parameter 212 A name/value pair that is member of the JOSE Header. 214 JWS Protected Header 215 JSON object that contains the Header Parameters that are integrity 216 protected by the JWS Signature digital signature or MAC operation. 217 For the JWS Compact Serialization, this comprises the entire JOSE 218 Header. For the JWS JSON Serialization, this is one component of 219 the JOSE Header. 221 JWS Unprotected Header 222 JSON object that contains the Header Parameters that are not 223 integrity protected. This can only be present when using the JWS 224 JSON Serialization. 226 Base64url Encoding 227 Base64 encoding using the URL- and filename-safe character set 228 defined in Section 5 of RFC 4648 [RFC4648], with all trailing '=' 229 characters omitted (as permitted by Section 3.2) and without the 230 inclusion of any line breaks, white space, or other additional 231 characters. Note that the base64url encoding of the empty octet 232 sequence is the empty string. (See Appendix C for notes on 233 implementing base64url encoding without padding.) 235 JWS Signing Input 236 The input to the digital signature or MAC computation. Its value 237 is ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 238 BASE64URL(JWS Payload)). 240 JWS Compact Serialization 241 A representation of the JWS as a compact, URL-safe string. 243 JWS JSON Serialization 244 A representation of the JWS as a JSON object. Unlike the JWS 245 Compact Serialization, the JWS JSON Serialization enables multiple 246 digital signatures and/or MACs to be applied to the same content. 247 This representation is neither optimized for compactness nor URL- 248 safe. 250 Unsecured JWS 251 A JWS object that provides no integrity protection. Unsecured 252 JWSs use the "alg" value "none". 254 Collision-Resistant Name 255 A name in a namespace that enables names to be allocated in a 256 manner such that they are highly unlikely to collide with other 257 names. Examples of collision-resistant namespaces include: Domain 258 Names, Object Identifiers (OIDs) as defined in the ITU-T X.660 and 259 X.670 Recommendation series, and Universally Unique IDentifiers 260 (UUIDs) [RFC4122]. When using an administratively delegated 261 namespace, the definer of a name needs to take reasonable 262 precautions to ensure they are in control of the portion of the 263 namespace they use to define the name. 265 StringOrURI 266 A JSON string value, with the additional requirement that while 267 arbitrary string values MAY be used, any value containing a ":" 268 character MUST be a URI [RFC3986]. StringOrURI values are 269 compared as case-sensitive strings with no transformations or 270 canonicalizations applied. 272 These terms defined by the JSON Web Encryption (JWE) [JWE] 273 specification are incorporated into this specification: "JSON Web 274 Encryption (JWE)", "JWE Compact Serialization", and "JWE JSON 275 Serialization". 277 These terms defined by the Internet Security Glossary, Version 2 278 [RFC4949] are incorporated into this specification: "Digital 279 Signature" and "Message Authentication Code (MAC)". 281 3. JSON Web Signature (JWS) Overview 283 JWS represents digitally signed or MACed content using JSON data 284 structures and base64url encoding. These JSON data structures MAY 285 contain white space and/or line breaks. A JWS represents these 286 logical values (each of which is defined in Section 2): 288 o JOSE Header 289 o JWS Payload 290 o JWS Signature 292 For a JWS object, the JOSE Header members are the union of the 293 members of these values (each of which is defined in Section 2): 295 o JWS Protected Header 296 o JWS Unprotected Header 298 This document defines two serializations for JWS objects: a compact, 299 URL-safe serialization called the JWS Compact Serialization and a 300 JSON serialization called the JWS JSON Serialization. In both 301 serializations, the JWS Protected Header, JWS Payload, and JWS 302 Signature are base64url encoded, since JSON lacks a way to directly 303 represent arbitrary octet sequences. 305 3.1. JWS Compact Serialization Overview 307 In the JWS Compact Serialization, no JWS Unprotected Header is used. 308 In this case, the JOSE Header and the JWS Protected Header are the 309 same. 311 In the JWS Compact Serialization, a JWS object is represented as the 312 concatenation: 314 BASE64URL(UTF8(JWS Protected Header)) || '.' || 315 BASE64URL(JWS Payload) || '.' || 316 BASE64URL(JWS Signature) 318 See Section 7.1 for more information about the JWS Compact 319 Serialization. 321 3.2. JWS JSON Serialization Overview 323 In the JWS JSON Serialization, one or both of the JWS Protected 324 Header and JWS Unprotected Header MUST be present. In this case, the 325 members of the JOSE Header are the union of the members of the JWS 326 Protected Header and the JWS Unprotected Header values that are 327 present. 329 In the JWS JSON Serialization, a JWS object is represented as the 330 combination of these four values: 331 BASE64URL(UTF8(JWS Protected Header)) 332 JWS Unprotected Header 333 BASE64URL(JWS Payload) 334 BASE64URL(JWS Signature) 336 The three base64url encoded result strings and the JWS Unprotected 337 Header value are represented as members within a JSON object. The 338 inclusion of some of these values is OPTIONAL. The JWS JSON 339 Serialization can also represent multiple signature and/or MAC 340 values, rather than just one. See Section 7.2 for more information 341 about the JWS JSON Serialization. 343 3.3. Example JWS 345 This section provides an example of a JWS. Its computation is 346 described in more detail in Appendix A.1, including specifying the 347 exact octet sequences representing the JSON values used and the key 348 value used. 350 The following example JWS Protected Header declares that the encoded 351 object is a JSON Web Token (JWT) [JWT] and the JWS Protected Header 352 and the JWS Payload are secured using the HMAC SHA-256 [RFC2104, SHS] 353 algorithm: 355 {"typ":"JWT", 356 "alg":"HS256"} 358 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 359 Header)) gives this value: 361 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 363 The UTF-8 representation of following JSON object is used as the JWS 364 Payload. (Note that the payload can be any content, and need not be 365 a representation of a JSON object.) 367 {"iss":"joe", 368 "exp":1300819380, 369 "http://example.com/is_root":true} 371 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value 372 (with line breaks for display purposes only): 374 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 375 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 377 Computing the HMAC of the JWS Signing Input ASCII(BASE64URL(UTF8(JWS 378 Protected Header)) || '.' || BASE64URL(JWS Payload)) with the HMAC 379 SHA-256 algorithm using the key specified in Appendix A.1 and 380 base64url encoding the result yields this BASE64URL(JWS Signature) 381 value: 383 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 385 Concatenating these values in the order Header.Payload.Signature with 386 period ('.') characters between the parts yields this complete JWS 387 representation using the JWS Compact Serialization (with line breaks 388 for display purposes only): 390 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 391 . 392 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 393 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 394 . 395 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 397 See Appendix A for additional examples, including an example using 398 the JWS JSON Serialization in Appendix A.6. 400 4. JOSE Header 402 For a JWS object, the members of the JSON object(s) representing the 403 JOSE Header describe the digital signature or MAC applied to the JWS 404 Protected Header and the JWS Payload and optionally additional 405 properties of the JWS. The Header Parameter names within the JOSE 406 Header MUST be unique; JWS parsers MUST either reject JWSs with 407 duplicate Header Parameter names or use a JSON parser that returns 408 only the lexically last duplicate member name, as specified in 409 Section 15.12 (The JSON Object) of ECMAScript 5.1 [ECMAScript]. 411 Implementations are required to understand the specific Header 412 Parameters defined by this specification that are designated as "MUST 413 be understood" and process them in the manner defined in this 414 specification. All other Header Parameters defined by this 415 specification that are not so designated MUST be ignored when not 416 understood. Unless listed as a critical Header Parameter, per 417 Section 4.1.11, all Header Parameters not defined by this 418 specification MUST be ignored when not understood. 420 There are three classes of Header Parameter names: Registered Header 421 Parameter names, Public Header Parameter names, and Private Header 422 Parameter names. 424 4.1. Registered Header Parameter Names 426 The following Header Parameter names for use in JWS objects are 427 registered in the IANA JSON Web Signature and Encryption Header 428 Parameters registry defined in Section 9.1, with meanings as defined 429 below. 431 As indicated by the common registry, JWSs and JWEs share a common 432 Header Parameter space; when a parameter is used by both 433 specifications, its usage must be compatible between the 434 specifications. 436 4.1.1. "alg" (Algorithm) Header Parameter 438 The "alg" (algorithm) Header Parameter identifies the cryptographic 439 algorithm used to secure the JWS. The JWS Signature value is not 440 valid if the "alg" value does not represent a supported algorithm, or 441 if there is not a key for use with that algorithm associated with the 442 party that digitally signed or MACed the content. "alg" values should 443 either be registered in the IANA JSON Web Signature and Encryption 444 Algorithms registry defined in [JWA] or be a value that contains a 445 Collision-Resistant Name. The "alg" value is a case-sensitive string 446 containing a StringOrURI value. This Header Parameter MUST be 447 present and MUST be understood and processed by implementations. 449 A list of defined "alg" values for this use can be found in the IANA 450 JSON Web Signature and Encryption Algorithms registry defined in 451 [JWA]; the initial contents of this registry are the values defined 452 in Section 3.1 of the JSON Web Algorithms (JWA) [JWA] specification. 454 4.1.2. "jku" (JWK Set URL) Header Parameter 456 The "jku" (JWK Set URL) Header Parameter is a URI [RFC3986] that 457 refers to a resource for a set of JSON-encoded public keys, one of 458 which corresponds to the key used to digitally sign the JWS. The 459 keys MUST be encoded as a JSON Web Key Set (JWK Set) [JWK]. The 460 protocol used to acquire the resource MUST provide integrity 461 protection; an HTTP GET request to retrieve the JWK Set MUST use TLS 462 [RFC2818, RFC5246]; the identity of the server MUST be validated, as 463 per Section 6 of RFC 6125 [RFC6125]. Also, see Section 8 on TLS 464 requirements. Use of this Header Parameter is OPTIONAL. 466 4.1.3. "jwk" (JSON Web Key) Header Parameter 468 The "jwk" (JSON Web Key) Header Parameter is the public key that 469 corresponds to the key used to digitally sign the JWS. This key is 470 represented as a JSON Web Key [JWK]. Use of this Header Parameter is 471 OPTIONAL. 473 4.1.4. "kid" (Key ID) Header Parameter 475 The "kid" (key ID) Header Parameter is a hint indicating which key 476 was used to secure the JWS. This parameter allows originators to 477 explicitly signal a change of key to recipients. The structure of 478 the "kid" value is unspecified. Its value MUST be a case-sensitive 479 string. Use of this Header Parameter is OPTIONAL. 481 When used with a JWK, the "kid" value is used to match a JWK "kid" 482 parameter value. 484 4.1.5. "x5u" (X.509 URL) Header Parameter 486 The "x5u" (X.509 URL) Header Parameter is a URI [RFC3986] that refers 487 to a resource for the X.509 public key certificate or certificate 488 chain [RFC5280] corresponding to the key used to digitally sign the 489 JWS. The identified resource MUST provide a representation of the 490 certificate or certificate chain that conforms to RFC 5280 [RFC5280] 491 in PEM encoded form, with each certificate delimited as specified in 492 Section 6.1 of RFC 4945 [RFC4945]. The certificate containing the 493 public key corresponding to the key used to digitally sign the JWS 494 MUST be the first certificate. This MAY be followed by additional 495 certificates, with each subsequent certificate being the one used to 496 certify the previous one. The protocol used to acquire the resource 497 MUST provide integrity protection; an HTTP GET request to retrieve 498 the certificate MUST use TLS [RFC2818, RFC5246]; the identity of the 499 server MUST be validated, as per Section 6 of RFC 6125 [RFC6125]. 500 Also, see Section 8 on TLS requirements. Use of this Header 501 Parameter is OPTIONAL. 503 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter 505 The "x5c" (X.509 Certificate Chain) Header Parameter contains the 506 X.509 public key certificate or certificate chain [RFC5280] 507 corresponding to the key used to digitally sign the JWS. The 508 certificate or certificate chain is represented as a JSON array of 509 certificate value strings. Each string in the array is a base64 510 encoded ([RFC4648] Section 4 -- not base64url encoded) DER 511 [ITU.X690.1994] PKIX certificate value. The certificate containing 512 the public key corresponding to the key used to digitally sign the 513 JWS MUST be the first certificate. This MAY be followed by 514 additional certificates, with each subsequent certificate being the 515 one used to certify the previous one. The recipient MUST validate 516 the certificate chain according to RFC 5280 [RFC5280] and reject the 517 signature if any validation failure occurs. Use of this Header 518 Parameter is OPTIONAL. 520 See Appendix B for an example "x5c" value. 522 4.1.7. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter 524 The "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter is a 525 base64url encoded SHA-1 thumbprint (a.k.a. digest) of the DER 526 encoding of the X.509 certificate [RFC5280] corresponding to the key 527 used to digitally sign the JWS. Note that certificate thumbprints 528 are also sometimes known as certificate fingerprints. Use of this 529 Header Parameter is OPTIONAL. 531 4.1.8. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header 532 Parameter 534 The "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header 535 Parameter is a base64url encoded SHA-256 thumbprint (a.k.a. digest) 536 of the DER encoding of the X.509 certificate [RFC5280] corresponding 537 to the key used to digitally sign the JWS. Note that certificate 538 thumbprints are also sometimes known as certificate fingerprints. 539 Use of this Header Parameter is OPTIONAL. 541 4.1.9. "typ" (Type) Header Parameter 543 The "typ" (type) Header Parameter is used by JWS applications to 544 declare the MIME Media Type [IANA.MediaTypes] of this complete JWS 545 object. This is intended for use by the application when more than 546 one kind of object could be present in an application data structure 547 that can contain a JWS object; the application can use this value to 548 disambiguate among the different kinds of objects that might be 549 present. It will typically not be used by applications when the kind 550 of object is already known. This parameter is ignored by JWS 551 implementations; any processing of this parameter is performed by the 552 JWS application. Use of this Header Parameter is OPTIONAL. 554 Per RFC 2045 [RFC2045], all media type values, subtype values, and 555 parameter names are case-insensitive. However, parameter values are 556 case-sensitive unless otherwise specified for the specific parameter. 558 To keep messages compact in common situations, it is RECOMMENDED that 559 producers omit an "application/" prefix of a media type value in a 560 "typ" Header Parameter when no other '/' appears in the media type 561 value. A recipient using the media type value MUST treat it as if 562 "application/" were prepended to any "typ" value not containing a 563 '/'. For instance, a "typ" value of "example" SHOULD be used to 564 represent the "application/example" media type; whereas, the media 565 type "application/example;part="1/2"" cannot be shortened to 566 "example;part="1/2"". 568 The "typ" value "JOSE" can be used by applications to indicate that 569 this object is a JWS or JWE using the JWS Compact Serialization or 570 the JWE Compact Serialization. The "typ" value "JOSE+JSON" can be 571 used by applications to indicate that this object is a JWS or JWE 572 using the JWS JSON Serialization or the JWE JSON Serialization. 573 Other type values can also be used by applications. 575 4.1.10. "cty" (Content Type) Header Parameter 577 The "cty" (content type) Header Parameter is used by JWS applications 578 to declare the MIME Media Type [IANA.MediaTypes] of the secured 579 content (the payload). This is intended for use by the application 580 when more than one kind of object could be present in the JWS 581 payload; the application can use this value to disambiguate among the 582 different kinds of objects that might be present. It will typically 583 not be used by applications when the kind of object is already known. 584 This parameter is ignored by JWS implementations; any processing of 585 this parameter is performed by the JWS application. Use of this 586 Header Parameter is OPTIONAL. 588 Per RFC 2045 [RFC2045], all media type values, subtype values, and 589 parameter names are case-insensitive. However, parameter values are 590 case-sensitive unless otherwise specified for the specific parameter. 592 To keep messages compact in common situations, it is RECOMMENDED that 593 producers omit an "application/" prefix of a media type value in a 594 "cty" Header Parameter when no other '/' appears in the media type 595 value. A recipient using the media type value MUST treat it as if 596 "application/" were prepended to any "cty" value not containing a 597 '/'. For instance, a "cty" value of "example" SHOULD be used to 598 represent the "application/example" media type; whereas, the media 599 type "application/example;part="1/2"" cannot be shortened to 600 "example;part="1/2"". 602 4.1.11. "crit" (Critical) Header Parameter 604 The "crit" (critical) Header Parameter indicates that extensions to 605 the initial RFC versions of [[ this specification ]] and [JWA] are 606 being used that MUST be understood and processed. Its value is an 607 array listing the Header Parameter names present in the JOSE Header 608 that use those extensions. If any of the listed extension Header 609 Parameters are not understood and supported by the recipient, it MUST 610 reject the JWS. Producers MUST NOT include Header Parameter names 611 defined by the initial RFC versions of [[ this specification ]] or 612 [JWA] for use with JWS, duplicate names, or names that do not occur 613 as Header Parameter names within the JOSE Header in the "crit" list. 614 Producers MUST NOT use the empty list "[]" as the "crit" value. 615 Recipients MAY reject the JWS if the critical list contains any 616 Header Parameter names defined by the initial RFC versions of [[ this 617 specification ]] or [JWA] for use with JWS, or any other constraints 618 on its use are violated. When used, this Header Parameter MUST be 619 integrity protected; therefore, it MUST occur only within the JWS 620 Protected Header. Use of this Header Parameter is OPTIONAL. This 621 Header Parameter MUST be understood and processed by implementations. 623 An example use, along with a hypothetical "exp" (expiration-time) 624 field is: 626 {"alg":"ES256", 627 "crit":["exp"], 628 "exp":1363284000 629 } 631 4.2. Public Header Parameter Names 633 Additional Header Parameter names can be defined by those using JWSs. 634 However, in order to prevent collisions, any new Header Parameter 635 name should either be registered in the IANA JSON Web Signature and 636 Encryption Header Parameters registry defined in Section 9.1 or be a 637 Public Name: a value that contains a Collision-Resistant Name. In 638 each case, the definer of the name or value needs to take reasonable 639 precautions to make sure they are in control of the part of the 640 namespace they use to define the Header Parameter name. 642 New Header Parameters should be introduced sparingly, as they can 643 result in non-interoperable JWSs. 645 4.3. Private Header Parameter Names 647 A producer and consumer of a JWS may agree to use Header Parameter 648 names that are Private Names: names that are not Registered Header 649 Parameter names Section 4.1 or Public Header Parameter names 650 Section 4.2. Unlike Public Header Parameter names, Private Header 651 Parameter names are subject to collision and should be used with 652 caution. 654 5. Producing and Consuming JWSs 656 5.1. Message Signature or MAC Computation 658 To create a JWS, one MUST perform these steps. The order of the 659 steps is not significant in cases where there are no dependencies 660 between the inputs and outputs of the steps. 662 1. Create the content to be used as the JWS Payload. 664 2. Compute the encoded payload value BASE64URL(JWS Payload). 666 3. Create the JSON object(s) containing the desired set of Header 667 Parameters, which together comprise the JOSE Header: if the JWS 668 Compact Serialization is being used, the JWS Protected Header, or 669 if the JWS JSON Serialization is being used, the JWS Protected 670 Header and/or the JWS Unprotected Header. 672 4. Compute the encoded header value BASE64URL(UTF8(JWS Protected 673 Header)). If the JWS Protected Header is not present (which can 674 only happen when using the JWS JSON Serialization and no 675 "protected" member is present), let this value be the empty 676 string. 678 5. Compute the JWS Signature in the manner defined for the 679 particular algorithm being used over the JWS Signing Input 680 ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 681 BASE64URL(JWS Payload)). The "alg" (algorithm) Header Parameter 682 MUST be present in the JOSE Header, with the algorithm value 683 accurately representing the algorithm used to construct the JWS 684 Signature. 686 6. Compute the encoded signature value BASE64URL(JWS Signature). 688 7. If the JWS JSON Serialization is being used, repeat this process 689 (steps 3-6) for each digital signature or MAC operation being 690 performed. 692 8. Create the desired serialized output. The JWS Compact 693 Serialization of this result is BASE64URL(UTF8(JWS Protected 694 Header)) || '.' || BASE64URL(JWS Payload) || '.' || BASE64URL(JWS 695 Signature). The JWS JSON Serialization is described in 696 Section 7.2. 698 5.2. Message Signature or MAC Validation 700 When validating a JWS, the following steps MUST be taken. The order 701 of the steps is not significant in cases where there are no 702 dependencies between the inputs and outputs of the steps. If any of 703 the listed steps fails, then the signature or MAC cannot be 704 validated. 706 When there are multiple JWS Signature values, it is an application 707 decision which of the JWS Signature values must successfully validate 708 for the JWS to be accepted. In some cases, all must successfully 709 validate or the JWS will be rejected. In other cases, only a 710 specific JWS signature value needs to be successfully validated. 711 However, in all cases, at least one JWS signature value MUST 712 successfully validate or the JWS MUST be rejected. 714 1. Parse the JWS representation to extract the serialized values 715 for the components of the JWS. When using the JWS Compact 716 Serialization, these components are the base64url encoded 717 representations of the JWS Protected Header, the JWS Payload, 718 and the JWS Signature, and when using the JWS JSON 719 Serialization, these components also include the unencoded JWS 720 Unprotected Header value. When using the JWS Compact 721 Serialization, the JWS Protected Header, the JWS Payload, and 722 the JWS Signature are represented as base64url encoded values in 723 that order, with each value being separated from the next by a 724 single period ('.') character, resulting in exactly two 725 delimiting period characters being used. The JWS JSON 726 Serialization is described in Section 7.2. 728 2. Base64url decode the encoded representation of the JWS Protected 729 Header, following the restriction that no line breaks, white 730 space, or other additional characters have been used. 732 3. Verify that the resulting octet sequence is a UTF-8 encoded 733 representation of a completely valid JSON object conforming to 734 RFC 7159 [RFC7159]; let the JWS Protected Header be this JSON 735 object. 737 4. If using the JWS Compact Serialization, let the JOSE Header be 738 the JWS Protected Header. Otherwise, when using the JWS JSON 739 Serialization, let the JOSE Header be the union of the members 740 of the corresponding JWS Protected Header and JWS Unprotected 741 Header, all of which must be completely valid JSON objects. 742 During this step, verify that the resulting JOSE Header does not 743 contain duplicate Header Parameter names. When using the JWS 744 JSON Serialization, this restriction includes that the same 745 Header Parameter name also MUST NOT occur in distinct JSON 746 object values that together comprise the JOSE Header. 748 5. Verify that the implementation understands and can process all 749 fields that it is required to support, whether required by this 750 specification, by the algorithm being used, or by the "crit" 751 Header Parameter value, and that the values of those parameters 752 are also understood and supported. 754 6. Base64url decode the encoded representation of the JWS Payload, 755 following the restriction that no line breaks, white space, or 756 other additional characters have been used. 758 7. Base64url decode the encoded representation of the JWS 759 Signature, following the restriction that no line breaks, white 760 space, or other additional characters have been used. 762 8. Validate the JWS Signature against the JWS Signing Input 763 ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 764 BASE64URL(JWS Payload)) in the manner defined for the algorithm 765 being used, which MUST be accurately represented by the value of 766 the "alg" (algorithm) Header Parameter, which MUST be present. 767 See Section 10.6 for security considerations on algorithm 768 validation. Record whether the validation succeeded or not. 770 9. If the JWS JSON Serialization is being used, repeat this process 771 (steps 4-8) for each digital signature or MAC value contained in 772 the representation. 774 10. If none of the validations in step 9 succeeded, then the JWS 775 MUST be rejected. Otherwise, in the JWS JSON Serialization 776 case, return a result to the application indicating which of the 777 validations succeeded and failed. In the JWS Compact 778 Serialization case, the result can simply indicate whether the 779 JWS was accepted or rejected. 781 Finally, note that it is an application decision which algorithms may 782 be used in a given context. Even if a JWS can be successfully 783 validated, unless the algorithm(s) used in the JWS are acceptable to 784 the application, it SHOULD reject the JWS. 786 5.3. String Comparison Rules 788 Processing a JWS inevitably requires comparing known strings to 789 members and values in JSON objects. For example, in checking what 790 the algorithm is, the Unicode string "alg" will be checked against 791 the member names in the JOSE Header to see if there is a matching 792 Header Parameter name. The same process is then used to determine if 793 the value of the "alg" Header Parameter represents a supported 794 algorithm. 796 The JSON rules for doing member name comparison are described in 797 Section 8.3 of RFC 7159 [RFC7159]. Since the only string comparison 798 operations that are performed are equality and inequality, the same 799 rules can be used for comparing both member names and member values 800 against known strings. 802 These comparison rules MUST be used for all JSON string comparisons 803 except in cases where the definition of the member explicitly calls 804 out that a different comparison rule is to be used for that member 805 value. Only the "typ" and "cty" member values defined in this 806 specification do not use these comparison rules. 808 Some applications may include case-insensitive information in a case- 809 sensitive value, such as including a DNS name as part of a "kid" (key 810 ID) value. In those cases, the application may need to define a 811 convention for the canonical case to use for representing the case- 812 insensitive portions, such as lowercasing them, if more than one 813 party might need to produce the same value so that they can be 814 compared. (However if all other parties consume whatever value the 815 producing party emitted verbatim without attempting to compare it to 816 an independently produced value, then the case used by the producer 817 will not matter.) 819 Also, see the JSON security considerations in Section 10.12 and the 820 Unicode security considerations in Section 10.13. 822 6. Key Identification 824 It is necessary for the recipient of a JWS to be able to determine 825 the key that was employed for the digital signature or MAC operation. 826 The key employed can be identified using the Header Parameter methods 827 described in Section 4.1 or can be identified using methods that are 828 outside the scope of this specification. Specifically, the Header 829 Parameters "jku", "jwk", "kid", "x5u", "x5c", "x5t", and "x5t#S256" 830 can be used to identify the key used. These Header Parameters MUST 831 be integrity protected if the information that they convey is to be 832 utilized in a trust decision. 834 The producer SHOULD include sufficient information in the Header 835 Parameters to identify the key used, unless the application uses 836 another means or convention to determine the key used. Validation of 837 the signature or MAC fails when the algorithm used requires a key 838 (which is true of all algorithms except for "none") and the key used 839 cannot be determined. 841 The means of exchanging any shared symmetric keys used is outside the 842 scope of this specification. 844 Also, see Appendix D for notes on possible key selection algorithms. 846 7. Serializations 848 JWS objects use one of two serializations, the JWS Compact 849 Serialization or the JWS JSON Serialization. Applications using this 850 specification need to specify what serialization and serialization 851 features are used for that application. For instance, applications 852 might specify that only the JWS JSON Serialization is used, that only 853 JWS JSON Serialization support for a single signature or MAC value is 854 used, or that support for multiple signatures and/or MAC values is 855 used. JWS implementations only need to implement the features needed 856 for the applications they are designed to support. 858 7.1. JWS Compact Serialization 860 The JWS Compact Serialization represents digitally signed or MACed 861 content as a compact, URL-safe string. This string is: 863 BASE64URL(UTF8(JWS Protected Header)) || '.' || 864 BASE64URL(JWS Payload) || '.' || 865 BASE64URL(JWS Signature) 867 Only one signature/MAC is supported by the JWS Compact Serialization 868 and it provides no syntax to represent a JWS Unprotected Header 869 value. 871 7.2. JWS JSON Serialization 873 The JWS JSON Serialization represents digitally signed or MACed 874 content as a JSON object. Content using the JWS JSON Serialization 875 can be secured with more than one digital signature and/or MAC 876 operation. This representation is neither optimized for compactness 877 nor URL-safe. 879 The following members are defined for use in top-level JSON objects 880 used for the JWS JSON Serialization: 882 payload 883 The "payload" member MUST be present and contain the value 884 BASE64URL(JWS Payload). 886 signatures 887 The "signatures" member value MUST be an array of JSON objects. 888 Each object represents a signature or MAC over the JWS Payload and 889 the JWS Protected Header. 891 The following members are defined for use in the JSON objects that 892 are elements of the "signatures" array: 894 protected 895 The "protected" member MUST be present and contain the value 896 BASE64URL(UTF8(JWS Protected Header)) when the JWS Protected 897 Header value is non-empty; otherwise, it MUST be absent. These 898 Header Parameter values are integrity protected. 900 header 901 The "header" member MUST be present and contain the value JWS 902 Unprotected Header when the JWS Unprotected Header value is non- 903 empty; otherwise, it MUST be absent. This value is represented as 904 an unencoded JSON object, rather than as a string. These Header 905 Parameter values are not integrity protected. 907 signature 908 The "signature" member MUST be present and contain the value 909 BASE64URL(JWS Signature). 911 At least one of the "protected" and "header" members MUST be present 912 for each signature/MAC computation so that an "alg" Header Parameter 913 value is conveyed. 915 Additional members can be present in both the JSON objects defined 916 above; if not understood by implementations encountering them, they 917 MUST be ignored. 919 The Header Parameter values used when creating or validating 920 individual signature or MAC values are the union of the two sets of 921 Header Parameter values that may be present: (1) the JWS Protected 922 Header represented in the "protected" member of the signature/MAC's 923 array element, and (2) the JWS Unprotected Header in the "header" 924 member of the signature/MAC's array element. The union of these sets 925 of Header Parameters comprises the JOSE Header. The Header Parameter 926 names in the two locations MUST be disjoint. 928 Each JWS Signature value is computed using the parameters of the 929 corresponding JOSE Header value in the same manner as for the JWS 930 Compact Serialization. This has the desirable property that each JWS 931 Signature value represented in the "signatures" array is identical to 932 the value that would have been computed for the same parameter in the 933 JWS Compact Serialization, provided that the JWS Protected Header 934 value for that signature/MAC computation (which represents the 935 integrity-protected Header Parameter values) matches that used in the 936 JWS Compact Serialization. 938 In summary, the syntax of a JWS using the JWS JSON Serialization is 939 as follows: 941 { 942 "payload":"", 943 "signatures":[ 944 {"protected":"", 945 "header":, 946 "signature":""}, 947 ... 948 {"protected":"", 949 "header":, 950 "signature":""}] 951 } 953 See Appendix A.6 for an example of computing a JWS using the JWS JSON 954 Serialization. 956 8. TLS Requirements 958 Implementations MUST support TLS. Which version(s) ought to be 959 implemented will vary over time, and depend on the widespread 960 deployment and known security vulnerabilities at the time of 961 implementation. At the time of this writing, TLS version 1.2 962 [RFC5246] is the most recent version. 964 To protect against information disclosure and tampering, 965 confidentiality protection MUST be applied using TLS with a 966 ciphersuite that provides confidentiality and integrity protection. 967 See current publications by the IETF TLS working group, including RFC 968 6176 [RFC6176], for guidance on the ciphersuites currently considered 969 to be appropriate for use. Also, see Recommendations for Secure Use 970 of TLS and DTLS [I-D.ietf-uta-tls-bcp] for recommendations on 971 improving the security of software and services using TLS. 973 Whenever TLS is used, the identity of the service provider encoded in 974 the TLS server certificate MUST be verified using the procedures 975 described in Section 6 of RFC 6125 [RFC6125]. TLS is used by the 976 "jku" and "x5u" Header Parameters defined by this specification. 978 9. IANA Considerations 980 The following registration procedure is used for all the registries 981 established by this specification. 983 Values are registered on a Specification Required [RFC5226] basis 984 after a three-week review period on the [TBD]@ietf.org mailing list, 985 on the advice of one or more Designated Experts. However, to allow 986 for the allocation of values prior to publication, the Designated 987 Expert(s) may approve registration once they are satisfied that such 988 a specification will be published. 990 Registration requests must be sent to the [TBD]@ietf.org mailing list 991 for review and comment, with an appropriate subject (e.g., "Request 992 for access token type: example"). [[ Note to the RFC Editor: The name 993 of the mailing list should be determined in consultation with the 994 IESG and IANA. Suggested name: jose-reg-review. ]] 996 Within the review period, the Designated Expert(s) will either 997 approve or deny the registration request, communicating this decision 998 to the review list and IANA. Denials should include an explanation 999 and, if applicable, suggestions as to how to make the request 1000 successful. Registration requests that are undetermined for a period 1001 longer than 21 days can be brought to the IESG's attention (using the 1002 iesg@ietf.org mailing list) for resolution. 1004 Criteria that should be applied by the Designated Expert(s) includes 1005 determining whether the proposed registration duplicates existing 1006 functionality, determining whether it is likely to be of general 1007 applicability or whether it is useful only for a single application, 1008 and whether the registration description is clear. 1010 IANA must only accept registry updates from the Designated Expert(s) 1011 and should direct all requests for registration to the review mailing 1012 list. 1014 It is suggested that multiple Designated Experts be appointed who are 1015 able to represent the perspectives of different applications using 1016 this specification, in order to enable broadly-informed review of 1017 registration decisions. In cases where a registration decision could 1018 be perceived as creating a conflict of interest for a particular 1019 Expert, that Expert should defer to the judgment of the other 1020 Expert(s). 1022 [[ Note to the RFC Editor and IANA: Pearl Liang of ICANN had 1023 requested that the draft supply the following proposed registry 1024 description information. It is to be used for all registries 1025 established by this specification. 1027 o Protocol Category: JSON Object Signing and Encryption (JOSE) 1029 o Registry Location: http://www.iana.org/assignments/jose 1031 o Webpage Title: (same as the protocol category) 1033 o Registry Name: (same as the section title, but excluding the word 1034 "Registry", for example "JSON Web Signature and Encryption Header 1035 Parameters") 1037 ]] 1039 9.1. JSON Web Signature and Encryption Header Parameters Registry 1041 This specification establishes the IANA JSON Web Signature and 1042 Encryption Header Parameters registry for Header Parameter names. 1043 The registry records the Header Parameter name and a reference to the 1044 specification that defines it. The same Header Parameter name can be 1045 registered multiple times, provided that the parameter usage is 1046 compatible between the specifications. Different registrations of 1047 the same Header Parameter name will typically use different Header 1048 Parameter Usage Location(s) values. 1050 9.1.1. Registration Template 1052 Header Parameter Name: 1053 The name requested (e.g., "kid"). Because a core goal of this 1054 specification is for the resulting representations to be compact, 1055 it is RECOMMENDED that the name be short -- not to exceed 8 1056 characters without a compelling reason to do so. This name is 1057 case-sensitive. Names may not match other registered names in a 1058 case-insensitive manner unless the Designated Expert(s) state that 1059 there is a compelling reason to allow an exception in this 1060 particular case. 1062 Header Parameter Description: 1063 Brief description of the Header Parameter (e.g., "Key ID"). 1065 Header Parameter Usage Location(s): 1066 The Header Parameter usage locations, which should be one or more 1067 of the values "JWS" or "JWE". 1069 Change Controller: 1070 For Standards Track RFCs, state "IESG". For others, give the name 1071 of the responsible party. Other details (e.g., postal address, 1072 email address, home page URI) may also be included. 1074 Specification Document(s): 1075 Reference to the document(s) that specify the parameter, 1076 preferably including URI(s) that can be used to retrieve copies of 1077 the document(s). An indication of the relevant sections may also 1078 be included but is not required. 1080 9.1.2. Initial Registry Contents 1082 This specification registers the Header Parameter names defined in 1083 Section 4.1 in this registry. 1085 o Header Parameter Name: "alg" 1086 o Header Parameter Description: Algorithm 1087 o Header Parameter Usage Location(s): JWS 1088 o Change Controller: IESG 1089 o Specification Document(s): Section 4.1.1 of [[ this document ]] 1091 o Header Parameter Name: "jku" 1092 o Header Parameter Description: JWK Set URL 1093 o Header Parameter Usage Location(s): JWS 1094 o Change Controller: IESG 1095 o Specification Document(s): Section 4.1.2 of [[ this document ]] 1096 o Header Parameter Name: "jwk" 1097 o Header Parameter Description: JSON Web Key 1098 o Header Parameter Usage Location(s): JWS 1099 o Change Controller: IESG 1100 o Specification document(s): Section 4.1.3 of [[ this document ]] 1102 o Header Parameter Name: "kid" 1103 o Header Parameter Description: Key ID 1104 o Header Parameter Usage Location(s): JWS 1105 o Change Controller: IESG 1106 o Specification Document(s): Section 4.1.4 of [[ this document ]] 1108 o Header Parameter Name: "x5u" 1109 o Header Parameter Description: X.509 URL 1110 o Header Parameter Usage Location(s): JWS 1111 o Change Controller: IESG 1112 o Specification Document(s): Section 4.1.5 of [[ this document ]] 1114 o Header Parameter Name: "x5c" 1115 o Header Parameter Description: X.509 Certificate Chain 1116 o Header Parameter Usage Location(s): JWS 1117 o Change Controller: IESG 1118 o Specification Document(s): Section 4.1.6 of [[ this document ]] 1120 o Header Parameter Name: "x5t" 1121 o Header Parameter Description: X.509 Certificate SHA-1 Thumbprint 1122 o Header Parameter Usage Location(s): JWS 1123 o Change Controller: IESG 1124 o Specification Document(s): Section 4.1.7 of [[ this document ]] 1126 o Header Parameter Name: "x5t#S256" 1127 o Header Parameter Description: X.509 Certificate SHA-256 Thumbprint 1128 o Header Parameter Usage Location(s): JWS 1129 o Change Controller: IESG 1130 o Specification Document(s): Section 4.1.8 of [[ this document ]] 1132 o Header Parameter Name: "typ" 1133 o Header Parameter Description: Type 1134 o Header Parameter Usage Location(s): JWS 1135 o Change Controller: IESG 1136 o Specification Document(s): Section 4.1.9 of [[ this document ]] 1138 o Header Parameter Name: "cty" 1139 o Header Parameter Description: Content Type 1140 o Header Parameter Usage Location(s): JWS 1141 o Change Controller: IESG 1142 o Specification Document(s): Section 4.1.10 of [[ this document ]] 1144 o Header Parameter Name: "crit" 1145 o Header Parameter Description: Critical 1146 o Header Parameter Usage Location(s): JWS 1147 o Change Controller: IESG 1148 o Specification Document(s): Section 4.1.11 of [[ this document ]] 1150 9.2. Media Type Registration 1152 9.2.1. Registry Contents 1154 This specification registers the "application/jose" Media Type 1155 [RFC2046] in the MIME Media Types registry [IANA.MediaTypes] in the 1156 manner described in RFC 6838 [RFC6838], which can be used to indicate 1157 that the content is a JWS or JWE object using the JWS Compact 1158 Serialization or the JWE Compact Serialization and the 1159 "application/jose+json" Media Type in the MIME Media Types registry, 1160 which can be used to indicate that the content is a JWS or JWE object 1161 using the JWS JSON Serialization or the JWE JSON Serialization. 1163 o Type name: application 1164 o Subtype name: jose 1165 o Required parameters: n/a 1166 o Optional parameters: n/a 1167 o Encoding considerations: 8bit; application/jose values are encoded 1168 as a series of base64url encoded values (some of which may be the 1169 empty string) each separated from the next by a single period 1170 ('.') character. 1171 o Security considerations: See the Security Considerations section 1172 of [[ this document ]] 1173 o Interoperability considerations: n/a 1174 o Published specification: [[ this document ]] 1175 o Applications that use this media type: OpenID Connect, Mozilla 1176 Persona, Salesforce, Google, Android, Windows Azure, Xbox One, and 1177 numerous others that use JWTs 1178 o Fragment identifier considerations: n/a 1179 o Additional information: Magic number(s): n/a, File extension(s): 1180 n/a, Macintosh file type code(s): n/a 1181 o Person & email address to contact for further information: Michael 1182 B. Jones, mbj@microsoft.com 1183 o Intended usage: COMMON 1184 o Restrictions on usage: none 1185 o Author: Michael B. Jones, mbj@microsoft.com 1186 o Change Controller: IESG 1187 o Provisional registration? No 1188 o Type name: application 1189 o Subtype name: jose+json 1190 o Required parameters: n/a 1191 o Optional parameters: n/a 1192 o Encoding considerations: 8bit; application/jose+json values are 1193 represented as a JSON Object; UTF-8 encoding SHOULD be employed 1194 for the JSON object. 1195 o Security considerations: See the Security Considerations section 1196 of [[ this document ]] 1197 o Interoperability considerations: n/a 1198 o Published specification: [[ this document ]] 1199 o Applications that use this media type: TBD 1200 o Fragment identifier considerations: n/a 1201 o Additional information: Magic number(s): n/a, File extension(s): 1202 n/a, Macintosh file type code(s): n/a 1203 o Person & email address to contact for further information: Michael 1204 B. Jones, mbj@microsoft.com 1205 o Intended usage: COMMON 1206 o Restrictions on usage: none 1207 o Author: Michael B. Jones, mbj@microsoft.com 1208 o Change Controller: IESG 1209 o Provisional registration? No 1211 10. Security Considerations 1213 All of the security issues that are pertinent to any cryptographic 1214 application must be addressed by JWS/JWE/JWK agents. Among these 1215 issues are protecting the user's asymmetric private and symmetric 1216 secret keys and employing countermeasures to various attacks. 1218 All the security considerations in XML DSIG 2.0 1219 [W3C.NOTE-xmldsig-core2-20130411], also apply to this specification, 1220 other than those that are XML specific. Likewise, many of the best 1221 practices documented in XML Signature Best Practices 1222 [W3C.NOTE-xmldsig-bestpractices-20130411] also apply to this 1223 specification, other than those that are XML specific. 1225 10.1. Key Entropy and Random Values 1227 Keys are only as strong as the amount of entropy used to generate 1228 them. A minimum of 128 bits of entropy should be used for all keys, 1229 and depending upon the application context, more may be required. 1231 Implementations must randomly generate public/private key pairs, 1232 message authentication (MAC) keys, and padding values. The use of 1233 inadequate pseudo-random number generators (PRNGs) to generate 1234 cryptographic keys can result in little or no security. An attacker 1235 may find it much easier to reproduce the PRNG environment that 1236 produced the keys, searching the resulting small set of 1237 possibilities, rather than brute force searching the whole key space. 1238 The generation of quality random numbers is difficult. RFC 4086 1239 [RFC4086] offers important guidance in this area. 1241 10.2. Key Protection 1243 Implementations must protect the signer's private key. Compromise of 1244 the signer's private key permits an attacker to masquerade as the 1245 signer. 1247 Implementations must protect the message authentication (MAC) key. 1248 Compromise of the MAC key may result in undetectable modification of 1249 the authenticated content. 1251 10.3. Key Origin Authentication 1253 The key management technique employed to obtain public keys must 1254 authenticate the origin of the key; otherwise, it is unknown what 1255 party signed the message. 1257 Likewise, the key management technique employed to distribute MAC 1258 keys must provide data origin authentication; otherwise, the contents 1259 are delivered with integrity from an unknown source. 1261 10.4. Cryptographic Agility 1263 See Section 8.1 of [JWA] for security considerations on cryptographic 1264 agility. 1266 10.5. Differences between Digital Signatures and MACs 1268 While MACs and digital signatures can both be used for integrity 1269 checking, there are some significant differences between the security 1270 properties that each of them provides. These need to be taken into 1271 consideration when designing protocols and selecting the algorithms 1272 to be used in protocols. 1274 Both signatures and MACs provide for integrity checking -- verifying 1275 that the message has not been modified since the integrity value was 1276 computed. However, MACs provide for origination identification only 1277 under specific circumstances. It can normally be assumed that a 1278 private key used for a signature is only in the hands of a single 1279 entity (although perhaps a distributed entity, in the case of 1280 replicated servers); however, a MAC key needs to be in the hands of 1281 all the entities that use it for integrity computation and checking. 1282 Validation of a MAC only provides corroboration that the message was 1283 generated by one of the parties that knows the symmetric MAC key. 1284 This means that origination can only be determined if a MAC key is 1285 known only to two entities and the recipient knows that it did not 1286 create the message. MAC validation cannot be used to prove 1287 origination to a third party. 1289 10.6. Algorithm Validation 1291 The digital signature representations for some algorithms include 1292 information about the algorithm used inside the signature value. For 1293 instance, signatures produced with RSASSA-PKCS-v1_5 [RFC3447] encode 1294 the hash function used and many libraries actually use the hash 1295 algorithm specified inside the signature when validating the 1296 signature. When using such libraries, as part of the algorithm 1297 validation performed, implementations MUST ensure that the algorithm 1298 information encoded in the signature corresponds to that specified 1299 with the "alg" Header Parameter. If this is not done, an attacker 1300 could claim to have used a strong hash algorithm while actually using 1301 a weak one represented in the signature value. 1303 10.7. Algorithm Protection 1305 In some usages of JWS, there is a risk of algorithm substitution 1306 attacks, in which an attacker can use an existing digital signature 1307 value with a different signature algorithm to make it appear that a 1308 signer has signed something that it has not. These attacks have been 1309 discussed in detail in the context of CMS [RFC6211]. This risk 1310 arises when all of the following are true: 1312 o Verifiers of a signature support multiple algorithms. 1314 o Given an existing signature, an attacker can find another payload 1315 that produces the same signature value with a different algorithm. 1317 o The payload crafted by the attacker is valid in the application 1318 context. 1320 There are several ways for an application to mitigate algorithm 1321 substitution attacks: 1323 o Use only digital signature algorithms that are not vulnerable to 1324 substitution attacks. Substitution attacks are only feasible if 1325 an attacker can compute pre-images for a hash function accepted by 1326 the recipient. All JWA-defined signature algorithms use SHA-2 1327 hashes, for which there are no known pre-image attacks, as of the 1328 time of this writing. 1330 o Require that the "alg" Header Parameter be carried in the 1331 protected header. (This is always the case when using the JWS 1332 Compact Serialization and is the approach taken by CMS [RFC6211].) 1334 o Include a field containing the algorithm in the application 1335 payload, and require that it be matched with the "alg" Header 1336 Parameter during verification. (This is the approach taken by 1337 PKIX [RFC5280].) 1339 10.8. Chosen Plaintext Attacks 1341 Creators of JWSs should not allow third parties to insert arbitrary 1342 content into the message without adding entropy not controlled by the 1343 third party. 1345 10.9. Timing Attacks 1347 When cryptographic algorithms are implemented in such a way that 1348 successful operations take a different amount of time than 1349 unsuccessful operations, attackers may be able to use the time 1350 difference to obtain information about the keys employed. Therefore, 1351 such timing differences must be avoided. 1353 10.10. Replay Protection 1355 While not directly in scope for this specification, note that 1356 applications using JWS (or JWE) objects can thwart replay attacks by 1357 including a unique message identifier as integrity-protected content 1358 in the JWS (or JWE) message and having the recipient verify that the 1359 message has not been previously received or acted upon. 1361 10.11. SHA-1 Certificate Thumbprints 1363 A SHA-1 hash is used when computing "x5t" (X.509 Certificate SHA-1 1364 Thumbprint) values, for compatibility reasons. Should an effective 1365 means of producing SHA-1 hash collisions be developed, and should an 1366 attacker wish to interfere with the use of a known certificate on a 1367 given system, this could be accomplished by creating another 1368 certificate whose SHA-1 hash value is the same and adding it to the 1369 certificate store used by the intended victim. A prerequisite to 1370 this attack succeeding is the attacker having write access to the 1371 intended victim's certificate store. 1373 Alternatively, the "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) 1374 Header Parameter could be used instead of "x5t". However, at the 1375 time of this writing, no development platform is known to support 1376 SHA-256 certificate thumbprints. 1378 10.12. JSON Security Considerations 1380 Strict JSON [RFC7159] validation is a security requirement. If 1381 malformed JSON is received, then the intent of the producer is 1382 impossible to reliably discern. Ambiguous and potentially 1383 exploitable situations could arise if the JSON parser used does not 1384 reject malformed JSON syntax. In particular, any JSON inputs not 1385 conforming to the JSON-text syntax defined in RFC 7159 input MUST be 1386 rejected in their entirety. 1388 Section 4 of the JSON Data Interchange Format specification [RFC7159] 1389 states "The names within an object SHOULD be unique", whereas this 1390 specification states that "Header Parameter names within this object 1391 MUST be unique; JWS parsers MUST either reject JWSs with duplicate 1392 Header Parameter names or use a JSON parser that returns only the 1393 lexically last duplicate member name, as specified in Section 15.12 1394 (The JSON Object) of ECMAScript 5.1 [ECMAScript]". Thus, this 1395 specification requires that the Section 4 "SHOULD" be treated as a 1396 "MUST" by producers and that it be either treated as a "MUST" or in 1397 the manner specified in ECMAScript 5.1 by consumers. Ambiguous and 1398 potentially exploitable situations could arise if the JSON parser 1399 used does not enforce the uniqueness of member names or returns an 1400 unpredictable value for duplicate member names. 1402 Some JSON parsers might not reject input that contains extra 1403 significant characters after a valid input. For instance, the input 1404 "{"tag":"value"}ABCD" contains a valid JSON-text object followed by 1405 the extra characters "ABCD". Such input MUST be rejected in its 1406 entirety. 1408 10.13. Unicode Comparison Security Considerations 1410 Header Parameter names and algorithm names are Unicode strings. For 1411 security reasons, the representations of these names must be compared 1412 verbatim after performing any escape processing (as per Section 8.3 1413 of RFC 7159 [RFC7159]). This means, for instance, that these JSON 1414 strings must compare as being equal ("sig", "\u0073ig"), whereas 1415 these must all compare as being not equal to the first set or to each 1416 other ("SIG", "Sig", "si\u0047"). 1418 JSON strings can contain characters outside the Unicode Basic 1419 Multilingual Plane. For instance, the G clef character (U+1D11E) may 1420 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWS 1421 implementations SHOULD ensure that characters outside the Basic 1422 Multilingual Plane are preserved and compared correctly; 1423 alternatively, if this is not possible due to these characters 1424 exercising limitations present in the underlying JSON implementation, 1425 then input containing them MUST be rejected. 1427 11. References 1429 11.1. Normative References 1431 [ECMAScript] 1432 Ecma International, "ECMAScript Language Specification, 1433 5.1 Edition", ECMA 262, June 2011. 1435 [IANA.MediaTypes] 1436 Internet Assigned Numbers Authority (IANA), "MIME Media 1437 Types", 2005. 1439 [ITU.X690.1994] 1440 International Telecommunications Union, "Information 1441 Technology - ASN.1 encoding rules: Specification of Basic 1442 Encoding Rules (BER), Canonical Encoding Rules (CER) and 1443 Distinguished Encoding Rules (DER)", ITU-T Recommendation 1444 X.690, 1994. 1446 [JWA] Jones, M., "JSON Web Algorithms (JWA)", 1447 draft-ietf-jose-json-web-algorithms (work in progress), 1448 October 2014. 1450 [JWK] Jones, M., "JSON Web Key (JWK)", 1451 draft-ietf-jose-json-web-key (work in progress), 1452 October 2014. 1454 [RFC20] Cerf, V., "ASCII format for Network Interchange", RFC 20, 1455 October 1969. 1457 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1458 Extensions (MIME) Part One: Format of Internet Message 1459 Bodies", RFC 2045, November 1996. 1461 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1462 Extensions (MIME) Part Two: Media Types", RFC 2046, 1463 November 1996. 1465 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1466 Requirement Levels", BCP 14, RFC 2119, March 1997. 1468 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 1470 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 1471 10646", STD 63, RFC 3629, November 2003. 1473 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1474 Resource Identifier (URI): Generic Syntax", STD 66, 1475 RFC 3986, January 2005. 1477 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 1478 Encodings", RFC 4648, October 2006. 1480 [RFC4945] Korver, B., "The Internet IP Security PKI Profile of 1481 IKEv1/ISAKMP, IKEv2, and PKIX", RFC 4945, August 2007. 1483 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2", 1484 RFC 4949, August 2007. 1486 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1487 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 1489 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1490 Housley, R., and W. Polk, "Internet X.509 Public Key 1491 Infrastructure Certificate and Certificate Revocation List 1492 (CRL) Profile", RFC 5280, May 2008. 1494 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 1495 Verification of Domain-Based Application Service Identity 1496 within Internet Public Key Infrastructure Using X.509 1497 (PKIX) Certificates in the Context of Transport Layer 1498 Security (TLS)", RFC 6125, March 2011. 1500 [RFC6176] Turner, S. and T. Polk, "Prohibiting Secure Sockets Layer 1501 (SSL) Version 2.0", RFC 6176, March 2011. 1503 [RFC7159] Bray, T., "The JavaScript Object Notation (JSON) Data 1504 Interchange Format", RFC 7159, March 2014. 1506 11.2. Informative References 1508 [CanvasApp] 1509 Facebook, "Canvas Applications", 2010. 1511 [I-D.ietf-uta-tls-bcp] 1512 Sheffer, Y., Holz, R., and P. Saint-Andre, 1513 "Recommendations for Secure Use of TLS and DTLS", 1514 draft-ietf-uta-tls-bcp-05 (work in progress), 1515 October 2014. 1517 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 1518 September 2010. 1520 [JWE] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)", 1521 draft-ietf-jose-json-web-encryption (work in progress), 1522 October 2014. 1524 [JWT] Jones, M., Bradley, J., and N. Sakimura, "JSON Web Token 1525 (JWT)", draft-ietf-oauth-json-web-token (work in 1526 progress), October 2014. 1528 [MagicSignatures] 1529 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 1530 Signatures", January 2011. 1532 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1533 Hashing for Message Authentication", RFC 2104, 1534 February 1997. 1536 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 1537 Standards (PKCS) #1: RSA Cryptography Specifications 1538 Version 2.1", RFC 3447, February 2003. 1540 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 1541 Requirements for Security", BCP 106, RFC 4086, June 2005. 1543 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 1544 Unique IDentifier (UUID) URN Namespace", RFC 4122, 1545 July 2005. 1547 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 1548 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 1549 May 2008. 1551 [RFC6211] Schaad, J., "Cryptographic Message Syntax (CMS) Algorithm 1552 Identifier Protection Attribute", RFC 6211, April 2011. 1554 [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type 1555 Specifications and Registration Procedures", BCP 13, 1556 RFC 6838, January 2013. 1558 [SHS] National Institute of Standards and Technology, "Secure 1559 Hash Standard (SHS)", FIPS PUB 180-4, March 2012. 1561 [W3C.NOTE-xmldsig-bestpractices-20130411] 1562 Hirsch, F. and P. Datta, "XML Signature Best Practices", 1563 World Wide Web Consortium Note NOTE-xmldsig-bestpractices- 1564 20130411, April 2013, . 1567 [W3C.NOTE-xmldsig-core2-20130411] 1568 Eastlake, D., Reagle, J., Solo, D., Hirsch, F., Roessler, 1569 T., Yiu, K., Datta, P., and S. Cantor, "XML Signature 1570 Syntax and Processing Version 2.0", World Wide Web 1571 Consortium Note NOTE-xmldsig-core2-20130411, April 2013, 1572 . 1574 Appendix A. JWS Examples 1576 This section provides several examples of JWSs. While the first 1577 three examples all represent JSON Web Tokens (JWTs) [JWT], the 1578 payload can be any octet sequence, as shown in Appendix A.4. 1580 A.1. Example JWS using HMAC SHA-256 1582 A.1.1. Encoding 1584 The following example JWS Protected Header declares that the data 1585 structure is a JSON Web Token (JWT) [JWT] and the JWS Signing Input 1586 is secured using the HMAC SHA-256 algorithm. 1588 {"typ":"JWT", 1589 "alg":"HS256"} 1591 To remove potential ambiguities in the representation of the JSON 1592 object above, the actual octet sequence representing UTF8(JWS 1593 Protected Header) used in this example is also included below. (Note 1594 that ambiguities can arise due to differing platform representations 1595 of line breaks (CRLF versus LF), differing spacing at the beginning 1596 and ends of lines, whether the last line has a terminating line break 1597 or not, and other causes. In the representation used in this 1598 example, the first line has no leading or trailing spaces, a CRLF 1599 line break (13, 10) occurs between the first and second lines, the 1600 second line has one leading space (32) and no trailing spaces, and 1601 the last line does not have a terminating line break.) The octets 1602 representing UTF8(JWS Protected Header) in this example (using JSON 1603 array notation) are: 1605 [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 1606 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] 1608 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1609 Header)) gives this value: 1611 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1613 The JWS Payload used in this example is the octets of the UTF-8 1614 representation of the JSON object below. (Note that the payload can 1615 be any base64url encoded octet sequence, and need not be a base64url 1616 encoded JSON object.) 1617 {"iss":"joe", 1618 "exp":1300819380, 1619 "http://example.com/is_root":true} 1621 The following octet sequence, which is the UTF-8 representation used 1622 in this example for the JSON object above, is the JWS Payload: 1624 [123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, 1625 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, 1626 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, 1627 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, 1628 111, 116, 34, 58, 116, 114, 117, 101, 125] 1630 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1631 Header)) gives this value (with line breaks for display purposes 1632 only): 1634 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1635 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1637 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1638 BASE64URL(JWS Payload) gives this string (with line breaks for 1639 display purposes only): 1641 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1642 . 1643 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1644 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1646 The resulting JWS Signing Input value, which is the ASCII 1647 representation of above string, is the following octet sequence 1648 (using JSON array notation): 1650 [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, 1651 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, 1652 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 1653 77, 105, 79, 105, 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 1654 74, 108, 101, 72, 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 1655 107, 122, 79, 68, 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 1656 72, 65, 54, 76, 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 1657 109, 78, 118, 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 1658 106, 112, 48, 99, 110, 86, 108, 102, 81] 1660 HMACs are generated using keys. This example uses the symmetric key 1661 represented in JSON Web Key [JWK] format below (with line breaks 1662 within values for display purposes only): 1664 {"kty":"oct", 1665 "k":"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75 1666 aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow" 1667 } 1669 Running the HMAC SHA-256 algorithm on the JWS Signing Input with this 1670 key yields this JWS Signature octet sequence: 1672 [116, 24, 223, 180, 151, 153, 224, 37, 79, 250, 96, 125, 216, 173, 1673 187, 186, 22, 212, 37, 77, 105, 214, 191, 240, 91, 88, 5, 88, 83, 1674 132, 141, 121] 1676 Encoding this JWS Signature as BASE64URL(JWS Signature) gives this 1677 value: 1679 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1681 Concatenating these values in the order Header.Payload.Signature with 1682 period ('.') characters between the parts yields this complete JWS 1683 representation using the JWS Compact Serialization (with line breaks 1684 for display purposes only): 1686 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1687 . 1688 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1689 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1690 . 1691 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1693 A.1.2. Validating 1695 Since the "alg" Header Parameter is "HS256", we validate the HMAC 1696 SHA-256 value contained in the JWS Signature. 1698 To validate the HMAC value, we repeat the previous process of using 1699 the correct key and the JWS Signing Input (which is the initial 1700 substring of the JWS Compact Serialization representation up until 1701 but not including the second period character) as input to the HMAC 1702 SHA-256 function and then taking the output and determining if it 1703 matches the JWS Signature (which is base64url decoded from the value 1704 encoded in the JWS representation). If it matches exactly, the HMAC 1705 has been validated. 1707 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 1708 A.2.1. Encoding 1710 The JWS Protected Header in this example is different from the 1711 previous example in two ways: First, because a different algorithm is 1712 being used, the "alg" value is different. Second, for illustration 1713 purposes only, the optional "typ" parameter is not used. (This 1714 difference is not related to the algorithm employed.) The JWS 1715 Protected Header used is: 1717 {"alg":"RS256"} 1719 The octets representing UTF8(JWS Protected Header) in this example 1720 (using JSON array notation) are: 1722 [123, 34, 97, 108, 103, 34, 58, 34, 82, 83, 50, 53, 54, 34, 125] 1724 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1725 Header)) gives this value: 1727 eyJhbGciOiJSUzI1NiJ9 1729 The JWS Payload used in this example, which follows, is the same as 1730 in the previous example. Since the BASE64URL(JWS Payload) value will 1731 therefore be the same, its computation is not repeated here. 1733 {"iss":"joe", 1734 "exp":1300819380, 1735 "http://example.com/is_root":true} 1737 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1738 BASE64URL(JWS Payload) gives this string (with line breaks for 1739 display purposes only): 1741 eyJhbGciOiJSUzI1NiJ9 1742 . 1743 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1744 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1746 The resulting JWS Signing Input value, which is the ASCII 1747 representation of above string, is the following octet sequence: 1749 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73, 1750 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1751 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1752 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1753 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1754 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1755 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1756 99, 110, 86, 108, 102, 81] 1758 This example uses the RSA key represented in JSON Web Key [JWK] 1759 format below (with line breaks within values for display purposes 1760 only): 1762 {"kty":"RSA", 1763 "n":"ofgWCuLjybRlzo0tZWJjNiuSfb4p4fAkd_wWJcyQoTbji9k0l8W26mPddx 1764 HmfHQp-Vaw-4qPCJrcS2mJPMEzP1Pt0Bm4d4QlL-yRT-SFd2lZS-pCgNMs 1765 D1W_YpRPEwOWvG6b32690r2jZ47soMZo9wGzjb_7OMg0LOL-bSf63kpaSH 1766 SXndS5z5rexMdbBYUsLA9e-KXBdQOS-UTo7WTBEMa2R2CapHg665xsmtdV 1767 MTBQY4uDZlxvb3qCo5ZwKh9kG4LT6_I5IhlJH7aGhyxXFvUK-DWNmoudF8 1768 NAco9_h9iaGNj8q2ethFkMLs91kzk2PAcDTW9gb54h4FRWyuXpoQ", 1769 "e":"AQAB", 1770 "d":"Eq5xpGnNCivDflJsRQBXHx1hdR1k6Ulwe2JZD50LpXyWPEAeP88vLNO97I 1771 jlA7_GQ5sLKMgvfTeXZx9SE-7YwVol2NXOoAJe46sui395IW_GO-pWJ1O0 1772 BkTGoVEn2bKVRUCgu-GjBVaYLU6f3l9kJfFNS3E0QbVdxzubSu3Mkqzjkn 1773 439X0M_V51gfpRLI9JYanrC4D4qAdGcopV_0ZHHzQlBjudU2QvXt4ehNYT 1774 CBr6XCLQUShb1juUO1ZdiYoFaFQT5Tw8bGUl_x_jTj3ccPDVZFD9pIuhLh 1775 BOneufuBiB4cS98l2SR_RQyGWSeWjnczT0QU91p1DhOVRuOopznQ" 1776 } 1778 The RSA private key is then passed to the RSA signing function, which 1779 also takes the hash type, SHA-256, and the JWS Signing Input as 1780 inputs. The result of the digital signature is an octet sequence, 1781 which represents a big endian integer. In this example, it is: 1783 [112, 46, 33, 137, 67, 232, 143, 209, 30, 181, 216, 45, 191, 120, 69, 1784 243, 65, 6, 174, 27, 129, 255, 247, 115, 17, 22, 173, 209, 113, 125, 1785 131, 101, 109, 66, 10, 253, 60, 150, 238, 221, 115, 162, 102, 62, 81, 1786 102, 104, 123, 0, 11, 135, 34, 110, 1, 135, 237, 16, 115, 249, 69, 1787 229, 130, 173, 252, 239, 22, 216, 90, 121, 142, 232, 198, 109, 219, 1788 61, 184, 151, 91, 23, 208, 148, 2, 190, 237, 213, 217, 217, 112, 7, 1789 16, 141, 178, 129, 96, 213, 248, 4, 12, 167, 68, 87, 98, 184, 31, 1790 190, 127, 249, 217, 46, 10, 231, 111, 36, 242, 91, 51, 187, 230, 244, 1791 74, 230, 30, 177, 4, 10, 203, 32, 4, 77, 62, 249, 18, 142, 212, 1, 1792 48, 121, 91, 212, 189, 59, 65, 238, 202, 208, 102, 171, 101, 25, 129, 1793 253, 228, 141, 247, 127, 55, 45, 195, 139, 159, 175, 221, 59, 239, 1794 177, 139, 93, 163, 204, 60, 46, 176, 47, 158, 58, 65, 214, 18, 202, 1795 173, 21, 145, 18, 115, 160, 95, 35, 185, 232, 56, 250, 175, 132, 157, 1796 105, 132, 41, 239, 90, 30, 136, 121, 130, 54, 195, 212, 14, 96, 69, 1797 34, 165, 68, 200, 242, 122, 122, 45, 184, 6, 99, 209, 108, 247, 202, 1798 234, 86, 222, 64, 92, 178, 33, 90, 69, 178, 194, 85, 102, 181, 90, 1799 193, 167, 72, 160, 112, 223, 200, 163, 42, 70, 149, 67, 208, 25, 238, 1800 251, 71] 1802 Encoding the signature as BASE64URL(JWS Signature) produces this 1803 value (with line breaks for display purposes only): 1805 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1806 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1807 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1808 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1809 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1810 p0igcN_IoypGlUPQGe77Rw 1812 Concatenating these values in the order Header.Payload.Signature with 1813 period ('.') characters between the parts yields this complete JWS 1814 representation using the JWS Compact Serialization (with line breaks 1815 for display purposes only): 1817 eyJhbGciOiJSUzI1NiJ9 1818 . 1819 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1820 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1821 . 1822 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1823 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1824 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1825 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1826 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1827 p0igcN_IoypGlUPQGe77Rw 1829 A.2.2. Validating 1831 Since the "alg" Header Parameter is "RS256", we validate the RSASSA- 1832 PKCS-v1_5 SHA-256 digital signature contained in the JWS Signature. 1834 Validating the JWS Signature is a bit different from the previous 1835 example. We pass the public key (n, e), the JWS Signature (which is 1836 base64url decoded from the value encoded in the JWS representation), 1837 and the JWS Signing Input (which is the initial substring of the JWS 1838 Compact Serialization representation up until but not including the 1839 second period character) to an RSASSA-PKCS-v1_5 signature verifier 1840 that has been configured to use the SHA-256 hash function. 1842 A.3. Example JWS using ECDSA P-256 SHA-256 1844 A.3.1. Encoding 1846 The JWS Protected Header for this example differs from the previous 1847 example because a different algorithm is being used. The JWS 1848 Protected Header used is: 1850 {"alg":"ES256"} 1852 The octets representing UTF8(JWS Protected Header) in this example 1853 (using JSON array notation) are: 1855 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 50, 53, 54, 34, 125] 1857 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1858 Header)) gives this value: 1860 eyJhbGciOiJFUzI1NiJ9 1862 The JWS Payload used in this example, which follows, is the same as 1863 in the previous examples. Since the BASE64URL(JWS Payload) value 1864 will therefore be the same, its computation is not repeated here. 1866 {"iss":"joe", 1867 "exp":1300819380, 1868 "http://example.com/is_root":true} 1870 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1871 BASE64URL(JWS Payload) gives this string (with line breaks for 1872 display purposes only): 1874 eyJhbGciOiJFUzI1NiJ9 1875 . 1876 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1877 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1879 The resulting JWS Signing Input value, which is the ASCII 1880 representation of above string, is the following octet sequence: 1882 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 73, 1883 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1884 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1885 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1886 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1887 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1888 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1889 99, 110, 86, 108, 102, 81] 1891 This example uses the elliptic curve key represented in JSON Web Key 1892 [JWK] format below: 1894 {"kty":"EC", 1895 "crv":"P-256", 1896 "x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU", 1897 "y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0", 1898 "d":"jpsQnnGQmL-YBIffH1136cspYG6-0iY7X1fCE9-E9LI" 1899 } 1901 The ECDSA private part d is then passed to an ECDSA signing function, 1902 which also takes the curve type, P-256, the hash type, SHA-256, and 1903 the JWS Signing Input as inputs. The result of the digital signature 1904 is the EC point (R, S), where R and S are unsigned integers. In this 1905 example, the R and S values, given as octet sequences representing 1906 big endian integers are: 1908 +--------+----------------------------------------------------------+ 1909 | Result | Value | 1910 | Name | | 1911 +--------+----------------------------------------------------------+ 1912 | R | [14, 209, 33, 83, 121, 99, 108, 72, 60, 47, 127, 21, 88, | 1913 | | 7, 212, 2, 163, 178, 40, 3, 58, 249, 124, 126, 23, 129, | 1914 | | 154, 195, 22, 158, 166, 101] | 1915 | S | [197, 10, 7, 211, 140, 60, 112, 229, 216, 241, 45, 175, | 1916 | | 8, 74, 84, 128, 166, 101, 144, 197, 242, 147, 80, 154, | 1917 | | 143, 63, 127, 138, 131, 163, 84, 213] | 1918 +--------+----------------------------------------------------------+ 1920 The JWS Signature is the value R || S. Encoding the signature as 1921 BASE64URL(JWS Signature) produces this value (with line breaks for 1922 display purposes only): 1924 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 1925 pmWQxfKTUJqPP3-Kg6NU1Q 1927 Concatenating these values in the order Header.Payload.Signature with 1928 period ('.') characters between the parts yields this complete JWS 1929 representation using the JWS Compact Serialization (with line breaks 1930 for display purposes only): 1932 eyJhbGciOiJFUzI1NiJ9 1933 . 1934 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1935 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1936 . 1937 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 1938 pmWQxfKTUJqPP3-Kg6NU1Q 1940 A.3.2. Validating 1942 Since the "alg" Header Parameter is "ES256", we validate the ECDSA 1943 P-256 SHA-256 digital signature contained in the JWS Signature. 1945 Validating the JWS Signature is a bit different from the previous 1946 examples. We need to split the 64 member octet sequence of the JWS 1947 Signature (which is base64url decoded from the value encoded in the 1948 JWS representation) into two 32 octet sequences, the first 1949 representing R and the second S. We then pass the public key (x, y), 1950 the signature (R, S), and the JWS Signing Input (which is the initial 1951 substring of the JWS Compact Serialization representation up until 1952 but not including the second period character) to an ECDSA signature 1953 verifier that has been configured to use the P-256 curve with the 1954 SHA-256 hash function. 1956 A.4. Example JWS using ECDSA P-521 SHA-512 1958 A.4.1. Encoding 1960 The JWS Protected Header for this example differs from the previous 1961 example because different ECDSA curves and hash functions are used. 1962 The JWS Protected Header used is: 1964 {"alg":"ES512"} 1966 The octets representing UTF8(JWS Protected Header) in this example 1967 (using JSON array notation) are: 1969 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 53, 49, 50, 34, 125] 1971 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1972 Header)) gives this value: 1974 eyJhbGciOiJFUzUxMiJ9 1976 The JWS Payload used in this example, is the ASCII string "Payload". 1977 The representation of this string is the octet sequence: 1979 [80, 97, 121, 108, 111, 97, 100] 1981 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value: 1983 UGF5bG9hZA 1985 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1986 BASE64URL(JWS Payload) gives this string: 1988 eyJhbGciOiJFUzUxMiJ9.UGF5bG9hZA 1990 The resulting JWS Signing Input value, which is the ASCII 1991 representation of above string, is the following octet sequence: 1993 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 85, 1994 120, 77, 105, 74, 57, 46, 85, 71, 70, 53, 98, 71, 57, 104, 90, 65] 1996 This example uses the elliptic curve key represented in JSON Web Key 1998 [JWK] format below (with line breaks within values for display 1999 purposes only): 2001 {"kty":"EC", 2002 "crv":"P-521", 2003 "x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_ 2004 NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk", 2005 "y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDl 2006 y79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2", 2007 "d":"AY5pb7A0UFiB3RELSD64fTLOSV_jazdF7fLYyuTw8lOfRhWg6Y6rUrPA 2008 xerEzgdRhajnu0ferB0d53vM9mE15j2C" 2009 } 2011 The ECDSA private part d is then passed to an ECDSA signing function, 2012 which also takes the curve type, P-521, the hash type, SHA-512, and 2013 the JWS Signing Input as inputs. The result of the digital signature 2014 is the EC point (R, S), where R and S are unsigned integers. In this 2015 example, the R and S values, given as octet sequences representing 2016 big endian integers are: 2018 +--------+----------------------------------------------------------+ 2019 | Result | Value | 2020 | Name | | 2021 +--------+----------------------------------------------------------+ 2022 | R | [1, 220, 12, 129, 231, 171, 194, 209, 232, 135, 233, | 2023 | | 117, 247, 105, 122, 210, 26, 125, 192, 1, 217, 21, 82, | 2024 | | 91, 45, 240, 255, 83, 19, 34, 239, 71, 48, 157, 147, | 2025 | | 152, 105, 18, 53, 108, 163, 214, 68, 231, 62, 153, 150, | 2026 | | 106, 194, 164, 246, 72, 143, 138, 24, 50, 129, 223, 133, | 2027 | | 206, 209, 172, 63, 237, 119, 109] | 2028 | S | [0, 111, 6, 105, 44, 5, 41, 208, 128, 61, 152, 40, 92, | 2029 | | 61, 152, 4, 150, 66, 60, 69, 247, 196, 170, 81, 193, | 2030 | | 199, 78, 59, 194, 169, 16, 124, 9, 143, 42, 142, 131, | 2031 | | 48, 206, 238, 34, 175, 83, 203, 220, 159, 3, 107, 155, | 2032 | | 22, 27, 73, 111, 68, 68, 21, 238, 144, 229, 232, 148, | 2033 | | 188, 222, 59, 242, 103] | 2034 +--------+----------------------------------------------------------+ 2036 The JWS Signature is the value R || S. Encoding the signature as 2037 BASE64URL(JWS Signature) produces this value (with line breaks for 2038 display purposes only): 2040 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 2041 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 2042 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 2044 Concatenating these values in the order Header.Payload.Signature with 2045 period ('.') characters between the parts yields this complete JWS 2046 representation using the JWS Compact Serialization (with line breaks 2047 for display purposes only): 2049 eyJhbGciOiJFUzUxMiJ9 2050 . 2051 UGF5bG9hZA 2052 . 2053 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 2054 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 2055 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 2057 A.4.2. Validating 2059 Since the "alg" Header Parameter is "ES512", we validate the ECDSA 2060 P-521 SHA-512 digital signature contained in the JWS Signature. 2062 Validating this JWS Signature is very similar to the previous 2063 example. We need to split the 132 member octet sequence of the JWS 2064 Signature into two 66 octet sequences, the first representing R and 2065 the second S. We then pass the public key (x, y), the signature (R, 2066 S), and the JWS Signing Input to an ECDSA signature verifier that has 2067 been configured to use the P-521 curve with the SHA-512 hash 2068 function. 2070 A.5. Example Unsecured JWS 2072 The following example JWS Protected Header declares that the encoded 2073 object is an Unsecured JWS: 2075 {"alg":"none"} 2077 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2078 Header)) gives this value: 2080 eyJhbGciOiJub25lIn0 2082 The JWS Payload used in this example, which follows, is the same as 2083 in the previous examples. Since the BASE64URL(JWS Payload) value 2084 will therefore be the same, its computation is not repeated here. 2086 {"iss":"joe", 2087 "exp":1300819380, 2088 "http://example.com/is_root":true} 2090 The JWS Signature is the empty octet string and BASE64URL(JWS 2091 Signature) is the empty string. 2093 Concatenating these parts in the order Header.Payload.Signature with 2094 period ('.') characters between the parts yields this complete JWS 2095 (with line breaks for display purposes only): 2097 eyJhbGciOiJub25lIn0 2098 . 2099 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 2100 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 2101 . 2103 A.6. Example JWS Using JWS JSON Serialization 2105 This section contains an example using the JWS JSON Serialization. 2106 This example demonstrates the capability for conveying multiple 2107 digital signatures and/or MACs for the same payload. 2109 The JWS Payload used in this example is the same as that used in the 2110 examples in Appendix A.2 and Appendix A.3 (with line breaks for 2111 display purposes only): 2113 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 2114 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 2116 Two digital signatures are used in this example: the first using 2117 RSASSA-PKCS-v1_5 SHA-256 and the second using ECDSA P-256 SHA-256. 2118 For the first, the JWS Protected Header and key are the same as in 2119 Appendix A.2, resulting in the same JWS Signature value; therefore, 2120 its computation is not repeated here. For the second, the JWS 2121 Protected Header and key are the same as in Appendix A.3, resulting 2122 in the same JWS Signature value; therefore, its computation is not 2123 repeated here. 2125 A.6.1. JWS Per-Signature Protected Headers 2127 The JWS Protected Header value used for the first signature is: 2129 {"alg":"RS256"} 2131 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2132 Header)) gives this value: 2134 eyJhbGciOiJSUzI1NiJ9 2136 The JWS Protected Header value used for the second signature is: 2138 {"alg":"ES256"} 2140 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2141 Header)) gives this value: 2143 eyJhbGciOiJFUzI1NiJ9 2145 A.6.2. JWS Per-Signature Unprotected Headers 2147 Key ID values are supplied for both keys using per-signature Header 2148 Parameters. The two values used to represent these Key IDs are: 2150 {"kid":"2010-12-29"} 2152 and 2154 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 2156 A.6.3. Complete JOSE Header Values 2158 Combining the protected and unprotected header values supplied, the 2159 JOSE Header values used for the first and second signatures 2160 respectively are: 2162 {"alg":"RS256", 2163 "kid":"2010-12-29"} 2165 and 2167 {"alg":"ES256", 2168 "kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 2170 A.6.4. Complete JWS JSON Serialization Representation 2172 The complete JSON Web Signature JSON Serialization for these values 2173 is as follows (with line breaks within values for display purposes 2174 only): 2176 {"payload": 2177 "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGF 2178 tcGxlLmNvbS9pc19yb290Ijp0cnVlfQ", 2179 "signatures":[ 2180 {"protected":"eyJhbGciOiJSUzI1NiJ9", 2181 "header": 2182 {"kid":"2010-12-29"}, 2183 "signature": 2184 "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZ 2185 mh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjb 2186 KBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHl 2187 b1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZES 2188 c6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AX 2189 LIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw"}, 2190 {"protected":"eyJhbGciOiJFUzI1NiJ9", 2191 "header": 2192 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"}, 2193 "signature": 2194 "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8IS 2195 lSApmWQxfKTUJqPP3-Kg6NU1Q"}] 2196 } 2198 Appendix B. "x5c" (X.509 Certificate Chain) Example 2200 The JSON array below is an example of a certificate chain that could 2201 be used as the value of an "x5c" (X.509 Certificate Chain) Header 2202 Parameter, per Section 4.1.6. Note that since these strings contain 2203 base64 encoded (not base64url encoded) values, they are allowed to 2204 contain white space and line breaks. 2206 ["MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVM 2207 xITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR2 2208 8gRGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExM 2209 TYwMTU0MzdaFw0yNjExMTYwMTU0MzdaMIHKMQswCQYDVQQGEwJVUzEQMA4GA1UE 2210 CBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEaMBgGA1UEChMRR29EYWR 2211 keS5jb20sIEluYy4xMzAxBgNVBAsTKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYW 2212 RkeS5jb20vcmVwb3NpdG9yeTEwMC4GA1UEAxMnR28gRGFkZHkgU2VjdXJlIENlc 2213 nRpZmljYXRpb24gQXV0aG9yaXR5MREwDwYDVQQFEwgwNzk2OTI4NzCCASIwDQYJ 2214 KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMQt1RWMnCZM7DI161+4WQFapmGBWTt 2215 wY6vj3D3HKrjJM9N55DrtPDAjhI6zMBS2sofDPZVUBJ7fmd0LJR4h3mUpfjWoqV 2216 Tr9vcyOdQmVZWt7/v+WIbXnvQAjYwqDL1CBM6nPwT27oDyqu9SoWlm2r4arV3aL 2217 GbqGmu75RpRSgAvSMeYddi5Kcju+GZtCpyz8/x4fKL4o/K1w/O5epHBp+YlLpyo 2218 7RJlbmr2EkRTcDCVw5wrWCs9CHRK8r5RsL+H0EwnWGu1NcWdrxcx+AuP7q2BNgW 2219 JCJjPOq8lh8BJ6qf9Z/dFjpfMFDniNoW1fho3/Rb2cRGadDAW/hOUoz+EDU8CAw 2220 EAAaOCATIwggEuMB0GA1UdDgQWBBT9rGEyk2xF1uLuhV+auud2mWjM5zAfBgNVH 2221 SMEGDAWgBTSxLDSkdRMEXGzYcs9of7dqGrU4zASBgNVHRMBAf8ECDAGAQH/AgEA 2222 MDMGCCsGAQUFBwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZ29kYWR 2223 keS5jb20wRgYDVR0fBD8wPTA7oDmgN4Y1aHR0cDovL2NlcnRpZmljYXRlcy5nb2 2224 RhZGR5LmNvbS9yZXBvc2l0b3J5L2dkcm9vdC5jcmwwSwYDVR0gBEQwQjBABgRVH 2225 SAAMDgwNgYIKwYBBQUHAgEWKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5j 2226 b20vcmVwb3NpdG9yeTAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggE 2227 BANKGwOy9+aG2Z+5mC6IGOgRQjhVyrEp0lVPLN8tESe8HkGsz2ZbwlFalEzAFPI 2228 UyIXvJxwqoJKSQ3kbTJSMUA2fCENZvD117esyfxVgqwcSeIaha86ykRvOe5GPLL 2229 5CkKSkB2XIsKd83ASe8T+5o0yGPwLPk9Qnt0hCqU7S+8MxZC9Y7lhyVJEnfzuz9 2230 p0iRFEUOOjZv2kWzRaJBydTXRE4+uXR21aITVSzGh6O1mawGhId/dQb8vxRMDsx 2231 uxN89txJx9OjxUUAiKEngHUuHqDTMBqLdElrRhjZkAzVvb3du6/KFUJheqwNTrZ 2232 EjYx8WnM25sgVjOuH0aBsXBTWVU+4=", 2233 "MIIE+zCCBGSgAwIBAgICAQ0wDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1Z 2234 hbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIE 2235 luYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb 2236 24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8x 2237 IDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTA0MDYyOTE3MDY 2238 yMFoXDTI0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRoZS 2239 BHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3MgM 2240 iBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN 2241 ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XC 2242 APVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux 2243 6wwdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLO 2244 tXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWo 2245 riMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZ 2246 Eewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjggHhMIIB3TAdBgNVHQ 2247 4EFgQU0sSw0pHUTBFxs2HLPaH+3ahq1OMwgdIGA1UdIwSByjCBx6GBwaSBvjCBu 2248 zEkMCIGA1UEBxMbVmFsaUNlcnQgVmFsaWRhdGlvbiBOZXR3b3JrMRcwFQYDVQQK 2249 Ew5WYWxpQ2VydCwgSW5jLjE1MDMGA1UECxMsVmFsaUNlcnQgQ2xhc3MgMiBQb2x 2250 pY3kgVmFsaWRhdGlvbiBBdXRob3JpdHkxITAfBgNVBAMTGGh0dHA6Ly93d3cudm 2251 FsaWNlcnQuY29tLzEgMB4GCSqGSIb3DQEJARYRaW5mb0B2YWxpY2VydC5jb22CA 2252 QEwDwYDVR0TAQH/BAUwAwEB/zAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGG 2253 F2h0dHA6Ly9vY3NwLmdvZGFkZHkuY29tMEQGA1UdHwQ9MDswOaA3oDWGM2h0dHA 2254 6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5jb20vcmVwb3NpdG9yeS9yb290LmNybD 2255 BLBgNVHSAERDBCMEAGBFUdIAAwODA2BggrBgEFBQcCARYqaHR0cDovL2NlcnRpZ 2256 mljYXRlcy5nb2RhZGR5LmNvbS9yZXBvc2l0b3J5MA4GA1UdDwEB/wQEAwIBBjAN 2257 BgkqhkiG9w0BAQUFAAOBgQC1QPmnHfbq/qQaQlpE9xXUhUaJwL6e4+PrxeNYiY+ 2258 Sn1eocSxI0YGyeR+sBjUZsE4OWBsUs5iB0QQeyAfJg594RAoYC5jcdnplDQ1tgM 2259 QLARzLrUc+cb53S8wGd9D0VmsfSxOaFIqII6hR8INMqzW/Rn453HWkrugp++85j 2260 09VZw==", 2261 "MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ 2262 0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNT 2263 AzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0a 2264 G9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkq 2265 hkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE 2266 5MDYyNjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTm 2267 V0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZ 2268 XJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQD 2269 ExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9 2270 AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5a 2271 vIWZJV16vYdA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zf 2272 N1SLUzm1NZ9WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwb 2273 P7RfZHM047QSv4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQU 2274 AA4GBADt/UG9vUJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQ 2275 C1u+mNr0HZDzTuIYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMM 2276 j4QssxsodyamEwCW/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd"] 2278 Appendix C. Notes on implementing base64url encoding without padding 2280 This appendix describes how to implement base64url encoding and 2281 decoding functions without padding based upon standard base64 2282 encoding and decoding functions that do use padding. 2284 To be concrete, example C# code implementing these functions is shown 2285 below. Similar code could be used in other languages. 2287 static string base64urlencode(byte [] arg) 2288 { 2289 string s = Convert.ToBase64String(arg); // Regular base64 encoder 2290 s = s.Split('=')[0]; // Remove any trailing '='s 2291 s = s.Replace('+', '-'); // 62nd char of encoding 2292 s = s.Replace('/', '_'); // 63rd char of encoding 2293 return s; 2294 } 2296 static byte [] base64urldecode(string arg) 2297 { 2298 string s = arg; 2299 s = s.Replace('-', '+'); // 62nd char of encoding 2300 s = s.Replace('_', '/'); // 63rd char of encoding 2301 switch (s.Length % 4) // Pad with trailing '='s 2302 { 2303 case 0: break; // No pad chars in this case 2304 case 2: s += "=="; break; // Two pad chars 2305 case 3: s += "="; break; // One pad char 2306 default: throw new System.Exception( 2307 "Illegal base64url string!"); 2308 } 2309 return Convert.FromBase64String(s); // Standard base64 decoder 2310 } 2312 As per the example code above, the number of '=' padding characters 2313 that needs to be added to the end of a base64url encoded string 2314 without padding to turn it into one with padding is a deterministic 2315 function of the length of the encoded string. Specifically, if the 2316 length mod 4 is 0, no padding is added; if the length mod 4 is 2, two 2317 '=' padding characters are added; if the length mod 4 is 3, one '=' 2318 padding character is added; if the length mod 4 is 1, the input is 2319 malformed. 2321 An example correspondence between unencoded and encoded values 2322 follows. The octet sequence below encodes into the string below, 2323 which when decoded, reproduces the octet sequence. 2324 3 236 255 224 193 2325 A-z_4ME 2327 Appendix D. Notes on Key Selection 2329 This appendix describes a set of possible algorithms for selecting 2330 the key to be used to validate the digital signature or MAC of a JWS 2331 object or for selecting the key to be used to decrypt a JWE object. 2332 This guidance describes a family of possible algorithms, rather than 2333 a single algorithm, because in different contexts, not all the 2334 sources of keys will be used, they can be tried in different orders, 2335 and sometimes not all the collected keys will be tried; hence, 2336 different algorithms will be used in different application contexts. 2338 The steps below are described for illustration purposes only; 2339 specific applications can and are likely to use different algorithms 2340 or perform some of the steps in different orders. Specific 2341 applications will frequently have a much simpler method of 2342 determining the keys to use, as there may be one or two key selection 2343 methods that are profiled for the application's use. This appendix 2344 supplements the normative information on key location in Section 6. 2346 These algorithms include the following steps. Note that the steps 2347 can be performed in any order and do not need to be treated as 2348 distinct. For example, keys can be tried as soon as they are found, 2349 rather than collecting all the keys before trying any. 2351 1. Collect the set of potentially applicable keys. Sources of keys 2352 may include: 2354 * Keys supplied by the application protocol being used. 2356 * Keys referenced by the "jku" (JWK Set URL) Header Parameter. 2358 * The key provided by the "jwk" (JSON Web Key) Header Parameter. 2360 * The key referenced by the "x5u" (X.509 URL) Header Parameter. 2362 * The key provided by the "x5c" (X.509 Certificate Chain) Header 2363 Parameter. 2365 * Other applicable keys available to the application. 2367 The order for collecting and trying keys from different key 2368 sources is typically application dependent. For example, 2369 frequently all keys from a one set of locations, such as local 2370 caches, will be tried before collecting and trying keys from 2371 other locations. 2373 2. Filter the set of collected keys. For instance, some 2374 applications will use only keys referenced by "kid" (key ID) or 2375 "x5t" (X.509 certificate SHA-1 thumbprint) parameters. If the 2376 application uses the "alg" (algorithm), "use" (public key use), 2377 or "key_ops" (key operations) parameters, keys with keys with 2378 inappropriate values of those parameters would be excluded. 2379 Additionally, keys might be filtered to include or exclude keys 2380 with certain other member values in an application specific 2381 manner. For some applications, no filtering will be applied. 2383 3. Order the set of collected keys. For instance, keys referenced 2384 by "kid" (Key ID) or "x5t" (X.509 Certificate SHA-1 Thumbprint) 2385 parameters might be tried before keys with neither of these 2386 values. Likewise, keys with certain member values might be 2387 ordered before keys with other member values. For some 2388 applications, no ordering will be applied. 2390 4. Make trust decisions about the keys. Signatures made with keys 2391 not meeting the application's trust criteria would not be 2392 accepted. Such criteria might include, but is not limited to the 2393 source of the key, whether the TLS certificate validates for keys 2394 retrieved from URLs, whether a key in an X.509 certificate is 2395 backed by a valid certificate chain, and other information known 2396 by the application. 2398 5. Attempt signature or MAC validation for a JWS object or 2399 decryption of a JWE object with some or all of the collected and 2400 possibly filtered and/or ordered keys. A limit on the number of 2401 keys to be tried might be applied. This process will normally 2402 terminate following a successful validation or decryption. 2404 Note that it is reasonable for some applications to perform signature 2405 or MAC validation prior to making a trust decision about a key, since 2406 keys for which the validation fails need no trust decision. 2408 Appendix E. Negative Test Case for "crit" Header Parameter 2410 Conforming implementations must reject input containing critical 2411 extensions that are not understood or cannot be processed. The 2412 following JWS must be rejected by all implementations, because it 2413 uses an extension Header Parameter name 2414 "http://example.invalid/UNDEFINED" that they do not understand. Any 2415 other similar input, in which the use of the value 2416 "http://example.invalid/UNDEFINED" is substituted for any other 2417 Header Parameter name not understood by the implementation, must also 2418 be rejected. 2420 The JWS Protected Header value for this JWS is: 2422 {"alg":"none", 2423 "crit":["http://example.invalid/UNDEFINED"], 2424 "http://example.invalid/UNDEFINED":true 2425 } 2427 The complete JWS that must be rejected is as follows (with line 2428 breaks for display purposes only): 2430 eyJhbGciOiJub25lIiwNCiAiY3JpdCI6WyJodHRwOi8vZXhhbXBsZS5jb20vVU5ERU 2431 ZJTkVEIl0sDQogImh0dHA6Ly9leGFtcGxlLmNvbS9VTkRFRklORUQiOnRydWUNCn0. 2432 RkFJTA. 2434 Appendix F. Detached Content 2436 In some contexts, it is useful integrity protect content that is not 2437 itself contained in a JWS object. One way to do this is create a JWS 2438 object in the normal fashion using a representation of the content as 2439 the payload, but then delete the payload representation from the JWS, 2440 and send this modified object to the recipient, rather than the JWS. 2441 When using the JWS Compact Serialization, the deletion is 2442 accomplished by replacing the second field (which contains 2443 BASE64URL(JWS Payload)) value with the empty string; when using the 2444 JWS JSON Serialization, the deletion is accomplished by deleting the 2445 "payload" member. This method assumes that the recipient can 2446 reconstruct the exact payload used in the JWS. To use the modified 2447 object, the recipient reconstructs the JWS by re-inserting the 2448 payload representation into the modified object, and uses the 2449 resulting JWS in the usual manner. Note that this method needs no 2450 support from JWS libraries, as applications can use this method by 2451 modifying the inputs and outputs of standard JWS libraries. 2453 Appendix G. Acknowledgements 2455 Solutions for signing JSON content were previously explored by Magic 2456 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 2457 Applications [CanvasApp], all of which influenced this draft. 2459 Thanks to Axel Nennker for his early implementation and feedback on 2460 the JWS and JWE specifications. 2462 This specification is the work of the JOSE Working Group, which 2463 includes dozens of active and dedicated participants. In particular, 2464 the following individuals contributed ideas, feedback, and wording 2465 that influenced this specification: 2467 Dirk Balfanz, Richard Barnes, Brian Campbell, Alissa Cooper, Breno de 2468 Medeiros, Stephen Farrell, Dick Hardt, Joe Hildebrand, Jeff Hodges, 2469 Russ Housley, Edmund Jay, Tero Kivinen, Yaron Y. Goland, Ben Laurie, 2470 Ted Lemon, James Manger, Matt Miller, Kathleen Moriarty, Tony 2471 Nadalin, Hideki Nara, Axel Nennker, John Panzer, Ray Polk, Emmanuel 2472 Raviart, Eric Rescorla, Pete Resnick, Jim Schaad, Paul Tarjan, Hannes 2473 Tschofenig, and Sean Turner. 2475 Jim Schaad and Karen O'Donoghue chaired the JOSE working group and 2476 Sean Turner, Stephen Farrell, and Kathleen Moriarty served as 2477 Security area directors during the creation of this specification. 2479 Appendix H. Document History 2481 [[ to be removed by the RFC Editor before publication as an RFC ]] 2483 -35 2485 o Addressed AppsDir reviews by Ray Polk. 2487 o Used real values for examples in the IANA Registration Template. 2489 -34 2491 o Addressed IESG review comments by Alissa Cooper, Pete Resnick, 2492 Richard Barnes, Ted Lemon, and Stephen Farrell. 2494 o Addressed Gen-ART review comments by Russ Housley. 2496 o Referenced RFC 4945 for PEM certificate delimiter syntax. 2498 -33 2500 o Noted that certificate thumbprints are also sometimes known as 2501 certificate fingerprints. 2503 o Added an informative reference to draft-ietf-uta-tls-bcp for 2504 recommendations on improving the security of software and services 2505 using TLS. 2507 o Changed the registration review period to three weeks. 2509 o Acknowledged additional contributors. 2511 -32 2513 o Addressed Gen-ART review comments by Russ Housley. 2515 o Addressed secdir review comments by Tero Kivinen, Stephen Kent, 2516 and Scott Kelly. 2518 o Replaced the term Plaintext JWS with Unsecured JWS. 2520 -31 2522 o Reworded the language about JWS implementations ignoring the "typ" 2523 and "cty" parameters, explicitly saying that their processing is 2524 performed by JWS applications. 2526 o Added additional guidance on ciphersuites currently considered to 2527 be appropriate for use, including a reference to a recent update 2528 by the TLS working group. 2530 -30 2532 o Added subsection headings within the Overview section for the two 2533 serializations. 2535 o Added references and cleaned up the reference syntax in a few 2536 places. 2538 o Applied minor wording changes to the Security Considerations 2539 section and made other local editorial improvements. 2541 -29 2543 o Replaced the terms JWS Header, JWE Header, and JWT Header with a 2544 single JOSE Header term defined in the JWS specification. This 2545 also enabled a single Header Parameter definition to be used and 2546 reduced other areas of duplication between specifications. 2548 -28 2550 o Revised the introduction to the Security Considerations section. 2551 Also introduced additional subsection headings for security 2552 considerations items and also moved a security consideration item 2553 here from the JWA draft. 2555 o Added text about when applications typically would and would not 2556 use "typ" and "cty" header parameters. 2558 -27 2560 o Added the "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) header 2561 parameter. 2563 o Stated that any JSON inputs not conforming to the JSON-text syntax 2564 defined in RFC 7159 input MUST be rejected in their entirety. 2566 o Simplified the TLS requirements. 2568 -26 2570 o Referenced Section 6 of RFC 6125 for TLS server certificate 2571 identity validation. 2573 o Described potential sources of ambiguity in representing the JSON 2574 objects used in the examples. The octets of the actual UTF-8 2575 representations of the JSON objects used in the examples are 2576 included to remove these ambiguities. 2578 o Added a small amount of additional explanatory text to the 2579 signature validation examples to aid implementers. 2581 o Noted that octet sequences are depicted using JSON array notation. 2583 o Updated references, including to W3C specifications. 2585 -25 2587 o No changes were made, other than to the version number and date. 2589 -24 2591 o Updated the JSON reference to RFC 7159. 2593 -23 2595 o Clarified that the base64url encoding includes no line breaks, 2596 white space, or other additional characters. 2598 -22 2600 o Corrected RFC 2119 terminology usage. 2602 o Replaced references to draft-ietf-json-rfc4627bis with RFC 7158. 2604 -21 2606 o Applied review comments to the appendix "Notes on Key Selection", 2607 addressing issue #93. 2609 o Changed some references from being normative to informative, 2610 addressing issue #90. 2612 o Applied review comments to the JSON Serialization section, 2613 addressing issue #121. 2615 -20 2617 o Made terminology definitions more consistent, addressing issue 2618 #165. 2620 o Restructured the JSON Serialization section to call out the 2621 parameters used in hanging lists, addressing issue #121. 2623 o Described key filtering and refined other aspects of the text in 2624 the appendix "Notes on Key Selection", addressing issue #93. 2626 o Replaced references to RFC 4627 with draft-ietf-json-rfc4627bis, 2627 addressing issue #90. 2629 -19 2631 o Added the appendix "Notes on Validation Key Selection", addressing 2632 issue #93. 2634 o Reordered the key selection parameters. 2636 -18 2638 o Updated the mandatory-to-implement (MTI) language to say that 2639 applications using this specification need to specify what 2640 serialization and serialization features are used for that 2641 application, addressing issue #119. 2643 o Changes to address editorial and minor issues #25, #89, #97, #110, 2644 #114, #115, #116, #117, #120, and #184. 2646 o Added and used Header Parameter Description registry field. 2648 -17 2649 o Refined the "typ" and "cty" definitions to always be MIME Media 2650 Types, with the omission of "application/" prefixes recommended 2651 for brevity, addressing issue #50. 2653 o Updated the mandatory-to-implement (MTI) language to say that 2654 general-purpose implementations must implement the single 2655 signature/MAC value case for both serializations whereas special- 2656 purpose implementations can implement just one serialization if 2657 that meets the needs of the use cases the implementation is 2658 designed for, addressing issue #119. 2660 o Explicitly named all the logical components of a JWS and defined 2661 the processing rules and serializations in terms of those 2662 components, addressing issues #60, #61, and #62. 2664 o Replaced verbose repetitive phases such as "base64url encode the 2665 octets of the UTF-8 representation of X" with mathematical 2666 notation such as "BASE64URL(UTF8(X))". 2668 o Terms used in multiple documents are now defined in one place and 2669 incorporated by reference. Some lightly used or obvious terms 2670 were also removed. This addresses issue #58. 2672 -16 2674 o Changes to address editorial and minor issues #50, #98, #99, #102, 2675 #104, #106, #107, #111, and #112. 2677 -15 2679 o Clarified that it is an application decision which signatures, 2680 MACs, or plaintext values must successfully validate for the JWS 2681 to be accepted, addressing issue #35. 2683 o Corrected editorial error in "ES512" example. 2685 o Changes to address editorial and minor issues #34, #96, #100, 2686 #101, #104, #105, and #106. 2688 -14 2690 o Stated that the "signature" parameter is to be omitted in the JWS 2691 JSON Serialization when its value would be empty (which is only 2692 the case for a Plaintext JWS). 2694 -13 2695 o Made all header parameter values be per-signature/MAC, addressing 2696 issue #24. 2698 -12 2700 o Clarified that the "typ" and "cty" header parameters are used in 2701 an application-specific manner and have no effect upon the JWS 2702 processing. 2704 o Replaced the MIME types "application/jws+json" and 2705 "application/jws" with "application/jose+json" and 2706 "application/jose". 2708 o Stated that recipients MUST either reject JWSs with duplicate 2709 Header Parameter Names or use a JSON parser that returns only the 2710 lexically last duplicate member name. 2712 o Added a Serializations section with parallel treatment of the JWS 2713 Compact Serialization and the JWS JSON Serialization and also 2714 moved the former Implementation Considerations content there. 2716 -11 2718 o Added Key Identification section. 2720 o For the JWS JSON Serialization, enable header parameter values to 2721 be specified in any of three parameters: the "protected" member 2722 that is integrity protected and shared among all recipients, the 2723 "unprotected" member that is not integrity protected and shared 2724 among all recipients, and the "header" member that is not 2725 integrity protected and specific to a particular recipient. (This 2726 does not affect the JWS Compact Serialization, in which all header 2727 parameter values are in a single integrity protected JWE Header 2728 value.) 2730 o Removed suggested compact serialization for multiple digital 2731 signatures and/or MACs. 2733 o Changed the MIME type name "application/jws-js" to 2734 "application/jws+json", addressing issue #22. 2736 o Tightened the description of the "crit" (critical) header 2737 parameter. 2739 o Added a negative test case for the "crit" header parameter 2741 -10 2742 o Added an appendix suggesting a possible compact serialization for 2743 JWSs with multiple digital signatures and/or MACs. 2745 -09 2747 o Added JWS JSON Serialization, as specified by 2748 draft-jones-jose-jws-json-serialization-04. 2750 o Registered "application/jws-js" MIME type and "JWS-JS" typ header 2751 parameter value. 2753 o Defined that the default action for header parameters that are not 2754 understood is to ignore them unless specifically designated as 2755 "MUST be understood" or included in the new "crit" (critical) 2756 header parameter list. This addressed issue #6. 2758 o Changed term "JWS Secured Input" to "JWS Signing Input". 2760 o Changed from using the term "byte" to "octet" when referring to 8 2761 bit values. 2763 o Changed member name from "recipients" to "signatures" in the JWS 2764 JSON Serialization. 2766 o Added complete values using the JWS Compact Serialization for all 2767 examples. 2769 -08 2771 o Applied editorial improvements suggested by Jeff Hodges and Hannes 2772 Tschofenig. Many of these simplified the terminology used. 2774 o Clarified statements of the form "This header parameter is 2775 OPTIONAL" to "Use of this header parameter is OPTIONAL". 2777 o Added a Header Parameter Usage Location(s) field to the IANA JSON 2778 Web Signature and Encryption Header Parameters registry. 2780 o Added seriesInfo information to Internet Draft references. 2782 -07 2784 o Updated references. 2786 -06 2788 o Changed "x5c" (X.509 Certificate Chain) representation from being 2789 a single string to being an array of strings, each containing a 2790 single base64 encoded DER certificate value, representing elements 2791 of the certificate chain. 2793 o Applied changes made by the RFC Editor to RFC 6749's registry 2794 language to this specification. 2796 -05 2798 o Added statement that "StringOrURI values are compared as case- 2799 sensitive strings with no transformations or canonicalizations 2800 applied". 2802 o Indented artwork elements to better distinguish them from the body 2803 text. 2805 -04 2807 o Completed JSON Security Considerations section, including 2808 considerations about rejecting input with duplicate member names. 2810 o Completed security considerations on the use of a SHA-1 hash when 2811 computing "x5t" (x.509 certificate thumbprint) values. 2813 o Refer to the registries as the primary sources of defined values 2814 and then secondarily reference the sections defining the initial 2815 contents of the registries. 2817 o Normatively reference XML DSIG 2.0 for its security 2818 considerations. 2820 o Added this language to Registration Templates: "This name is case 2821 sensitive. Names that match other registered names in a case 2822 insensitive manner SHOULD NOT be accepted." 2824 o Reference draft-jones-jose-jws-json-serialization instead of 2825 draft-jones-json-web-signature-json-serialization. 2827 o Described additional open issues. 2829 o Applied editorial suggestions. 2831 -03 2833 o Added the "cty" (content type) header parameter for declaring type 2834 information about the secured content, as opposed to the "typ" 2835 (type) header parameter, which declares type information about 2836 this object. 2838 o Added "Collision Resistant Namespace" to the terminology section. 2840 o Reference ITU.X690.1994 for DER encoding. 2842 o Added an example JWS using ECDSA P-521 SHA-512. This has 2843 particular illustrative value because of the use of the 521 bit 2844 integers in the key and signature values. This is also an example 2845 in which the payload is not a base64url encoded JSON object. 2847 o Added an example "x5c" value. 2849 o No longer say "the UTF-8 representation of the JWS Secured Input 2850 (which is the same as the ASCII representation)". Just call it 2851 "the ASCII representation of the JWS Secured Input". 2853 o Added Registration Template sections for defined registries. 2855 o Added Registry Contents sections to populate registry values. 2857 o Changed name of the JSON Web Signature and Encryption "typ" Values 2858 registry to be the JSON Web Signature and Encryption Type Values 2859 registry, since it is used for more than just values of the "typ" 2860 parameter. 2862 o Moved registries JSON Web Signature and Encryption Header 2863 Parameters and JSON Web Signature and Encryption Type Values to 2864 the JWS specification. 2866 o Numerous editorial improvements. 2868 -02 2870 o Clarified that it is an error when a "kid" value is included and 2871 no matching key is found. 2873 o Removed assumption that "kid" (key ID) can only refer to an 2874 asymmetric key. 2876 o Clarified that JWSs with duplicate Header Parameter Names MUST be 2877 rejected. 2879 o Clarified the relationship between "typ" header parameter values 2880 and MIME types. 2882 o Registered application/jws MIME type and "JWS" typ header 2883 parameter value. 2885 o Simplified JWK terminology to get replace the "JWK Key Object" and 2886 "JWK Container Object" terms with simply "JSON Web Key (JWK)" and 2887 "JSON Web Key Set (JWK Set)" and to eliminate potential confusion 2888 between single keys and sets of keys. As part of this change, the 2889 Header Parameter Name for a public key value was changed from 2890 "jpk" (JSON Public Key) to "jwk" (JSON Web Key). 2892 o Added suggestion on defining additional header parameters such as 2893 "x5t#S256" in the future for certificate thumbprints using hash 2894 algorithms other than SHA-1. 2896 o Specify RFC 2818 server identity validation, rather than RFC 6125 2897 (paralleling the same decision in the OAuth specs). 2899 o Generalized language to refer to Message Authentication Codes 2900 (MACs) rather than Hash-based Message Authentication Codes (HMACs) 2901 unless in a context specific to HMAC algorithms. 2903 o Reformatted to give each header parameter its own section heading. 2905 -01 2907 o Moved definition of Plaintext JWSs (using "alg":"none") here from 2908 the JWT specification since this functionality is likely to be 2909 useful in more contexts that just for JWTs. 2911 o Added "jpk" and "x5c" header parameters for including JWK public 2912 keys and X.509 certificate chains directly in the header. 2914 o Clarified that this specification is defining the JWS Compact 2915 Serialization. Referenced the new JWS-JS spec, which defines the 2916 JWS JSON Serialization. 2918 o Added text "New header parameters should be introduced sparingly 2919 since an implementation that does not understand a parameter MUST 2920 reject the JWS". 2922 o Clarified that the order of the creation and validation steps is 2923 not significant in cases where there are no dependencies between 2924 the inputs and outputs of the steps. 2926 o Changed "no canonicalization is performed" to "no canonicalization 2927 need be performed". 2929 o Corrected the Magic Signatures reference. 2931 o Made other editorial improvements suggested by JOSE working group 2932 participants. 2934 -00 2936 o Created the initial IETF draft based upon 2937 draft-jones-json-web-signature-04 with no normative changes. 2939 o Changed terminology to no longer call both digital signatures and 2940 HMACs "signatures". 2942 Authors' Addresses 2944 Michael B. Jones 2945 Microsoft 2947 Email: mbj@microsoft.com 2948 URI: http://self-issued.info/ 2950 John Bradley 2951 Ping Identity 2953 Email: ve7jtb@ve7jtb.com 2954 URI: http://www.thread-safe.com/ 2956 Nat Sakimura 2957 Nomura Research Institute 2959 Email: n-sakimura@nri.co.jp 2960 URI: http://nat.sakimura.org/