idnits 2.17.1 draft-ietf-jose-json-web-signature-32.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 (September 23, 2014) is 3501 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 1882 -- Looks like a reference, but probably isn't: '34' on line 1882 -- Looks like a reference, but probably isn't: '97' on line 1892 -- Looks like a reference, but probably isn't: '108' on line 1892 -- Looks like a reference, but probably isn't: '103' on line 1882 -- Looks like a reference, but probably isn't: '58' on line 1882 -- Looks like a reference, but probably isn't: '82' on line 1635 -- Looks like a reference, but probably isn't: '83' on line 1882 -- Looks like a reference, but probably isn't: '50' on line 1882 -- Looks like a reference, but probably isn't: '53' on line 1882 -- Looks like a reference, but probably isn't: '54' on line 1768 -- Looks like a reference, but probably isn't: '125' on line 1882 -- Looks like a reference, but probably isn't: '69' on line 1882 -- Looks like a reference, but probably isn't: '49' on line 1882 -- Looks like a reference, but probably isn't: '80' on line 1892 -- Looks like a reference, but probably isn't: '121' on line 1892 -- Looks like a reference, but probably isn't: '111' on line 1892 -- Looks like a reference, but probably isn't: '100' on line 1892 -- Looks like a reference, but probably isn't: '0' on line 2202 -- Possible downref: Non-RFC (?) normative reference: ref. 'ECMAScript' -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.X690.1994' ** Downref: Normative reference to an Historic RFC: RFC 1421 ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** 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) -- Possible downref: Non-RFC (?) normative reference: ref. 'USASCII' -- 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 (~~), 1 warning (==), 26 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: March 27, 2015 Ping Identity 6 N. Sakimura 7 NRI 8 September 23, 2014 10 JSON Web Signature (JWS) 11 draft-ietf-jose-json-web-signature-32 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 March 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 . . . . . . . . . . . . . . . . . . . . . . . . . 4 59 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 4 60 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 5 61 3. JSON Web Signature (JWS) Overview . . . . . . . . . . . . . . 6 62 3.1. JWS Compact Serialization Overview . . . . . . . . . . . 7 63 3.2. JWS JSON Serialization Overview . . . . . . . . . . . . . 7 64 3.3. Example JWS . . . . . . . . . . . . . . . . . . . . . . . 8 65 4. JOSE Header . . . . . . . . . . . . . . . . . . . . . . . . . 9 66 4.1. Registered Header Parameter Names . . . . . . . . . . . . 9 67 4.1.1. "alg" (Algorithm) Header Parameter . . . . . . . . . . 10 68 4.1.2. "jku" (JWK Set URL) Header Parameter . . . . . . . . . 10 69 4.1.3. "jwk" (JSON Web Key) Header Parameter . . . . . . . . 10 70 4.1.4. "kid" (Key ID) Header Parameter . . . . . . . . . . . 10 71 4.1.5. "x5u" (X.509 URL) Header Parameter . . . . . . . . . . 11 72 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter . . . 11 73 4.1.7. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header 74 Parameter . . . . . . . . . . . . . . . . . . . . . . 11 75 4.1.8. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) 76 Header Parameter . . . . . . . . . . . . . . . . . . . 11 77 4.1.9. "typ" (Type) Header Parameter . . . . . . . . . . . . 12 78 4.1.10. "cty" (Content Type) Header Parameter . . . . . . . . 12 79 4.1.11. "crit" (Critical) Header Parameter . . . . . . . . . . 13 80 4.2. Public Header Parameter Names . . . . . . . . . . . . . . 14 81 4.3. Private Header Parameter Names . . . . . . . . . . . . . 14 82 5. Producing and Consuming JWSs . . . . . . . . . . . . . . . . . 14 83 5.1. Message Signature or MAC Computation . . . . . . . . . . 14 84 5.2. Message Signature or MAC Validation . . . . . . . . . . . 15 85 5.3. String Comparison Rules . . . . . . . . . . . . . . . . . 16 86 6. Key Identification . . . . . . . . . . . . . . . . . . . . . . 17 87 7. Serializations . . . . . . . . . . . . . . . . . . . . . . . . 17 88 7.1. JWS Compact Serialization . . . . . . . . . . . . . . . . 18 89 7.2. JWS JSON Serialization . . . . . . . . . . . . . . . . . 18 90 8. TLS Requirements . . . . . . . . . . . . . . . . . . . . . . . 20 91 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 20 92 9.1. JSON Web Signature and Encryption Header Parameters 93 Registry . . . . . . . . . . . . . . . . . . . . . . . . 21 94 9.1.1. Registration Template . . . . . . . . . . . . . . . . 22 95 9.1.2. Initial Registry Contents . . . . . . . . . . . . . . 22 97 9.2. Media Type Registration . . . . . . . . . . . . . . . . . 24 98 9.2.1. Registry Contents . . . . . . . . . . . . . . . . . . 24 99 10. Security Considerations . . . . . . . . . . . . . . . . . . . 25 100 10.1. Key Entropy and Random Values . . . . . . . . . . . . . . 25 101 10.2. Key Protection . . . . . . . . . . . . . . . . . . . . . 26 102 10.3. Key Origin Authentication . . . . . . . . . . . . . . . . 26 103 10.4. Cryptographic Agility . . . . . . . . . . . . . . . . . . 26 104 10.5. Differences between Digital Signatures and MACs . . . . . 26 105 10.6. Algorithm Validation . . . . . . . . . . . . . . . . . . 27 106 10.7. Algorithm Protection . . . . . . . . . . . . . . . . . . 27 107 10.8. Chosen Plaintext Attacks . . . . . . . . . . . . . . . . 28 108 10.9. Timing Attacks . . . . . . . . . . . . . . . . . . . . . 28 109 10.10. Replay Protection . . . . . . . . . . . . . . . . . . . . 28 110 10.11. SHA-1 Certificate Thumbprints . . . . . . . . . . . . . . 28 111 10.12. JSON Security Considerations . . . . . . . . . . . . . . 28 112 10.13. Unicode Comparison Security Considerations . . . . . . . 29 113 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 30 114 11.1. Normative References . . . . . . . . . . . . . . . . . . 30 115 11.2. Informative References . . . . . . . . . . . . . . . . . 31 116 Appendix A. JWS Examples . . . . . . . . . . . . . . . . . . . . 32 117 A.1. Example JWS using HMAC SHA-256 . . . . . . . . . . . . . 32 118 A.1.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 33 119 A.1.2. Validating . . . . . . . . . . . . . . . . . . . . . . 35 120 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 . . . . . . . 35 121 A.2.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 35 122 A.2.2. Validating . . . . . . . . . . . . . . . . . . . . . . 38 123 A.3. Example JWS using ECDSA P-256 SHA-256 . . . . . . . . . . 38 124 A.3.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 38 125 A.3.2. Validating . . . . . . . . . . . . . . . . . . . . . . 40 126 A.4. Example JWS using ECDSA P-521 SHA-512 . . . . . . . . . . 41 127 A.4.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 41 128 A.4.2. Validating . . . . . . . . . . . . . . . . . . . . . . 43 129 A.5. Example Unsecured JWS . . . . . . . . . . . . . . . . . . 43 130 A.6. Example JWS Using JWS JSON Serialization . . . . . . . . 44 131 A.6.1. JWS Per-Signature Protected Headers . . . . . . . . . 44 132 A.6.2. JWS Per-Signature Unprotected Headers . . . . . . . . 45 133 A.6.3. Complete JOSE Header Values . . . . . . . . . . . . . 45 134 A.6.4. Complete JWS JSON Serialization Representation . . . . 45 135 Appendix B. "x5c" (X.509 Certificate Chain) Example . . . . . . . 46 136 Appendix C. Notes on implementing base64url encoding without 137 padding . . . . . . . . . . . . . . . . . . . . . . . 48 138 Appendix D. Notes on Key Selection . . . . . . . . . . . . . . . 49 139 Appendix E. Negative Test Case for "crit" Header Parameter . . . 50 140 Appendix F. Detached Content . . . . . . . . . . . . . . . . . . 51 141 Appendix G. Acknowledgements . . . . . . . . . . . . . . . . . . 51 142 Appendix H. Document History . . . . . . . . . . . . . . . . . . 52 143 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 61 145 1. Introduction 147 JSON Web Signature (JWS) represents content secured with digital 148 signatures or Message Authentication Codes (MACs) using JavaScript 149 Object Notation (JSON) [RFC7159] based data structures. The JWS 150 cryptographic mechanisms provide integrity protection for an 151 arbitrary sequence of octets. See Section 10.5 for a discussion on 152 the differences between Digital Signatures and MACs. 154 Two closely related serializations for JWS objects are defined. The 155 JWS Compact Serialization is a compact, URL-safe representation 156 intended for space constrained environments such as HTTP 157 Authorization headers and URI query parameters. The JWS JSON 158 Serialization represents JWS objects as JSON objects and enables 159 multiple signatures and/or MACs to be applied to the same content. 160 Both share the same cryptographic underpinnings. 162 Cryptographic algorithms and identifiers for use with this 163 specification are described in the separate JSON Web Algorithms (JWA) 164 [JWA] specification and an IANA registry defined by that 165 specification. Related encryption capabilities are described in the 166 separate JSON Web Encryption (JWE) [JWE] specification. 168 Names defined by this specification are short because a core goal is 169 for the resulting representations to be compact. 171 1.1. Notational Conventions 173 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 174 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 175 "OPTIONAL" in this document are to be interpreted as described in Key 176 words for use in RFCs to Indicate Requirement Levels [RFC2119]. If 177 these words are used without being spelled in uppercase then they are 178 to be interpreted with their normal natural language meanings. 180 BASE64URL(OCTETS) denotes the base64url encoding of OCTETS, per 181 Section 2. 183 UTF8(STRING) denotes the octets of the UTF-8 [RFC3629] representation 184 of STRING. 186 ASCII(STRING) denotes the octets of the ASCII [USASCII] 187 representation of STRING. 189 The concatenation of two values A and B is denoted as A || B. 191 2. Terminology 193 These terms are defined by this specification: 195 JSON Web Signature (JWS) 196 A data structure representing a digitally signed or MACed message. 198 JOSE Header 199 JSON object containing the parameters describing the cryptographic 200 operations and parameters employed. The JOSE Header is comprised 201 of a set of Header Parameters. 203 JWS Payload 204 The sequence of octets to be secured -- a.k.a., the message. The 205 payload can contain an arbitrary sequence of octets. 207 JWS Signature 208 Digital signature or MAC over the JWS Protected Header and the JWS 209 Payload. 211 Header Parameter 212 A name/value pair that is member of the JOSE Header. 214 JWS Protected Header 215 JSON object that contains the Header Parameters that are integrity 216 protected by the JWS Signature digital signature or MAC operation. 217 For the JWS Compact Serialization, this comprises the entire JOSE 218 Header. For the JWS JSON Serialization, this is one component of 219 the JOSE Header. 221 JWS Unprotected Header 222 JSON object that contains the Header Parameters that are not 223 integrity protected. This can only be present when using the JWS 224 JSON Serialization. 226 Base64url Encoding 227 Base64 encoding using the URL- and filename-safe character set 228 defined in Section 5 of RFC 4648 [RFC4648], with all trailing '=' 229 characters omitted (as permitted by Section 3.2) and without the 230 inclusion of any line breaks, white space, or other additional 231 characters. (See Appendix C for notes on implementing base64url 232 encoding without padding.) 234 JWS Signing Input 235 The input to the digital signature or MAC computation. Its value 236 is ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 237 BASE64URL(JWS Payload)). 239 JWS Compact Serialization 240 A representation of the JWS as a compact, URL-safe string. 242 JWS JSON Serialization 243 A representation of the JWS as a JSON object. Unlike the JWS 244 Compact Serialization, the JWS JSON Serialization enables multiple 245 digital signatures and/or MACs to be applied to the same content. 246 This representation is neither optimized for compactness nor URL- 247 safe. 249 Unsecured JWS 250 A JWS object that provides no integrity protection. 252 Collision-Resistant Name 253 A name in a namespace that enables names to be allocated in a 254 manner such that they are highly unlikely to collide with other 255 names. Examples of collision-resistant namespaces include: Domain 256 Names, Object Identifiers (OIDs) as defined in the ITU-T X.660 and 257 X.670 Recommendation series, and Universally Unique IDentifiers 258 (UUIDs) [RFC4122]. When using an administratively delegated 259 namespace, the definer of a name needs to take reasonable 260 precautions to ensure they are in control of the portion of the 261 namespace they use to define the name. 263 StringOrURI 264 A JSON string value, with the additional requirement that while 265 arbitrary string values MAY be used, any value containing a ":" 266 character MUST be a URI [RFC3986]. StringOrURI values are 267 compared as case-sensitive strings with no transformations or 268 canonicalizations applied. 270 These terms defined by the JSON Web Encryption (JWE) [JWE] 271 specification are incorporated into this specification: "JSON Web 272 Encryption (JWE)" and "JWE Compact Serialization". 274 3. JSON Web Signature (JWS) Overview 276 JWS represents digitally signed or MACed content using JSON data 277 structures and base64url encoding. These JSON data structures MAY 278 contain white space and/or line breaks. A JWS represents these 279 logical values (each of which is defined in Section 2): 281 o JOSE Header 282 o JWS Payload 283 o JWS Signature 285 For a JWS object, the JOSE Header members are the union of the 286 members of these values (each of which is defined in Section 2): 288 o JWS Protected Header 289 o JWS Unprotected Header 291 This document defines two serializations for JWS objects: a compact, 292 URL-safe serialization called the JWS Compact Serialization and a 293 JSON serialization called the JWS JSON Serialization. In both 294 serializations, the JWS Protected Header, JWS Payload, and JWS 295 Signature are base64url encoded for transmission, since JSON lacks a 296 way to directly represent arbitrary octet sequences. 298 3.1. JWS Compact Serialization Overview 300 In the JWS Compact Serialization, no JWS Unprotected Header is used. 301 In this case, the JOSE Header and the JWS Protected Header are the 302 same. 304 In the JWS Compact Serialization, a JWS object is represented as the 305 concatenation: 307 BASE64URL(UTF8(JWS Protected Header)) || '.' || 308 BASE64URL(JWS Payload) || '.' || 309 BASE64URL(JWS Signature) 311 3.2. JWS JSON Serialization Overview 313 In the JWS JSON Serialization, one or both of the JWS Protected 314 Header and JWS Unprotected Header MUST be present. In this case, the 315 members of the JOSE Header are the combination of the members of the 316 JWS Protected Header and the JWS Unprotected Header values that are 317 present. 319 In the JWS JSON Serialization, a JWS object is represented as the 320 combination of these four values, 321 BASE64URL(UTF8(JWS Protected Header)), 322 JWS Unprotected Header, 323 BASE64URL(JWS Payload), and 324 BASE64URL(JWS Signature), 325 with the three base64url encoding result strings and the JWS 326 Unprotected Header value being represented as members within a JSON 327 object. The inclusion of some of these values is OPTIONAL. The JWS 328 JSON Serialization can also represent multiple signature and/or MAC 329 values, rather than just one. See Section 7.2 for more information 330 about the JWS JSON Serialization. 332 3.3. Example JWS 334 This section provides an example of a JWS. Its computation is 335 described in more detail in Appendix A.1, including specifying the 336 exact octet sequences representing the JSON values used and the key 337 value used. 339 The following example JWS Protected Header declares that the encoded 340 object is a JSON Web Token (JWT) [JWT] and the JWS Protected Header 341 and the JWS Payload are secured using the HMAC SHA-256 [RFC2104, SHS] 342 algorithm: 344 {"typ":"JWT", 345 "alg":"HS256"} 347 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 348 Header)) gives this value: 350 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 352 The UTF-8 representation of following JSON object is used as the JWS 353 Payload. (Note that the payload can be any content, and need not be 354 a representation of a JSON object.) 356 {"iss":"joe", 357 "exp":1300819380, 358 "http://example.com/is_root":true} 360 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value 361 (with line breaks for display purposes only): 363 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 364 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 366 Computing the HMAC of the JWS Signing Input ASCII(BASE64URL(UTF8(JWS 367 Protected Header)) || '.' || BASE64URL(JWS Payload)) with the HMAC 368 SHA-256 algorithm using the key specified in Appendix A.1 and 369 base64url encoding the result yields this BASE64URL(JWS Signature) 370 value: 372 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 374 Concatenating these values in the order Header.Payload.Signature with 375 period ('.') characters between the parts yields this complete JWS 376 representation using the JWS Compact Serialization (with line breaks 377 for display purposes only): 379 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 380 . 381 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 382 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 383 . 384 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 386 See Appendix A for additional examples. 388 4. JOSE Header 390 For a JWS object, the members of the JSON object(s) representing the 391 JOSE Header describe the digital signature or MAC applied to the JWS 392 Protected Header and the JWS Payload and optionally additional 393 properties of the JWS. The Header Parameter names within the JOSE 394 Header MUST be unique; recipients MUST either reject JWSs with 395 duplicate Header Parameter names or use a JSON parser that returns 396 only the lexically last duplicate member name, as specified in 397 Section 15.12 (The JSON Object) of ECMAScript 5.1 [ECMAScript]. 399 Implementations are required to understand the specific Header 400 Parameters defined by this specification that are designated as "MUST 401 be understood" and process them in the manner defined in this 402 specification. All other Header Parameters defined by this 403 specification that are not so designated MUST be ignored when not 404 understood. Unless listed as a critical Header Parameter, per 405 Section 4.1.11, all Header Parameters not defined by this 406 specification MUST be ignored when not understood. 408 There are three classes of Header Parameter names: Registered Header 409 Parameter names, Public Header Parameter names, and Private Header 410 Parameter names. 412 4.1. Registered Header Parameter Names 414 The following Header Parameter names for use in JWS objects are 415 registered in the IANA JSON Web Signature and Encryption Header 416 Parameters registry defined in Section 9.1, with meanings as defined 417 below. 419 As indicated by the common registry, JWSs and JWEs share a common 420 Header Parameter space; when a parameter is used by both 421 specifications, its usage must be compatible between the 422 specifications. 424 4.1.1. "alg" (Algorithm) Header Parameter 426 The "alg" (algorithm) Header Parameter identifies the cryptographic 427 algorithm used to secure the JWS. The JWS Signature value is not 428 valid if the "alg" value does not represent a supported algorithm, or 429 if there is not a key for use with that algorithm associated with the 430 party that digitally signed or MACed the content. "alg" values should 431 either be registered in the IANA JSON Web Signature and Encryption 432 Algorithms registry defined in [JWA] or be a value that contains a 433 Collision-Resistant Name. The "alg" value is a case-sensitive string 434 containing a StringOrURI value. This Header Parameter MUST be 435 present and MUST be understood and processed by implementations. 437 A list of defined "alg" values for this use can be found in the IANA 438 JSON Web Signature and Encryption Algorithms registry defined in 439 [JWA]; the initial contents of this registry are the values defined 440 in Section 3.1 of the JSON Web Algorithms (JWA) [JWA] specification. 442 4.1.2. "jku" (JWK Set URL) Header Parameter 444 The "jku" (JWK Set URL) Header Parameter is a URI [RFC3986] that 445 refers to a resource for a set of JSON-encoded public keys, one of 446 which corresponds to the key used to digitally sign the JWS. The 447 keys MUST be encoded as a JSON Web Key Set (JWK Set) [JWK]. The 448 protocol used to acquire the resource MUST provide integrity 449 protection; an HTTP GET request to retrieve the JWK Set MUST use TLS 450 [RFC2818, RFC5246]; the identity of the server MUST be validated, as 451 per Section 6 of RFC 6125 [RFC6125]. Use of this Header Parameter is 452 OPTIONAL. 454 4.1.3. "jwk" (JSON Web Key) Header Parameter 456 The "jwk" (JSON Web Key) Header Parameter is the public key that 457 corresponds to the key used to digitally sign the JWS. This key is 458 represented as a JSON Web Key [JWK]. Use of this Header Parameter is 459 OPTIONAL. 461 4.1.4. "kid" (Key ID) Header Parameter 463 The "kid" (key ID) Header Parameter is a hint indicating which key 464 was used to secure the JWS. This parameter allows originators to 465 explicitly signal a change of key to recipients. The structure of 466 the "kid" value is unspecified. Its value MUST be a string. Use of 467 this Header Parameter is OPTIONAL. 469 When used with a JWK, the "kid" value is used to match a JWK "kid" 470 parameter value. 472 4.1.5. "x5u" (X.509 URL) Header Parameter 474 The "x5u" (X.509 URL) Header Parameter is a URI [RFC3986] that refers 475 to a resource for the X.509 public key certificate or certificate 476 chain [RFC5280] corresponding to the key used to digitally sign the 477 JWS. The identified resource MUST provide a representation of the 478 certificate or certificate chain that conforms to RFC 5280 [RFC5280] 479 in PEM encoded form [RFC1421]. The certificate containing the public 480 key corresponding to the key used to digitally sign the JWS MUST be 481 the first certificate. This MAY be followed by additional 482 certificates, with each subsequent certificate being the one used to 483 certify the previous one. The protocol used to acquire the resource 484 MUST provide integrity protection; an HTTP GET request to retrieve 485 the certificate MUST use TLS [RFC2818, RFC5246]; the identity of the 486 server MUST be validated, as per Section 6 of RFC 6125 [RFC6125]. 487 Use of this Header Parameter is OPTIONAL. 489 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter 491 The "x5c" (X.509 Certificate Chain) Header Parameter contains the 492 X.509 public key certificate or certificate chain [RFC5280] 493 corresponding to the key used to digitally sign the JWS. The 494 certificate or certificate chain is represented as a JSON array of 495 certificate value strings. Each string in the array is a base64 496 encoded ([RFC4648] Section 4 -- not base64url encoded) DER 497 [ITU.X690.1994] PKIX certificate value. The certificate containing 498 the public key corresponding to the key used to digitally sign the 499 JWS MUST be the first certificate. This MAY be followed by 500 additional certificates, with each subsequent certificate being the 501 one used to certify the previous one. The recipient MUST validate 502 the certificate chain according to RFC 5280 [RFC5280] and reject the 503 signature if any validation failure occurs. Use of this Header 504 Parameter is OPTIONAL. 506 See Appendix B for an example "x5c" value. 508 4.1.7. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter 510 The "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter is a 511 base64url encoded SHA-1 thumbprint (a.k.a. digest) of the DER 512 encoding of the X.509 certificate [RFC5280] corresponding to the key 513 used to digitally sign the JWS. Use of this Header Parameter is 514 OPTIONAL. 516 4.1.8. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header 517 Parameter 519 The "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header 520 Parameter is a base64url encoded SHA-256 thumbprint (a.k.a. digest) 521 of the DER encoding of the X.509 certificate [RFC5280] corresponding 522 to the key used to digitally sign the JWS. Use of this Header 523 Parameter is OPTIONAL. 525 4.1.9. "typ" (Type) Header Parameter 527 The "typ" (type) Header Parameter is used by JWS applications to 528 declare the MIME Media Type [IANA.MediaTypes] of this complete JWS 529 object. This is intended for use by the application when more than 530 one kind of object could be present in an application data structure 531 that can contain a JWS object; the application can use this value to 532 disambiguate among the different kinds of objects that might be 533 present. It will typically not be used by applications when the kind 534 of object is already known. This parameter is ignored by JWS 535 implementations; any processing of this parameter is performed by the 536 JWS application. Use of this Header Parameter is OPTIONAL. 538 Per RFC 2045 [RFC2045], all media type values, subtype values, and 539 parameter names are case-insensitive. However, parameter values are 540 case-sensitive unless otherwise specified for the specific parameter. 542 To keep messages compact in common situations, it is RECOMMENDED that 543 senders omit an "application/" prefix of a media type value in a 544 "typ" Header Parameter when no other '/' appears in the media type 545 value. A recipient using the media type value MUST treat it as if 546 "application/" were prepended to any "typ" value not containing a 547 '/'. For instance, a "typ" value of "example" SHOULD be used to 548 represent the "application/example" media type; whereas, the media 549 type "application/example;part="1/2"" cannot be shortened to 550 "example;part="1/2"". 552 The "typ" value "JOSE" can be used by applications to indicate that 553 this object is a JWS or JWE using the JWS Compact Serialization or 554 the JWE Compact Serialization. The "typ" value "JOSE+JSON" can be 555 used by applications to indicate that this object is a JWS or JWE 556 using the JWS JSON Serialization or the JWE JSON Serialization. 557 Other type values can also be used by applications. 559 4.1.10. "cty" (Content Type) Header Parameter 561 The "cty" (content type) Header Parameter is used by JWS applications 562 to declare the MIME Media Type [IANA.MediaTypes] of the secured 563 content (the payload). This is intended for use by the application 564 when more than one kind of object could be present in the JWS 565 payload; the application can use this value to disambiguate among the 566 different kinds of objects that might be present. It will typically 567 not be used by applications when the kind of object is already known. 569 This parameter is ignored by JWS implementations; any processing of 570 this parameter is performed by the JWS application. Use of this 571 Header Parameter is OPTIONAL. 573 Per RFC 2045 [RFC2045], all media type values, subtype values, and 574 parameter names are case-insensitive. However, parameter values are 575 case-sensitive unless otherwise specified for the specific parameter. 577 To keep messages compact in common situations, it is RECOMMENDED that 578 senders omit an "application/" prefix of a media type value in a 579 "cty" Header Parameter when no other '/' appears in the media type 580 value. A recipient using the media type value MUST treat it as if 581 "application/" were prepended to any "cty" value not containing a 582 '/'. For instance, a "cty" value of "example" SHOULD be used to 583 represent the "application/example" media type; whereas, the media 584 type "application/example;part="1/2"" cannot be shortened to 585 "example;part="1/2"". 587 4.1.11. "crit" (Critical) Header Parameter 589 The "crit" (critical) Header Parameter indicates that extensions to 590 the initial RFC versions of [[ this specification ]] and [JWA] are 591 being used that MUST be understood and processed. Its value is an 592 array listing the Header Parameter names present in the JOSE Header 593 that use those extensions. If any of the listed extension Header 594 Parameters are not understood and supported by the receiver, it MUST 595 reject the JWS. Senders MUST NOT include Header Parameter names 596 defined by the initial RFC versions of [[ this specification ]] or 597 [JWA] for use with JWS, duplicate names, or names that do not occur 598 as Header Parameter names within the JOSE Header in the "crit" list. 599 Senders MUST NOT use the empty list "[]" as the "crit" value. 600 Recipients MAY reject the JWS if the critical list contains any 601 Header Parameter names defined by the initial RFC versions of [[ this 602 specification ]] or [JWA] for use with JWS, or any other constraints 603 on its use are violated. This Header Parameter MUST be integrity 604 protected, and therefore MUST occur only within the JWS Protected 605 Header, when used. Use of this Header Parameter is OPTIONAL. This 606 Header Parameter MUST be understood and processed by implementations. 608 An example use, along with a hypothetical "exp" (expiration-time) 609 field is: 611 {"alg":"ES256", 612 "crit":["exp"], 613 "exp":1363284000 614 } 616 4.2. Public Header Parameter Names 618 Additional Header Parameter names can be defined by those using JWSs. 619 However, in order to prevent collisions, any new Header Parameter 620 name should either be registered in the IANA JSON Web Signature and 621 Encryption Header Parameters registry defined in Section 9.1 or be a 622 Public Name: a value that contains a Collision-Resistant Name. In 623 each case, the definer of the name or value needs to take reasonable 624 precautions to make sure they are in control of the part of the 625 namespace they use to define the Header Parameter name. 627 New Header Parameters should be introduced sparingly, as they can 628 result in non-interoperable JWSs. 630 4.3. Private Header Parameter Names 632 A producer and consumer of a JWS may agree to use Header Parameter 633 names that are Private Names: names that are not Registered Header 634 Parameter names Section 4.1 or Public Header Parameter names 635 Section 4.2. Unlike Public Header Parameter names, Private Header 636 Parameter names are subject to collision and should be used with 637 caution. 639 5. Producing and Consuming JWSs 641 5.1. Message Signature or MAC Computation 643 To create a JWS, one MUST perform these steps. The order of the 644 steps is not significant in cases where there are no dependencies 645 between the inputs and outputs of the steps. 646 1. Create the content to be used as the JWS Payload. 647 2. Compute the encoded payload value BASE64URL(JWS Payload). 648 3. Create the JSON object(s) containing the desired set of Header 649 Parameters, which together comprise the JOSE Header: the JWS 650 Protected Header, and if the JWS JSON Serialization is being 651 used, the JWS Unprotected Header. 652 4. Compute the encoded header value BASE64URL(UTF8(JWS Protected 653 Header)). If the JWS Protected Header is not present (which can 654 only happen when using the JWS JSON Serialization and no 655 "protected" member is present), let this value be the empty 656 string. 657 5. Compute the JWS Signature in the manner defined for the 658 particular algorithm being used over the JWS Signing Input 659 ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 660 BASE64URL(JWS Payload)). The "alg" (algorithm) Header Parameter 661 MUST be present in the JOSE Header, with the algorithm value 662 accurately representing the algorithm used to construct the JWS 663 Signature. 664 6. Compute the encoded signature value BASE64URL(JWS Signature). 665 7. These three encoded values are used in both the JWS Compact 666 Serialization and the JWS JSON Serialization representations. 667 8. If the JWS JSON Serialization is being used, repeat this process 668 (steps 3-7) for each digital signature or MAC operation being 669 performed. 670 9. Create the desired serialized output. The JWS Compact 671 Serialization of this result is BASE64URL(UTF8(JWS Protected 672 Header)) || '.' || BASE64URL(JWS Payload) || '.' || BASE64URL(JWS 673 Signature). The JWS JSON Serialization is described in 674 Section 7.2. 676 5.2. Message Signature or MAC Validation 678 When validating a JWS, the following steps MUST be taken. The order 679 of the steps is not significant in cases where there are no 680 dependencies between the inputs and outputs of the steps. If any of 681 the listed steps fails, then the signature or MAC cannot be 682 validated. 684 When there are multiple JWS Signature values, it is an application 685 decision which of the JWS Signature values must successfully validate 686 for the JWS to be accepted. In some cases, all must successfully 687 validate or the JWS will be rejected. In other cases, only a 688 specific JWS signature value needs to be successfully validated. 689 However, in all cases, at least one JWS signature value MUST 690 successfully validate or the JWS MUST be rejected. 692 1. Parse the JWS representation to extract the serialized values 693 for the components of the JWS. When using the JWS Compact 694 Serialization, these components are the base64url encoded 695 representations of the JWS Protected Header, the JWS Payload, 696 and the JWS Signature, and when using the JWS JSON 697 Serialization, these components also include the unencoded JWS 698 Unprotected Header value. When using the JWS Compact 699 Serialization, the JWS Protected Header, the JWS Payload, and 700 the JWS Signature are represented as base64url encoded values in 701 that order, separated by two period ('.') characters. The JWS 702 JSON Serialization is described in Section 7.2. 703 2. The encoded representation of the JWS Protected Header MUST be 704 successfully base64url decoded following the restriction that no 705 padding characters have been used. 706 3. The resulting octet sequence MUST be a UTF-8 encoded 707 representation of a completely valid JSON object conforming to 708 RFC 7159 [RFC7159], which is the JWS Protected Header. 710 4. If using the JWS Compact Serialization, let the JOSE Header be 711 the JWS Protected Header. Otherwise, when using the JWS JSON 712 Serialization, let the JOSE Header be the union of the members 713 of the corresponding JWS Protected Header and JWS Unprotected 714 Header, all of which must be completely valid JSON objects. 715 5. The resulting JOSE Header MUST NOT contain duplicate Header 716 Parameter names. When using the JWS JSON Serialization, this 717 restriction includes that the same Header Parameter name also 718 MUST NOT occur in distinct JSON object values that together 719 comprise the JOSE Header. 720 6. Verify that the implementation understands and can process all 721 fields that it is required to support, whether required by this 722 specification, by the algorithm being used, or by the "crit" 723 Header Parameter value, and that the values of those parameters 724 are also understood and supported. 725 7. The encoded representation of the JWS Payload MUST be 726 successfully base64url decoded following the restriction that no 727 padding characters have been used. 728 8. The encoded representation of the JWS Signature MUST be 729 successfully base64url decoded following the restriction that no 730 padding characters have been used. 731 9. Validate the JWS Signature against the JWS Signing Input 732 ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 733 BASE64URL(JWS Payload)) in the manner defined for the algorithm 734 being used, which MUST be accurately represented by the value of 735 the "alg" (algorithm) Header Parameter, which MUST be present. 736 See Section 10.6 for security considerations on algorithm 737 validation. Record whether the validation succeeded or not. 738 10. If the JWS JSON Serialization is being used, repeat this process 739 (steps 4-9) for each digital signature or MAC value contained in 740 the representation. 741 11. If none of the validations in step 9 succeeded, then the JWS 742 MUST be rejected. Otherwise, in the JWS JSON Serialization 743 case, return a result to the application indicating which of the 744 validations succeeded and failed. In the JWS Compact 745 Serialization case, the result can simply indicate whether the 746 JWS was accepted or rejected. 748 Finally, note that it is an application decision which algorithms are 749 acceptable in a given context. Even if a JWS can be successfully 750 validated, unless the algorithm(s) used in the JWS are acceptable to 751 the application, it SHOULD reject the JWS. 753 5.3. String Comparison Rules 755 Processing a JWS inevitably requires comparing known strings to 756 members and values in a JSON object. For example, in checking what 757 the algorithm is, the Unicode string "alg" will be checked against 758 the member names in the JOSE Header to see if there is a matching 759 Header Parameter name. The same process is then used to determine if 760 the value of the "alg" Header Parameter represents a supported 761 algorithm. 763 Since the only string comparison operations that are performed are 764 equality and inequality, the same rules can be used for comparing 765 both member names and member values against known strings. The JSON 766 rules for doing member name comparison are described in Section 8.3 767 of RFC 7159 [RFC7159]. 769 Also, see the JSON security considerations in Section 10.12 and the 770 Unicode security considerations in Section 10.13. 772 6. Key Identification 774 It is necessary for the recipient of a JWS to be able to determine 775 the key that was employed for the digital signature or MAC operation. 776 The key employed can be identified using the Header Parameter methods 777 described in Section 4.1 or can be identified using methods that are 778 outside the scope of this specification. Specifically, the Header 779 Parameters "jku", "jwk", "kid", "x5u", "x5c", "x5t", and "x5t#S256" 780 can be used to identify the key used. These Header Parameters MUST 781 be integrity protected if the information that they convey is to be 782 utilized in a trust decision. 784 The sender SHOULD include sufficient information in the Header 785 Parameters to identify the key used, unless the application uses 786 another means or convention to determine the key used. Validation of 787 the signature or MAC fails when the algorithm used requires a key 788 (which is true of all algorithms except for "none") and the key used 789 cannot be determined. 791 The means of exchanging any shared symmetric keys used is outside the 792 scope of this specification. 794 Also, see Appendix D for notes on possible key selection algorithms. 796 7. Serializations 798 JWS objects use one of two serializations, the JWS Compact 799 Serialization or the JWS JSON Serialization. Applications using this 800 specification need to specify what serialization and serialization 801 features are used for that application. For instance, applications 802 might specify that only the JWS JSON Serialization is used, that only 803 JWS JSON Serialization support for a single signature or MAC value is 804 used, or that support for multiple signatures and/or MAC values is 805 used. JWS implementations only need to implement the features needed 806 for the applications they are designed to support. 808 7.1. JWS Compact Serialization 810 The JWS Compact Serialization represents digitally signed or MACed 811 content as a compact, URL-safe string. This string is: 813 BASE64URL(UTF8(JWS Protected Header)) || '.' || 814 BASE64URL(JWS Payload) || '.' || 815 BASE64URL(JWS Signature) 817 Only one signature/MAC is supported by the JWS Compact Serialization 818 and it provides no syntax to represent a JWS Unprotected Header 819 value. 821 7.2. JWS JSON Serialization 823 The JWS JSON Serialization represents digitally signed or MACed 824 content as a JSON object. Content using the JWS JSON Serialization 825 can be secured with more than one digital signature and/or MAC 826 operation. This representation is neither optimized for compactness 827 nor URL-safe. 829 The following members are defined for use in top-level JSON objects 830 used for the JWS JSON Serialization: 832 payload 833 The "payload" member MUST be present and contain the value 834 BASE64URL(JWS Payload). 836 signatures 837 The "signatures" member value MUST be an array of JSON objects. 838 Each object represents a signature or MAC over the JWS Payload and 839 the JWS Protected Header. 841 The following members are defined for use in the JSON objects that 842 are elements of the "signatures" array: 844 protected 845 The "protected" member MUST be present and contain the value 846 BASE64URL(UTF8(JWS Protected Header)) when the JWS Protected 847 Header value is non-empty; otherwise, it MUST be absent. These 848 Header Parameter values are integrity protected. 850 header 851 The "header" member MUST be present and contain the value JWS 852 Unprotected Header when the JWS Unprotected Header value is non- 853 empty; otherwise, it MUST be absent. This value is represented as 854 an unencoded JSON object, rather than as a string. These Header 855 Parameter values are not integrity protected. 857 signature 858 The "signature" member MUST be present and contain the value 859 BASE64URL(JWS Signature). 861 At least one of the "protected" and "header" members MUST be present 862 for each signature/MAC computation so that an "alg" Header Parameter 863 value is conveyed. 865 Additional members can be present in both the JSON objects defined 866 above; if not understood by implementations encountering them, they 867 MUST be ignored. 869 The Header Parameter values used when creating or validating 870 individual signature or MAC values are the union of the two sets of 871 Header Parameter values that may be present: (1) the JWS Protected 872 Header represented in the "protected" member of the signature/MAC's 873 array element, and (2) the JWS Unprotected Header in the "header" 874 member of the signature/MAC's array element. The union of these sets 875 of Header Parameters comprises the JOSE Header. The Header Parameter 876 names in the two locations MUST be disjoint. 878 Each JWS Signature value is computed using the parameters of the 879 corresponding JOSE Header value in the same manner as for the JWS 880 Compact Serialization. This has the desirable property that each JWS 881 Signature value represented in the "signatures" array is identical to 882 the value that would have been computed for the same parameter in the 883 JWS Compact Serialization, provided that the JWS Protected Header 884 value for that signature/MAC computation (which represents the 885 integrity-protected Header Parameter values) matches that used in the 886 JWS Compact Serialization. 888 In summary, the syntax of a JWS using the JWS JSON Serialization is 889 as follows: 891 { 892 "payload":"", 893 "signatures":[ 894 {"protected":"", 895 "header":, 896 "signature":""}, 897 ... 898 {"protected":"", 899 "header":, 900 "signature":""}] 901 } 903 See Appendix A.6 for an example of computing a JWS using the JWS JSON 904 Serialization. 906 8. TLS Requirements 908 Implementations MUST support TLS. Which version(s) ought to be 909 implemented will vary over time, and depend on the widespread 910 deployment and known security vulnerabilities at the time of 911 implementation. At the time of this writing, TLS version 1.2 912 [RFC5246] is the most recent version. 914 To protect against information disclosure and tampering, 915 confidentiality protection MUST be applied using TLS with a 916 ciphersuite that provides confidentiality and integrity protection. 917 See current publications by the IETF TLS working group, including RFC 918 6176 [RFC6176], for guidance on the ciphersuites currently considered 919 to be appropriate for use. 921 Whenever TLS is used, the identity of the service provider encoded in 922 the TLS server certificate MUST be verified using the procedures 923 described in Section 6 of RFC 6125 [RFC6125]. 925 9. IANA Considerations 927 The following registration procedure is used for all the registries 928 established by this specification. 930 Values are registered on a Specification Required [RFC5226] basis 931 after a two-week review period on the [TBD]@ietf.org mailing list, on 932 the advice of one or more Designated Experts. However, to allow for 933 the allocation of values prior to publication, the Designated 934 Expert(s) may approve registration once they are satisfied that such 935 a specification will be published. 937 Registration requests must be sent to the [TBD]@ietf.org mailing list 938 for review and comment, with an appropriate subject (e.g., "Request 939 for access token type: example"). [[ Note to the RFC Editor: The name 940 of the mailing list should be determined in consultation with the 941 IESG and IANA. Suggested name: jose-reg-review. ]] 943 Within the review period, the Designated Expert(s) will either 944 approve or deny the registration request, communicating this decision 945 to the review list and IANA. Denials should include an explanation 946 and, if applicable, suggestions as to how to make the request 947 successful. Registration requests that are undetermined for a period 948 longer than 21 days can be brought to the IESG's attention (using the 949 iesg@iesg.org mailing list) for resolution. 951 Criteria that should be applied by the Designated Expert(s) includes 952 determining whether the proposed registration duplicates existing 953 functionality, determining whether it is likely to be of general 954 applicability or whether it is useful only for a single application, 955 and whether the registration makes sense. 957 IANA must only accept registry updates from the Designated Expert(s) 958 and should direct all requests for registration to the review mailing 959 list. 961 It is suggested that multiple Designated Experts be appointed who are 962 able to represent the perspectives of different applications using 963 this specification, in order to enable broadly-informed review of 964 registration decisions. In cases where a registration decision could 965 be perceived as creating a conflict of interest for a particular 966 Expert, that Expert should defer to the judgment of the other 967 Expert(s). 969 9.1. JSON Web Signature and Encryption Header Parameters Registry 971 This specification establishes the IANA JSON Web Signature and 972 Encryption Header Parameters registry for Header Parameter names. 973 The registry records the Header Parameter name and a reference to the 974 specification that defines it. The same Header Parameter name can be 975 registered multiple times, provided that the parameter usage is 976 compatible between the specifications. Different registrations of 977 the same Header Parameter name will typically use different Header 978 Parameter Usage Location(s) values. 980 9.1.1. Registration Template 982 Header Parameter Name: 983 The name requested (e.g., "example"). Because a core goal of this 984 specification is for the resulting representations to be compact, 985 it is RECOMMENDED that the name be short -- not to exceed 8 986 characters without a compelling reason to do so. This name is 987 case-sensitive. Names may not match other registered names in a 988 case-insensitive manner unless the Designated Expert(s) state that 989 there is a compelling reason to allow an exception in this 990 particular case. 992 Header Parameter Description: 993 Brief description of the Header Parameter (e.g., "Example 994 description"). 996 Header Parameter Usage Location(s): 997 The Header Parameter usage locations, which should be one or more 998 of the values "JWS" or "JWE". 1000 Change Controller: 1001 For Standards Track RFCs, state "IESG". For others, give the name 1002 of the responsible party. Other details (e.g., postal address, 1003 email address, home page URI) may also be included. 1005 Specification Document(s): 1006 Reference to the document(s) that specify the parameter, 1007 preferably including URI(s) that can be used to retrieve copies of 1008 the document(s). An indication of the relevant sections may also 1009 be included but is not required. 1011 9.1.2. Initial Registry Contents 1013 This specification registers the Header Parameter names defined in 1014 Section 4.1 in this registry. 1016 o Header Parameter Name: "alg" 1017 o Header Parameter Description: Algorithm 1018 o Header Parameter Usage Location(s): JWS 1019 o Change Controller: IESG 1020 o Specification Document(s): Section 4.1.1 of [[ this document ]] 1022 o Header Parameter Name: "jku" 1023 o Header Parameter Description: JWK Set URL 1024 o Header Parameter Usage Location(s): JWS 1025 o Change Controller: IESG 1026 o Specification Document(s): Section 4.1.2 of [[ this document ]] 1028 o Header Parameter Name: "jwk" 1029 o Header Parameter Description: JSON Web Key 1030 o Header Parameter Usage Location(s): JWS 1031 o Change Controller: IESG 1032 o Specification document(s): Section 4.1.3 of [[ this document ]] 1034 o Header Parameter Name: "kid" 1035 o Header Parameter Description: Key ID 1036 o Header Parameter Usage Location(s): JWS 1037 o Change Controller: IESG 1038 o Specification Document(s): Section 4.1.4 of [[ this document ]] 1040 o Header Parameter Name: "x5u" 1041 o Header Parameter Description: X.509 URL 1042 o Header Parameter Usage Location(s): JWS 1043 o Change Controller: IESG 1044 o Specification Document(s): Section 4.1.5 of [[ this document ]] 1046 o Header Parameter Name: "x5c" 1047 o Header Parameter Description: X.509 Certificate Chain 1048 o Header Parameter Usage Location(s): JWS 1049 o Change Controller: IESG 1050 o Specification Document(s): Section 4.1.6 of [[ this document ]] 1052 o Header Parameter Name: "x5t" 1053 o Header Parameter Description: X.509 Certificate SHA-1 Thumbprint 1054 o Header Parameter Usage Location(s): JWS 1055 o Change Controller: IESG 1056 o Specification Document(s): Section 4.1.7 of [[ this document ]] 1058 o Header Parameter Name: "x5t#S256" 1059 o Header Parameter Description: X.509 Certificate SHA-256 Thumbprint 1060 o Header Parameter Usage Location(s): JWS 1061 o Change Controller: IESG 1062 o Specification Document(s): Section 4.1.8 of [[ this document ]] 1064 o Header Parameter Name: "typ" 1065 o Header Parameter Description: Type 1066 o Header Parameter Usage Location(s): JWS 1067 o Change Controller: IESG 1068 o Specification Document(s): Section 4.1.9 of [[ this document ]] 1070 o Header Parameter Name: "cty" 1071 o Header Parameter Description: Content Type 1072 o Header Parameter Usage Location(s): JWS 1073 o Change Controller: IESG 1074 o Specification Document(s): Section 4.1.10 of [[ this document ]] 1076 o Header Parameter Name: "crit" 1077 o Header Parameter Description: Critical 1078 o Header Parameter Usage Location(s): JWS 1079 o Change Controller: IESG 1080 o Specification Document(s): Section 4.1.11 of [[ this document ]] 1082 9.2. Media Type Registration 1084 9.2.1. Registry Contents 1086 This specification registers the "application/jose" Media Type 1087 [RFC2046] in the MIME Media Types registry [IANA.MediaTypes], which 1088 can be used to indicate that the content is a JWS or JWE object using 1089 the JWS Compact Serialization or the JWE Compact Serialization and 1090 the "application/jose+json" Media Type in the MIME Media Types 1091 registry, which can be used to indicate that the content is a JWS or 1092 JWE object using the JWS JSON Serialization or the JWE JSON 1093 Serialization. 1095 o Type name: application 1096 o Subtype name: jose 1097 o Required parameters: n/a 1098 o Optional parameters: n/a 1099 o Encoding considerations: 8bit; application/jose values are encoded 1100 as a series of base64url encoded values (some of which may be the 1101 empty string) separated by period ('.') characters. 1102 o Security considerations: See the Security Considerations section 1103 of [[ this document ]] 1104 o Interoperability considerations: n/a 1105 o Published specification: [[ this document ]] 1106 o Applications that use this media type: OpenID Connect, Mozilla 1107 Persona, Salesforce, Google, Android, Windows Azure, Xbox One, and 1108 numerous others that use JWTs 1109 o Additional information: Magic number(s): n/a, File extension(s): 1110 n/a, Macintosh file type code(s): n/a 1111 o Person & email address to contact for further information: Michael 1112 B. Jones, mbj@microsoft.com 1113 o Intended usage: COMMON 1114 o Restrictions on usage: none 1115 o Author: Michael B. Jones, mbj@microsoft.com 1116 o Change Controller: IESG 1117 o Type name: application 1118 o Subtype name: jose+json 1119 o Required parameters: n/a 1120 o Optional parameters: n/a 1121 o Encoding considerations: 8bit; application/jose+json values are 1122 represented as a JSON Object; UTF-8 encoding SHOULD be employed 1123 for the JSON object. 1124 o Security considerations: See the Security Considerations section 1125 of [[ this document ]] 1126 o Interoperability considerations: n/a 1127 o Published specification: [[ this document ]] 1128 o Applications that use this media type: TBD 1129 o Additional information: Magic number(s): n/a, File extension(s): 1130 n/a, Macintosh file type code(s): n/a 1131 o Person & email address to contact for further information: Michael 1132 B. Jones, mbj@microsoft.com 1133 o Intended usage: COMMON 1134 o Restrictions on usage: none 1135 o Author: Michael B. Jones, mbj@microsoft.com 1136 o Change Controller: IESG 1138 10. Security Considerations 1140 All of the security issues that are pertinent to any cryptographic 1141 application must be addressed by JWS/JWE/JWK agents. Among these 1142 issues are protecting the user's asymmetric private and symmetric 1143 secret keys and employing countermeasures to various attacks. 1145 All the security considerations in XML DSIG 2.0 1146 [W3C.NOTE-xmldsig-core2-20130411], also apply to this specification, 1147 other than those that are XML specific. Likewise, many of the best 1148 practices documented in XML Signature Best Practices 1149 [W3C.NOTE-xmldsig-bestpractices-20130411] also apply to this 1150 specification, other than those that are XML specific. 1152 10.1. Key Entropy and Random Values 1154 Keys are only as strong as the amount of entropy used to generate 1155 them. A minimum of 128 bits of entropy should be used for all keys, 1156 and depending upon the application context, more may be required. 1158 Implementations must randomly generate public/private key pairs, 1159 message authentication (MAC) keys, and padding values. The use of 1160 inadequate pseudo-random number generators (PRNGs) to generate 1161 cryptographic keys can result in little or no security. An attacker 1162 may find it much easier to reproduce the PRNG environment that 1163 produced the keys, searching the resulting small set of 1164 possibilities, rather than brute force searching the whole key space. 1165 The generation of quality random numbers is difficult. RFC 4086 1166 [RFC4086] offers important guidance in this area. 1168 10.2. Key Protection 1170 Implementations must protect the signer's private key. Compromise of 1171 the signer's private key permits an attacker to masquerade as the 1172 signer. 1174 Implementations must protect the message authentication (MAC) key. 1175 Compromise of the MAC key may result in undetectable modification of 1176 the authenticated content. 1178 10.3. Key Origin Authentication 1180 The key management technique employed to obtain public keys must 1181 authenticate the origin of the key; otherwise, it is unknown what 1182 party signed the message. 1184 Likewise, the key management technique employed to distribute MAC 1185 keys must provide data origin authentication; otherwise, the contents 1186 are delivered with integrity from an unknown source. 1188 10.4. Cryptographic Agility 1190 See Section 8.1 of [JWA] for security considerations on cryptographic 1191 agility. 1193 10.5. Differences between Digital Signatures and MACs 1195 While MACs and digital signatures can both be used for integrity 1196 checking, there are some significant differences between the security 1197 properties that each of them provides. These need to be taken into 1198 consideration when designing protocols and selecting the algorithms 1199 to be used in protocols. 1201 Both signatures and MACs provide for integrity checking -- verifying 1202 that the message has not been modified since the integrity value was 1203 computed. However, MACs provide for origination identification only 1204 under specific circumstances. It can normally be assumed that a 1205 private key used for a signature is only in the hands of a single 1206 entity (although perhaps a distributed entity, in the case of 1207 replicated servers); however, a MAC key needs to be in the hands of 1208 all the entities that use it for integrity computation and checking. 1209 This means that origination can only be determined if a MAC key is 1210 known only to two entities and the receiver knows that it did not 1211 create the message. MAC validation cannot be used to prove 1212 origination to a third party. 1214 10.6. Algorithm Validation 1216 The digital signature representations for some algorithms include 1217 information about the algorithm used inside the signature value. For 1218 instance, signatures produced with RSASSA-PKCS-v1_5 [RFC3447] encode 1219 the hash function used and many libraries actually use the hash 1220 algorithm specified inside the signature when validating the 1221 signature. When using such libraries, as part of the algorithm 1222 validation performed, implementations MUST ensure that the algorithm 1223 information encoded in the signature corresponds to that specified 1224 with the "alg" Header Parameter. If this is not done, an attacker 1225 could claim to have used a strong hash algorithm while actually using 1226 a weak one represented in the signature value. 1228 10.7. Algorithm Protection 1230 In some usages of JWS, there is a risk of algorithm substitution 1231 attacks, in which an attacker can use an existing digital signature 1232 value with a different signature algorithm to make it appear that a 1233 signer has signed something that it has not. These attacks have been 1234 discussed in detail in the context of CMS [RFC6211]. This risk 1235 arises when all of the following are true: 1237 o Verifiers of a signature support multiple algorithms. 1239 o Given an existing signature, an attacker can find another payload 1240 that produces the same signature value with a different algorithm. 1242 o The payload crafted by the attacker is valid in the application 1243 context. 1245 There are several ways for an application to mitigate algorithm 1246 substitution attacks: 1248 o Use only digital signature algorithms that are not vulnerable to 1249 substitution attacks. Substitution attacks are only feasible if 1250 an attacker can compute pre-images for a hash function accepted by 1251 the recipient. All JWA-defined signature algorithms use SHA-2 1252 hashes, for which there are no known pre-image attacks, as of the 1253 time of this writing. 1255 o Require that the "alg" Header Parameter be carried in the 1256 protected header. (This is always the case when using the JWS 1257 Compact Serialization and is the approach taken by CMS [RFC6211].) 1259 o Include a field containing the algorithm in the application 1260 payload, and require that it be matched with the "alg" Header 1261 Parameter during verification. (This is the approach taken by 1262 PKIX [RFC5280].) 1264 10.8. Chosen Plaintext Attacks 1266 Creators of JWSs should not allow third parties to insert arbitrary 1267 content into the message without adding entropy not controlled by the 1268 third party. 1270 10.9. Timing Attacks 1272 When cryptographic algorithms are implemented in such a way that 1273 successful operations take a different amount of time than 1274 unsuccessful operations, attackers may be able to use the time 1275 difference to obtain information about the keys employed. Therefore, 1276 such timing differences must be avoided. 1278 10.10. Replay Protection 1280 While not directly in scope for this specification, note that 1281 applications using JWS (or JWE) objects can thwart replay attacks by 1282 including a unique message identifier as integrity-protected content 1283 in the JWS (or JWE) message and having the recipient verify that the 1284 message has not been previously received or acted upon. 1286 10.11. SHA-1 Certificate Thumbprints 1288 A SHA-1 hash is used when computing "x5t" (X.509 Certificate SHA-1 1289 Thumbprint) values, for compatibility reasons. Should an effective 1290 means of producing SHA-1 hash collisions be developed, and should an 1291 attacker wish to interfere with the use of a known certificate on a 1292 given system, this could be accomplished by creating another 1293 certificate whose SHA-1 hash value is the same and adding it to the 1294 certificate store used by the intended victim. A prerequisite to 1295 this attack succeeding is the attacker having write access to the 1296 intended victim's certificate store. 1298 Alternatively, the "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) 1299 Header Parameter could be used instead of "x5t". However, at the 1300 time of this writing, no development platform is known to support 1301 SHA-256 certificate thumbprints. 1303 10.12. JSON Security Considerations 1305 Strict JSON [RFC7159] validation is a security requirement. If 1306 malformed JSON is received, then the intent of the sender is 1307 impossible to reliably discern. Ambiguous and potentially 1308 exploitable situations could arise if the JSON parser used does not 1309 reject malformed JSON syntax. In particular, any JSON inputs not 1310 conforming to the JSON-text syntax defined in RFC 7159 input MUST be 1311 rejected in their entirety. 1313 Section 4 of the JSON Data Interchange Format specification [RFC7159] 1314 states "The names within an object SHOULD be unique", whereas this 1315 specification states that "Header Parameter names within this object 1316 MUST be unique; recipients MUST either reject JWSs with duplicate 1317 Header Parameter names or use a JSON parser that returns only the 1318 lexically last duplicate member name, as specified in Section 15.12 1319 (The JSON Object) of ECMAScript 5.1 [ECMAScript]". Thus, this 1320 specification requires that the Section 4 "SHOULD" be treated as a 1321 "MUST" by senders and that it be either treated as a "MUST" or in the 1322 manner specified in ECMAScript 5.1 by receivers. Ambiguous and 1323 potentially exploitable situations could arise if the JSON parser 1324 used does not enforce the uniqueness of member names or returns an 1325 unpredictable value for duplicate member names. 1327 Some JSON parsers might not reject input that contains extra 1328 significant characters after a valid input. For instance, the input 1329 "{"tag":"value"}ABCD" contains a valid JSON-text object followed by 1330 the extra characters "ABCD". Such input MUST be rejected in its 1331 entirety. 1333 10.13. Unicode Comparison Security Considerations 1335 Header Parameter names and algorithm names are Unicode strings. For 1336 security reasons, the representations of these names must be compared 1337 verbatim after performing any escape processing (as per Section 8.3 1338 of RFC 7159 [RFC7159]). This means, for instance, that these JSON 1339 strings must compare as being equal ("sig", "\u0073ig"), whereas 1340 these must all compare as being not equal to the first set or to each 1341 other ("SIG", "Sig", "si\u0047"). 1343 JSON strings can contain characters outside the Unicode Basic 1344 Multilingual Plane. For instance, the G clef character (U+1D11E) may 1345 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWS 1346 implementations SHOULD ensure that characters outside the Basic 1347 Multilingual Plane are preserved and compared correctly; 1348 alternatively, if this is not possible due to these characters 1349 exercising limitations present in the underlying JSON implementation, 1350 then input containing them MUST be rejected. 1352 11. References 1353 11.1. Normative References 1355 [ECMAScript] 1356 Ecma International, "ECMAScript Language Specification, 1357 5.1 Edition", ECMA 262, June 2011. 1359 [IANA.MediaTypes] 1360 Internet Assigned Numbers Authority (IANA), "MIME Media 1361 Types", 2005. 1363 [ITU.X690.1994] 1364 International Telecommunications Union, "Information 1365 Technology - ASN.1 encoding rules: Specification of Basic 1366 Encoding Rules (BER), Canonical Encoding Rules (CER) and 1367 Distinguished Encoding Rules (DER)", ITU-T Recommendation 1368 X.690, 1994. 1370 [JWA] Jones, M., "JSON Web Algorithms (JWA)", 1371 draft-ietf-jose-json-web-algorithms (work in progress), 1372 September 2014. 1374 [JWK] Jones, M., "JSON Web Key (JWK)", 1375 draft-ietf-jose-json-web-key (work in progress), 1376 September 2014. 1378 [RFC1421] Linn, J., "Privacy Enhancement for Internet Electronic 1379 Mail: Part I: Message Encryption and Authentication 1380 Procedures", RFC 1421, February 1993. 1382 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1383 Extensions (MIME) Part One: Format of Internet Message 1384 Bodies", RFC 2045, November 1996. 1386 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1387 Extensions (MIME) Part Two: Media Types", RFC 2046, 1388 November 1996. 1390 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1391 Requirement Levels", BCP 14, RFC 2119, March 1997. 1393 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 1395 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 1396 10646", STD 63, RFC 3629, November 2003. 1398 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1399 Resource Identifier (URI): Generic Syntax", STD 66, 1400 RFC 3986, January 2005. 1402 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 1403 Encodings", RFC 4648, October 2006. 1405 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1406 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 1408 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1409 Housley, R., and W. Polk, "Internet X.509 Public Key 1410 Infrastructure Certificate and Certificate Revocation List 1411 (CRL) Profile", RFC 5280, May 2008. 1413 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 1414 Verification of Domain-Based Application Service Identity 1415 within Internet Public Key Infrastructure Using X.509 1416 (PKIX) Certificates in the Context of Transport Layer 1417 Security (TLS)", RFC 6125, March 2011. 1419 [RFC6176] Turner, S. and T. Polk, "Prohibiting Secure Sockets Layer 1420 (SSL) Version 2.0", RFC 6176, March 2011. 1422 [RFC7159] Bray, T., "The JavaScript Object Notation (JSON) Data 1423 Interchange Format", RFC 7159, March 2014. 1425 [USASCII] American National Standards Institute, "Coded Character 1426 Set -- 7-bit American Standard Code for Information 1427 Interchange", ANSI X3.4, 1986. 1429 11.2. Informative References 1431 [CanvasApp] 1432 Facebook, "Canvas Applications", 2010. 1434 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 1435 September 2010. 1437 [JWE] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)", 1438 draft-ietf-jose-json-web-encryption (work in progress), 1439 September 2014. 1441 [JWT] Jones, M., Bradley, J., and N. Sakimura, "JSON Web Token 1442 (JWT)", draft-ietf-oauth-json-web-token (work in 1443 progress), September 2014. 1445 [MagicSignatures] 1446 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 1447 Signatures", January 2011. 1449 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1450 Hashing for Message Authentication", RFC 2104, 1451 February 1997. 1453 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 1454 Standards (PKCS) #1: RSA Cryptography Specifications 1455 Version 2.1", RFC 3447, February 2003. 1457 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 1458 Requirements for Security", BCP 106, RFC 4086, June 2005. 1460 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 1461 Unique IDentifier (UUID) URN Namespace", RFC 4122, 1462 July 2005. 1464 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 1465 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 1466 May 2008. 1468 [RFC6211] Schaad, J., "Cryptographic Message Syntax (CMS) Algorithm 1469 Identifier Protection Attribute", RFC 6211, April 2011. 1471 [SHS] National Institute of Standards and Technology, "Secure 1472 Hash Standard (SHS)", FIPS PUB 180-4, March 2012. 1474 [W3C.NOTE-xmldsig-bestpractices-20130411] 1475 Hirsch, F. and P. Datta, "XML Signature Best Practices", 1476 World Wide Web Consortium Note NOTE-xmldsig-bestpractices- 1477 20130411, April 2013, . 1480 [W3C.NOTE-xmldsig-core2-20130411] 1481 Eastlake, D., Reagle, J., Solo, D., Hirsch, F., Roessler, 1482 T., Yiu, K., Datta, P., and S. Cantor, "XML Signature 1483 Syntax and Processing Version 2.0", World Wide Web 1484 Consortium Note NOTE-xmldsig-core2-20130411, April 2013, 1485 . 1487 Appendix A. JWS Examples 1489 This section provides several examples of JWSs. While the first 1490 three examples all represent JSON Web Tokens (JWTs) [JWT], the 1491 payload can be any octet sequence, as shown in Appendix A.4. 1493 A.1. Example JWS using HMAC SHA-256 1494 A.1.1. Encoding 1496 The following example JWS Protected Header declares that the data 1497 structure is a JSON Web Token (JWT) [JWT] and the JWS Signing Input 1498 is secured using the HMAC SHA-256 algorithm. 1500 {"typ":"JWT", 1501 "alg":"HS256"} 1503 To remove potential ambiguities in the representation of the JSON 1504 object above, the actual octet sequence representing UTF8(JWS 1505 Protected Header) used in this example is also included below. (Note 1506 that ambiguities can arise due to differing platform representations 1507 of line breaks (CRLF versus LF), differing spacing at the beginning 1508 and ends of lines, whether the last line has a terminating line break 1509 or not, and other causes. In the representation used in this 1510 example, the first line has no leading or trailing spaces, a CRLF 1511 line break (13, 10) occurs between the first and second lines, the 1512 second line has one leading space (32) and no trailing spaces, and 1513 the last line does not have a terminating line break.) The octets 1514 representing UTF8(JWS Protected Header) in this example (using JSON 1515 array notation) are: 1517 [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 1518 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] 1520 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1521 Header)) gives this value: 1523 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1525 The JWS Payload used in this example is the octets of the UTF-8 1526 representation of the JSON object below. (Note that the payload can 1527 be any base64url encoded octet sequence, and need not be a base64url 1528 encoded JSON object.) 1530 {"iss":"joe", 1531 "exp":1300819380, 1532 "http://example.com/is_root":true} 1534 The following octet sequence, which is the UTF-8 representation used 1535 in this example for the JSON object above, is the JWS Payload: 1537 [123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, 1538 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, 1539 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, 1540 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, 1541 111, 116, 34, 58, 116, 114, 117, 101, 125] 1542 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1543 Header)) gives this value (with line breaks for display purposes 1544 only): 1546 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1547 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1549 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1550 BASE64URL(JWS Payload) gives this string (with line breaks for 1551 display purposes only): 1553 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1554 . 1555 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1556 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1558 The resulting JWS Signing Input value, which is the ASCII 1559 representation of above string, is the following octet sequence 1560 (using JSON array notation): 1562 [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, 1563 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, 1564 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 1565 77, 105, 79, 105, 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 1566 74, 108, 101, 72, 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 1567 107, 122, 79, 68, 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 1568 72, 65, 54, 76, 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 1569 109, 78, 118, 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 1570 106, 112, 48, 99, 110, 86, 108, 102, 81] 1572 HMACs are generated using keys. This example uses the symmetric key 1573 represented in JSON Web Key [JWK] format below (with line breaks 1574 within values for display purposes only): 1576 {"kty":"oct", 1577 "k":"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75 1578 aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow" 1579 } 1581 Running the HMAC SHA-256 algorithm on the JWS Signing Input with this 1582 key yields this JWS Signature octet sequence: 1584 [116, 24, 223, 180, 151, 153, 224, 37, 79, 250, 96, 125, 216, 173, 1585 187, 186, 22, 212, 37, 77, 105, 214, 191, 240, 91, 88, 5, 88, 83, 1586 132, 141, 121] 1588 Encoding this JWS Signature as BASE64URL(JWS Signature) gives this 1589 value: 1591 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1593 Concatenating these values in the order Header.Payload.Signature with 1594 period ('.') characters between the parts yields this complete JWS 1595 representation using the JWS Compact Serialization (with line breaks 1596 for display purposes only): 1598 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1599 . 1600 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1601 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1602 . 1603 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1605 A.1.2. Validating 1607 Since the "alg" Header Parameter is "HS256", we validate the HMAC 1608 SHA-256 value contained in the JWS Signature. 1610 To validate the HMAC value, we repeat the previous process of using 1611 the correct key and the JWS Signing Input (which is the initial 1612 substring of the JWS Compact Serialization representation up until 1613 but not including the second period character) as input to the HMAC 1614 SHA-256 function and then taking the output and determining if it 1615 matches the JWS Signature (which is base64url decoded from the value 1616 encoded in the JWS representation). If it matches exactly, the HMAC 1617 has been validated. 1619 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 1621 A.2.1. Encoding 1623 The JWS Protected Header in this example is different from the 1624 previous example in two ways: First, because a different algorithm is 1625 being used, the "alg" value is different. Second, for illustration 1626 purposes only, the optional "typ" parameter is not used. (This 1627 difference is not related to the algorithm employed.) The JWS 1628 Protected Header used is: 1630 {"alg":"RS256"} 1632 The octets representing UTF8(JWS Protected Header) in this example 1633 (using JSON array notation) are: 1635 [123, 34, 97, 108, 103, 34, 58, 34, 82, 83, 50, 53, 54, 34, 125] 1637 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1638 Header)) gives this value: 1640 eyJhbGciOiJSUzI1NiJ9 1642 The JWS Payload used in this example, which follows, is the same as 1643 in the previous example. Since the BASE64URL(JWS Payload) value will 1644 therefore be the same, its computation is not repeated here. 1646 {"iss":"joe", 1647 "exp":1300819380, 1648 "http://example.com/is_root":true} 1650 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1651 BASE64URL(JWS Payload) gives this string (with line breaks for 1652 display purposes only): 1654 eyJhbGciOiJSUzI1NiJ9 1655 . 1656 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1657 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1659 The resulting JWS Signing Input value, which is the ASCII 1660 representation of above string, is the following octet sequence: 1662 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73, 1663 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1664 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1665 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1666 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1667 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1668 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1669 99, 110, 86, 108, 102, 81] 1671 This example uses the RSA key represented in JSON Web Key [JWK] 1672 format below (with line breaks within values for display purposes 1673 only): 1675 {"kty":"RSA", 1676 "n":"ofgWCuLjybRlzo0tZWJjNiuSfb4p4fAkd_wWJcyQoTbji9k0l8W26mPddx 1677 HmfHQp-Vaw-4qPCJrcS2mJPMEzP1Pt0Bm4d4QlL-yRT-SFd2lZS-pCgNMs 1678 D1W_YpRPEwOWvG6b32690r2jZ47soMZo9wGzjb_7OMg0LOL-bSf63kpaSH 1679 SXndS5z5rexMdbBYUsLA9e-KXBdQOS-UTo7WTBEMa2R2CapHg665xsmtdV 1680 MTBQY4uDZlxvb3qCo5ZwKh9kG4LT6_I5IhlJH7aGhyxXFvUK-DWNmoudF8 1681 NAco9_h9iaGNj8q2ethFkMLs91kzk2PAcDTW9gb54h4FRWyuXpoQ", 1682 "e":"AQAB", 1683 "d":"Eq5xpGnNCivDflJsRQBXHx1hdR1k6Ulwe2JZD50LpXyWPEAeP88vLNO97I 1684 jlA7_GQ5sLKMgvfTeXZx9SE-7YwVol2NXOoAJe46sui395IW_GO-pWJ1O0 1685 BkTGoVEn2bKVRUCgu-GjBVaYLU6f3l9kJfFNS3E0QbVdxzubSu3Mkqzjkn 1686 439X0M_V51gfpRLI9JYanrC4D4qAdGcopV_0ZHHzQlBjudU2QvXt4ehNYT 1687 CBr6XCLQUShb1juUO1ZdiYoFaFQT5Tw8bGUl_x_jTj3ccPDVZFD9pIuhLh 1688 BOneufuBiB4cS98l2SR_RQyGWSeWjnczT0QU91p1DhOVRuOopznQ" 1689 } 1691 The RSA private key is then passed to the RSA signing function, which 1692 also takes the hash type, SHA-256, and the JWS Signing Input as 1693 inputs. The result of the digital signature is an octet sequence, 1694 which represents a big endian integer. In this example, it is: 1696 [112, 46, 33, 137, 67, 232, 143, 209, 30, 181, 216, 45, 191, 120, 69, 1697 243, 65, 6, 174, 27, 129, 255, 247, 115, 17, 22, 173, 209, 113, 125, 1698 131, 101, 109, 66, 10, 253, 60, 150, 238, 221, 115, 162, 102, 62, 81, 1699 102, 104, 123, 0, 11, 135, 34, 110, 1, 135, 237, 16, 115, 249, 69, 1700 229, 130, 173, 252, 239, 22, 216, 90, 121, 142, 232, 198, 109, 219, 1701 61, 184, 151, 91, 23, 208, 148, 2, 190, 237, 213, 217, 217, 112, 7, 1702 16, 141, 178, 129, 96, 213, 248, 4, 12, 167, 68, 87, 98, 184, 31, 1703 190, 127, 249, 217, 46, 10, 231, 111, 36, 242, 91, 51, 187, 230, 244, 1704 74, 230, 30, 177, 4, 10, 203, 32, 4, 77, 62, 249, 18, 142, 212, 1, 1705 48, 121, 91, 212, 189, 59, 65, 238, 202, 208, 102, 171, 101, 25, 129, 1706 253, 228, 141, 247, 127, 55, 45, 195, 139, 159, 175, 221, 59, 239, 1707 177, 139, 93, 163, 204, 60, 46, 176, 47, 158, 58, 65, 214, 18, 202, 1708 173, 21, 145, 18, 115, 160, 95, 35, 185, 232, 56, 250, 175, 132, 157, 1709 105, 132, 41, 239, 90, 30, 136, 121, 130, 54, 195, 212, 14, 96, 69, 1710 34, 165, 68, 200, 242, 122, 122, 45, 184, 6, 99, 209, 108, 247, 202, 1711 234, 86, 222, 64, 92, 178, 33, 90, 69, 178, 194, 85, 102, 181, 90, 1712 193, 167, 72, 160, 112, 223, 200, 163, 42, 70, 149, 67, 208, 25, 238, 1713 251, 71] 1715 Encoding the signature as BASE64URL(JWS Signature) produces this 1716 value (with line breaks for display purposes only): 1718 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1719 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1720 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1721 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1722 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1723 p0igcN_IoypGlUPQGe77Rw 1725 Concatenating these values in the order Header.Payload.Signature with 1726 period ('.') characters between the parts yields this complete JWS 1727 representation using the JWS Compact Serialization (with line breaks 1728 for display purposes only): 1730 eyJhbGciOiJSUzI1NiJ9 1731 . 1732 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1733 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1734 . 1735 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1736 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1737 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1738 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1739 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1740 p0igcN_IoypGlUPQGe77Rw 1742 A.2.2. Validating 1744 Since the "alg" Header Parameter is "RS256", we validate the RSASSA- 1745 PKCS-v1_5 SHA-256 digital signature contained in the JWS Signature. 1747 Validating the JWS Signature is a bit different from the previous 1748 example. We pass the public key (n, e), the JWS Signature (which is 1749 base64url decoded from the value encoded in the JWS representation), 1750 and the JWS Signing Input (which is the initial substring of the JWS 1751 Compact Serialization representation up until but not including the 1752 second period character) to an RSASSA-PKCS-v1_5 signature verifier 1753 that has been configured to use the SHA-256 hash function. 1755 A.3. Example JWS using ECDSA P-256 SHA-256 1757 A.3.1. Encoding 1759 The JWS Protected Header for this example differs from the previous 1760 example because a different algorithm is being used. The JWS 1761 Protected Header used is: 1763 {"alg":"ES256"} 1765 The octets representing UTF8(JWS Protected Header) in this example 1766 (using JSON array notation) are: 1768 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 50, 53, 54, 34, 125] 1770 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1771 Header)) gives this value: 1773 eyJhbGciOiJFUzI1NiJ9 1775 The JWS Payload used in this example, which follows, is the same as 1776 in the previous examples. Since the BASE64URL(JWS Payload) value 1777 will therefore be the same, its computation is not repeated here. 1779 {"iss":"joe", 1780 "exp":1300819380, 1781 "http://example.com/is_root":true} 1783 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1784 BASE64URL(JWS Payload) gives this string (with line breaks for 1785 display purposes only): 1787 eyJhbGciOiJFUzI1NiJ9 1788 . 1789 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1790 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1792 The resulting JWS Signing Input value, which is the ASCII 1793 representation of above string, is the following octet sequence: 1795 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 73, 1796 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1797 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1798 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1799 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1800 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1801 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1802 99, 110, 86, 108, 102, 81] 1804 This example uses the elliptic curve key represented in JSON Web Key 1805 [JWK] format below: 1807 {"kty":"EC", 1808 "crv":"P-256", 1809 "x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU", 1810 "y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0", 1811 "d":"jpsQnnGQmL-YBIffH1136cspYG6-0iY7X1fCE9-E9LI" 1812 } 1814 The ECDSA private part d is then passed to an ECDSA signing function, 1815 which also takes the curve type, P-256, the hash type, SHA-256, and 1816 the JWS Signing Input as inputs. The result of the digital signature 1817 is the EC point (R, S), where R and S are unsigned integers. In this 1818 example, the R and S values, given as octet sequences representing 1819 big endian integers are: 1821 +--------+----------------------------------------------------------+ 1822 | Result | Value | 1823 | Name | | 1824 +--------+----------------------------------------------------------+ 1825 | R | [14, 209, 33, 83, 121, 99, 108, 72, 60, 47, 127, 21, 88, | 1826 | | 7, 212, 2, 163, 178, 40, 3, 58, 249, 124, 126, 23, 129, | 1827 | | 154, 195, 22, 158, 166, 101] | 1828 | S | [197, 10, 7, 211, 140, 60, 112, 229, 216, 241, 45, 175, | 1829 | | 8, 74, 84, 128, 166, 101, 144, 197, 242, 147, 80, 154, | 1830 | | 143, 63, 127, 138, 131, 163, 84, 213] | 1831 +--------+----------------------------------------------------------+ 1833 The JWS Signature is the value R || S. Encoding the signature as 1834 BASE64URL(JWS Signature) produces this value (with line breaks for 1835 display purposes only): 1837 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 1838 pmWQxfKTUJqPP3-Kg6NU1Q 1840 Concatenating these values in the order Header.Payload.Signature with 1841 period ('.') characters between the parts yields this complete JWS 1842 representation using the JWS Compact Serialization (with line breaks 1843 for display purposes only): 1845 eyJhbGciOiJFUzI1NiJ9 1846 . 1847 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1848 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1849 . 1850 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 1851 pmWQxfKTUJqPP3-Kg6NU1Q 1853 A.3.2. Validating 1855 Since the "alg" Header Parameter is "ES256", we validate the ECDSA 1856 P-256 SHA-256 digital signature contained in the JWS Signature. 1858 Validating the JWS Signature is a bit different from the previous 1859 examples. We need to split the 64 member octet sequence of the JWS 1860 Signature (which is base64url decoded from the value encoded in the 1861 JWS representation) into two 32 octet sequences, the first 1862 representing R and the second S. We then pass the public key (x, y), 1863 the signature (R, S), and the JWS Signing Input (which is the initial 1864 substring of the JWS Compact Serialization representation up until 1865 but not including the second period character) to an ECDSA signature 1866 verifier that has been configured to use the P-256 curve with the 1867 SHA-256 hash function. 1869 A.4. Example JWS using ECDSA P-521 SHA-512 1871 A.4.1. Encoding 1873 The JWS Protected Header for this example differs from the previous 1874 example because different ECDSA curves and hash functions are used. 1875 The JWS Protected Header used is: 1877 {"alg":"ES512"} 1879 The octets representing UTF8(JWS Protected Header) in this example 1880 (using JSON array notation) are: 1882 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 53, 49, 50, 34, 125] 1884 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1885 Header)) gives this value: 1887 eyJhbGciOiJFUzUxMiJ9 1889 The JWS Payload used in this example, is the ASCII string "Payload". 1890 The representation of this string is the octet sequence: 1892 [80, 97, 121, 108, 111, 97, 100] 1894 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value: 1896 UGF5bG9hZA 1898 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1899 BASE64URL(JWS Payload) gives this string: 1901 eyJhbGciOiJFUzUxMiJ9.UGF5bG9hZA 1903 The resulting JWS Signing Input value, which is the ASCII 1904 representation of above string, is the following octet sequence: 1906 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 85, 1907 120, 77, 105, 74, 57, 46, 85, 71, 70, 53, 98, 71, 57, 104, 90, 65] 1909 This example uses the elliptic curve key represented in JSON Web Key 1910 [JWK] format below (with line breaks within values for display 1911 purposes only): 1913 {"kty":"EC", 1914 "crv":"P-521", 1915 "x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_ 1916 NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk", 1917 "y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDl 1918 y79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2", 1919 "d":"AY5pb7A0UFiB3RELSD64fTLOSV_jazdF7fLYyuTw8lOfRhWg6Y6rUrPA 1920 xerEzgdRhajnu0ferB0d53vM9mE15j2C" 1921 } 1923 The ECDSA private part d is then passed to an ECDSA signing function, 1924 which also takes the curve type, P-521, the hash type, SHA-512, and 1925 the JWS Signing Input as inputs. The result of the digital signature 1926 is the EC point (R, S), where R and S are unsigned integers. In this 1927 example, the R and S values, given as octet sequences representing 1928 big endian integers are: 1930 +--------+----------------------------------------------------------+ 1931 | Result | Value | 1932 | Name | | 1933 +--------+----------------------------------------------------------+ 1934 | R | [1, 220, 12, 129, 231, 171, 194, 209, 232, 135, 233, | 1935 | | 117, 247, 105, 122, 210, 26, 125, 192, 1, 217, 21, 82, | 1936 | | 91, 45, 240, 255, 83, 19, 34, 239, 71, 48, 157, 147, | 1937 | | 152, 105, 18, 53, 108, 163, 214, 68, 231, 62, 153, 150, | 1938 | | 106, 194, 164, 246, 72, 143, 138, 24, 50, 129, 223, 133, | 1939 | | 206, 209, 172, 63, 237, 119, 109] | 1940 | S | [0, 111, 6, 105, 44, 5, 41, 208, 128, 61, 152, 40, 92, | 1941 | | 61, 152, 4, 150, 66, 60, 69, 247, 196, 170, 81, 193, | 1942 | | 199, 78, 59, 194, 169, 16, 124, 9, 143, 42, 142, 131, | 1943 | | 48, 206, 238, 34, 175, 83, 203, 220, 159, 3, 107, 155, | 1944 | | 22, 27, 73, 111, 68, 68, 21, 238, 144, 229, 232, 148, | 1945 | | 188, 222, 59, 242, 103] | 1946 +--------+----------------------------------------------------------+ 1948 The JWS Signature is the value R || S. Encoding the signature as 1949 BASE64URL(JWS Signature) produces this value (with line breaks for 1950 display purposes only): 1952 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 1953 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 1954 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 1956 Concatenating these values in the order Header.Payload.Signature with 1957 period ('.') characters between the parts yields this complete JWS 1958 representation using the JWS Compact Serialization (with line breaks 1959 for display purposes only): 1961 eyJhbGciOiJFUzUxMiJ9 1962 . 1963 UGF5bG9hZA 1964 . 1965 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 1966 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 1967 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 1969 A.4.2. Validating 1971 Since the "alg" Header Parameter is "ES512", we validate the ECDSA 1972 P-521 SHA-512 digital signature contained in the JWS Signature. 1974 Validating this JWS Signature is very similar to the previous 1975 example. We need to split the 132 member octet sequence of the JWS 1976 Signature into two 66 octet sequences, the first representing R and 1977 the second S. We then pass the public key (x, y), the signature (R, 1978 S), and the JWS Signing Input to an ECDSA signature verifier that has 1979 been configured to use the P-521 curve with the SHA-512 hash 1980 function. 1982 A.5. Example Unsecured JWS 1984 The following example JWS Protected Header declares that the encoded 1985 object is an Unsecured JWS: 1987 {"alg":"none"} 1989 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1990 Header)) gives this value: 1992 eyJhbGciOiJub25lIn0 1994 The JWS Payload used in this example, which follows, is the same as 1995 in the previous examples. Since the BASE64URL(JWS Payload) value 1996 will therefore be the same, its computation is not repeated here. 1998 {"iss":"joe", 1999 "exp":1300819380, 2000 "http://example.com/is_root":true} 2002 The JWS Signature is the empty octet string and BASE64URL(JWS 2003 Signature) is the empty string. 2005 Concatenating these parts in the order Header.Payload.Signature with 2006 period ('.') characters between the parts yields this complete JWS 2007 (with line breaks for display purposes only): 2009 eyJhbGciOiJub25lIn0 2010 . 2011 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 2012 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 2013 . 2015 A.6. Example JWS Using JWS JSON Serialization 2017 This section contains an example using the JWS JSON Serialization. 2018 This example demonstrates the capability for conveying multiple 2019 digital signatures and/or MACs for the same payload. 2021 The JWS Payload used in this example is the same as that used in the 2022 examples in Appendix A.2 and Appendix A.3 (with line breaks for 2023 display purposes only): 2025 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 2026 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 2028 Two digital signatures are used in this example: the first using 2029 RSASSA-PKCS-v1_5 SHA-256 and the second using ECDSA P-256 SHA-256. 2030 For the first, the JWS Protected Header and key are the same as in 2031 Appendix A.2, resulting in the same JWS Signature value; therefore, 2032 its computation is not repeated here. For the second, the JWS 2033 Protected Header and key are the same as in Appendix A.3, resulting 2034 in the same JWS Signature value; therefore, its computation is not 2035 repeated here. 2037 A.6.1. JWS Per-Signature Protected Headers 2039 The JWS Protected Header value used for the first signature is: 2041 {"alg":"RS256"} 2043 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2044 Header)) gives this value: 2046 eyJhbGciOiJSUzI1NiJ9 2048 The JWS Protected Header value used for the second signature is: 2050 {"alg":"ES256"} 2052 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2053 Header)) gives this value: 2055 eyJhbGciOiJFUzI1NiJ9 2057 A.6.2. JWS Per-Signature Unprotected Headers 2059 Key ID values are supplied for both keys using per-signature Header 2060 Parameters. The two values used to represent these Key IDs are: 2062 {"kid":"2010-12-29"} 2064 and 2066 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 2068 A.6.3. Complete JOSE Header Values 2070 Combining the protected and unprotected header values supplied, the 2071 JOSE Header values used for the first and second signatures 2072 respectively are: 2074 {"alg":"RS256", 2075 "kid":"2010-12-29"} 2077 and 2079 {"alg":"ES256", 2080 "kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 2082 A.6.4. Complete JWS JSON Serialization Representation 2084 The complete JSON Web Signature JSON Serialization for these values 2085 is as follows (with line breaks within values for display purposes 2086 only): 2088 {"payload": 2089 "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGF 2090 tcGxlLmNvbS9pc19yb290Ijp0cnVlfQ", 2091 "signatures":[ 2092 {"protected":"eyJhbGciOiJSUzI1NiJ9", 2093 "header": 2094 {"kid":"2010-12-29"}, 2095 "signature": 2096 "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZ 2097 mh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjb 2098 KBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHl 2099 b1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZES 2100 c6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AX 2101 LIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw"}, 2102 {"protected":"eyJhbGciOiJFUzI1NiJ9", 2103 "header": 2104 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"}, 2105 "signature": 2106 "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8IS 2107 lSApmWQxfKTUJqPP3-Kg6NU1Q"}] 2108 } 2110 Appendix B. "x5c" (X.509 Certificate Chain) Example 2112 The JSON array below is an example of a certificate chain that could 2113 be used as the value of an "x5c" (X.509 Certificate Chain) Header 2114 Parameter, per Section 4.1.6. Note that since these strings contain 2115 base64 encoded (not base64url encoded) values, they are allowed to 2116 contain white space and line breaks. 2118 ["MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVM 2119 xITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR2 2120 8gRGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExM 2121 TYwMTU0MzdaFw0yNjExMTYwMTU0MzdaMIHKMQswCQYDVQQGEwJVUzEQMA4GA1UE 2122 CBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEaMBgGA1UEChMRR29EYWR 2123 keS5jb20sIEluYy4xMzAxBgNVBAsTKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYW 2124 RkeS5jb20vcmVwb3NpdG9yeTEwMC4GA1UEAxMnR28gRGFkZHkgU2VjdXJlIENlc 2125 nRpZmljYXRpb24gQXV0aG9yaXR5MREwDwYDVQQFEwgwNzk2OTI4NzCCASIwDQYJ 2126 KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMQt1RWMnCZM7DI161+4WQFapmGBWTt 2127 wY6vj3D3HKrjJM9N55DrtPDAjhI6zMBS2sofDPZVUBJ7fmd0LJR4h3mUpfjWoqV 2128 Tr9vcyOdQmVZWt7/v+WIbXnvQAjYwqDL1CBM6nPwT27oDyqu9SoWlm2r4arV3aL 2129 GbqGmu75RpRSgAvSMeYddi5Kcju+GZtCpyz8/x4fKL4o/K1w/O5epHBp+YlLpyo 2130 7RJlbmr2EkRTcDCVw5wrWCs9CHRK8r5RsL+H0EwnWGu1NcWdrxcx+AuP7q2BNgW 2131 JCJjPOq8lh8BJ6qf9Z/dFjpfMFDniNoW1fho3/Rb2cRGadDAW/hOUoz+EDU8CAw 2132 EAAaOCATIwggEuMB0GA1UdDgQWBBT9rGEyk2xF1uLuhV+auud2mWjM5zAfBgNVH 2133 SMEGDAWgBTSxLDSkdRMEXGzYcs9of7dqGrU4zASBgNVHRMBAf8ECDAGAQH/AgEA 2134 MDMGCCsGAQUFBwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZ29kYWR 2135 keS5jb20wRgYDVR0fBD8wPTA7oDmgN4Y1aHR0cDovL2NlcnRpZmljYXRlcy5nb2 2136 RhZGR5LmNvbS9yZXBvc2l0b3J5L2dkcm9vdC5jcmwwSwYDVR0gBEQwQjBABgRVH 2137 SAAMDgwNgYIKwYBBQUHAgEWKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5j 2138 b20vcmVwb3NpdG9yeTAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggE 2139 BANKGwOy9+aG2Z+5mC6IGOgRQjhVyrEp0lVPLN8tESe8HkGsz2ZbwlFalEzAFPI 2140 UyIXvJxwqoJKSQ3kbTJSMUA2fCENZvD117esyfxVgqwcSeIaha86ykRvOe5GPLL 2141 5CkKSkB2XIsKd83ASe8T+5o0yGPwLPk9Qnt0hCqU7S+8MxZC9Y7lhyVJEnfzuz9 2142 p0iRFEUOOjZv2kWzRaJBydTXRE4+uXR21aITVSzGh6O1mawGhId/dQb8vxRMDsx 2143 uxN89txJx9OjxUUAiKEngHUuHqDTMBqLdElrRhjZkAzVvb3du6/KFUJheqwNTrZ 2144 EjYx8WnM25sgVjOuH0aBsXBTWVU+4=", 2145 "MIIE+zCCBGSgAwIBAgICAQ0wDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1Z 2146 hbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIE 2147 luYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb 2148 24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8x 2149 IDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTA0MDYyOTE3MDY 2150 yMFoXDTI0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRoZS 2151 BHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3MgM 2152 iBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN 2153 ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XC 2154 APVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux 2155 6wwdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLO 2156 tXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWo 2157 riMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZ 2158 Eewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjggHhMIIB3TAdBgNVHQ 2159 4EFgQU0sSw0pHUTBFxs2HLPaH+3ahq1OMwgdIGA1UdIwSByjCBx6GBwaSBvjCBu 2160 zEkMCIGA1UEBxMbVmFsaUNlcnQgVmFsaWRhdGlvbiBOZXR3b3JrMRcwFQYDVQQK 2161 Ew5WYWxpQ2VydCwgSW5jLjE1MDMGA1UECxMsVmFsaUNlcnQgQ2xhc3MgMiBQb2x 2162 pY3kgVmFsaWRhdGlvbiBBdXRob3JpdHkxITAfBgNVBAMTGGh0dHA6Ly93d3cudm 2163 FsaWNlcnQuY29tLzEgMB4GCSqGSIb3DQEJARYRaW5mb0B2YWxpY2VydC5jb22CA 2164 QEwDwYDVR0TAQH/BAUwAwEB/zAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGG 2165 F2h0dHA6Ly9vY3NwLmdvZGFkZHkuY29tMEQGA1UdHwQ9MDswOaA3oDWGM2h0dHA 2166 6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5jb20vcmVwb3NpdG9yeS9yb290LmNybD 2167 BLBgNVHSAERDBCMEAGBFUdIAAwODA2BggrBgEFBQcCARYqaHR0cDovL2NlcnRpZ 2168 mljYXRlcy5nb2RhZGR5LmNvbS9yZXBvc2l0b3J5MA4GA1UdDwEB/wQEAwIBBjAN 2169 BgkqhkiG9w0BAQUFAAOBgQC1QPmnHfbq/qQaQlpE9xXUhUaJwL6e4+PrxeNYiY+ 2170 Sn1eocSxI0YGyeR+sBjUZsE4OWBsUs5iB0QQeyAfJg594RAoYC5jcdnplDQ1tgM 2171 QLARzLrUc+cb53S8wGd9D0VmsfSxOaFIqII6hR8INMqzW/Rn453HWkrugp++85j 2172 09VZw==", 2173 "MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ 2174 0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNT 2175 AzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0a 2176 G9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkq 2177 hkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE 2178 5MDYyNjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTm 2179 V0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZ 2180 XJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQD 2181 ExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9 2182 AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5a 2183 vIWZJV16vYdA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zf 2184 N1SLUzm1NZ9WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwb 2185 P7RfZHM047QSv4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQU 2186 AA4GBADt/UG9vUJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQ 2187 C1u+mNr0HZDzTuIYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMM 2188 j4QssxsodyamEwCW/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd"] 2190 Appendix C. Notes on implementing base64url encoding without padding 2192 This appendix describes how to implement base64url encoding and 2193 decoding functions without padding based upon standard base64 2194 encoding and decoding functions that do use padding. 2196 To be concrete, example C# code implementing these functions is shown 2197 below. Similar code could be used in other languages. 2199 static string base64urlencode(byte [] arg) 2200 { 2201 string s = Convert.ToBase64String(arg); // Regular base64 encoder 2202 s = s.Split('=')[0]; // Remove any trailing '='s 2203 s = s.Replace('+', '-'); // 62nd char of encoding 2204 s = s.Replace('/', '_'); // 63rd char of encoding 2205 return s; 2206 } 2208 static byte [] base64urldecode(string arg) 2209 { 2210 string s = arg; 2211 s = s.Replace('-', '+'); // 62nd char of encoding 2212 s = s.Replace('_', '/'); // 63rd char of encoding 2213 switch (s.Length % 4) // Pad with trailing '='s 2214 { 2215 case 0: break; // No pad chars in this case 2216 case 2: s += "=="; break; // Two pad chars 2217 case 3: s += "="; break; // One pad char 2218 default: throw new System.Exception( 2219 "Illegal base64url string!"); 2220 } 2221 return Convert.FromBase64String(s); // Standard base64 decoder 2222 } 2224 As per the example code above, the number of '=' padding characters 2225 that needs to be added to the end of a base64url encoded string 2226 without padding to turn it into one with padding is a deterministic 2227 function of the length of the encoded string. Specifically, if the 2228 length mod 4 is 0, no padding is added; if the length mod 4 is 2, two 2229 '=' padding characters are added; if the length mod 4 is 3, one '=' 2230 padding character is added; if the length mod 4 is 1, the input is 2231 malformed. 2233 An example correspondence between unencoded and encoded values 2234 follows. The octet sequence below encodes into the string below, 2235 which when decoded, reproduces the octet sequence. 2236 3 236 255 224 193 2237 A-z_4ME 2239 Appendix D. Notes on Key Selection 2241 This appendix describes a set of possible algorithms for selecting 2242 the key to be used to validate the digital signature or MAC of a JWS 2243 object or for selecting the key to be used to decrypt a JWE object. 2244 This guidance describes a family of possible algorithms, rather than 2245 a single algorithm, because in different contexts, not all the 2246 sources of keys will be used, they can be tried in different orders, 2247 and sometimes not all the collected keys will be tried; hence, 2248 different algorithms will be used in different application contexts. 2250 The steps below are described for illustration purposes only; 2251 specific applications can and are likely to use different algorithms 2252 or perform some of the steps in different orders. Specific 2253 applications will frequently have a much simpler method of 2254 determining the keys to use, as there may be one or two key selection 2255 methods that are profiled for the application's use. This appendix 2256 supplements the normative information on key location in Section 6. 2258 These algorithms include the following steps. Note that the steps 2259 can be performed in any order and do not need to be treated as 2260 distinct. For example, keys can be tried as soon as they are found, 2261 rather than collecting all the keys before trying any. 2263 1. Collect the set of potentially applicable keys. Sources of keys 2264 may include: 2266 * Keys supplied by the application protocol being used. 2268 * Keys referenced by the "jku" (JWK Set URL) Header Parameter. 2270 * The key provided by the "jwk" (JSON Web Key) Header Parameter. 2272 * The key referenced by the "x5u" (X.509 URL) Header Parameter. 2274 * The key provided by the "x5c" (X.509 Certificate Chain) Header 2275 Parameter. 2277 * Other applicable keys available to the application. 2279 The order for collecting and trying keys from different key 2280 sources is typically application dependent. For example, 2281 frequently all keys from a one set of locations, such as local 2282 caches, will be tried before collecting and trying keys from 2283 other locations. 2285 2. Filter the set of collected keys. For instance, some 2286 applications will use only keys referenced by "kid" (key ID) or 2287 "x5t" (X.509 certificate SHA-1 thumbprint) parameters. If the 2288 application uses the "alg" (algorithm), "use" (public key use), 2289 or "key_ops" (key operations) parameters, keys with keys with 2290 inappropriate values of those parameters would be excluded. 2291 Additionally, keys might be filtered to include or exclude keys 2292 with certain other member values in an application specific 2293 manner. For some applications, no filtering will be applied. 2295 3. Order the set of collected keys. For instance, keys referenced 2296 by "kid" (Key ID) or "x5t" (X.509 Certificate SHA-1 Thumbprint) 2297 parameters might be tried before keys with neither of these 2298 values. Likewise, keys with certain member values might be 2299 ordered before keys with other member values. For some 2300 applications, no ordering will be applied. 2302 4. Make trust decisions about the keys. Signatures made with keys 2303 not meeting the application's trust criteria would not be 2304 accepted. Such criteria might include, but is not limited to the 2305 source of the key, whether the TLS certificate validates for keys 2306 retrieved from URLs, whether a key in an X.509 certificate is 2307 backed by a valid certificate chain, and other information known 2308 by the application. 2310 5. Attempt signature or MAC validation for a JWS object or 2311 decryption of a JWE object with some or all of the collected and 2312 possibly filtered and/or ordered keys. A limit on the number of 2313 keys to be tried might be applied. This process will normally 2314 terminate following a successful validation or decryption. 2316 Note that it is reasonable for some applications to perform signature 2317 or MAC validation prior to making a trust decision about a key, since 2318 keys for which the validation fails need no trust decision. 2320 Appendix E. Negative Test Case for "crit" Header Parameter 2322 Conforming implementations must reject input containing critical 2323 extensions that are not understood or cannot be processed. The 2324 following JWS must be rejected by all implementations, because it 2325 uses an extension Header Parameter name 2326 "http://example.invalid/UNDEFINED" that they do not understand. Any 2327 other similar input, in which the use of the value 2328 "http://example.invalid/UNDEFINED" is substituted for any other 2329 Header Parameter name not understood by the implementation, must also 2330 be rejected. 2332 The JWS Protected Header value for this JWS is: 2334 {"alg":"none", 2335 "crit":["http://example.invalid/UNDEFINED"], 2336 "http://example.invalid/UNDEFINED":true 2337 } 2339 The complete JWS that must be rejected is as follows (with line 2340 breaks for display purposes only): 2342 eyJhbGciOiJub25lIiwNCiAiY3JpdCI6WyJodHRwOi8vZXhhbXBsZS5jb20vVU5ERU 2343 ZJTkVEIl0sDQogImh0dHA6Ly9leGFtcGxlLmNvbS9VTkRFRklORUQiOnRydWUNCn0. 2344 RkFJTA. 2346 Appendix F. Detached Content 2348 In some contexts, it is useful integrity protect content that is not 2349 itself contained in a JWS object. One way to do this is create a JWS 2350 object in the normal fashion using a representation of the content as 2351 the payload, but then delete the payload representation from the JWS, 2352 and send this modified object to the recipient, rather than the JWS. 2353 When using the JWS Compact Serialization, the deletion is 2354 accomplished by replacing the second field (which contains 2355 BASE64URL(JWS Payload)) value with the empty string; when using the 2356 JWS JSON Serialization, the deletion is accomplished by deleting the 2357 "payload" member. This method assumes that the recipient can 2358 reconstruct the exact payload used in the JWS. To use the modified 2359 object, the recipient reconstructs the JWS by re-inserting the 2360 payload representation into the modified object, and uses the 2361 resulting JWS in the usual manner. Note that this method needs no 2362 support from JWS libraries, as applications can use this method by 2363 modifying the inputs and outputs of standard JWS libraries. 2365 Appendix G. Acknowledgements 2367 Solutions for signing JSON content were previously explored by Magic 2368 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 2369 Applications [CanvasApp], all of which influenced this draft. 2371 Thanks to Axel Nennker for his early implementation and feedback on 2372 the JWS and JWE specifications. 2374 This specification is the work of the JOSE Working Group, which 2375 includes dozens of active and dedicated participants. In particular, 2376 the following individuals contributed ideas, feedback, and wording 2377 that influenced this specification: 2379 Dirk Balfanz, Richard Barnes, Brian Campbell, Breno de Medeiros, Dick 2380 Hardt, Joe Hildebrand, Jeff Hodges, Edmund Jay, Yaron Y. Goland, Ben 2381 Laurie, James Manger, Matt Miller, Kathleen Moriarty, Tony Nadalin, 2382 Hideki Nara, Axel Nennker, John Panzer, Emmanuel Raviart, Eric 2383 Rescorla, Jim Schaad, Paul Tarjan, Hannes Tschofenig, and Sean 2384 Turner. 2386 Jim Schaad and Karen O'Donoghue chaired the JOSE working group and 2387 Sean Turner, Stephen Farrell, and Kathleen Moriarty served as 2388 Security area directors during the creation of this specification. 2390 Appendix H. Document History 2392 [[ to be removed by the RFC Editor before publication as an RFC ]] 2394 -32 2396 o Addressed Gen-ART review comments by Russ Housley. 2398 o Addressed secdir review comments by Tero Kivinen, Stephen Kent, 2399 and Scott Kelly. 2401 o Replaced the term Plaintext JWS with Unsecured JWS. 2403 -31 2405 o Reworded the language about JWS implementations ignoring the "typ" 2406 and "cty" parameters, explicitly saying that their processing is 2407 performed by JWS applications. 2409 o Added additional guidance on ciphersuites currently considered to 2410 be appropriate for use, including a reference to a recent update 2411 by the TLS working group. 2413 -30 2415 o Added subsection headings within the Overview section for the two 2416 serializations. 2418 o Added references and cleaned up the reference syntax in a few 2419 places. 2421 o Applied minor wording changes to the Security Considerations 2422 section and made other local editorial improvements. 2424 -29 2426 o Replaced the terms JWS Header, JWE Header, and JWT Header with a 2427 single JOSE Header term defined in the JWS specification. This 2428 also enabled a single Header Parameter definition to be used and 2429 reduced other areas of duplication between specifications. 2431 -28 2433 o Revised the introduction to the Security Considerations section. 2434 Also introduced additional subsection headings for security 2435 considerations items and also moved a security consideration item 2436 here from the JWA draft. 2438 o Added text about when applications typically would and would not 2439 use "typ" and "cty" header parameters. 2441 -27 2443 o Added the "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) header 2444 parameter. 2446 o Stated that any JSON inputs not conforming to the JSON-text syntax 2447 defined in RFC 7159 input MUST be rejected in their entirety. 2449 o Simplified the TLS requirements. 2451 -26 2453 o Referenced Section 6 of RFC 6125 for TLS server certificate 2454 identity validation. 2456 o Described potential sources of ambiguity in representing the JSON 2457 objects used in the examples. The octets of the actual UTF-8 2458 representations of the JSON objects used in the examples are 2459 included to remove these ambiguities. 2461 o Added a small amount of additional explanatory text to the 2462 signature validation examples to aid implementers. 2464 o Noted that octet sequences are depicted using JSON array notation. 2466 o Updated references, including to W3C specifications. 2468 -25 2470 o No changes were made, other than to the version number and date. 2472 -24 2474 o Updated the JSON reference to RFC 7159. 2476 -23 2478 o Clarified that the base64url encoding includes no line breaks, 2479 white space, or other additional characters. 2481 -22 2483 o Corrected RFC 2119 terminology usage. 2485 o Replaced references to draft-ietf-json-rfc4627bis with RFC 7158. 2487 -21 2489 o Applied review comments to the appendix "Notes on Key Selection", 2490 addressing issue #93. 2492 o Changed some references from being normative to informative, 2493 addressing issue #90. 2495 o Applied review comments to the JSON Serialization section, 2496 addressing issue #121. 2498 -20 2500 o Made terminology definitions more consistent, addressing issue 2501 #165. 2503 o Restructured the JSON Serialization section to call out the 2504 parameters used in hanging lists, addressing issue #121. 2506 o Described key filtering and refined other aspects of the text in 2507 the appendix "Notes on Key Selection", addressing issue #93. 2509 o Replaced references to RFC 4627 with draft-ietf-json-rfc4627bis, 2510 addressing issue #90. 2512 -19 2513 o Added the appendix "Notes on Validation Key Selection", addressing 2514 issue #93. 2516 o Reordered the key selection parameters. 2518 -18 2520 o Updated the mandatory-to-implement (MTI) language to say that 2521 applications using this specification need to specify what 2522 serialization and serialization features are used for that 2523 application, addressing issue #119. 2525 o Changes to address editorial and minor issues #25, #89, #97, #110, 2526 #114, #115, #116, #117, #120, and #184. 2528 o Added and used Header Parameter Description registry field. 2530 -17 2532 o Refined the "typ" and "cty" definitions to always be MIME Media 2533 Types, with the omission of "application/" prefixes recommended 2534 for brevity, addressing issue #50. 2536 o Updated the mandatory-to-implement (MTI) language to say that 2537 general-purpose implementations must implement the single 2538 signature/MAC value case for both serializations whereas special- 2539 purpose implementations can implement just one serialization if 2540 that meets the needs of the use cases the implementation is 2541 designed for, addressing issue #119. 2543 o Explicitly named all the logical components of a JWS and defined 2544 the processing rules and serializations in terms of those 2545 components, addressing issues #60, #61, and #62. 2547 o Replaced verbose repetitive phases such as "base64url encode the 2548 octets of the UTF-8 representation of X" with mathematical 2549 notation such as "BASE64URL(UTF8(X))". 2551 o Terms used in multiple documents are now defined in one place and 2552 incorporated by reference. Some lightly used or obvious terms 2553 were also removed. This addresses issue #58. 2555 -16 2557 o Changes to address editorial and minor issues #50, #98, #99, #102, 2558 #104, #106, #107, #111, and #112. 2560 -15 2561 o Clarified that it is an application decision which signatures, 2562 MACs, or plaintext values must successfully validate for the JWS 2563 to be accepted, addressing issue #35. 2565 o Corrected editorial error in "ES512" example. 2567 o Changes to address editorial and minor issues #34, #96, #100, 2568 #101, #104, #105, and #106. 2570 -14 2572 o Stated that the "signature" parameter is to be omitted in the JWS 2573 JSON Serialization when its value would be empty (which is only 2574 the case for a Plaintext JWS). 2576 -13 2578 o Made all header parameter values be per-signature/MAC, addressing 2579 issue #24. 2581 -12 2583 o Clarified that the "typ" and "cty" header parameters are used in 2584 an application-specific manner and have no effect upon the JWS 2585 processing. 2587 o Replaced the MIME types "application/jws+json" and 2588 "application/jws" with "application/jose+json" and 2589 "application/jose". 2591 o Stated that recipients MUST either reject JWSs with duplicate 2592 Header Parameter Names or use a JSON parser that returns only the 2593 lexically last duplicate member name. 2595 o Added a Serializations section with parallel treatment of the JWS 2596 Compact Serialization and the JWS JSON Serialization and also 2597 moved the former Implementation Considerations content there. 2599 -11 2601 o Added Key Identification section. 2603 o For the JWS JSON Serialization, enable header parameter values to 2604 be specified in any of three parameters: the "protected" member 2605 that is integrity protected and shared among all recipients, the 2606 "unprotected" member that is not integrity protected and shared 2607 among all recipients, and the "header" member that is not 2608 integrity protected and specific to a particular recipient. (This 2609 does not affect the JWS Compact Serialization, in which all header 2610 parameter values are in a single integrity protected JWE Header 2611 value.) 2613 o Removed suggested compact serialization for multiple digital 2614 signatures and/or MACs. 2616 o Changed the MIME type name "application/jws-js" to 2617 "application/jws+json", addressing issue #22. 2619 o Tightened the description of the "crit" (critical) header 2620 parameter. 2622 o Added a negative test case for the "crit" header parameter 2624 -10 2626 o Added an appendix suggesting a possible compact serialization for 2627 JWSs with multiple digital signatures and/or MACs. 2629 -09 2631 o Added JWS JSON Serialization, as specified by 2632 draft-jones-jose-jws-json-serialization-04. 2634 o Registered "application/jws-js" MIME type and "JWS-JS" typ header 2635 parameter value. 2637 o Defined that the default action for header parameters that are not 2638 understood is to ignore them unless specifically designated as 2639 "MUST be understood" or included in the new "crit" (critical) 2640 header parameter list. This addressed issue #6. 2642 o Changed term "JWS Secured Input" to "JWS Signing Input". 2644 o Changed from using the term "byte" to "octet" when referring to 8 2645 bit values. 2647 o Changed member name from "recipients" to "signatures" in the JWS 2648 JSON Serialization. 2650 o Added complete values using the JWS Compact Serialization for all 2651 examples. 2653 -08 2655 o Applied editorial improvements suggested by Jeff Hodges and Hannes 2656 Tschofenig. Many of these simplified the terminology used. 2658 o Clarified statements of the form "This header parameter is 2659 OPTIONAL" to "Use of this header parameter is OPTIONAL". 2661 o Added a Header Parameter Usage Location(s) field to the IANA JSON 2662 Web Signature and Encryption Header Parameters registry. 2664 o Added seriesInfo information to Internet Draft references. 2666 -07 2668 o Updated references. 2670 -06 2672 o Changed "x5c" (X.509 Certificate Chain) representation from being 2673 a single string to being an array of strings, each containing a 2674 single base64 encoded DER certificate value, representing elements 2675 of the certificate chain. 2677 o Applied changes made by the RFC Editor to RFC 6749's registry 2678 language to this specification. 2680 -05 2682 o Added statement that "StringOrURI values are compared as case- 2683 sensitive strings with no transformations or canonicalizations 2684 applied". 2686 o Indented artwork elements to better distinguish them from the body 2687 text. 2689 -04 2691 o Completed JSON Security Considerations section, including 2692 considerations about rejecting input with duplicate member names. 2694 o Completed security considerations on the use of a SHA-1 hash when 2695 computing "x5t" (x.509 certificate thumbprint) values. 2697 o Refer to the registries as the primary sources of defined values 2698 and then secondarily reference the sections defining the initial 2699 contents of the registries. 2701 o Normatively reference XML DSIG 2.0 for its security 2702 considerations. 2704 o Added this language to Registration Templates: "This name is case 2705 sensitive. Names that match other registered names in a case 2706 insensitive manner SHOULD NOT be accepted." 2708 o Reference draft-jones-jose-jws-json-serialization instead of 2709 draft-jones-json-web-signature-json-serialization. 2711 o Described additional open issues. 2713 o Applied editorial suggestions. 2715 -03 2717 o Added the "cty" (content type) header parameter for declaring type 2718 information about the secured content, as opposed to the "typ" 2719 (type) header parameter, which declares type information about 2720 this object. 2722 o Added "Collision Resistant Namespace" to the terminology section. 2724 o Reference ITU.X690.1994 for DER encoding. 2726 o Added an example JWS using ECDSA P-521 SHA-512. This has 2727 particular illustrative value because of the use of the 521 bit 2728 integers in the key and signature values. This is also an example 2729 in which the payload is not a base64url encoded JSON object. 2731 o Added an example "x5c" value. 2733 o No longer say "the UTF-8 representation of the JWS Secured Input 2734 (which is the same as the ASCII representation)". Just call it 2735 "the ASCII representation of the JWS Secured Input". 2737 o Added Registration Template sections for defined registries. 2739 o Added Registry Contents sections to populate registry values. 2741 o Changed name of the JSON Web Signature and Encryption "typ" Values 2742 registry to be the JSON Web Signature and Encryption Type Values 2743 registry, since it is used for more than just values of the "typ" 2744 parameter. 2746 o Moved registries JSON Web Signature and Encryption Header 2747 Parameters and JSON Web Signature and Encryption Type Values to 2748 the JWS specification. 2750 o Numerous editorial improvements. 2752 -02 2753 o Clarified that it is an error when a "kid" value is included and 2754 no matching key is found. 2756 o Removed assumption that "kid" (key ID) can only refer to an 2757 asymmetric key. 2759 o Clarified that JWSs with duplicate Header Parameter Names MUST be 2760 rejected. 2762 o Clarified the relationship between "typ" header parameter values 2763 and MIME types. 2765 o Registered application/jws MIME type and "JWS" typ header 2766 parameter value. 2768 o Simplified JWK terminology to get replace the "JWK Key Object" and 2769 "JWK Container Object" terms with simply "JSON Web Key (JWK)" and 2770 "JSON Web Key Set (JWK Set)" and to eliminate potential confusion 2771 between single keys and sets of keys. As part of this change, the 2772 Header Parameter Name for a public key value was changed from 2773 "jpk" (JSON Public Key) to "jwk" (JSON Web Key). 2775 o Added suggestion on defining additional header parameters such as 2776 "x5t#S256" in the future for certificate thumbprints using hash 2777 algorithms other than SHA-1. 2779 o Specify RFC 2818 server identity validation, rather than RFC 6125 2780 (paralleling the same decision in the OAuth specs). 2782 o Generalized language to refer to Message Authentication Codes 2783 (MACs) rather than Hash-based Message Authentication Codes (HMACs) 2784 unless in a context specific to HMAC algorithms. 2786 o Reformatted to give each header parameter its own section heading. 2788 -01 2790 o Moved definition of Plaintext JWSs (using "alg":"none") here from 2791 the JWT specification since this functionality is likely to be 2792 useful in more contexts that just for JWTs. 2794 o Added "jpk" and "x5c" header parameters for including JWK public 2795 keys and X.509 certificate chains directly in the header. 2797 o Clarified that this specification is defining the JWS Compact 2798 Serialization. Referenced the new JWS-JS spec, which defines the 2799 JWS JSON Serialization. 2801 o Added text "New header parameters should be introduced sparingly 2802 since an implementation that does not understand a parameter MUST 2803 reject the JWS". 2805 o Clarified that the order of the creation and validation steps is 2806 not significant in cases where there are no dependencies between 2807 the inputs and outputs of the steps. 2809 o Changed "no canonicalization is performed" to "no canonicalization 2810 need be performed". 2812 o Corrected the Magic Signatures reference. 2814 o Made other editorial improvements suggested by JOSE working group 2815 participants. 2817 -00 2819 o Created the initial IETF draft based upon 2820 draft-jones-json-web-signature-04 with no normative changes. 2822 o Changed terminology to no longer call both digital signatures and 2823 HMACs "signatures". 2825 Authors' Addresses 2827 Michael B. Jones 2828 Microsoft 2830 Email: mbj@microsoft.com 2831 URI: http://self-issued.info/ 2833 John Bradley 2834 Ping Identity 2836 Email: ve7jtb@ve7jtb.com 2837 URI: http://www.thread-safe.com/ 2839 Nat Sakimura 2840 Nomura Research Institute 2842 Email: n-sakimura@nri.co.jp 2843 URI: http://nat.sakimura.org/