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