idnits 2.17.1 draft-ietf-jose-json-web-signature-40.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 (January 13, 2015) is 3391 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 2031 -- Looks like a reference, but probably isn't: '34' on line 2031 -- Looks like a reference, but probably isn't: '97' on line 2041 -- Looks like a reference, but probably isn't: '108' on line 2041 -- Looks like a reference, but probably isn't: '103' on line 2031 -- Looks like a reference, but probably isn't: '58' on line 2031 -- Looks like a reference, but probably isn't: '82' on line 1769 -- Looks like a reference, but probably isn't: '83' on line 2031 -- Looks like a reference, but probably isn't: '50' on line 2031 -- Looks like a reference, but probably isn't: '53' on line 2031 -- Looks like a reference, but probably isn't: '54' on line 1917 -- Looks like a reference, but probably isn't: '125' on line 2031 -- Looks like a reference, but probably isn't: '69' on line 2031 -- Looks like a reference, but probably isn't: '49' on line 2031 -- Looks like a reference, but probably isn't: '80' on line 2041 -- Looks like a reference, but probably isn't: '121' on line 2041 -- Looks like a reference, but probably isn't: '111' on line 2041 -- Looks like a reference, but probably isn't: '100' on line 2041 -- Looks like a reference, but probably isn't: '0' on line 2376 -- Possible downref: Non-RFC (?) normative reference: ref. 'ECMAScript' -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.X690.1994' ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** Downref: Normative reference to an Informational RFC: RFC 4949 ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 6125 (Obsoleted by RFC 9525) ** Obsolete normative reference: RFC 7159 (Obsoleted by RFC 8259) -- Possible downref: Non-RFC (?) normative reference: ref. 'UNICODE' == Outdated reference: A later version (-11) exists of draft-ietf-uta-tls-bcp-08 -- Obsolete informational reference (is this intentional?): RFC 3447 (Obsoleted by RFC 8017) -- Obsolete informational reference (is this intentional?): RFC 5226 (Obsoleted by RFC 8126) Summary: 5 errors (**), 0 flaws (~~), 2 warnings (==), 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: July 17, 2015 Ping Identity 6 N. Sakimura 7 NRI 8 January 13, 2015 10 JSON Web Signature (JWS) 11 draft-ietf-jose-json-web-signature-40 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 July 17, 2015. 41 Copyright Notice 43 Copyright (c) 2015 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (http://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 5 59 1.1. Notational Conventions . . . . . . . . . . . . . . . . . 5 60 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 6 61 3. JSON Web Signature (JWS) Overview . . . . . . . . . . . . . . 7 62 3.1. JWS Compact Serialization Overview . . . . . . . . . . . 8 63 3.2. JWS JSON Serialization Overview . . . . . . . . . . . . . 8 64 3.3. Example JWS . . . . . . . . . . . . . . . . . . . . . . . 9 65 4. JOSE Header . . . . . . . . . . . . . . . . . . . . . . . . . 10 66 4.1. Registered Header Parameter Names . . . . . . . . . . . . 11 67 4.1.1. "alg" (Algorithm) Header Parameter . . . . . . . . . . 11 68 4.1.2. "jku" (JWK Set URL) Header Parameter . . . . . . . . . 11 69 4.1.3. "jwk" (JSON Web Key) Header Parameter . . . . . . . . 11 70 4.1.4. "kid" (Key ID) Header Parameter . . . . . . . . . . . 12 71 4.1.5. "x5u" (X.509 URL) Header Parameter . . . . . . . . . . 12 72 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter . . . 12 73 4.1.7. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header 74 Parameter . . . . . . . . . . . . . . . . . . . . . . 13 75 4.1.8. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) 76 Header Parameter . . . . . . . . . . . . . . . . . . . 13 77 4.1.9. "typ" (Type) Header Parameter . . . . . . . . . . . . 13 78 4.1.10. "cty" (Content Type) Header Parameter . . . . . . . . 14 79 4.1.11. "crit" (Critical) Header Parameter . . . . . . . . . . 14 80 4.2. Public Header Parameter Names . . . . . . . . . . . . . . 15 81 4.3. Private Header Parameter Names . . . . . . . . . . . . . 15 82 5. Producing and Consuming JWSs . . . . . . . . . . . . . . . . . 15 83 5.1. Message Signature or MAC Computation . . . . . . . . . . 15 84 5.2. Message Signature or MAC Validation . . . . . . . . . . . 16 85 5.3. String Comparison Rules . . . . . . . . . . . . . . . . . 18 86 6. Key Identification . . . . . . . . . . . . . . . . . . . . . . 19 87 7. Serializations . . . . . . . . . . . . . . . . . . . . . . . . 19 88 7.1. JWS Compact Serialization . . . . . . . . . . . . . . . . 20 89 7.2. JWS JSON Serialization . . . . . . . . . . . . . . . . . 20 90 7.2.1. General JWS JSON Serialization Syntax . . . . . . . . 20 91 7.2.2. Flattened JWS JSON Serialization Syntax . . . . . . . 22 92 8. TLS Requirements . . . . . . . . . . . . . . . . . . . . . . . 23 93 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23 94 9.1. JSON Web Signature and Encryption Header Parameters 95 Registry . . . . . . . . . . . . . . . . . . . . . . . . 24 97 9.1.1. Registration Template . . . . . . . . . . . . . . . . 25 98 9.1.2. Initial Registry Contents . . . . . . . . . . . . . . 25 99 9.2. Media Type Registration . . . . . . . . . . . . . . . . . 27 100 9.2.1. Registry Contents . . . . . . . . . . . . . . . . . . 27 101 10. Security Considerations . . . . . . . . . . . . . . . . . . . 28 102 10.1. Key Entropy and Random Values . . . . . . . . . . . . . . 28 103 10.2. Key Protection . . . . . . . . . . . . . . . . . . . . . 29 104 10.3. Key Origin Authentication . . . . . . . . . . . . . . . . 29 105 10.4. Cryptographic Agility . . . . . . . . . . . . . . . . . . 29 106 10.5. Differences between Digital Signatures and MACs . . . . . 29 107 10.6. Algorithm Validation . . . . . . . . . . . . . . . . . . 30 108 10.7. Algorithm Protection . . . . . . . . . . . . . . . . . . 30 109 10.8. Chosen Plaintext Attacks . . . . . . . . . . . . . . . . 31 110 10.9. Timing Attacks . . . . . . . . . . . . . . . . . . . . . 31 111 10.10. Replay Protection . . . . . . . . . . . . . . . . . . . . 31 112 10.11. SHA-1 Certificate Thumbprints . . . . . . . . . . . . . . 31 113 10.12. JSON Security Considerations . . . . . . . . . . . . . . 32 114 10.13. Unicode Comparison Security Considerations . . . . . . . 32 115 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 33 116 11.1. Normative References . . . . . . . . . . . . . . . . . . 33 117 11.2. Informative References . . . . . . . . . . . . . . . . . 34 118 Appendix A. JWS Examples . . . . . . . . . . . . . . . . . . . . 36 119 A.1. Example JWS using HMAC SHA-256 . . . . . . . . . . . . . 36 120 A.1.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 36 121 A.1.2. Validating . . . . . . . . . . . . . . . . . . . . . . 38 122 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 . . . . . . . 39 123 A.2.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 39 124 A.2.2. Validating . . . . . . . . . . . . . . . . . . . . . . 41 125 A.3. Example JWS using ECDSA P-256 SHA-256 . . . . . . . . . . 42 126 A.3.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 42 127 A.3.2. Validating . . . . . . . . . . . . . . . . . . . . . . 44 128 A.4. Example JWS using ECDSA P-521 SHA-512 . . . . . . . . . . 44 129 A.4.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 44 130 A.4.2. Validating . . . . . . . . . . . . . . . . . . . . . . 46 131 A.5. Example Unsecured JWS . . . . . . . . . . . . . . . . . . 46 132 A.6. Example JWS using General JWS JSON Serialization . . . . 47 133 A.6.1. JWS Per-Signature Protected Headers . . . . . . . . . 48 134 A.6.2. JWS Per-Signature Unprotected Headers . . . . . . . . 48 135 A.6.3. Complete JOSE Header Values . . . . . . . . . . . . . 48 136 A.6.4. Complete JWS JSON Serialization Representation . . . . 49 137 A.7. Example JWS using Flattened JWS JSON Serialization . . . 49 138 Appendix B. "x5c" (X.509 Certificate Chain) Example . . . . . . . 50 139 Appendix C. Notes on implementing base64url encoding without 140 padding . . . . . . . . . . . . . . . . . . . . . . . 52 141 Appendix D. Notes on Key Selection . . . . . . . . . . . . . . . 53 142 Appendix E. Negative Test Case for "crit" Header Parameter . . . 54 143 Appendix F. Detached Content . . . . . . . . . . . . . . . . . . 55 144 Appendix G. Acknowledgements . . . . . . . . . . . . . . . . . . 55 145 Appendix H. Document History . . . . . . . . . . . . . . . . . . 56 146 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 67 148 1. Introduction 150 JSON Web Signature (JWS) represents content secured with digital 151 signatures or Message Authentication Codes (MACs) using JavaScript 152 Object Notation (JSON) [RFC7159] based data structures. The JWS 153 cryptographic mechanisms provide integrity protection for an 154 arbitrary sequence of octets. See Section 10.5 for a discussion on 155 the differences between Digital Signatures and MACs. 157 Two closely related serializations for JWSs are defined. The JWS 158 Compact Serialization is a compact, URL-safe representation intended 159 for space constrained environments such as HTTP Authorization headers 160 and URI query parameters. The JWS JSON Serialization represents JWSs 161 as JSON objects and enables multiple signatures and/or MACs to be 162 applied to the same content. Both share the same cryptographic 163 underpinnings. 165 Cryptographic algorithms and identifiers for use with this 166 specification are described in the separate JSON Web Algorithms (JWA) 167 [JWA] specification and an IANA registry defined by that 168 specification. Related encryption capabilities are described in the 169 separate JSON Web Encryption (JWE) [JWE] specification. 171 Names defined by this specification are short because a core goal is 172 for the resulting representations to be compact. 174 1.1. Notational Conventions 176 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 177 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 178 "OPTIONAL" in this document are to be interpreted as described in Key 179 words for use in RFCs to Indicate Requirement Levels [RFC2119]. If 180 these words are used without being spelled in uppercase then they are 181 to be interpreted with their normal natural language meanings. 183 BASE64URL(OCTETS) denotes the base64url encoding of OCTETS, per 184 Section 2. 186 UTF8(STRING) denotes the octets of the UTF-8 [RFC3629] representation 187 of STRING, where STRING is a sequence of zero or more Unicode 188 [UNICODE] characters. 190 ASCII(STRING) denotes the octets of the ASCII [RFC20] representation 191 of STRING, where STRING is a sequence of zero or more ASCII 192 characters. 194 The concatenation of two values A and B is denoted as A || B. 196 2. Terminology 198 These terms are defined by this specification: 200 JSON Web Signature (JWS) 201 A data structure representing a digitally signed or MACed message. 203 JOSE Header 204 JSON object containing the parameters describing the cryptographic 205 operations and parameters employed. The JOSE Header is comprised 206 of a set of Header Parameters. 208 JWS Payload 209 The sequence of octets to be secured -- a.k.a., the message. The 210 payload can contain an arbitrary sequence of octets. 212 JWS Signature 213 Digital signature or MAC over the JWS Protected Header and the JWS 214 Payload. 216 Header Parameter 217 A name/value pair that is member of the JOSE Header. 219 JWS Protected Header 220 JSON object that contains the Header Parameters that are integrity 221 protected by the JWS Signature digital signature or MAC operation. 222 For the JWS Compact Serialization, this comprises the entire JOSE 223 Header. For the JWS JSON Serialization, this is one component of 224 the JOSE Header. 226 JWS Unprotected Header 227 JSON object that contains the Header Parameters that are not 228 integrity protected. This can only be present when using the JWS 229 JSON Serialization. 231 Base64url Encoding 232 Base64 encoding using the URL- and filename-safe character set 233 defined in Section 5 of RFC 4648 [RFC4648], with all trailing '=' 234 characters omitted (as permitted by Section 3.2) and without the 235 inclusion of any line breaks, white space, or other additional 236 characters. Note that the base64url encoding of the empty octet 237 sequence is the empty string. (See Appendix C for notes on 238 implementing base64url encoding without padding.) 240 JWS Signing Input 241 The input to the digital signature or MAC computation. Its value 242 is ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 243 BASE64URL(JWS Payload)). 245 JWS Compact Serialization 246 A representation of the JWS as a compact, URL-safe string. 248 JWS JSON Serialization 249 A representation of the JWS as a JSON object. Unlike the JWS 250 Compact Serialization, the JWS JSON Serialization enables multiple 251 digital signatures and/or MACs to be applied to the same content. 252 This representation is neither optimized for compactness nor URL- 253 safe. 255 Unsecured JWS 256 A JWS that provides no integrity protection. Unsecured JWSs use 257 the "alg" value "none". 259 Collision-Resistant Name 260 A name in a namespace that enables names to be allocated in a 261 manner such that they are highly unlikely to collide with other 262 names. Examples of collision-resistant namespaces include: Domain 263 Names, Object Identifiers (OIDs) as defined in the ITU-T X.660 and 264 X.670 Recommendation series, and Universally Unique IDentifiers 265 (UUIDs) [RFC4122]. When using an administratively delegated 266 namespace, the definer of a name needs to take reasonable 267 precautions to ensure they are in control of the portion of the 268 namespace they use to define the name. 270 StringOrURI 271 A JSON string value, with the additional requirement that while 272 arbitrary string values MAY be used, any value containing a ":" 273 character MUST be a URI [RFC3986]. StringOrURI values are 274 compared as case-sensitive strings with no transformations or 275 canonicalizations applied. 277 These terms defined by the JSON Web Encryption (JWE) [JWE] 278 specification are incorporated into this specification: "JSON Web 279 Encryption (JWE)", "JWE Compact Serialization", and "JWE JSON 280 Serialization". 282 These terms defined by the Internet Security Glossary, Version 2 283 [RFC4949] are incorporated into this specification: "Digital 284 Signature" and "Message Authentication Code (MAC)". 286 3. JSON Web Signature (JWS) Overview 288 JWS represents digitally signed or MACed content using JSON data 289 structures and base64url encoding. These JSON data structures MAY 290 contain white space and/or line breaks before or after any JSON 291 values or structural characters, in accordance with Section 2 of RFC 292 7159 [RFC7159]. A JWS represents these logical values (each of which 293 is defined in Section 2): 295 o JOSE Header 296 o JWS Payload 297 o JWS Signature 299 For a JWS, the JOSE Header members are the union of the members of 300 these values (each of which is defined in Section 2): 302 o JWS Protected Header 303 o JWS Unprotected Header 305 This document defines two serializations for JWSs: a compact, URL- 306 safe serialization called the JWS Compact Serialization and a JSON 307 serialization called the JWS JSON Serialization. In both 308 serializations, the JWS Protected Header, JWS Payload, and JWS 309 Signature are base64url encoded, since JSON lacks a way to directly 310 represent arbitrary octet sequences. 312 3.1. JWS Compact Serialization Overview 314 In the JWS Compact Serialization, no JWS Unprotected Header is used. 315 In this case, the JOSE Header and the JWS Protected Header are the 316 same. 318 In the JWS Compact Serialization, a JWS is represented as the 319 concatenation: 321 BASE64URL(UTF8(JWS Protected Header)) || '.' || 322 BASE64URL(JWS Payload) || '.' || 323 BASE64URL(JWS Signature) 325 See Section 7.1 for more information about the JWS Compact 326 Serialization. 328 3.2. JWS JSON Serialization Overview 330 In the JWS JSON Serialization, one or both of the JWS Protected 331 Header and JWS Unprotected Header MUST be present. In this case, the 332 members of the JOSE Header are the union of the members of the JWS 333 Protected Header and the JWS Unprotected Header values that are 334 present. 336 In the JWS JSON Serialization, a JWS is represented as a JSON object 337 containing some or all of these four members: 339 "protected", with the value BASE64URL(UTF8(JWS Protected Header)) 340 "header", with the value JWS Unprotected Header 341 "payload", with the value BASE64URL(JWS Payload) 342 "signature", with the value BASE64URL(JWS Signature) 344 The three base64url encoded result strings and the JWS Unprotected 345 Header value are represented as members within a JSON object. The 346 inclusion of some of these values is OPTIONAL. The JWS JSON 347 Serialization can also represent multiple signature and/or MAC 348 values, rather than just one. See Section 7.2 for more information 349 about the JWS JSON Serialization. 351 3.3. Example JWS 353 This section provides an example of a JWS. Its computation is 354 described in more detail in Appendix A.1, including specifying the 355 exact octet sequences representing the JSON values used and the key 356 value used. 358 The following example JWS Protected Header declares that the encoded 359 object is a JSON Web Token (JWT) [JWT] and the JWS Protected Header 360 and the JWS Payload are secured using the HMAC SHA-256 [RFC2104, SHS] 361 algorithm: 363 {"typ":"JWT", 364 "alg":"HS256"} 366 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 367 Header)) gives this value: 369 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 371 The UTF-8 representation of following JSON object is used as the JWS 372 Payload. (Note that the payload can be any content, and need not be 373 a representation of a JSON object.) 375 {"iss":"joe", 376 "exp":1300819380, 377 "http://example.com/is_root":true} 379 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value 380 (with line breaks for display purposes only): 382 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 383 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 385 Computing the HMAC of the JWS Signing Input ASCII(BASE64URL(UTF8(JWS 386 Protected Header)) || '.' || BASE64URL(JWS Payload)) with the HMAC 387 SHA-256 algorithm using the key specified in Appendix A.1 and 388 base64url encoding the result yields this BASE64URL(JWS Signature) 389 value: 391 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 393 Concatenating these values in the order Header.Payload.Signature with 394 period ('.') characters between the parts yields this complete JWS 395 representation using the JWS Compact Serialization (with line breaks 396 for display purposes only): 398 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 399 . 400 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 401 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 402 . 403 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 405 See Appendix A for additional examples, including examples using the 406 JWS JSON Serialization in Sections A.6 and A.7. 408 4. JOSE Header 410 For a JWS, the members of the JSON object(s) representing the JOSE 411 Header describe the digital signature or MAC applied to the JWS 412 Protected Header and the JWS Payload and optionally additional 413 properties of the JWS. The Header Parameter names within the JOSE 414 Header MUST be unique; JWS parsers MUST either reject JWSs with 415 duplicate Header Parameter names or use a JSON parser that returns 416 only the lexically last duplicate member name, as specified in 417 Section 15.12 (The JSON Object) of ECMAScript 5.1 [ECMAScript]. 419 Implementations are required to understand the specific Header 420 Parameters defined by this specification that are designated as "MUST 421 be understood" and process them in the manner defined in this 422 specification. All other Header Parameters defined by this 423 specification that are not so designated MUST be ignored when not 424 understood. Unless listed as a critical Header Parameter, per 425 Section 4.1.11, all Header Parameters not defined by this 426 specification MUST be ignored when not understood. 428 There are three classes of Header Parameter names: Registered Header 429 Parameter names, Public Header Parameter names, and Private Header 430 Parameter names. 432 4.1. Registered Header Parameter Names 434 The following Header Parameter names for use in JWSs are registered 435 in the IANA JSON Web Signature and Encryption Header Parameters 436 registry defined in Section 9.1, with meanings as defined below. 438 As indicated by the common registry, JWSs and JWEs share a common 439 Header Parameter space; when a parameter is used by both 440 specifications, its usage must be compatible between the 441 specifications. 443 4.1.1. "alg" (Algorithm) Header Parameter 445 The "alg" (algorithm) Header Parameter identifies the cryptographic 446 algorithm used to secure the JWS. The JWS Signature value is not 447 valid if the "alg" value does not represent a supported algorithm, or 448 if there is not a key for use with that algorithm associated with the 449 party that digitally signed or MACed the content. "alg" values should 450 either be registered in the IANA JSON Web Signature and Encryption 451 Algorithms registry defined in [JWA] or be a value that contains a 452 Collision-Resistant Name. The "alg" value is a case-sensitive ASCII 453 string containing a StringOrURI value. This Header Parameter MUST be 454 present and MUST be understood and processed by implementations. 456 A list of defined "alg" values for this use can be found in the IANA 457 JSON Web Signature and Encryption Algorithms registry defined in 458 [JWA]; the initial contents of this registry are the values defined 459 in Section 3.1 of the JSON Web Algorithms (JWA) [JWA] specification. 461 4.1.2. "jku" (JWK Set URL) Header Parameter 463 The "jku" (JWK Set URL) Header Parameter is a URI [RFC3986] that 464 refers to a resource for a set of JSON-encoded public keys, one of 465 which corresponds to the key used to digitally sign the JWS. The 466 keys MUST be encoded as a JSON Web Key Set (JWK Set) [JWK]. The 467 protocol used to acquire the resource MUST provide integrity 468 protection; an HTTP GET request to retrieve the JWK Set MUST use TLS 469 [RFC2818, RFC5246]; the identity of the server MUST be validated, as 470 per Section 6 of RFC 6125 [RFC6125]. Also, see Section 8 on TLS 471 requirements. Use of this Header Parameter is OPTIONAL. 473 4.1.3. "jwk" (JSON Web Key) Header Parameter 475 The "jwk" (JSON Web Key) Header Parameter is the public key that 476 corresponds to the key used to digitally sign the JWS. This key is 477 represented as a JSON Web Key [JWK]. Use of this Header Parameter is 478 OPTIONAL. 480 4.1.4. "kid" (Key ID) Header Parameter 482 The "kid" (key ID) Header Parameter is a hint indicating which key 483 was used to secure the JWS. This parameter allows originators to 484 explicitly signal a change of key to recipients. The structure of 485 the "kid" value is unspecified. Its value MUST be a case-sensitive 486 string. Use of this Header Parameter is OPTIONAL. 488 When used with a JWK, the "kid" value is used to match a JWK "kid" 489 parameter value. 491 4.1.5. "x5u" (X.509 URL) Header Parameter 493 The "x5u" (X.509 URL) Header Parameter is a URI [RFC3986] that refers 494 to a resource for the X.509 public key certificate or certificate 495 chain [RFC5280] corresponding to the key used to digitally sign the 496 JWS. The identified resource MUST provide a representation of the 497 certificate or certificate chain that conforms to RFC 5280 [RFC5280] 498 in PEM encoded form, with each certificate delimited as specified in 499 Section 6.1 of RFC 4945 [RFC4945]. The certificate containing the 500 public key corresponding to the key used to digitally sign the JWS 501 MUST be the first certificate. This MAY be followed by additional 502 certificates, with each subsequent certificate being the one used to 503 certify the previous one. The protocol used to acquire the resource 504 MUST provide integrity protection; an HTTP GET request to retrieve 505 the certificate MUST use TLS [RFC2818, RFC5246]; the identity of the 506 server MUST be validated, as per Section 6 of RFC 6125 [RFC6125]. 507 Also, see Section 8 on TLS requirements. Use of this Header 508 Parameter is OPTIONAL. 510 4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter 512 The "x5c" (X.509 Certificate Chain) Header Parameter contains the 513 X.509 public key certificate or certificate chain [RFC5280] 514 corresponding to the key used to digitally sign the JWS. The 515 certificate or certificate chain is represented as a JSON array of 516 certificate value strings. Each string in the array is a base64 517 encoded ([RFC4648] Section 4 -- not base64url encoded) DER 518 [ITU.X690.1994] PKIX certificate value. The certificate containing 519 the public key corresponding to the key used to digitally sign the 520 JWS MUST be the first certificate. This MAY be followed by 521 additional certificates, with each subsequent certificate being the 522 one used to certify the previous one. The recipient MUST validate 523 the certificate chain according to RFC 5280 [RFC5280] and consider 524 the certificate or certificate chain to be invalid if any validation 525 failure occurs. Use of this Header Parameter is OPTIONAL. 527 See Appendix B for an example "x5c" value. 529 4.1.7. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter 531 The "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter is a 532 base64url encoded SHA-1 thumbprint (a.k.a. digest) of the DER 533 encoding of the X.509 certificate [RFC5280] corresponding to the key 534 used to digitally sign the JWS. Note that certificate thumbprints 535 are also sometimes known as certificate fingerprints. Use of this 536 Header Parameter is OPTIONAL. 538 4.1.8. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header 539 Parameter 541 The "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header 542 Parameter is a base64url encoded SHA-256 thumbprint (a.k.a. digest) 543 of the DER encoding of the X.509 certificate [RFC5280] corresponding 544 to the key used to digitally sign the JWS. Note that certificate 545 thumbprints are also sometimes known as certificate fingerprints. 546 Use of this Header Parameter is OPTIONAL. 548 4.1.9. "typ" (Type) Header Parameter 550 The "typ" (type) Header Parameter is used by JWS applications to 551 declare the MIME Media Type [IANA.MediaTypes] of this complete JWS. 552 This is intended for use by the application when more than one kind 553 of object could be present in an application data structure that can 554 contain a JWS; the application can use this value to disambiguate 555 among the different kinds of objects that might be present. It will 556 typically not be used by applications when the kind of object is 557 already known. This parameter is ignored by JWS implementations; any 558 processing of this parameter is performed by the JWS application. 559 Use of this Header Parameter is OPTIONAL. 561 Per RFC 2045 [RFC2045], all media type values, subtype values, and 562 parameter names are case-insensitive. However, parameter values are 563 case-sensitive unless otherwise specified for the specific parameter. 565 To keep messages compact in common situations, it is RECOMMENDED that 566 producers omit an "application/" prefix of a media type value in a 567 "typ" Header Parameter when no other '/' appears in the media type 568 value. A recipient using the media type value MUST treat it as if 569 "application/" were prepended to any "typ" value not containing a 570 '/'. For instance, a "typ" value of "example" SHOULD be used to 571 represent the "application/example" media type; whereas, the media 572 type "application/example;part="1/2"" cannot be shortened to 573 "example;part="1/2"". 575 The "typ" value "JOSE" can be used by applications to indicate that 576 this object is a JWS or JWE using the JWS Compact Serialization or 577 the JWE Compact Serialization. The "typ" value "JOSE+JSON" can be 578 used by applications to indicate that this object is a JWS or JWE 579 using the JWS JSON Serialization or the JWE JSON Serialization. 580 Other type values can also be used by applications. 582 4.1.10. "cty" (Content Type) Header Parameter 584 The "cty" (content type) Header Parameter is used by JWS applications 585 to declare the MIME Media Type [IANA.MediaTypes] of the secured 586 content (the payload). This is intended for use by the application 587 when more than one kind of object could be present in the JWS 588 payload; the application can use this value to disambiguate among the 589 different kinds of objects that might be present. It will typically 590 not be used by applications when the kind of object is already known. 591 This parameter is ignored by JWS implementations; any processing of 592 this parameter is performed by the JWS application. Use of this 593 Header Parameter is OPTIONAL. 595 Per RFC 2045 [RFC2045], all media type values, subtype values, and 596 parameter names are case-insensitive. However, parameter values are 597 case-sensitive unless otherwise specified for the specific parameter. 599 To keep messages compact in common situations, it is RECOMMENDED that 600 producers omit an "application/" prefix of a media type value in a 601 "cty" Header Parameter when no other '/' appears in the media type 602 value. A recipient using the media type value MUST treat it as if 603 "application/" were prepended to any "cty" value not containing a 604 '/'. For instance, a "cty" value of "example" SHOULD be used to 605 represent the "application/example" media type; whereas, the media 606 type "application/example;part="1/2"" cannot be shortened to 607 "example;part="1/2"". 609 4.1.11. "crit" (Critical) Header Parameter 611 The "crit" (critical) Header Parameter indicates that extensions to 612 the initial RFC versions of [[ this specification ]] and [JWA] are 613 being used that MUST be understood and processed. Its value is an 614 array listing the Header Parameter names present in the JOSE Header 615 that use those extensions. If any of the listed extension Header 616 Parameters are not understood and supported by the recipient, it MUST 617 reject the JWS. Producers MUST NOT include Header Parameter names 618 defined by the initial RFC versions of [[ this specification ]] or 619 [JWA] for use with JWS, duplicate names, or names that do not occur 620 as Header Parameter names within the JOSE Header in the "crit" list. 621 Producers MUST NOT use the empty list "[]" as the "crit" value. 622 Recipients MAY reject the JWS if the critical list contains any 623 Header Parameter names defined by the initial RFC versions of [[ this 624 specification ]] or [JWA] for use with JWS, or any other constraints 625 on its use are violated. When used, this Header Parameter MUST be 626 integrity protected; therefore, it MUST occur only within the JWS 627 Protected Header. Use of this Header Parameter is OPTIONAL. This 628 Header Parameter MUST be understood and processed by implementations. 630 An example use, along with a hypothetical "exp" (expiration-time) 631 field is: 633 {"alg":"ES256", 634 "crit":["exp"], 635 "exp":1363284000 636 } 638 4.2. Public Header Parameter Names 640 Additional Header Parameter names can be defined by those using JWSs. 641 However, in order to prevent collisions, any new Header Parameter 642 name should either be registered in the IANA JSON Web Signature and 643 Encryption Header Parameters registry defined in Section 9.1 or be a 644 Public Name: a value that contains a Collision-Resistant Name. In 645 each case, the definer of the name or value needs to take reasonable 646 precautions to make sure they are in control of the part of the 647 namespace they use to define the Header Parameter name. 649 New Header Parameters should be introduced sparingly, as they can 650 result in non-interoperable JWSs. 652 4.3. Private Header Parameter Names 654 A producer and consumer of a JWS may agree to use Header Parameter 655 names that are Private Names: names that are not Registered Header 656 Parameter names Section 4.1 or Public Header Parameter names 657 Section 4.2. Unlike Public Header Parameter names, Private Header 658 Parameter names are subject to collision and should be used with 659 caution. 661 5. Producing and Consuming JWSs 663 5.1. Message Signature or MAC Computation 665 To create a JWS, the following steps are performed. The order of the 666 steps is not significant in cases where there are no dependencies 667 between the inputs and outputs of the steps. 669 1. Create the content to be used as the JWS Payload. 671 2. Compute the encoded payload value BASE64URL(JWS Payload). 673 3. Create the JSON object(s) containing the desired set of Header 674 Parameters, which together comprise the JOSE Header: if the JWS 675 Compact Serialization is being used, the JWS Protected Header, or 676 if the JWS JSON Serialization is being used, the JWS Protected 677 Header and/or the JWS Unprotected Header. 679 4. Compute the encoded header value BASE64URL(UTF8(JWS Protected 680 Header)). If the JWS Protected Header is not present (which can 681 only happen when using the JWS JSON Serialization and no 682 "protected" member is present), let this value be the empty 683 string. 685 5. Compute the JWS Signature in the manner defined for the 686 particular algorithm being used over the JWS Signing Input 687 ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 688 BASE64URL(JWS Payload)). The "alg" (algorithm) Header Parameter 689 MUST be present in the JOSE Header, with the algorithm value 690 accurately representing the algorithm used to construct the JWS 691 Signature. 693 6. Compute the encoded signature value BASE64URL(JWS Signature). 695 7. If the JWS JSON Serialization is being used, repeat this process 696 (steps 3-6) for each digital signature or MAC operation being 697 performed. 699 8. Create the desired serialized output. The JWS Compact 700 Serialization of this result is BASE64URL(UTF8(JWS Protected 701 Header)) || '.' || BASE64URL(JWS Payload) || '.' || BASE64URL(JWS 702 Signature). The JWS JSON Serialization is described in 703 Section 7.2. 705 5.2. Message Signature or MAC Validation 707 When validating a JWS, the following steps are performed. The order 708 of the steps is not significant in cases where there are no 709 dependencies between the inputs and outputs of the steps. If any of 710 the listed steps fails, then the signature or MAC cannot be 711 validated. 713 When there are multiple JWS Signature values, it is an application 714 decision which of the JWS Signature values must successfully validate 715 for the JWS to be accepted. In some cases, all must successfully 716 validate or the JWS will be considered invalid. In other cases, only 717 a specific JWS Signature value needs to be successfully validated. 718 However, in all cases, at least one JWS Signature value MUST 719 successfully validate or the JWS MUST be considered invalid. 721 1. Parse the JWS representation to extract the serialized values 722 for the components of the JWS. When using the JWS Compact 723 Serialization, these components are the base64url encoded 724 representations of the JWS Protected Header, the JWS Payload, 725 and the JWS Signature, and when using the JWS JSON 726 Serialization, these components also include the unencoded JWS 727 Unprotected Header value. When using the JWS Compact 728 Serialization, the JWS Protected Header, the JWS Payload, and 729 the JWS Signature are represented as base64url encoded values in 730 that order, with each value being separated from the next by a 731 single period ('.') character, resulting in exactly two 732 delimiting period characters being used. The JWS JSON 733 Serialization is described in Section 7.2. 735 2. Base64url decode the encoded representation of the JWS Protected 736 Header, following the restriction that no line breaks, white 737 space, or other additional characters have been used. 739 3. Verify that the resulting octet sequence is a UTF-8 encoded 740 representation of a completely valid JSON object conforming to 741 RFC 7159 [RFC7159]; let the JWS Protected Header be this JSON 742 object. 744 4. If using the JWS Compact Serialization, let the JOSE Header be 745 the JWS Protected Header. Otherwise, when using the JWS JSON 746 Serialization, let the JOSE Header be the union of the members 747 of the corresponding JWS Protected Header and JWS Unprotected 748 Header, all of which must be completely valid JSON objects. 749 During this step, verify that the resulting JOSE Header does not 750 contain duplicate Header Parameter names. When using the JWS 751 JSON Serialization, this restriction includes that the same 752 Header Parameter name also MUST NOT occur in distinct JSON 753 object values that together comprise the JOSE Header. 755 5. Verify that the implementation understands and can process all 756 fields that it is required to support, whether required by this 757 specification, by the algorithm being used, or by the "crit" 758 Header Parameter value, and that the values of those parameters 759 are also understood and supported. 761 6. Base64url decode the encoded representation of the JWS Payload, 762 following the restriction that no line breaks, white space, or 763 other additional characters have been used. 765 7. Base64url decode the encoded representation of the JWS 766 Signature, following the restriction that no line breaks, white 767 space, or other additional characters have been used. 769 8. Validate the JWS Signature against the JWS Signing Input 770 ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || 771 BASE64URL(JWS Payload)) in the manner defined for the algorithm 772 being used, which MUST be accurately represented by the value of 773 the "alg" (algorithm) Header Parameter, which MUST be present. 774 See Section 10.6 for security considerations on algorithm 775 validation. Record whether the validation succeeded or not. 777 9. If the JWS JSON Serialization is being used, repeat this process 778 (steps 4-8) for each digital signature or MAC value contained in 779 the representation. 781 10. If none of the validations in step 9 succeeded, then the JWS 782 MUST be considered invalid. Otherwise, in the JWS JSON 783 Serialization case, return a result to the application 784 indicating which of the validations succeeded and failed. In 785 the JWS Compact Serialization case, the result can simply 786 indicate whether or not the JWS was successfully validated. 788 Finally, note that it is an application decision which algorithms may 789 be used in a given context. Even if a JWS can be successfully 790 validated, unless the algorithm(s) used in the JWS are acceptable to 791 the application, it SHOULD consider the JWS to be invalid. 793 5.3. String Comparison Rules 795 Processing a JWS inevitably requires comparing known strings to 796 members and values in JSON objects. For example, in checking what 797 the algorithm is, the Unicode string "alg" will be checked against 798 the member names in the JOSE Header to see if there is a matching 799 Header Parameter name. The same process is then used to determine if 800 the value of the "alg" Header Parameter represents a supported 801 algorithm. 803 The JSON rules for doing member name comparison are described in 804 Section 8.3 of RFC 7159 [RFC7159]. Since the only string comparison 805 operations that are performed are equality and inequality, the same 806 rules can be used for comparing both member names and member values 807 against known strings. 809 These comparison rules MUST be used for all JSON string comparisons 810 except in cases where the definition of the member explicitly calls 811 out that a different comparison rule is to be used for that member 812 value. Only the "typ" and "cty" member values defined in this 813 specification do not use these comparison rules. 815 Some applications may include case-insensitive information in a case- 816 sensitive value, such as including a DNS name as part of a "kid" (key 817 ID) value. In those cases, the application may need to define a 818 convention for the canonical case to use for representing the case- 819 insensitive portions, such as lowercasing them, if more than one 820 party might need to produce the same value so that they can be 821 compared. (However if all other parties consume whatever value the 822 producing party emitted verbatim without attempting to compare it to 823 an independently produced value, then the case used by the producer 824 will not matter.) 826 Also, see the JSON security considerations in Section 10.12 and the 827 Unicode security considerations in Section 10.13. 829 6. Key Identification 831 It is necessary for the recipient of a JWS to be able to determine 832 the key that was employed for the digital signature or MAC operation. 833 The key employed can be identified using the Header Parameter methods 834 described in Section 4.1 or can be identified using methods that are 835 outside the scope of this specification. Specifically, the Header 836 Parameters "jku", "jwk", "kid", "x5u", "x5c", "x5t", and "x5t#S256" 837 can be used to identify the key used. These Header Parameters MUST 838 be integrity protected if the information that they convey is to be 839 utilized in a trust decision; however, if the only information used 840 in the trust decision is a key, these parameters need not be 841 integrity protected, since changing them in a way that causes a 842 different key to be used will cause the validation to fail. 844 The producer SHOULD include sufficient information in the Header 845 Parameters to identify the key used, unless the application uses 846 another means or convention to determine the key used. Validation of 847 the signature or MAC fails when the algorithm used requires a key 848 (which is true of all algorithms except for "none") and the key used 849 cannot be determined. 851 The means of exchanging any shared symmetric keys used is outside the 852 scope of this specification. 854 Also, see Appendix D for notes on possible key selection algorithms. 856 7. Serializations 858 JWSs use one of two serializations: the JWS Compact Serialization or 859 the JWS JSON Serialization. Applications using this specification 860 need to specify what serialization and serialization features are 861 used for that application. For instance, applications might specify 862 that only the JWS JSON Serialization is used, that only JWS JSON 863 Serialization support for a single signature or MAC value is used, or 864 that support for multiple signatures and/or MAC values is used. JWS 865 implementations only need to implement the features needed for the 866 applications they are designed to support. 868 7.1. JWS Compact Serialization 870 The JWS Compact Serialization represents digitally signed or MACed 871 content as a compact, URL-safe string. This string is: 873 BASE64URL(UTF8(JWS Protected Header)) || '.' || 874 BASE64URL(JWS Payload) || '.' || 875 BASE64URL(JWS Signature) 877 Only one signature/MAC is supported by the JWS Compact Serialization 878 and it provides no syntax to represent a JWS Unprotected Header 879 value. 881 7.2. JWS JSON Serialization 883 The JWS JSON Serialization represents digitally signed or MACed 884 content as a JSON object. This representation is neither optimized 885 for compactness nor URL-safe. 887 Two closely related syntaxes are defined for the JWS JSON 888 Serialization: a fully general syntax, with which content can be 889 secured with more than one digital signature and/or MAC operation, 890 and a flattened syntax, which is optimized for the single digital 891 signature or MAC case. 893 7.2.1. General JWS JSON Serialization Syntax 895 The following members are defined for use in top-level JSON objects 896 used for the fully general JWS JSON Serialization syntax: 898 payload 899 The "payload" member MUST be present and contain the value 900 BASE64URL(JWS Payload). 902 signatures 903 The "signatures" member value MUST be an array of JSON objects. 904 Each object represents a signature or MAC over the JWS Payload and 905 the JWS Protected Header. 907 The following members are defined for use in the JSON objects that 908 are elements of the "signatures" array: 910 protected 911 The "protected" member MUST be present and contain the value 912 BASE64URL(UTF8(JWS Protected Header)) when the JWS Protected 913 Header value is non-empty; otherwise, it MUST be absent. These 914 Header Parameter values are integrity protected. 916 header 917 The "header" member MUST be present and contain the value JWS 918 Unprotected Header when the JWS Unprotected Header value is non- 919 empty; otherwise, it MUST be absent. This value is represented as 920 an unencoded JSON object, rather than as a string. These Header 921 Parameter values are not integrity protected. 923 signature 924 The "signature" member MUST be present and contain the value 925 BASE64URL(JWS Signature). 927 At least one of the "protected" and "header" members MUST be present 928 for each signature/MAC computation so that an "alg" Header Parameter 929 value is conveyed. 931 Additional members can be present in both the JSON objects defined 932 above; if not understood by implementations encountering them, they 933 MUST be ignored. 935 The Header Parameter values used when creating or validating 936 individual signature or MAC values are the union of the two sets of 937 Header Parameter values that may be present: (1) the JWS Protected 938 Header represented in the "protected" member of the signature/MAC's 939 array element, and (2) the JWS Unprotected Header in the "header" 940 member of the signature/MAC's array element. The union of these sets 941 of Header Parameters comprises the JOSE Header. The Header Parameter 942 names in the two locations MUST be disjoint. 944 Each JWS Signature value is computed using the parameters of the 945 corresponding JOSE Header value in the same manner as for the JWS 946 Compact Serialization. This has the desirable property that each JWS 947 Signature value represented in the "signatures" array is identical to 948 the value that would have been computed for the same parameter in the 949 JWS Compact Serialization, provided that the JWS Protected Header 950 value for that signature/MAC computation (which represents the 951 integrity protected Header Parameter values) matches that used in the 952 JWS Compact Serialization. 954 In summary, the syntax of a JWS using the general JWS JSON 955 Serialization is as follows: 957 { 958 "payload":"", 959 "signatures":[ 960 {"protected":"", 961 "header":, 962 "signature":""}, 963 ... 964 {"protected":"", 965 "header":, 966 "signature":""}] 967 } 969 See Appendix A.6 for an example JWS using the general JWS JSON 970 Serialization syntax. 972 7.2.2. Flattened JWS JSON Serialization Syntax 974 The flattened JWS JSON Serialization syntax is based upon the general 975 syntax, but flattens it, optimizing it for the single digital 976 signature/MAC case. It flattens it by removing the "signatures" 977 member and instead placing those members defined for use in the 978 "signatures" array (the "protected", "header", and "signature" 979 members) in the top-level JSON object (at the same level as the 980 "payload" member). 982 The "signatures" member MUST NOT be present when using this syntax. 983 Other than this syntax difference, JWS JSON Serialization objects 984 using the flattened syntax are processed identically to those using 985 the general syntax. 987 In summary, the syntax of a JWS using the flattened JWS JSON 988 Serialization is as follows: 990 { 991 "payload":"", 992 "protected":"", 993 "header":, 994 "signature":"" 995 } 997 See Appendix A.7 for an example JWS using the flattened JWS JSON 998 Serialization syntax. 1000 8. TLS Requirements 1002 Implementations supporting the "jku" and/or "x5u" Header Parameters 1003 MUST support TLS. Which TLS version(s) ought to be implemented will 1004 vary over time, and depend on the widespread deployment and known 1005 security vulnerabilities at the time of implementation. At the time 1006 of this writing, TLS version 1.2 [RFC5246] is the most recent 1007 version. 1009 To protect against information disclosure and tampering, 1010 confidentiality protection MUST be applied using TLS with a 1011 ciphersuite that provides confidentiality and integrity protection. 1012 See current publications by the IETF TLS working group, including RFC 1013 6176 [RFC6176], for guidance on the ciphersuites currently considered 1014 to be appropriate for use. Also, see Recommendations for Secure Use 1015 of TLS and DTLS [I-D.ietf-uta-tls-bcp] for recommendations on 1016 improving the security of software and services using TLS. 1018 Whenever TLS is used, the identity of the service provider encoded in 1019 the TLS server certificate MUST be verified using the procedures 1020 described in Section 6 of RFC 6125 [RFC6125]. 1022 9. IANA Considerations 1024 The following registration procedure is used for all the registries 1025 established by this specification. 1027 Values are registered on a Specification Required [RFC5226] basis 1028 after a three-week review period on the jose-reg-review@ietf.org 1029 mailing list, on the advice of one or more Designated Experts. 1030 However, to allow for the allocation of values prior to publication, 1031 the Designated Expert(s) may approve registration once they are 1032 satisfied that such a specification will be published. 1034 Registration requests must be sent to the jose-reg-review@ietf.org 1035 mailing list for review and comment, with an appropriate subject 1036 (e.g., "Request to register header parameter: example"). 1038 Within the review period, the Designated Expert(s) will either 1039 approve or deny the registration request, communicating this decision 1040 to the review list and IANA. Denials should include an explanation 1041 and, if applicable, suggestions as to how to make the request 1042 successful. Registration requests that are undetermined for a period 1043 longer than 21 days can be brought to the IESG's attention (using the 1044 iesg@ietf.org mailing list) for resolution. 1046 Criteria that should be applied by the Designated Expert(s) includes 1047 determining whether the proposed registration duplicates existing 1048 functionality, determining whether it is likely to be of general 1049 applicability or whether it is useful only for a single application, 1050 and whether the registration description is clear. 1052 IANA must only accept registry updates from the Designated Expert(s) 1053 and should direct all requests for registration to the review mailing 1054 list. 1056 It is suggested that multiple Designated Experts be appointed who are 1057 able to represent the perspectives of different applications using 1058 this specification, in order to enable broadly-informed review of 1059 registration decisions. In cases where a registration decision could 1060 be perceived as creating a conflict of interest for a particular 1061 Expert, that Expert should defer to the judgment of the other 1062 Expert(s). 1064 [[ Note to the RFC Editor and IANA: Pearl Liang of ICANN had 1065 requested that the draft supply the following proposed registry 1066 description information. It is to be used for all registries 1067 established by this specification. 1069 o Protocol Category: JSON Object Signing and Encryption (JOSE) 1071 o Registry Location: http://www.iana.org/assignments/jose 1073 o Webpage Title: (same as the protocol category) 1075 o Registry Name: (same as the section title, but excluding the word 1076 "Registry", for example "JSON Web Signature and Encryption Header 1077 Parameters") 1079 ]] 1081 9.1. JSON Web Signature and Encryption Header Parameters Registry 1083 This specification establishes the IANA JSON Web Signature and 1084 Encryption Header Parameters registry for Header Parameter names. 1085 The registry records the Header Parameter name and a reference to the 1086 specification that defines it. The same Header Parameter name can be 1087 registered multiple times, provided that the parameter usage is 1088 compatible between the specifications. Different registrations of 1089 the same Header Parameter name will typically use different Header 1090 Parameter Usage Location(s) values. 1092 9.1.1. Registration Template 1094 Header Parameter Name: 1095 The name requested (e.g., "kid"). Because a core goal of this 1096 specification is for the resulting representations to be compact, 1097 it is RECOMMENDED that the name be short -- not to exceed 8 1098 characters without a compelling reason to do so. This name is 1099 case-sensitive. Names may not match other registered names in a 1100 case-insensitive manner unless the Designated Expert(s) state that 1101 there is a compelling reason to allow an exception in this 1102 particular case. 1104 Header Parameter Description: 1105 Brief description of the Header Parameter (e.g., "Key ID"). 1107 Header Parameter Usage Location(s): 1108 The Header Parameter usage locations, which should be one or more 1109 of the values "JWS" or "JWE". 1111 Change Controller: 1112 For Standards Track RFCs, state "IESG". For others, give the name 1113 of the responsible party. Other details (e.g., postal address, 1114 email address, home page URI) may also be included. 1116 Specification Document(s): 1117 Reference to the document(s) that specify the parameter, 1118 preferably including URI(s) that can be used to retrieve copies of 1119 the document(s). An indication of the relevant sections may also 1120 be included but is not required. 1122 9.1.2. Initial Registry Contents 1124 This specification registers the Header Parameter names defined in 1125 Section 4.1 in this registry. 1127 o Header Parameter Name: "alg" 1128 o Header Parameter Description: Algorithm 1129 o Header Parameter Usage Location(s): JWS 1130 o Change Controller: IESG 1131 o Specification Document(s): Section 4.1.1 of [[ this document ]] 1133 o Header Parameter Name: "jku" 1134 o Header Parameter Description: JWK Set URL 1135 o Header Parameter Usage Location(s): JWS 1136 o Change Controller: IESG 1137 o Specification Document(s): Section 4.1.2 of [[ this document ]] 1138 o Header Parameter Name: "jwk" 1139 o Header Parameter Description: JSON Web Key 1140 o Header Parameter Usage Location(s): JWS 1141 o Change Controller: IESG 1142 o Specification document(s): Section 4.1.3 of [[ this document ]] 1144 o Header Parameter Name: "kid" 1145 o Header Parameter Description: Key ID 1146 o Header Parameter Usage Location(s): JWS 1147 o Change Controller: IESG 1148 o Specification Document(s): Section 4.1.4 of [[ this document ]] 1150 o Header Parameter Name: "x5u" 1151 o Header Parameter Description: X.509 URL 1152 o Header Parameter Usage Location(s): JWS 1153 o Change Controller: IESG 1154 o Specification Document(s): Section 4.1.5 of [[ this document ]] 1156 o Header Parameter Name: "x5c" 1157 o Header Parameter Description: X.509 Certificate Chain 1158 o Header Parameter Usage Location(s): JWS 1159 o Change Controller: IESG 1160 o Specification Document(s): Section 4.1.6 of [[ this document ]] 1162 o Header Parameter Name: "x5t" 1163 o Header Parameter Description: X.509 Certificate SHA-1 Thumbprint 1164 o Header Parameter Usage Location(s): JWS 1165 o Change Controller: IESG 1166 o Specification Document(s): Section 4.1.7 of [[ this document ]] 1168 o Header Parameter Name: "x5t#S256" 1169 o Header Parameter Description: X.509 Certificate SHA-256 Thumbprint 1170 o Header Parameter Usage Location(s): JWS 1171 o Change Controller: IESG 1172 o Specification Document(s): Section 4.1.8 of [[ this document ]] 1174 o Header Parameter Name: "typ" 1175 o Header Parameter Description: Type 1176 o Header Parameter Usage Location(s): JWS 1177 o Change Controller: IESG 1178 o Specification Document(s): Section 4.1.9 of [[ this document ]] 1180 o Header Parameter Name: "cty" 1181 o Header Parameter Description: Content Type 1182 o Header Parameter Usage Location(s): JWS 1183 o Change Controller: IESG 1184 o Specification Document(s): Section 4.1.10 of [[ this document ]] 1186 o Header Parameter Name: "crit" 1187 o Header Parameter Description: Critical 1188 o Header Parameter Usage Location(s): JWS 1189 o Change Controller: IESG 1190 o Specification Document(s): Section 4.1.11 of [[ this document ]] 1192 9.2. Media Type Registration 1194 9.2.1. Registry Contents 1196 This specification registers the "application/jose" Media Type 1197 [RFC2046] in the MIME Media Types registry [IANA.MediaTypes] in the 1198 manner described in RFC 6838 [RFC6838], which can be used to indicate 1199 that the content is a JWS or JWE using the JWS Compact Serialization 1200 or the JWE Compact Serialization and the "application/jose+json" 1201 Media Type in the MIME Media Types registry, which can be used to 1202 indicate that the content is a JWS or JWE using the JWS JSON 1203 Serialization or the JWE JSON Serialization. 1205 o Type name: application 1206 o Subtype name: jose 1207 o Required parameters: n/a 1208 o Optional parameters: n/a 1209 o Encoding considerations: 8bit; application/jose values are encoded 1210 as a series of base64url encoded values (some of which may be the 1211 empty string) each separated from the next by a single period 1212 ('.') character. 1213 o Security considerations: See the Security Considerations section 1214 of [[ this document ]] 1215 o Interoperability considerations: n/a 1216 o Published specification: [[ this document ]] 1217 o Applications that use this media type: OpenID Connect, Mozilla 1218 Persona, Salesforce, Google, Android, Windows Azure, Xbox One, 1219 Amazon Web Services, and numerous others that use JWTs 1220 o Fragment identifier considerations: n/a 1221 o Additional information: Magic number(s): n/a, File extension(s): 1222 n/a, Macintosh file type code(s): n/a 1223 o Person & email address to contact for further information: Michael 1224 B. Jones, mbj@microsoft.com 1225 o Intended usage: COMMON 1226 o Restrictions on usage: none 1227 o Author: Michael B. Jones, mbj@microsoft.com 1228 o Change Controller: IESG 1229 o Provisional registration? No 1230 o Type name: application 1231 o Subtype name: jose+json 1232 o Required parameters: n/a 1233 o Optional parameters: n/a 1234 o Encoding considerations: 8bit; application/jose+json values are 1235 represented as a JSON Object; UTF-8 encoding SHOULD be employed 1236 for the JSON object. 1237 o Security considerations: See the Security Considerations section 1238 of [[ this document ]] 1239 o Interoperability considerations: n/a 1240 o Published specification: [[ this document ]] 1241 o Applications that use this media type: TBD 1242 o Fragment identifier considerations: n/a 1243 o Additional information: Magic number(s): n/a, File extension(s): 1244 n/a, Macintosh file type code(s): n/a 1245 o Person & email address to contact for further information: Michael 1246 B. Jones, mbj@microsoft.com 1247 o Intended usage: COMMON 1248 o Restrictions on usage: none 1249 o Author: Michael B. Jones, mbj@microsoft.com 1250 o Change Controller: IESG 1251 o Provisional registration? No 1253 10. Security Considerations 1255 All of the security issues that are pertinent to any cryptographic 1256 application must be addressed by JWS/JWE/JWK agents. Among these 1257 issues are protecting the user's asymmetric private and symmetric 1258 secret keys and employing countermeasures to various attacks. 1260 All the security considerations in XML DSIG 2.0 1261 [W3C.NOTE-xmldsig-core2-20130411], also apply to this specification, 1262 other than those that are XML specific. Likewise, many of the best 1263 practices documented in XML Signature Best Practices 1264 [W3C.NOTE-xmldsig-bestpractices-20130411] also apply to this 1265 specification, other than those that are XML specific. 1267 10.1. Key Entropy and Random Values 1269 Keys are only as strong as the amount of entropy used to generate 1270 them. A minimum of 128 bits of entropy should be used for all keys, 1271 and depending upon the application context, more may be required. 1273 Implementations must randomly generate public/private key pairs, 1274 message authentication (MAC) keys, and padding values. The use of 1275 inadequate pseudo-random number generators (PRNGs) to generate 1276 cryptographic keys can result in little or no security. An attacker 1277 may find it much easier to reproduce the PRNG environment that 1278 produced the keys, searching the resulting small set of 1279 possibilities, rather than brute force searching the whole key space. 1280 The generation of quality random numbers is difficult. RFC 4086 1281 [RFC4086] offers important guidance in this area. 1283 10.2. Key Protection 1285 Implementations must protect the signer's private key. Compromise of 1286 the signer's private key permits an attacker to masquerade as the 1287 signer. 1289 Implementations must protect the message authentication (MAC) key. 1290 Compromise of the MAC key may result in undetectable modification of 1291 the authenticated content. 1293 10.3. Key Origin Authentication 1295 The key management technique employed to obtain public keys must 1296 authenticate the origin of the key; otherwise, it is unknown what 1297 party signed the message. 1299 Likewise, the key management technique employed to distribute MAC 1300 keys must provide data origin authentication; otherwise, the contents 1301 are delivered with integrity from an unknown source. 1303 10.4. Cryptographic Agility 1305 See Section 8.1 of [JWA] for security considerations on cryptographic 1306 agility. 1308 10.5. Differences between Digital Signatures and MACs 1310 While MACs and digital signatures can both be used for integrity 1311 checking, there are some significant differences between the security 1312 properties that each of them provides. These need to be taken into 1313 consideration when designing protocols and selecting the algorithms 1314 to be used in protocols. 1316 Both signatures and MACs provide for integrity checking -- verifying 1317 that the message has not been modified since the integrity value was 1318 computed. However, MACs provide for origination identification only 1319 under specific circumstances. It can normally be assumed that a 1320 private key used for a signature is only in the hands of a single 1321 entity (although perhaps a distributed entity, in the case of 1322 replicated servers); however, a MAC key needs to be in the hands of 1323 all the entities that use it for integrity computation and checking. 1324 Validation of a MAC only provides corroboration that the message was 1325 generated by one of the parties that knows the symmetric MAC key. 1326 This means that origination can only be determined if a MAC key is 1327 known only to two entities and the recipient knows that it did not 1328 create the message. MAC validation cannot be used to prove 1329 origination to a third party. 1331 10.6. Algorithm Validation 1333 The digital signature representations for some algorithms include 1334 information about the algorithm used inside the signature value. For 1335 instance, signatures produced with RSASSA-PKCS-v1_5 [RFC3447] encode 1336 the hash function used and many libraries actually use the hash 1337 algorithm specified inside the signature when validating the 1338 signature. When using such libraries, as part of the algorithm 1339 validation performed, implementations MUST ensure that the algorithm 1340 information encoded in the signature corresponds to that specified 1341 with the "alg" Header Parameter. If this is not done, an attacker 1342 could claim to have used a strong hash algorithm while actually using 1343 a weak one represented in the signature value. 1345 10.7. Algorithm Protection 1347 In some usages of JWS, there is a risk of algorithm substitution 1348 attacks, in which an attacker can use an existing digital signature 1349 value with a different signature algorithm to make it appear that a 1350 signer has signed something that it has not. These attacks have been 1351 discussed in detail in the context of CMS [RFC6211]. This risk 1352 arises when all of the following are true: 1354 o Verifiers of a signature support multiple algorithms. 1356 o Given an existing signature, an attacker can find another payload 1357 that produces the same signature value with a different algorithm. 1359 o The payload crafted by the attacker is valid in the application 1360 context. 1362 There are several ways for an application to mitigate algorithm 1363 substitution attacks: 1365 o Use only digital signature algorithms that are not vulnerable to 1366 substitution attacks. Substitution attacks are only feasible if 1367 an attacker can compute pre-images for a hash function accepted by 1368 the recipient. All JWA-defined signature algorithms use SHA-2 1369 hashes, for which there are no known pre-image attacks, as of the 1370 time of this writing. 1372 o Require that the "alg" Header Parameter be carried in the 1373 protected header. (This is always the case when using the JWS 1374 Compact Serialization and is the approach taken by CMS [RFC6211].) 1376 o Include a field containing the algorithm in the application 1377 payload, and require that it be matched with the "alg" Header 1378 Parameter during verification. (This is the approach taken by 1379 PKIX [RFC5280].) 1381 10.8. Chosen Plaintext Attacks 1383 Creators of JWSs should not allow third parties to insert arbitrary 1384 content into the message without adding entropy not controlled by the 1385 third party. 1387 10.9. Timing Attacks 1389 When cryptographic algorithms are implemented in such a way that 1390 successful operations take a different amount of time than 1391 unsuccessful operations, attackers may be able to use the time 1392 difference to obtain information about the keys employed. Therefore, 1393 such timing differences must be avoided. 1395 10.10. Replay Protection 1397 While not directly in scope for this specification, note that 1398 applications using JWS (or JWE) objects can thwart replay attacks by 1399 including a unique message identifier as integrity protected content 1400 in the JWS (or JWE) message and having the recipient verify that the 1401 message has not been previously received or acted upon. 1403 10.11. SHA-1 Certificate Thumbprints 1405 A SHA-1 hash is used when computing "x5t" (X.509 Certificate SHA-1 1406 Thumbprint) values, for compatibility reasons. Should an effective 1407 means of producing SHA-1 hash collisions be developed, and should an 1408 attacker wish to interfere with the use of a known certificate on a 1409 given system, this could be accomplished by creating another 1410 certificate whose SHA-1 hash value is the same and adding it to the 1411 certificate store used by the intended victim. A prerequisite to 1412 this attack succeeding is the attacker having write access to the 1413 intended victim's certificate store. 1415 Alternatively, the "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) 1416 Header Parameter could be used instead of "x5t". However, at the 1417 time of this writing, no development platform is known to support 1418 SHA-256 certificate thumbprints. 1420 10.12. JSON Security Considerations 1422 Strict JSON [RFC7159] validation is a security requirement. If 1423 malformed JSON is received, then the intent of the producer is 1424 impossible to reliably discern. Ambiguous and potentially 1425 exploitable situations could arise if the JSON parser used does not 1426 reject malformed JSON syntax. In particular, any JSON inputs not 1427 conforming to the JSON-text syntax defined in RFC 7159 input MUST be 1428 rejected in their entirety by JSON parsers. 1430 Section 4 of the JSON Data Interchange Format specification [RFC7159] 1431 states "The names within an object SHOULD be unique", whereas this 1432 specification states that "Header Parameter names within this object 1433 MUST be unique; JWS parsers MUST either reject JWSs with duplicate 1434 Header Parameter names or use a JSON parser that returns only the 1435 lexically last duplicate member name, as specified in Section 15.12 1436 (The JSON Object) of ECMAScript 5.1 [ECMAScript]". Thus, this 1437 specification requires that the Section 4 "SHOULD" be treated as a 1438 "MUST" by producers and that it be either treated as a "MUST" or in 1439 the manner specified in ECMAScript 5.1 by consumers. Ambiguous and 1440 potentially exploitable situations could arise if the JSON parser 1441 used does not enforce the uniqueness of member names or returns an 1442 unpredictable value for duplicate member names. 1444 Some JSON parsers might not reject input that contains extra 1445 significant characters after a valid input. For instance, the input 1446 "{"tag":"value"}ABCD" contains a valid JSON-text object followed by 1447 the extra characters "ABCD". Such input MUST be rejected in its 1448 entirety. 1450 10.13. Unicode Comparison Security Considerations 1452 Header Parameter names and algorithm names are Unicode strings. For 1453 security reasons, the representations of these names must be compared 1454 verbatim after performing any escape processing (as per Section 8.3 1455 of RFC 7159 [RFC7159]). This means, for instance, that these JSON 1456 strings must compare as being equal ("sig", "\u0073ig"), whereas 1457 these must all compare as being not equal to the first set or to each 1458 other ("SIG", "Sig", "si\u0047"). 1460 JSON strings can contain characters outside the Unicode Basic 1461 Multilingual Plane. For instance, the G clef character (U+1D11E) may 1462 be represented in a JSON string as "\uD834\uDD1E". Ideally, JWS 1463 implementations SHOULD ensure that characters outside the Basic 1464 Multilingual Plane are preserved and compared correctly; 1465 alternatively, if this is not possible due to these characters 1466 exercising limitations present in the underlying JSON implementation, 1467 then input containing them MUST be rejected. 1469 11. References 1471 11.1. Normative References 1473 [ECMAScript] 1474 Ecma International, "ECMAScript Language Specification, 1475 5.1 Edition", ECMA 262, June 2011. 1477 [IANA.MediaTypes] 1478 Internet Assigned Numbers Authority (IANA), "MIME Media 1479 Types", 2005. 1481 [ITU.X690.1994] 1482 International Telecommunications Union, "Information 1483 Technology - ASN.1 encoding rules: Specification of Basic 1484 Encoding Rules (BER), Canonical Encoding Rules (CER) and 1485 Distinguished Encoding Rules (DER)", ITU-T Recommendation 1486 X.690, 1994. 1488 [JWA] Jones, M., "JSON Web Algorithms (JWA)", 1489 draft-ietf-jose-json-web-algorithms (work in progress), 1490 January 2015. 1492 [JWK] Jones, M., "JSON Web Key (JWK)", 1493 draft-ietf-jose-json-web-key (work in progress), 1494 January 2015. 1496 [RFC20] Cerf, V., "ASCII format for Network Interchange", RFC 20, 1497 October 1969. 1499 [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1500 Extensions (MIME) Part One: Format of Internet Message 1501 Bodies", RFC 2045, November 1996. 1503 [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail 1504 Extensions (MIME) Part Two: Media Types", RFC 2046, 1505 November 1996. 1507 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1508 Requirement Levels", BCP 14, RFC 2119, March 1997. 1510 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 1512 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 1513 10646", STD 63, RFC 3629, November 2003. 1515 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1516 Resource Identifier (URI): Generic Syntax", STD 66, 1517 RFC 3986, January 2005. 1519 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 1520 Encodings", RFC 4648, October 2006. 1522 [RFC4945] Korver, B., "The Internet IP Security PKI Profile of 1523 IKEv1/ISAKMP, IKEv2, and PKIX", RFC 4945, August 2007. 1525 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2", 1526 RFC 4949, August 2007. 1528 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 1529 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 1531 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1532 Housley, R., and W. Polk, "Internet X.509 Public Key 1533 Infrastructure Certificate and Certificate Revocation List 1534 (CRL) Profile", RFC 5280, May 2008. 1536 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 1537 Verification of Domain-Based Application Service Identity 1538 within Internet Public Key Infrastructure Using X.509 1539 (PKIX) Certificates in the Context of Transport Layer 1540 Security (TLS)", RFC 6125, March 2011. 1542 [RFC6176] Turner, S. and T. Polk, "Prohibiting Secure Sockets Layer 1543 (SSL) Version 2.0", RFC 6176, March 2011. 1545 [RFC7159] Bray, T., "The JavaScript Object Notation (JSON) Data 1546 Interchange Format", RFC 7159, March 2014. 1548 [UNICODE] The Unicode Consortium, "The Unicode Standard", 1991-, 1549 . 1551 11.2. Informative References 1553 [CanvasApp] 1554 Facebook, "Canvas Applications", 2010. 1556 [I-D.ietf-uta-tls-bcp] 1557 Sheffer, Y., Holz, R., and P. Saint-Andre, 1558 "Recommendations for Secure Use of TLS and DTLS", 1559 draft-ietf-uta-tls-bcp-08 (work in progress), 1560 December 2014. 1562 [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", 1563 September 2010. 1565 [JWE] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)", 1566 draft-ietf-jose-json-web-encryption (work in progress), 1567 January 2015. 1569 [JWT] Jones, M., Bradley, J., and N. Sakimura, "JSON Web Token 1570 (JWT)", draft-ietf-oauth-json-web-token (work in 1571 progress), December 2014. 1573 [MagicSignatures] 1574 Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic 1575 Signatures", January 2011. 1577 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 1578 Hashing for Message Authentication", RFC 2104, 1579 February 1997. 1581 [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography 1582 Standards (PKCS) #1: RSA Cryptography Specifications 1583 Version 2.1", RFC 3447, February 2003. 1585 [RFC4086] Eastlake, D., Schiller, J., and S. Crocker, "Randomness 1586 Requirements for Security", BCP 106, RFC 4086, June 2005. 1588 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 1589 Unique IDentifier (UUID) URN Namespace", RFC 4122, 1590 July 2005. 1592 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 1593 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 1594 May 2008. 1596 [RFC6211] Schaad, J., "Cryptographic Message Syntax (CMS) Algorithm 1597 Identifier Protection Attribute", RFC 6211, April 2011. 1599 [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type 1600 Specifications and Registration Procedures", BCP 13, 1601 RFC 6838, January 2013. 1603 [SHS] National Institute of Standards and Technology, "Secure 1604 Hash Standard (SHS)", FIPS PUB 180-4, March 2012. 1606 [W3C.NOTE-xmldsig-bestpractices-20130411] 1607 Hirsch, F. and P. Datta, "XML Signature Best Practices", 1608 World Wide Web Consortium Note NOTE-xmldsig-bestpractices- 1609 20130411, April 2013, . 1612 [W3C.NOTE-xmldsig-core2-20130411] 1613 Eastlake, D., Reagle, J., Solo, D., Hirsch, F., Roessler, 1614 T., Yiu, K., Datta, P., and S. Cantor, "XML Signature 1615 Syntax and Processing Version 2.0", World Wide Web 1616 Consortium Note NOTE-xmldsig-core2-20130411, April 2013, 1617 . 1619 Appendix A. JWS Examples 1621 This section provides several examples of JWSs. While the first 1622 three examples all represent JSON Web Tokens (JWTs) [JWT], the 1623 payload can be any octet sequence, as shown in Appendix A.4. 1625 A.1. Example JWS using HMAC SHA-256 1627 A.1.1. Encoding 1629 The following example JWS Protected Header declares that the data 1630 structure is a JSON Web Token (JWT) [JWT] and the JWS Signing Input 1631 is secured using the HMAC SHA-256 algorithm. 1633 {"typ":"JWT", 1634 "alg":"HS256"} 1636 To remove potential ambiguities in the representation of the JSON 1637 object above, the actual octet sequence representing UTF8(JWS 1638 Protected Header) used in this example is also included below. (Note 1639 that ambiguities can arise due to differing platform representations 1640 of line breaks (CRLF versus LF), differing spacing at the beginning 1641 and ends of lines, whether the last line has a terminating line break 1642 or not, and other causes. In the representation used in this 1643 example, the first line has no leading or trailing spaces, a CRLF 1644 line break (13, 10) occurs between the first and second lines, the 1645 second line has one leading space (32) and no trailing spaces, and 1646 the last line does not have a terminating line break.) The octets 1647 representing UTF8(JWS Protected Header) in this example (using JSON 1648 array notation) are: 1650 [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, 1651 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] 1653 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1654 Header)) gives this value: 1656 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1658 The JWS Payload used in this example is the octets of the UTF-8 1659 representation of the JSON object below. (Note that the payload can 1660 be any base64url encoded octet sequence, and need not be a base64url 1661 encoded JSON object.) 1663 {"iss":"joe", 1664 "exp":1300819380, 1665 "http://example.com/is_root":true} 1667 The following octet sequence, which is the UTF-8 representation used 1668 in this example for the JSON object above, is the JWS Payload: 1670 [123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, 1671 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, 1672 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, 1673 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, 1674 111, 116, 34, 58, 116, 114, 117, 101, 125] 1676 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1677 Header)) gives this value (with line breaks for display purposes 1678 only): 1680 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1681 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1683 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1684 BASE64URL(JWS Payload) gives this string (with line breaks for 1685 display purposes only): 1687 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1688 . 1689 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1690 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1692 The resulting JWS Signing Input value, which is the ASCII 1693 representation of above string, is the following octet sequence 1694 (using JSON array notation): 1696 [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, 1697 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, 1698 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 1699 77, 105, 79, 105, 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 1700 74, 108, 101, 72, 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 1701 107, 122, 79, 68, 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 1702 72, 65, 54, 76, 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 1703 109, 78, 118, 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 1704 106, 112, 48, 99, 110, 86, 108, 102, 81] 1706 HMACs are generated using keys. This example uses the symmetric key 1707 represented in JSON Web Key [JWK] format below (with line breaks 1708 within values for display purposes only): 1710 {"kty":"oct", 1711 "k":"AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75 1712 aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow" 1713 } 1715 Running the HMAC SHA-256 algorithm on the JWS Signing Input with this 1716 key yields this JWS Signature octet sequence: 1718 [116, 24, 223, 180, 151, 153, 224, 37, 79, 250, 96, 125, 216, 173, 1719 187, 186, 22, 212, 37, 77, 105, 214, 191, 240, 91, 88, 5, 88, 83, 1720 132, 141, 121] 1722 Encoding this JWS Signature as BASE64URL(JWS Signature) gives this 1723 value: 1725 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1727 Concatenating these values in the order Header.Payload.Signature with 1728 period ('.') characters between the parts yields this complete JWS 1729 representation using the JWS Compact Serialization (with line breaks 1730 for display purposes only): 1732 eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 1733 . 1734 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1735 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1736 . 1737 dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk 1739 A.1.2. Validating 1741 Since the "alg" Header Parameter is "HS256", we validate the HMAC 1742 SHA-256 value contained in the JWS Signature. 1744 To validate the HMAC value, we repeat the previous process of using 1745 the correct key and the JWS Signing Input (which is the initial 1746 substring of the JWS Compact Serialization representation up until 1747 but not including the second period character) as input to the HMAC 1748 SHA-256 function and then taking the output and determining if it 1749 matches the JWS Signature (which is base64url decoded from the value 1750 encoded in the JWS representation). If it matches exactly, the HMAC 1751 has been validated. 1753 A.2. Example JWS using RSASSA-PKCS-v1_5 SHA-256 1755 A.2.1. Encoding 1757 The JWS Protected Header in this example is different from the 1758 previous example in two ways: First, because a different algorithm is 1759 being used, the "alg" value is different. Second, for illustration 1760 purposes only, the optional "typ" parameter is not used. (This 1761 difference is not related to the algorithm employed.) The JWS 1762 Protected Header used is: 1764 {"alg":"RS256"} 1766 The octets representing UTF8(JWS Protected Header) in this example 1767 (using JSON array notation) are: 1769 [123, 34, 97, 108, 103, 34, 58, 34, 82, 83, 50, 53, 54, 34, 125] 1771 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1772 Header)) gives this value: 1774 eyJhbGciOiJSUzI1NiJ9 1776 The JWS Payload used in this example, which follows, is the same as 1777 in the previous example. Since the BASE64URL(JWS Payload) value will 1778 therefore be the same, its computation is not repeated here. 1780 {"iss":"joe", 1781 "exp":1300819380, 1782 "http://example.com/is_root":true} 1784 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1785 BASE64URL(JWS Payload) gives this string (with line breaks for 1786 display purposes only): 1788 eyJhbGciOiJSUzI1NiJ9 1789 . 1790 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1791 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1793 The resulting JWS Signing Input value, which is the ASCII 1794 representation of above string, is the following octet sequence: 1796 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73, 1797 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1798 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1799 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1800 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1801 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1802 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1803 99, 110, 86, 108, 102, 81] 1805 This example uses the RSA key represented in JSON Web Key [JWK] 1806 format below (with line breaks within values for display purposes 1807 only): 1809 {"kty":"RSA", 1810 "n":"ofgWCuLjybRlzo0tZWJjNiuSfb4p4fAkd_wWJcyQoTbji9k0l8W26mPddx 1811 HmfHQp-Vaw-4qPCJrcS2mJPMEzP1Pt0Bm4d4QlL-yRT-SFd2lZS-pCgNMs 1812 D1W_YpRPEwOWvG6b32690r2jZ47soMZo9wGzjb_7OMg0LOL-bSf63kpaSH 1813 SXndS5z5rexMdbBYUsLA9e-KXBdQOS-UTo7WTBEMa2R2CapHg665xsmtdV 1814 MTBQY4uDZlxvb3qCo5ZwKh9kG4LT6_I5IhlJH7aGhyxXFvUK-DWNmoudF8 1815 NAco9_h9iaGNj8q2ethFkMLs91kzk2PAcDTW9gb54h4FRWyuXpoQ", 1816 "e":"AQAB", 1817 "d":"Eq5xpGnNCivDflJsRQBXHx1hdR1k6Ulwe2JZD50LpXyWPEAeP88vLNO97I 1818 jlA7_GQ5sLKMgvfTeXZx9SE-7YwVol2NXOoAJe46sui395IW_GO-pWJ1O0 1819 BkTGoVEn2bKVRUCgu-GjBVaYLU6f3l9kJfFNS3E0QbVdxzubSu3Mkqzjkn 1820 439X0M_V51gfpRLI9JYanrC4D4qAdGcopV_0ZHHzQlBjudU2QvXt4ehNYT 1821 CBr6XCLQUShb1juUO1ZdiYoFaFQT5Tw8bGUl_x_jTj3ccPDVZFD9pIuhLh 1822 BOneufuBiB4cS98l2SR_RQyGWSeWjnczT0QU91p1DhOVRuOopznQ", 1823 "p":"4BzEEOtIpmVdVEZNCqS7baC4crd0pqnRH_5IB3jw3bcxGn6QLvnEtfdUdi 1824 YrqBdss1l58BQ3KhooKeQTa9AB0Hw_Py5PJdTJNPY8cQn7ouZ2KKDcmnPG 1825 BY5t7yLc1QlQ5xHdwW1VhvKn-nXqhJTBgIPgtldC-KDV5z-y2XDwGUc", 1826 "q":"uQPEfgmVtjL0Uyyx88GZFF1fOunH3-7cepKmtH4pxhtCoHqpWmT8YAmZxa 1827 ewHgHAjLYsp1ZSe7zFYHj7C6ul7TjeLQeZD_YwD66t62wDmpe_HlB-TnBA 1828 -njbglfIsRLtXlnDzQkv5dTltRJ11BKBBypeeF6689rjcJIDEz9RWdc", 1829 "dp":"BwKfV3Akq5_MFZDFZCnW-wzl-CCo83WoZvnLQwCTeDv8uzluRSnm71I3Q 1830 CLdhrqE2e9YkxvuxdBfpT_PI7Yz-FOKnu1R6HsJeDCjn12Sk3vmAktV2zb 1831 34MCdy7cpdTh_YVr7tss2u6vneTwrA86rZtu5Mbr1C1XsmvkxHQAdYo0", 1832 "dq":"h_96-mK1R_7glhsum81dZxjTnYynPbZpHziZjeeHcXYsXaaMwkOlODsWa 1833 7I9xXDoRwbKgB719rrmI2oKr6N3Do9U0ajaHF-NKJnwgjMd2w9cjz3_-ky 1834 NlxAr2v4IKhGNpmM5iIgOS1VZnOZ68m6_pbLBSp3nssTdlqvd0tIiTHU", 1835 "qi":"IYd7DHOhrWvxkwPQsRM2tOgrjbcrfvtQJipd-DlcxyVuuM9sQLdgjVk2o 1836 y26F0EmpScGLq2MowX7fhd_QJQ3ydy5cY7YIBi87w93IKLEdfnbJtoOPLU 1837 W0ITrJReOgo1cq9SbsxYawBgfp_gh6A5603k2-ZQwVK0JKSHuLFkuQ3U" 1838 } 1840 The RSA private key is then passed to the RSA signing function, which 1841 also takes the hash type, SHA-256, and the JWS Signing Input as 1842 inputs. The result of the digital signature is an octet sequence, 1843 which represents a big endian integer. In this example, it is: 1845 [112, 46, 33, 137, 67, 232, 143, 209, 30, 181, 216, 45, 191, 120, 69, 1846 243, 65, 6, 174, 27, 129, 255, 247, 115, 17, 22, 173, 209, 113, 125, 1847 131, 101, 109, 66, 10, 253, 60, 150, 238, 221, 115, 162, 102, 62, 81, 1848 102, 104, 123, 0, 11, 135, 34, 110, 1, 135, 237, 16, 115, 249, 69, 1849 229, 130, 173, 252, 239, 22, 216, 90, 121, 142, 232, 198, 109, 219, 1850 61, 184, 151, 91, 23, 208, 148, 2, 190, 237, 213, 217, 217, 112, 7, 1851 16, 141, 178, 129, 96, 213, 248, 4, 12, 167, 68, 87, 98, 184, 31, 1852 190, 127, 249, 217, 46, 10, 231, 111, 36, 242, 91, 51, 187, 230, 244, 1853 74, 230, 30, 177, 4, 10, 203, 32, 4, 77, 62, 249, 18, 142, 212, 1, 1854 48, 121, 91, 212, 189, 59, 65, 238, 202, 208, 102, 171, 101, 25, 129, 1855 253, 228, 141, 247, 127, 55, 45, 195, 139, 159, 175, 221, 59, 239, 1856 177, 139, 93, 163, 204, 60, 46, 176, 47, 158, 58, 65, 214, 18, 202, 1857 173, 21, 145, 18, 115, 160, 95, 35, 185, 232, 56, 250, 175, 132, 157, 1858 105, 132, 41, 239, 90, 30, 136, 121, 130, 54, 195, 212, 14, 96, 69, 1859 34, 165, 68, 200, 242, 122, 122, 45, 184, 6, 99, 209, 108, 247, 202, 1860 234, 86, 222, 64, 92, 178, 33, 90, 69, 178, 194, 85, 102, 181, 90, 1861 193, 167, 72, 160, 112, 223, 200, 163, 42, 70, 149, 67, 208, 25, 238, 1862 251, 71] 1864 Encoding the signature as BASE64URL(JWS Signature) produces this 1865 value (with line breaks for display purposes only): 1867 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1868 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1869 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1870 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1871 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1872 p0igcN_IoypGlUPQGe77Rw 1874 Concatenating these values in the order Header.Payload.Signature with 1875 period ('.') characters between the parts yields this complete JWS 1876 representation using the JWS Compact Serialization (with line breaks 1877 for display purposes only): 1879 eyJhbGciOiJSUzI1NiJ9 1880 . 1881 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1882 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1883 . 1884 cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7 1885 AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4 1886 BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K 1887 0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv 1888 hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB 1889 p0igcN_IoypGlUPQGe77Rw 1891 A.2.2. Validating 1893 Since the "alg" Header Parameter is "RS256", we validate the RSASSA- 1894 PKCS-v1_5 SHA-256 digital signature contained in the JWS Signature. 1896 Validating the JWS Signature is a bit different from the previous 1897 example. We pass the public key (n, e), the JWS Signature (which is 1898 base64url decoded from the value encoded in the JWS representation), 1899 and the JWS Signing Input (which is the initial substring of the JWS 1900 Compact Serialization representation up until but not including the 1901 second period character) to an RSASSA-PKCS-v1_5 signature verifier 1902 that has been configured to use the SHA-256 hash function. 1904 A.3. Example JWS using ECDSA P-256 SHA-256 1906 A.3.1. Encoding 1908 The JWS Protected Header for this example differs from the previous 1909 example because a different algorithm is being used. The JWS 1910 Protected Header used is: 1912 {"alg":"ES256"} 1914 The octets representing UTF8(JWS Protected Header) in this example 1915 (using JSON array notation) are: 1917 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 50, 53, 54, 34, 125] 1919 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 1920 Header)) gives this value: 1922 eyJhbGciOiJFUzI1NiJ9 1924 The JWS Payload used in this example, which follows, is the same as 1925 in the previous examples. Since the BASE64URL(JWS Payload) value 1926 will therefore be the same, its computation is not repeated here. 1928 {"iss":"joe", 1929 "exp":1300819380, 1930 "http://example.com/is_root":true} 1932 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 1933 BASE64URL(JWS Payload) gives this string (with line breaks for 1934 display purposes only): 1936 eyJhbGciOiJFUzI1NiJ9 1937 . 1938 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1939 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1941 The resulting JWS Signing Input value, which is the ASCII 1942 representation of above string, is the following octet sequence: 1944 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 73, 1945 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, 1946 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, 1947 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, 107, 122, 79, 68, 1948 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, 72, 65, 54, 76, 1949 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, 109, 78, 118, 1950 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, 106, 112, 48, 1951 99, 110, 86, 108, 102, 81] 1953 This example uses the elliptic curve key represented in JSON Web Key 1954 [JWK] format below: 1956 {"kty":"EC", 1957 "crv":"P-256", 1958 "x":"f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU", 1959 "y":"x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0", 1960 "d":"jpsQnnGQmL-YBIffH1136cspYG6-0iY7X1fCE9-E9LI" 1961 } 1963 The ECDSA private part d is then passed to an ECDSA signing function, 1964 which also takes the curve type, P-256, the hash type, SHA-256, and 1965 the JWS Signing Input as inputs. The result of the digital signature 1966 is the EC point (R, S), where R and S are unsigned integers. In this 1967 example, the R and S values, given as octet sequences representing 1968 big endian integers are: 1970 +--------+----------------------------------------------------------+ 1971 | Result | Value | 1972 | Name | | 1973 +--------+----------------------------------------------------------+ 1974 | R | [14, 209, 33, 83, 121, 99, 108, 72, 60, 47, 127, 21, 88, | 1975 | | 7, 212, 2, 163, 178, 40, 3, 58, 249, 124, 126, 23, 129, | 1976 | | 154, 195, 22, 158, 166, 101] | 1977 | S | [197, 10, 7, 211, 140, 60, 112, 229, 216, 241, 45, 175, | 1978 | | 8, 74, 84, 128, 166, 101, 144, 197, 242, 147, 80, 154, | 1979 | | 143, 63, 127, 138, 131, 163, 84, 213] | 1980 +--------+----------------------------------------------------------+ 1982 The JWS Signature is the value R || S. Encoding the signature as 1983 BASE64URL(JWS Signature) produces this value (with line breaks for 1984 display purposes only): 1986 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 1987 pmWQxfKTUJqPP3-Kg6NU1Q 1989 Concatenating these values in the order Header.Payload.Signature with 1990 period ('.') characters between the parts yields this complete JWS 1991 representation using the JWS Compact Serialization (with line breaks 1992 for display purposes only): 1994 eyJhbGciOiJFUzI1NiJ9 1995 . 1996 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 1997 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 1998 . 1999 DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSA 2000 pmWQxfKTUJqPP3-Kg6NU1Q 2002 A.3.2. Validating 2004 Since the "alg" Header Parameter is "ES256", we validate the ECDSA 2005 P-256 SHA-256 digital signature contained in the JWS Signature. 2007 Validating the JWS Signature is a bit different from the previous 2008 examples. We need to split the 64 member octet sequence of the JWS 2009 Signature (which is base64url decoded from the value encoded in the 2010 JWS representation) into two 32 octet sequences, the first 2011 representing R and the second S. We then pass the public key (x, y), 2012 the signature (R, S), and the JWS Signing Input (which is the initial 2013 substring of the JWS Compact Serialization representation up until 2014 but not including the second period character) to an ECDSA signature 2015 verifier that has been configured to use the P-256 curve with the 2016 SHA-256 hash function. 2018 A.4. Example JWS using ECDSA P-521 SHA-512 2020 A.4.1. Encoding 2022 The JWS Protected Header for this example differs from the previous 2023 example because different ECDSA curves and hash functions are used. 2024 The JWS Protected Header used is: 2026 {"alg":"ES512"} 2028 The octets representing UTF8(JWS Protected Header) in this example 2029 (using JSON array notation) are: 2031 [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 53, 49, 50, 34, 125] 2033 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2034 Header)) gives this value: 2036 eyJhbGciOiJFUzUxMiJ9 2038 The JWS Payload used in this example, is the ASCII string "Payload". 2039 The representation of this string is the octet sequence: 2041 [80, 97, 121, 108, 111, 97, 100] 2042 Encoding this JWS Payload as BASE64URL(JWS Payload) gives this value: 2044 UGF5bG9hZA 2046 Combining these as BASE64URL(UTF8(JWS Protected Header)) || '.' || 2047 BASE64URL(JWS Payload) gives this string: 2049 eyJhbGciOiJFUzUxMiJ9.UGF5bG9hZA 2051 The resulting JWS Signing Input value, which is the ASCII 2052 representation of above string, is the following octet sequence: 2054 [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 85, 2055 120, 77, 105, 74, 57, 46, 85, 71, 70, 53, 98, 71, 57, 104, 90, 65] 2057 This example uses the elliptic curve key represented in JSON Web Key 2058 [JWK] format below (with line breaks within values for display 2059 purposes only): 2061 {"kty":"EC", 2062 "crv":"P-521", 2063 "x":"AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_ 2064 NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk", 2065 "y":"ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDl 2066 y79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2", 2067 "d":"AY5pb7A0UFiB3RELSD64fTLOSV_jazdF7fLYyuTw8lOfRhWg6Y6rUrPA 2068 xerEzgdRhajnu0ferB0d53vM9mE15j2C" 2069 } 2071 The ECDSA private part d is then passed to an ECDSA signing function, 2072 which also takes the curve type, P-521, the hash type, SHA-512, and 2073 the JWS Signing Input as inputs. The result of the digital signature 2074 is the EC point (R, S), where R and S are unsigned integers. In this 2075 example, the R and S values, given as octet sequences representing 2076 big endian integers are: 2078 +--------+----------------------------------------------------------+ 2079 | Result | Value | 2080 | Name | | 2081 +--------+----------------------------------------------------------+ 2082 | R | [1, 220, 12, 129, 231, 171, 194, 209, 232, 135, 233, | 2083 | | 117, 247, 105, 122, 210, 26, 125, 192, 1, 217, 21, 82, | 2084 | | 91, 45, 240, 255, 83, 19, 34, 239, 71, 48, 157, 147, | 2085 | | 152, 105, 18, 53, 108, 163, 214, 68, 231, 62, 153, 150, | 2086 | | 106, 194, 164, 246, 72, 143, 138, 24, 50, 129, 223, 133, | 2087 | | 206, 209, 172, 63, 237, 119, 109] | 2088 | S | [0, 111, 6, 105, 44, 5, 41, 208, 128, 61, 152, 40, 92, | 2089 | | 61, 152, 4, 150, 66, 60, 69, 247, 196, 170, 81, 193, | 2090 | | 199, 78, 59, 194, 169, 16, 124, 9, 143, 42, 142, 131, | 2091 | | 48, 206, 238, 34, 175, 83, 203, 220, 159, 3, 107, 155, | 2092 | | 22, 27, 73, 111, 68, 68, 21, 238, 144, 229, 232, 148, | 2093 | | 188, 222, 59, 242, 103] | 2094 +--------+----------------------------------------------------------+ 2096 The JWS Signature is the value R || S. Encoding the signature as 2097 BASE64URL(JWS Signature) produces this value (with line breaks for 2098 display purposes only): 2100 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 2101 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 2102 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 2104 Concatenating these values in the order Header.Payload.Signature with 2105 period ('.') characters between the parts yields this complete JWS 2106 representation using the JWS Compact Serialization (with line breaks 2107 for display purposes only): 2109 eyJhbGciOiJFUzUxMiJ9 2110 . 2111 UGF5bG9hZA 2112 . 2113 AdwMgeerwtHoh-l192l60hp9wAHZFVJbLfD_UxMi70cwnZOYaRI1bKPWROc-mZZq 2114 wqT2SI-KGDKB34XO0aw_7XdtAG8GaSwFKdCAPZgoXD2YBJZCPEX3xKpRwcdOO8Kp 2115 EHwJjyqOgzDO7iKvU8vcnwNrmxYbSW9ERBXukOXolLzeO_Jn 2117 A.4.2. Validating 2119 Since the "alg" Header Parameter is "ES512", we validate the ECDSA 2120 P-521 SHA-512 digital signature contained in the JWS Signature. 2122 Validating this JWS Signature is very similar to the previous 2123 example. We need to split the 132 member octet sequence of the JWS 2124 Signature into two 66 octet sequences, the first representing R and 2125 the second S. We then pass the public key (x, y), the signature (R, 2126 S), and the JWS Signing Input to an ECDSA signature verifier that has 2127 been configured to use the P-521 curve with the SHA-512 hash 2128 function. 2130 A.5. Example Unsecured JWS 2132 The following example JWS Protected Header declares that the encoded 2133 object is an Unsecured JWS: 2135 {"alg":"none"} 2137 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2138 Header)) gives this value: 2140 eyJhbGciOiJub25lIn0 2142 The JWS Payload used in this example, which follows, is the same as 2143 in the previous examples. Since the BASE64URL(JWS Payload) value 2144 will therefore be the same, its computation is not repeated here. 2146 {"iss":"joe", 2147 "exp":1300819380, 2148 "http://example.com/is_root":true} 2150 The JWS Signature is the empty octet string and BASE64URL(JWS 2151 Signature) is the empty string. 2153 Concatenating these values in the order Header.Payload.Signature with 2154 period ('.') characters between the parts yields this complete JWS 2155 representation using the JWS Compact Serialization (with line breaks 2156 for display purposes only): 2158 eyJhbGciOiJub25lIn0 2159 . 2160 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 2161 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 2162 . 2164 A.6. Example JWS using General JWS JSON Serialization 2166 This section contains an example using the general JWS JSON 2167 Serialization syntax. This example demonstrates the capability for 2168 conveying multiple digital signatures and/or MACs for the same 2169 payload. 2171 The JWS Payload used in this example is the same as that used in the 2172 examples in Appendix A.2 and Appendix A.3 (with line breaks for 2173 display purposes only): 2175 eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt 2176 cGxlLmNvbS9pc19yb290Ijp0cnVlfQ 2178 Two digital signatures are used in this example: the first using 2179 RSASSA-PKCS-v1_5 SHA-256 and the second using ECDSA P-256 SHA-256. 2180 For the first, the JWS Protected Header and key are the same as in 2181 Appendix A.2, resulting in the same JWS Signature value; therefore, 2182 its computation is not repeated here. For the second, the JWS 2183 Protected Header and key are the same as in Appendix A.3, resulting 2184 in the same JWS Signature value; therefore, its computation is not 2185 repeated here. 2187 A.6.1. JWS Per-Signature Protected Headers 2189 The JWS Protected Header value used for the first signature is: 2191 {"alg":"RS256"} 2193 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2194 Header)) gives this value: 2196 eyJhbGciOiJSUzI1NiJ9 2198 The JWS Protected Header value used for the second signature is: 2200 {"alg":"ES256"} 2202 Encoding this JWS Protected Header as BASE64URL(UTF8(JWS Protected 2203 Header)) gives this value: 2205 eyJhbGciOiJFUzI1NiJ9 2207 A.6.2. JWS Per-Signature Unprotected Headers 2209 Key ID values are supplied for both keys using per-signature Header 2210 Parameters. The two values used to represent these Key IDs are: 2212 {"kid":"2010-12-29"} 2214 and 2216 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 2218 A.6.3. Complete JOSE Header Values 2220 Combining the protected and unprotected header values supplied, the 2221 JOSE Header values used for the first and second signatures 2222 respectively are: 2224 {"alg":"RS256", 2225 "kid":"2010-12-29"} 2227 and 2229 {"alg":"ES256", 2230 "kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"} 2232 A.6.4. Complete JWS JSON Serialization Representation 2234 The complete JWS JSON Serialization for these values is as follows 2235 (with line breaks within values for display purposes only): 2237 { 2238 "payload": 2239 "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGF 2240 tcGxlLmNvbS9pc19yb290Ijp0cnVlfQ", 2241 "signatures":[ 2242 {"protected":"eyJhbGciOiJSUzI1NiJ9", 2243 "header": 2244 {"kid":"2010-12-29"}, 2245 "signature": 2246 "cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZ 2247 mh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjb 2248 KBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHl 2249 b1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZES 2250 c6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AX 2251 LIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw"}, 2252 {"protected":"eyJhbGciOiJFUzI1NiJ9", 2253 "header": 2254 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"}, 2255 "signature": 2256 "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8IS 2257 lSApmWQxfKTUJqPP3-Kg6NU1Q"}] 2258 } 2260 A.7. Example JWS using Flattened JWS JSON Serialization 2262 This section contains an example using the flattened JWS JSON 2263 Serialization syntax. This example demonstrates the capability for 2264 conveying a single digital signature or MAC in a flattened JSON 2265 structure. 2267 The values in this example are the same as those in the second 2268 signature of the previous example in Appendix A.6. 2270 The complete JWS JSON Serialization for these values is as follows 2271 (with line breaks within values for display purposes only): 2273 { 2274 "payload": 2275 "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGF 2276 tcGxlLmNvbS9pc19yb290Ijp0cnVlfQ", 2277 "protected":"eyJhbGciOiJFUzI1NiJ9", 2278 "header": 2279 {"kid":"e9bc097a-ce51-4036-9562-d2ade882db0d"}, 2280 "signature": 2281 "DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8IS 2282 lSApmWQxfKTUJqPP3-Kg6NU1Q" 2283 } 2285 Appendix B. "x5c" (X.509 Certificate Chain) Example 2287 The JSON array below is an example of a certificate chain that could 2288 be used as the value of an "x5c" (X.509 Certificate Chain) Header 2289 Parameter, per Section 4.1.6 (with line breaks within values for 2290 display purposes only): 2292 ["MIIE3jCCA8agAwIBAgICAwEwDQYJKoZIhvcNAQEFBQAwYzELMAkGA1UEBhMCVVM 2293 xITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR2 2294 8gRGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExM 2295 TYwMTU0MzdaFw0yNjExMTYwMTU0MzdaMIHKMQswCQYDVQQGEwJVUzEQMA4GA1UE 2296 CBMHQXJpem9uYTETMBEGA1UEBxMKU2NvdHRzZGFsZTEaMBgGA1UEChMRR29EYWR 2297 keS5jb20sIEluYy4xMzAxBgNVBAsTKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYW 2298 RkeS5jb20vcmVwb3NpdG9yeTEwMC4GA1UEAxMnR28gRGFkZHkgU2VjdXJlIENlc 2299 nRpZmljYXRpb24gQXV0aG9yaXR5MREwDwYDVQQFEwgwNzk2OTI4NzCCASIwDQYJ 2300 KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMQt1RWMnCZM7DI161+4WQFapmGBWTt 2301 wY6vj3D3HKrjJM9N55DrtPDAjhI6zMBS2sofDPZVUBJ7fmd0LJR4h3mUpfjWoqV 2302 Tr9vcyOdQmVZWt7/v+WIbXnvQAjYwqDL1CBM6nPwT27oDyqu9SoWlm2r4arV3aL 2303 GbqGmu75RpRSgAvSMeYddi5Kcju+GZtCpyz8/x4fKL4o/K1w/O5epHBp+YlLpyo 2304 7RJlbmr2EkRTcDCVw5wrWCs9CHRK8r5RsL+H0EwnWGu1NcWdrxcx+AuP7q2BNgW 2305 JCJjPOq8lh8BJ6qf9Z/dFjpfMFDniNoW1fho3/Rb2cRGadDAW/hOUoz+EDU8CAw 2306 EAAaOCATIwggEuMB0GA1UdDgQWBBT9rGEyk2xF1uLuhV+auud2mWjM5zAfBgNVH 2307 SMEGDAWgBTSxLDSkdRMEXGzYcs9of7dqGrU4zASBgNVHRMBAf8ECDAGAQH/AgEA 2308 MDMGCCsGAQUFBwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZ29kYWR 2309 keS5jb20wRgYDVR0fBD8wPTA7oDmgN4Y1aHR0cDovL2NlcnRpZmljYXRlcy5nb2 2310 RhZGR5LmNvbS9yZXBvc2l0b3J5L2dkcm9vdC5jcmwwSwYDVR0gBEQwQjBABgRVH 2311 SAAMDgwNgYIKwYBBQUHAgEWKmh0dHA6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5j 2312 b20vcmVwb3NpdG9yeTAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggE 2313 BANKGwOy9+aG2Z+5mC6IGOgRQjhVyrEp0lVPLN8tESe8HkGsz2ZbwlFalEzAFPI 2314 UyIXvJxwqoJKSQ3kbTJSMUA2fCENZvD117esyfxVgqwcSeIaha86ykRvOe5GPLL 2315 5CkKSkB2XIsKd83ASe8T+5o0yGPwLPk9Qnt0hCqU7S+8MxZC9Y7lhyVJEnfzuz9 2316 p0iRFEUOOjZv2kWzRaJBydTXRE4+uXR21aITVSzGh6O1mawGhId/dQb8vxRMDsx 2317 uxN89txJx9OjxUUAiKEngHUuHqDTMBqLdElrRhjZkAzVvb3du6/KFUJheqwNTrZ 2318 EjYx8WnM25sgVjOuH0aBsXBTWVU+4=", 2319 "MIIE+zCCBGSgAwIBAgICAQ0wDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1Z 2320 hbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIE 2321 luYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb 2322 24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8x 2323 IDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTA0MDYyOTE3MDY 2324 yMFoXDTI0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRoZS 2325 BHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3MgM 2326 iBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN 2327 ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XC 2328 APVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux 2329 6wwdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLO 2330 tXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWo 2331 riMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZ 2332 Eewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjggHhMIIB3TAdBgNVHQ 2333 4EFgQU0sSw0pHUTBFxs2HLPaH+3ahq1OMwgdIGA1UdIwSByjCBx6GBwaSBvjCBu 2334 zEkMCIGA1UEBxMbVmFsaUNlcnQgVmFsaWRhdGlvbiBOZXR3b3JrMRcwFQYDVQQK 2335 Ew5WYWxpQ2VydCwgSW5jLjE1MDMGA1UECxMsVmFsaUNlcnQgQ2xhc3MgMiBQb2x 2336 pY3kgVmFsaWRhdGlvbiBBdXRob3JpdHkxITAfBgNVBAMTGGh0dHA6Ly93d3cudm 2337 FsaWNlcnQuY29tLzEgMB4GCSqGSIb3DQEJARYRaW5mb0B2YWxpY2VydC5jb22CA 2338 QEwDwYDVR0TAQH/BAUwAwEB/zAzBggrBgEFBQcBAQQnMCUwIwYIKwYBBQUHMAGG 2339 F2h0dHA6Ly9vY3NwLmdvZGFkZHkuY29tMEQGA1UdHwQ9MDswOaA3oDWGM2h0dHA 2340 6Ly9jZXJ0aWZpY2F0ZXMuZ29kYWRkeS5jb20vcmVwb3NpdG9yeS9yb290LmNybD 2341 BLBgNVHSAERDBCMEAGBFUdIAAwODA2BggrBgEFBQcCARYqaHR0cDovL2NlcnRpZ 2342 mljYXRlcy5nb2RhZGR5LmNvbS9yZXBvc2l0b3J5MA4GA1UdDwEB/wQEAwIBBjAN 2343 BgkqhkiG9w0BAQUFAAOBgQC1QPmnHfbq/qQaQlpE9xXUhUaJwL6e4+PrxeNYiY+ 2344 Sn1eocSxI0YGyeR+sBjUZsE4OWBsUs5iB0QQeyAfJg594RAoYC5jcdnplDQ1tgM 2345 QLARzLrUc+cb53S8wGd9D0VmsfSxOaFIqII6hR8INMqzW/Rn453HWkrugp++85j 2346 09VZw==", 2347 "MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ 2348 0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNT 2349 AzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0a 2350 G9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkq 2351 hkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE 2352 5MDYyNjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTm 2353 V0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZ 2354 XJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQD 2355 ExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9 2356 AdmFsaWNlcnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5a 2357 vIWZJV16vYdA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zf 2358 N1SLUzm1NZ9WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwb 2359 P7RfZHM047QSv4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQU 2360 AA4GBADt/UG9vUJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQ 2361 C1u+mNr0HZDzTuIYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMM 2362 j4QssxsodyamEwCW/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd"] 2364 Appendix C. Notes on implementing base64url encoding without padding 2366 This appendix describes how to implement base64url encoding and 2367 decoding functions without padding based upon standard base64 2368 encoding and decoding functions that do use padding. 2370 To be concrete, example C# code implementing these functions is shown 2371 below. Similar code could be used in other languages. 2373 static string base64urlencode(byte [] arg) 2374 { 2375 string s = Convert.ToBase64String(arg); // Regular base64 encoder 2376 s = s.Split('=')[0]; // Remove any trailing '='s 2377 s = s.Replace('+', '-'); // 62nd char of encoding 2378 s = s.Replace('/', '_'); // 63rd char of encoding 2379 return s; 2380 } 2382 static byte [] base64urldecode(string arg) 2383 { 2384 string s = arg; 2385 s = s.Replace('-', '+'); // 62nd char of encoding 2386 s = s.Replace('_', '/'); // 63rd char of encoding 2387 switch (s.Length % 4) // Pad with trailing '='s 2388 { 2389 case 0: break; // No pad chars in this case 2390 case 2: s += "=="; break; // Two pad chars 2391 case 3: s += "="; break; // One pad char 2392 default: throw new System.Exception( 2393 "Illegal base64url string!"); 2394 } 2395 return Convert.FromBase64String(s); // Standard base64 decoder 2396 } 2398 As per the example code above, the number of '=' padding characters 2399 that needs to be added to the end of a base64url encoded string 2400 without padding to turn it into one with padding is a deterministic 2401 function of the length of the encoded string. Specifically, if the 2402 length mod 4 is 0, no padding is added; if the length mod 4 is 2, two 2403 '=' padding characters are added; if the length mod 4 is 3, one '=' 2404 padding character is added; if the length mod 4 is 1, the input is 2405 malformed. 2407 An example correspondence between unencoded and encoded values 2408 follows. The octet sequence below encodes into the string below, 2409 which when decoded, reproduces the octet sequence. 2410 3 236 255 224 193 2411 A-z_4ME 2413 Appendix D. Notes on Key Selection 2415 This appendix describes a set of possible algorithms for selecting 2416 the key to be used to validate the digital signature or MAC of a JWS 2417 or for selecting the key to be used to decrypt a JWE. This guidance 2418 describes a family of possible algorithms, rather than a single 2419 algorithm, because in different contexts, not all the sources of keys 2420 will be used, they can be tried in different orders, and sometimes 2421 not all the collected keys will be tried; hence, different algorithms 2422 will be used in different application contexts. 2424 The steps below are described for illustration purposes only; 2425 specific applications can and are likely to use different algorithms 2426 or perform some of the steps in different orders. Specific 2427 applications will frequently have a much simpler method of 2428 determining the keys to use, as there may be one or two key selection 2429 methods that are profiled for the application's use. This appendix 2430 supplements the normative information on key location in Section 6. 2432 These algorithms include the following steps. Note that the steps 2433 can be performed in any order and do not need to be treated as 2434 distinct. For example, keys can be tried as soon as they are found, 2435 rather than collecting all the keys before trying any. 2437 1. Collect the set of potentially applicable keys. Sources of keys 2438 may include: 2440 * Keys supplied by the application protocol being used. 2442 * Keys referenced by the "jku" (JWK Set URL) Header Parameter. 2444 * The key provided by the "jwk" (JSON Web Key) Header Parameter. 2446 * The key referenced by the "x5u" (X.509 URL) Header Parameter. 2448 * The key provided by the "x5c" (X.509 Certificate Chain) Header 2449 Parameter. 2451 * Other applicable keys available to the application. 2453 The order for collecting and trying keys from different key 2454 sources is typically application dependent. For example, 2455 frequently all keys from a one set of locations, such as local 2456 caches, will be tried before collecting and trying keys from 2457 other locations. 2459 2. Filter the set of collected keys. For instance, some 2460 applications will use only keys referenced by "kid" (key ID) or 2461 "x5t" (X.509 certificate SHA-1 thumbprint) parameters. If the 2462 application uses the "alg" (algorithm), "use" (public key use), 2463 or "key_ops" (key operations) parameters, keys with keys with 2464 inappropriate values of those parameters would be excluded. 2465 Additionally, keys might be filtered to include or exclude keys 2466 with certain other member values in an application specific 2467 manner. For some applications, no filtering will be applied. 2469 3. Order the set of collected keys. For instance, keys referenced 2470 by "kid" (Key ID) or "x5t" (X.509 Certificate SHA-1 Thumbprint) 2471 parameters might be tried before keys with neither of these 2472 values. Likewise, keys with certain member values might be 2473 ordered before keys with other member values. For some 2474 applications, no ordering will be applied. 2476 4. Make trust decisions about the keys. Signatures made with keys 2477 not meeting the application's trust criteria would not be 2478 accepted. Such criteria might include, but is not limited to the 2479 source of the key, whether the TLS certificate validates for keys 2480 retrieved from URLs, whether a key in an X.509 certificate is 2481 backed by a valid certificate chain, and other information known 2482 by the application. 2484 5. Attempt signature or MAC validation for a JWS or decryption of a 2485 JWE with some or all of the collected and possibly filtered 2486 and/or ordered keys. A limit on the number of keys to be tried 2487 might be applied. This process will normally terminate following 2488 a successful validation or decryption. 2490 Note that it is reasonable for some applications to perform signature 2491 or MAC validation prior to making a trust decision about a key, since 2492 keys for which the validation fails need no trust decision. 2494 Appendix E. Negative Test Case for "crit" Header Parameter 2496 Conforming implementations must reject input containing critical 2497 extensions that are not understood or cannot be processed. The 2498 following JWS must be rejected by all implementations, because it 2499 uses an extension Header Parameter name 2500 "http://example.invalid/UNDEFINED" that they do not understand. Any 2501 other similar input, in which the use of the value 2502 "http://example.invalid/UNDEFINED" is substituted for any other 2503 Header Parameter name not understood by the implementation, must also 2504 be rejected. 2506 The JWS Protected Header value for this JWS is: 2508 {"alg":"none", 2509 "crit":["http://example.invalid/UNDEFINED"], 2510 "http://example.invalid/UNDEFINED":true 2511 } 2513 The complete JWS that must be rejected is as follows (with line 2514 breaks for display purposes only): 2516 eyJhbGciOiJub25lIiwNCiAiY3JpdCI6WyJodHRwOi8vZXhhbXBsZS5jb20vVU5ERU 2517 ZJTkVEIl0sDQogImh0dHA6Ly9leGFtcGxlLmNvbS9VTkRFRklORUQiOnRydWUNCn0. 2518 RkFJTA. 2520 Appendix F. Detached Content 2522 In some contexts, it is useful integrity protect content that is not 2523 itself contained in a JWS. One way to do this is create a JWS in the 2524 normal fashion using a representation of the content as the payload, 2525 but then delete the payload representation from the JWS, and send 2526 this modified object to the recipient, rather than the JWS. When 2527 using the JWS Compact Serialization, the deletion is accomplished by 2528 replacing the second field (which contains BASE64URL(JWS Payload)) 2529 value with the empty string; when using the JWS JSON Serialization, 2530 the deletion is accomplished by deleting the "payload" member. This 2531 method assumes that the recipient can reconstruct the exact payload 2532 used in the JWS. To use the modified object, the recipient 2533 reconstructs the JWS by re-inserting the payload representation into 2534 the modified object, and uses the resulting JWS in the usual manner. 2535 Note that this method needs no support from JWS libraries, as 2536 applications can use this method by modifying the inputs and outputs 2537 of standard JWS libraries. 2539 Appendix G. Acknowledgements 2541 Solutions for signing JSON content were previously explored by Magic 2542 Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas 2543 Applications [CanvasApp], all of which influenced this draft. 2545 Thanks to Axel Nennker for his early implementation and feedback on 2546 the JWS and JWE specifications. 2548 This specification is the work of the JOSE Working Group, which 2549 includes dozens of active and dedicated participants. In particular, 2550 the following individuals contributed ideas, feedback, and wording 2551 that influenced this specification: 2553 Dirk Balfanz, Richard Barnes, Brian Campbell, Alissa Cooper, Breno de 2554 Medeiros, Stephen Farrell, Dick Hardt, Joe Hildebrand, Jeff Hodges, 2555 Russ Housley, Edmund Jay, Tero Kivinen, Yaron Y. Goland, Ben Laurie, 2556 Ted Lemon, James Manger, Matt Miller, Kathleen Moriarty, Tony 2557 Nadalin, Hideki Nara, Axel Nennker, John Panzer, Ray Polk, Emmanuel 2558 Raviart, Eric Rescorla, Pete Resnick, Jim Schaad, Paul Tarjan, Hannes 2559 Tschofenig, and Sean Turner. 2561 Jim Schaad and Karen O'Donoghue chaired the JOSE working group and 2562 Sean Turner, Stephen Farrell, and Kathleen Moriarty served as 2563 Security area directors during the creation of this specification. 2565 Appendix H. Document History 2567 [[ to be removed by the RFC Editor before publication as an RFC ]] 2569 -40 2571 o Clarified the definitions of UTF8(STRING) and ASCII(STRING). 2573 o Stated that line breaks are for display purposes only in places 2574 where this disclaimer was needed and missing. 2576 -39 2578 o Updated the reference to draft-ietf-uta-tls-bcp. 2580 -38 2582 o Replaced uses of the phrases "JWS object" and "JWE object" with 2583 "JWS" and "JWE". 2585 o Added member names to the JWS JSON Serialization Overview. 2587 o Applied other minor editorial improvements. 2589 -37 2591 o Updated the TLS requirements language to only require 2592 implementations to support TLS when they support features using 2593 TLS. 2595 o Updated the language about integrity protecting Header Parameters 2596 when used in a trust decision. 2598 o Restricted algorithm names to using only ASCII characters. 2600 o When describing actions taken as a result of validation failures, 2601 changed statements about rejecting the JWS to statements about 2602 considering the JWS to be invalid. 2604 o Added the CRT parameter values to example RSA private key 2605 representations. 2607 o Updated the example IANA registration request subject line. 2609 -36 2611 o Defined a flattened JWS JSON Serialization syntax, which is 2612 optimized for the single digital signature or MAC case. 2614 o Clarified where white space and line breaks may occur in JSON 2615 objects by referencing Section 2 of RFC 7159. 2617 o Specified that registration reviews occur on the 2618 jose-reg-review@ietf.org mailing list. 2620 -35 2622 o Addressed AppsDir reviews by Ray Polk. 2624 o Used real values for examples in the IANA Registration Template. 2626 -34 2628 o Addressed IESG review comments by Alissa Cooper, Pete Resnick, 2629 Richard Barnes, Ted Lemon, and Stephen Farrell. 2631 o Addressed Gen-ART review comments by Russ Housley. 2633 o Referenced RFC 4945 for PEM certificate delimiter syntax. 2635 -33 2637 o Noted that certificate thumbprints are also sometimes known as 2638 certificate fingerprints. 2640 o Added an informative reference to draft-ietf-uta-tls-bcp for 2641 recommendations on improving the security of software and services 2642 using TLS. 2644 o Changed the registration review period to three weeks. 2646 o Acknowledged additional contributors. 2648 -32 2650 o Addressed Gen-ART review comments by Russ Housley. 2652 o Addressed secdir review comments by Tero Kivinen, Stephen Kent, 2653 and Scott Kelly. 2655 o Replaced the term Plaintext JWS with Unsecured JWS. 2657 -31 2659 o Reworded the language about JWS implementations ignoring the "typ" 2660 and "cty" parameters, explicitly saying that their processing is 2661 performed by JWS applications. 2663 o Added additional guidance on ciphersuites currently considered to 2664 be appropriate for use, including a reference to a recent update 2665 by the TLS working group. 2667 -30 2669 o Added subsection headings within the Overview section for the two 2670 serializations. 2672 o Added references and cleaned up the reference syntax in a few 2673 places. 2675 o Applied minor wording changes to the Security Considerations 2676 section and made other local editorial improvements. 2678 -29 2680 o Replaced the terms JWS Header, JWE Header, and JWT Header with a 2681 single JOSE Header term defined in the JWS specification. This 2682 also enabled a single Header Parameter definition to be used and 2683 reduced other areas of duplication between specifications. 2685 -28 2687 o Revised the introduction to the Security Considerations section. 2688 Also introduced additional subsection headings for security 2689 considerations items and also moved a security consideration item 2690 here from the JWA draft. 2692 o Added text about when applications typically would and would not 2693 use "typ" and "cty" header parameters. 2695 -27 2696 o Added the "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) header 2697 parameter. 2699 o Stated that any JSON inputs not conforming to the JSON-text syntax 2700 defined in RFC 7159 input MUST be rejected in their entirety. 2702 o Simplified the TLS requirements. 2704 -26 2706 o Referenced Section 6 of RFC 6125 for TLS server certificate 2707 identity validation. 2709 o Described potential sources of ambiguity in representing the JSON 2710 objects used in the examples. The octets of the actual UTF-8 2711 representations of the JSON objects used in the examples are 2712 included to remove these ambiguities. 2714 o Added a small amount of additional explanatory text to the 2715 signature validation examples to aid implementers. 2717 o Noted that octet sequences are depicted using JSON array notation. 2719 o Updated references, including to W3C specifications. 2721 -25 2723 o No changes were made, other than to the version number and date. 2725 -24 2727 o Updated the JSON reference to RFC 7159. 2729 -23 2731 o Clarified that the base64url encoding includes no line breaks, 2732 white space, or other additional characters. 2734 -22 2736 o Corrected RFC 2119 terminology usage. 2738 o Replaced references to draft-ietf-json-rfc4627bis with RFC 7158. 2740 -21 2742 o Applied review comments to the appendix "Notes on Key Selection", 2743 addressing issue #93. 2745 o Changed some references from being normative to informative, 2746 addressing issue #90. 2748 o Applied review comments to the JSON Serialization section, 2749 addressing issue #121. 2751 -20 2753 o Made terminology definitions more consistent, addressing issue 2754 #165. 2756 o Restructured the JSON Serialization section to call out the 2757 parameters used in hanging lists, addressing issue #121. 2759 o Described key filtering and refined other aspects of the text in 2760 the appendix "Notes on Key Selection", addressing issue #93. 2762 o Replaced references to RFC 4627 with draft-ietf-json-rfc4627bis, 2763 addressing issue #90. 2765 -19 2767 o Added the appendix "Notes on Validation Key Selection", addressing 2768 issue #93. 2770 o Reordered the key selection parameters. 2772 -18 2774 o Updated the mandatory-to-implement (MTI) language to say that 2775 applications using this specification need to specify what 2776 serialization and serialization features are used for that 2777 application, addressing issue #119. 2779 o Changes to address editorial and minor issues #25, #89, #97, #110, 2780 #114, #115, #116, #117, #120, and #184. 2782 o Added and used Header Parameter Description registry field. 2784 -17 2786 o Refined the "typ" and "cty" definitions to always be MIME Media 2787 Types, with the omission of "application/" prefixes recommended 2788 for brevity, addressing issue #50. 2790 o Updated the mandatory-to-implement (MTI) language to say that 2791 general-purpose implementations must implement the single 2792 signature/MAC value case for both serializations whereas special- 2793 purpose implementations can implement just one serialization if 2794 that meets the needs of the use cases the implementation is 2795 designed for, addressing issue #119. 2797 o Explicitly named all the logical components of a JWS and defined 2798 the processing rules and serializations in terms of those 2799 components, addressing issues #60, #61, and #62. 2801 o Replaced verbose repetitive phases such as "base64url encode the 2802 octets of the UTF-8 representation of X" with mathematical 2803 notation such as "BASE64URL(UTF8(X))". 2805 o Terms used in multiple documents are now defined in one place and 2806 incorporated by reference. Some lightly used or obvious terms 2807 were also removed. This addresses issue #58. 2809 -16 2811 o Changes to address editorial and minor issues #50, #98, #99, #102, 2812 #104, #106, #107, #111, and #112. 2814 -15 2816 o Clarified that it is an application decision which signatures, 2817 MACs, or plaintext values must successfully validate for the JWS 2818 to be accepted, addressing issue #35. 2820 o Corrected editorial error in "ES512" example. 2822 o Changes to address editorial and minor issues #34, #96, #100, 2823 #101, #104, #105, and #106. 2825 -14 2827 o Stated that the "signature" parameter is to be omitted in the JWS 2828 JSON Serialization when its value would be empty (which is only 2829 the case for a Plaintext JWS). 2831 -13 2833 o Made all header parameter values be per-signature/MAC, addressing 2834 issue #24. 2836 -12 2838 o Clarified that the "typ" and "cty" header parameters are used in 2839 an application-specific manner and have no effect upon the JWS 2840 processing. 2842 o Replaced the MIME types "application/jws+json" and 2843 "application/jws" with "application/jose+json" and 2844 "application/jose". 2846 o Stated that recipients MUST either reject JWSs with duplicate 2847 Header Parameter Names or use a JSON parser that returns only the 2848 lexically last duplicate member name. 2850 o Added a Serializations section with parallel treatment of the JWS 2851 Compact Serialization and the JWS JSON Serialization and also 2852 moved the former Implementation Considerations content there. 2854 -11 2856 o Added Key Identification section. 2858 o For the JWS JSON Serialization, enable header parameter values to 2859 be specified in any of three parameters: the "protected" member 2860 that is integrity protected and shared among all recipients, the 2861 "unprotected" member that is not integrity protected and shared 2862 among all recipients, and the "header" member that is not 2863 integrity protected and specific to a particular recipient. (This 2864 does not affect the JWS Compact Serialization, in which all header 2865 parameter values are in a single integrity protected JWE Header 2866 value.) 2868 o Removed suggested compact serialization for multiple digital 2869 signatures and/or MACs. 2871 o Changed the MIME type name "application/jws-js" to 2872 "application/jws+json", addressing issue #22. 2874 o Tightened the description of the "crit" (critical) header 2875 parameter. 2877 o Added a negative test case for the "crit" header parameter 2879 -10 2881 o Added an appendix suggesting a possible compact serialization for 2882 JWSs with multiple digital signatures and/or MACs. 2884 -09 2886 o Added JWS JSON Serialization, as specified by 2887 draft-jones-jose-jws-json-serialization-04. 2889 o Registered "application/jws-js" MIME type and "JWS-JS" typ header 2890 parameter value. 2892 o Defined that the default action for header parameters that are not 2893 understood is to ignore them unless specifically designated as 2894 "MUST be understood" or included in the new "crit" (critical) 2895 header parameter list. This addressed issue #6. 2897 o Changed term "JWS Secured Input" to "JWS Signing Input". 2899 o Changed from using the term "byte" to "octet" when referring to 8 2900 bit values. 2902 o Changed member name from "recipients" to "signatures" in the JWS 2903 JSON Serialization. 2905 o Added complete values using the JWS Compact Serialization for all 2906 examples. 2908 -08 2910 o Applied editorial improvements suggested by Jeff Hodges and Hannes 2911 Tschofenig. Many of these simplified the terminology used. 2913 o Clarified statements of the form "This header parameter is 2914 OPTIONAL" to "Use of this header parameter is OPTIONAL". 2916 o Added a Header Parameter Usage Location(s) field to the IANA JSON 2917 Web Signature and Encryption Header Parameters registry. 2919 o Added seriesInfo information to Internet Draft references. 2921 -07 2923 o Updated references. 2925 -06 2927 o Changed "x5c" (X.509 Certificate Chain) representation from being 2928 a single string to being an array of strings, each containing a 2929 single base64 encoded DER certificate value, representing elements 2930 of the certificate chain. 2932 o Applied changes made by the RFC Editor to RFC 6749's registry 2933 language to this specification. 2935 -05 2936 o Added statement that "StringOrURI values are compared as case- 2937 sensitive strings with no transformations or canonicalizations 2938 applied". 2940 o Indented artwork elements to better distinguish them from the body 2941 text. 2943 -04 2945 o Completed JSON Security Considerations section, including 2946 considerations about rejecting input with duplicate member names. 2948 o Completed security considerations on the use of a SHA-1 hash when 2949 computing "x5t" (x.509 certificate thumbprint) values. 2951 o Refer to the registries as the primary sources of defined values 2952 and then secondarily reference the sections defining the initial 2953 contents of the registries. 2955 o Normatively reference XML DSIG 2.0 for its security 2956 considerations. 2958 o Added this language to Registration Templates: "This name is case 2959 sensitive. Names that match other registered names in a case 2960 insensitive manner SHOULD NOT be accepted." 2962 o Reference draft-jones-jose-jws-json-serialization instead of 2963 draft-jones-json-web-signature-json-serialization. 2965 o Described additional open issues. 2967 o Applied editorial suggestions. 2969 -03 2971 o Added the "cty" (content type) header parameter for declaring type 2972 information about the secured content, as opposed to the "typ" 2973 (type) header parameter, which declares type information about 2974 this object. 2976 o Added "Collision Resistant Namespace" to the terminology section. 2978 o Reference ITU.X690.1994 for DER encoding. 2980 o Added an example JWS using ECDSA P-521 SHA-512. This has 2981 particular illustrative value because of the use of the 521 bit 2982 integers in the key and signature values. This is also an example 2983 in which the payload is not a base64url encoded JSON object. 2985 o Added an example "x5c" value. 2987 o No longer say "the UTF-8 representation of the JWS Secured Input 2988 (which is the same as the ASCII representation)". Just call it 2989 "the ASCII representation of the JWS Secured Input". 2991 o Added Registration Template sections for defined registries. 2993 o Added Registry Contents sections to populate registry values. 2995 o Changed name of the JSON Web Signature and Encryption "typ" Values 2996 registry to be the JSON Web Signature and Encryption Type Values 2997 registry, since it is used for more than just values of the "typ" 2998 parameter. 3000 o Moved registries JSON Web Signature and Encryption Header 3001 Parameters and JSON Web Signature and Encryption Type Values to 3002 the JWS specification. 3004 o Numerous editorial improvements. 3006 -02 3008 o Clarified that it is an error when a "kid" value is included and 3009 no matching key is found. 3011 o Removed assumption that "kid" (key ID) can only refer to an 3012 asymmetric key. 3014 o Clarified that JWSs with duplicate Header Parameter Names MUST be 3015 rejected. 3017 o Clarified the relationship between "typ" header parameter values 3018 and MIME types. 3020 o Registered application/jws MIME type and "JWS" typ header 3021 parameter value. 3023 o Simplified JWK terminology to get replace the "JWK Key Object" and 3024 "JWK Container Object" terms with simply "JSON Web Key (JWK)" and 3025 "JSON Web Key Set (JWK Set)" and to eliminate potential confusion 3026 between single keys and sets of keys. As part of this change, the 3027 Header Parameter Name for a public key value was changed from 3028 "jpk" (JSON Public Key) to "jwk" (JSON Web Key). 3030 o Added suggestion on defining additional header parameters such as 3031 "x5t#S256" in the future for certificate thumbprints using hash 3032 algorithms other than SHA-1. 3034 o Specify RFC 2818 server identity validation, rather than RFC 6125 3035 (paralleling the same decision in the OAuth specs). 3037 o Generalized language to refer to Message Authentication Codes 3038 (MACs) rather than Hash-based Message Authentication Codes (HMACs) 3039 unless in a context specific to HMAC algorithms. 3041 o Reformatted to give each header parameter its own section heading. 3043 -01 3045 o Moved definition of Plaintext JWSs (using "alg":"none") here from 3046 the JWT specification since this functionality is likely to be 3047 useful in more contexts that just for JWTs. 3049 o Added "jpk" and "x5c" header parameters for including JWK public 3050 keys and X.509 certificate chains directly in the header. 3052 o Clarified that this specification is defining the JWS Compact 3053 Serialization. Referenced the new JWS-JS spec, which defines the 3054 JWS JSON Serialization. 3056 o Added text "New header parameters should be introduced sparingly 3057 since an implementation that does not understand a parameter MUST 3058 reject the JWS". 3060 o Clarified that the order of the creation and validation steps is 3061 not significant in cases where there are no dependencies between 3062 the inputs and outputs of the steps. 3064 o Changed "no canonicalization is performed" to "no canonicalization 3065 need be performed". 3067 o Corrected the Magic Signatures reference. 3069 o Made other editorial improvements suggested by JOSE working group 3070 participants. 3072 -00 3074 o Created the initial IETF draft based upon 3075 draft-jones-json-web-signature-04 with no normative changes. 3077 o Changed terminology to no longer call both digital signatures and 3078 HMACs "signatures". 3080 Authors' Addresses 3082 Michael B. Jones 3083 Microsoft 3085 Email: mbj@microsoft.com 3086 URI: http://self-issued.info/ 3088 John Bradley 3089 Ping Identity 3091 Email: ve7jtb@ve7jtb.com 3092 URI: http://www.thread-safe.com/ 3094 Nat Sakimura 3095 Nomura Research Institute 3097 Email: n-sakimura@nri.co.jp 3098 URI: http://nat.sakimura.org/