| < draft-jones-json-web-signature-02.txt | draft-jones-json-web-signature-03.txt > | |||
|---|---|---|---|---|
| Network Working Group M. Jones | Network Working Group M. Jones | |||
| Internet-Draft Microsoft | Internet-Draft Microsoft | |||
| Intended status: Standards Track D. Balfanz | Intended status: Standards Track D. Balfanz | |||
| Expires: October 31, 2011 Google | Expires: May 2, 2012 Google | |||
| J. Bradley | J. Bradley | |||
| independent | independent | |||
| Y. Goland | Y. Goland | |||
| Microsoft | Microsoft | |||
| J. Panzer | J. Panzer | |||
| N. Sakimura | N. Sakimura | |||
| Nomura Research Institute | Nomura Research Institute | |||
| P. Tarjan | P. Tarjan | |||
| April 29, 2011 | October 30, 2011 | |||
| JSON Web Signature (JWS) | JSON Web Signature (JWS) | |||
| draft-jones-json-web-signature-02 | draft-jones-json-web-signature-03 | |||
| Abstract | Abstract | |||
| JSON Web Signature (JWS) is a means of representing signed content | JSON Web Signature (JWS) is a means of representing signed content | |||
| using JSON data structures. Related encryption capabilities are | using JSON data structures. Related encryption capabilities are | |||
| described in the separate JSON Web Encryption (JWE) specification. | described in the separate JSON Web Encryption (JWE) specification. | |||
| Requirements Language | Requirements Language | |||
| The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", | |||
| skipping to change at page 1, line 49 ¶ | skipping to change at page 1, line 49 ¶ | |||
| Internet-Drafts are working documents of the Internet Engineering | Internet-Drafts are working documents of the Internet Engineering | |||
| Task Force (IETF). Note that other groups may also distribute | Task Force (IETF). Note that other groups may also distribute | |||
| working documents as Internet-Drafts. The list of current Internet- | working documents as Internet-Drafts. The list of current Internet- | |||
| Drafts is at http://datatracker.ietf.org/drafts/current/. | Drafts is at http://datatracker.ietf.org/drafts/current/. | |||
| Internet-Drafts are draft documents valid for a maximum of six months | Internet-Drafts are draft documents valid for a maximum of six months | |||
| and may be updated, replaced, or obsoleted by other documents at any | and may be updated, replaced, or obsoleted by other documents at any | |||
| time. It is inappropriate to use Internet-Drafts as reference | time. It is inappropriate to use Internet-Drafts as reference | |||
| material or to cite them other than as "work in progress." | material or to cite them other than as "work in progress." | |||
| This Internet-Draft will expire on October 31, 2011. | This Internet-Draft will expire on May 2, 2012. | |||
| Copyright Notice | Copyright Notice | |||
| Copyright (c) 2011 IETF Trust and the persons identified as the | Copyright (c) 2011 IETF Trust and the persons identified as the | |||
| document authors. All rights reserved. | document authors. All rights reserved. | |||
| This document is subject to BCP 78 and the IETF Trust's Legal | This document is subject to BCP 78 and the IETF Trust's Legal | |||
| Provisions Relating to IETF Documents | Provisions Relating to IETF Documents | |||
| (http://trustee.ietf.org/license-info) in effect on the date of | (http://trustee.ietf.org/license-info) in effect on the date of | |||
| publication of this document. Please review these documents | publication of this document. Please review these documents | |||
| skipping to change at page 3, line 13 ¶ | skipping to change at page 3, line 13 ¶ | |||
| described in the Simplified BSD License. | described in the Simplified BSD License. | |||
| Table of Contents | Table of Contents | |||
| 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 | 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
| 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 | 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 | |||
| 3. JSON Web Signature (JWS) Overview . . . . . . . . . . . . . . 5 | 3. JSON Web Signature (JWS) Overview . . . . . . . . . . . . . . 5 | |||
| 3.1. Example JWS . . . . . . . . . . . . . . . . . . . . . . . 5 | 3.1. Example JWS . . . . . . . . . . . . . . . . . . . . . . . 5 | |||
| 4. JWS Header . . . . . . . . . . . . . . . . . . . . . . . . . . 6 | 4. JWS Header . . . . . . . . . . . . . . . . . . . . . . . . . . 6 | |||
| 4.1. Reserved Header Parameter Names . . . . . . . . . . . . . 6 | 4.1. Reserved Header Parameter Names . . . . . . . . . . . . . 6 | |||
| 4.2. Public Header Parameter Names . . . . . . . . . . . . . . 9 | 4.2. Public Header Parameter Names . . . . . . . . . . . . . . 10 | |||
| 4.3. Private Header Parameter Names . . . . . . . . . . . . . . 9 | 4.3. Private Header Parameter Names . . . . . . . . . . . . . . 10 | |||
| 5. Rules for Creating and Validating a JWS . . . . . . . . . . . 9 | 5. Rules for Creating and Validating a JWS . . . . . . . . . . . 10 | |||
| 6. Base64url encoding as used by JWSs . . . . . . . . . . . . . . 11 | 6. Signing JWSs with Cryptographic Algorithms . . . . . . . . . . 12 | |||
| 7. Signing JWSs with Cryptographic Algorithms . . . . . . . . . . 11 | 6.1. Creating a JWS with HMAC SHA-256, HMAC SHA-384, or | |||
| 7.1. Creating a JWS with HMAC SHA-256, HMAC SHA-384, or | HMAC SHA-512 . . . . . . . . . . . . . . . . . . . . . . . 13 | |||
| HMAC SHA-512 . . . . . . . . . . . . . . . . . . . . . . . 12 | 6.2. Creating a JWS with RSA SHA-256, RSA SHA-384, or RSA | |||
| 7.2. Creating a JWS with RSA SHA-256, RSA SHA-384, or RSA | SHA-512 . . . . . . . . . . . . . . . . . . . . . . . . . 14 | |||
| SHA-512 . . . . . . . . . . . . . . . . . . . . . . . . . 13 | 6.3. Creating a JWS with ECDSA P-256 SHA-256, ECDSA P-384 | |||
| 7.3. Creating a JWS with ECDSA P-256 SHA-256, ECDSA P-384 | SHA-384, or ECDSA P-521 SHA-512 . . . . . . . . . . . . . 15 | |||
| SHA-384, or ECDSA P-521 SHA-512 . . . . . . . . . . . . . 14 | 6.4. Additional Algorithms . . . . . . . . . . . . . . . . . . 17 | |||
| 7.4. Additional Algorithms . . . . . . . . . . . . . . . . . . 16 | 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 17 | |||
| 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 | 8. Security Considerations . . . . . . . . . . . . . . . . . . . 18 | |||
| 9. Security Considerations . . . . . . . . . . . . . . . . . . . 16 | 8.1. Unicode Comparison Security Issues . . . . . . . . . . . . 18 | |||
| 9.1. Unicode Comparison Security Issues . . . . . . . . . . . . 17 | 9. Open Issues and Things To Be Done (TBD) . . . . . . . . . . . 19 | |||
| 10. Open Issues and Things To Be Done (TBD) . . . . . . . . . . . 17 | 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 20 | |||
| 11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 18 | 10.1. Normative References . . . . . . . . . . . . . . . . . . . 20 | |||
| 11.1. Normative References . . . . . . . . . . . . . . . . . . . 18 | 10.2. Informative References . . . . . . . . . . . . . . . . . . 22 | |||
| 11.2. Informative References . . . . . . . . . . . . . . . . . . 20 | Appendix A. JWS Examples . . . . . . . . . . . . . . . . . . . . 22 | |||
| Appendix A. JWS Examples . . . . . . . . . . . . . . . . . . . . 20 | A.1. JWS using HMAC SHA-256 . . . . . . . . . . . . . . . . . . 22 | |||
| A.1. JWS using HMAC SHA-256 . . . . . . . . . . . . . . . . . . 20 | A.1.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 22 | |||
| A.1.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 21 | A.1.2. Decoding . . . . . . . . . . . . . . . . . . . . . . . 24 | |||
| A.1.2. Decoding . . . . . . . . . . . . . . . . . . . . . . . 22 | A.1.3. Validating . . . . . . . . . . . . . . . . . . . . . . 24 | |||
| A.1.3. Validating . . . . . . . . . . . . . . . . . . . . . . 22 | A.2. JWS using RSA SHA-256 . . . . . . . . . . . . . . . . . . 24 | |||
| A.2. JWS using RSA SHA-256 . . . . . . . . . . . . . . . . . . 23 | A.2.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 25 | |||
| A.2.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 23 | A.2.2. Decoding . . . . . . . . . . . . . . . . . . . . . . . 28 | |||
| A.2.2. Decoding . . . . . . . . . . . . . . . . . . . . . . . 26 | A.2.3. Validating . . . . . . . . . . . . . . . . . . . . . . 28 | |||
| A.2.3. Validating . . . . . . . . . . . . . . . . . . . . . . 26 | A.3. JWS using ECDSA P-256 SHA-256 . . . . . . . . . . . . . . 29 | |||
| A.3. JWS using ECDSA P-256 SHA-256 . . . . . . . . . . . . . . 27 | A.3.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 29 | |||
| A.3.1. Encoding . . . . . . . . . . . . . . . . . . . . . . . 27 | A.3.2. Decoding . . . . . . . . . . . . . . . . . . . . . . . 30 | |||
| A.3.2. Decoding . . . . . . . . . . . . . . . . . . . . . . . 28 | A.3.3. Validating . . . . . . . . . . . . . . . . . . . . . . 31 | |||
| A.3.3. Validating . . . . . . . . . . . . . . . . . . . . . . 29 | Appendix B. Algorithm Identifier Cross-Reference . . . . . . . . 31 | |||
| Appendix B. Algorithm Identifier Cross-Reference . . . . . . . . 29 | ||||
| Appendix C. Notes on implementing base64url encoding without | Appendix C. Notes on implementing base64url encoding without | |||
| padding . . . . . . . . . . . . . . . . . . . . . . . 31 | padding . . . . . . . . . . . . . . . . . . . . . . . 33 | |||
| Appendix D. Acknowledgements . . . . . . . . . . . . . . . . . . 32 | Appendix D. Acknowledgements . . . . . . . . . . . . . . . . . . 34 | |||
| Appendix E. Document History . . . . . . . . . . . . . . . . . . 33 | Appendix E. Document History . . . . . . . . . . . . . . . . . . 35 | |||
| Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 33 | Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 36 | |||
| 1. Introduction | 1. Introduction | |||
| JSON Web Signature (JWS) is a compact signature format intended for | JSON Web Signature (JWS) is a compact signature format intended for | |||
| space constrained environments such as HTTP Authorization headers and | space constrained environments such as HTTP Authorization headers and | |||
| URI query parameters. It represents signed content using JSON | URI query parameters. It represents signed content using JSON | |||
| [RFC4627] data structures. The JWS signature mechanisms are | [RFC4627] data structures. The JWS signature mechanisms are | |||
| independent of the type of content being signed, allowing arbitrary | independent of the type of content being signed, allowing arbitrary | |||
| content to be signed. A related encryption capability is described | content to be signed. A related encryption capability is described | |||
| in a separate JSON Web Encryption (JWE) [JWE] specification. | in a separate JSON Web Encryption (JWE) [JWE] specification. | |||
| 2. Terminology | 2. Terminology | |||
| JSON Web Signature (JWS) A data structure cryptographically securing | JSON Web Signature (JWS) A data structure cryptographically securing | |||
| a JWS Header Input and a JWS Payload Input with a JWS Crypto | a JWS Header and a JWS Payload with a JWS Signature. | |||
| Output. | ||||
| JWS Header Input A string containing a base64url encoded JSON object | JWS Header A string containing a JSON object that describes the | |||
| that describes the cryptographic operations applied to the JWS | signature applied to the JWS Header and the JWS Payload to create | |||
| Header Input and the JWS Payload Input. | the JWS Signature. | |||
| JWS Payload Input A string containing base64url encoded content. | JWS Payload The bytes to be signed - a.k.a., the message. | |||
| JWS Crypto Output A string containing base64url encoded | JWS Signature A byte array containing the cryptographic material | |||
| cryptographic material that secures the contents of the JWS Header | that secures the contents of the JWS Header and the JWS Payload. | |||
| Input and the JWS Payload Input. | ||||
| Decoded JWS Header Input JWS Header Input that has been base64url | Encoded JWS Header Base64url encoding of the bytes of the UTF-8 RFC | |||
| decoded back into a JSON object. | 3629 [RFC3629] representation of the JWS Header. | |||
| Decoded JWS Payload Input JWS Payload Input that has been base64url | Encoded JWS Payload Base64url encoding of the JWS Payload. | |||
| decoded. | ||||
| Decoded JWS Crypto Output JWS Crypto Output that has been base64url | Encoded JWS Signature Base64url encoding of the JWS Signature. | |||
| decoded back into cryptographic material. | ||||
| JWS Signing Input The concatenation of the JWS Header Input, a | JWS Signing Input The concatenation of the Encoded JWS Header, a | |||
| period ('.') character, and the JWS Payload Input. | period ('.') character, and the Encoded JWS Payload. | |||
| Header Parameter Names The names of the members within the JSON | Header Parameter Names The names of the members within the JSON | |||
| object represented in a JWS Header Input. | object represented in a JWS Header. | |||
| Header Parameter Values The values of the members within the JSON | Header Parameter Values The values of the members within the JSON | |||
| object represented in a JWS Header Input. | object represented in a JWS Header. | |||
| Digital Signature For the purposes of this specification, we use | Digital Signature For the purposes of this specification, we use | |||
| this term to encompass both Hash-based Message Authentication | this term to encompass both Hash-based Message Authentication | |||
| Codes (HMACs), which can provide authenticity but not non- | Codes (HMACs), which can provide authenticity but not non- | |||
| repudiation, and digital signatures using public key algorithms, | repudiation, and digital signatures using public key algorithms, | |||
| which can provide both. Readers should be aware of this | which can provide both. Readers should be aware of this | |||
| distinction, despite the decision to use a single term for both | distinction, despite the decision to use a single term for both | |||
| concepts to improve readability of the specification. | concepts to improve readability of the specification. | |||
| Base64url Encoding For the purposes of this specification, this term | Base64url Encoding For the purposes of this specification, this term | |||
| always refers to the he URL- and filename-safe Base64 encoding | always refers to the he URL- and filename-safe Base64 encoding | |||
| described in RFC 4648 [RFC4648], Section 5, with the '=' padding | described in RFC 4648 [RFC4648], Section 5, with the (non URL- | |||
| characters omitted, as permitted by Section 3.2. | safe) '=' padding characters omitted, as permitted by Section 3.2. | |||
| (See Appendix C for notes on implementing base64url encoding | ||||
| without padding.) | ||||
| 3. JSON Web Signature (JWS) Overview | 3. JSON Web Signature (JWS) Overview | |||
| JWSs represent content that is base64url encoded and digitally | JWS represents signed content using JSON data structures and | |||
| signed, and optionally encrypted, using JSON data structures. A | base64url encoding. The representation consists of three parts: the | |||
| portion of the base64url encoded content that is signed is the JWS | JWS Header, the JWS Payload, and the JWS Signature. The three parts | |||
| Payload Input. An accompanying base64url encoded JSON object - the | are base64url-encoded for transmission, and typically represented as | |||
| JWS Header Input - describes the signature method used. | the concatenation of the encoded strings in that order, with the | |||
| three strings being separated by period ('.') characters, as is done | ||||
| when used in JSON Web Tokens (JWTs) [JWT]. | ||||
| The member names within the Decoded JWS Header Input are referred to | A base64url encoded JSON object - the JWS Header - describes the | |||
| as Header Parameter Names. These names MUST be unique. The | signature method used. A portion of the base64url encoded content | |||
| corresponding values are referred to as Header Parameter Values. | that is signed is the Encoded JWS Payload. Finally, JWSs contain a | |||
| signature that ensures the integrity of the contents of the JWS | ||||
| Header and the JWS Payload. This signature value is base64url | ||||
| encoded to produce the Encoded JWS Signature. | ||||
| JWSs contain a signature that ensures the integrity of the contents | The member names within the JWS Header are referred to as Header | |||
| of the JWS Header Input and the JWS Payload Input. This signature | Parameter Names. These names MUST be unique. The corresponding | |||
| value is the JWS Crypto Output. The JSON Header object MUST contain | values are referred to as Header Parameter Values. The JWS Header | |||
| an "alg" parameter, the value of which is a string that unambiguously | MUST contain an "alg" parameter, the value of which is a string that | |||
| identifies the algorithm used to sign the JWS Header Input and the | unambiguously identifies the algorithm used to sign the JWS Header | |||
| JWS Payload Input to produce the JWS Crypto Output. | and the JWS Payload to produce the JWS Signature. | |||
| 3.1. Example JWS | 3.1. Example JWS | |||
| The following example JSON header object declares that the encoded | The following example JWS Header declares that the encoded object is | |||
| object is a JSON Web Token (JWT) [JWT] and the JWS Header Input and | a JSON Web Token (JWT) [JWT] and the JWS Header and the JWS Payload | |||
| the JWS Payload Input are signed using the HMAC SHA-256 algorithm: | are signed using the HMAC SHA-256 algorithm: | |||
| {"typ":"JWT", | {"typ":"JWT", | |||
| "alg":"HS256"} | "alg":"HS256"} | |||
| Base64url encoding the UTF-8 representation of the JSON header object | Base64url encoding the bytes of the UTF-8 representation of the JWS | |||
| yields this JWS Header Input value: | Header yields this Encoded JWS Header value: | |||
| eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 | eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 | |||
| The following is an example of a JSON object that can be encoded to | The following is an example of a JSON object that can be used as a | |||
| produce a JWS Payload Input. (Note that the payload can be any | JWS Payload. (Note that the payload can be any content, and need not | |||
| base64url encoded content, and need not be a base64url encoded JSON | be a representation of a JSON object.) | |||
| object.) | ||||
| {"iss":"joe", | {"iss":"joe", | |||
| "exp":1300819380, | "exp":1300819380, | |||
| "http://example.com/is_root":true} | "http://example.com/is_root":true} | |||
| Base64url encoding the UTF-8 representation of the JSON object yields | Base64url encoding the bytes of the UTF-8 representation of the JSON | |||
| the following JWS Payload Input. | object yields the following Encoded JWS Payload. | |||
| eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | |||
| Signing the UTF-8 representation of the JWS Signing Input (the | Signing the UTF-8 representation of the JWS Signing Input (the | |||
| concatenation of the JWS Header Input, a period ('.') character, and | concatenation of the Encoded JWS Header, a period ('.') character, | |||
| the JWS Payload Input) with the HMAC SHA-256 algorithm and base64url | and the Encoded JWS Payload) with the HMAC SHA-256 algorithm and | |||
| encoding the result, as per Section 7.1, yields this JWS Crypto | base64url encoding the result, as per Section 6.1, yields this | |||
| Output value: | Encoded JWS Signature value: | |||
| dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk | dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk | |||
| This computation is illustrated in more detail in Appendix A.1. | This computation is illustrated in more detail in Appendix A.1. | |||
| 4. JWS Header | 4. JWS Header | |||
| The members of the JSON object represented by the Decoded JWS Header | The members of the JSON object represented by the JWS Header describe | |||
| Input describe the signature applied to the JWS Header Input and the | the signature applied to the Encoded JWS Header and the Encoded JWS | |||
| JWS Payload Input and optionally additional properties of the JWS. | Payload and optionally additional properties of the JWS. | |||
| Implementations MUST understand the entire contents of the header; | Implementations MUST understand the entire contents of the header; | |||
| otherwise, the JWS MUST be rejected for processing. | otherwise, the JWS MUST be rejected for processing. | |||
| 4.1. Reserved Header Parameter Names | 4.1. Reserved Header Parameter Names | |||
| The following header parameter names are reserved. All the names are | The following header parameter names are reserved. All the names are | |||
| short because a core goal of JWSs is for the representations to be | short because a core goal of JWSs is for the representations to be | |||
| compact. | compact. | |||
| +-----------+--------+--------------+-------------------------------+ | +-----------+--------+-------------+--------------------------------+ | |||
| | Header | JSON | Header | Header Parameter Semantics | | | Header | JSON | Header | Header Parameter Semantics | | |||
| | Parameter | Value | Parameter | | | | Parameter | Value | Parameter | | | |||
| | Name | Type | Syntax | | | | Name | Type | Syntax | | | |||
| +-----------+--------+--------------+-------------------------------+ | +-----------+--------+-------------+--------------------------------+ | |||
| | alg | string | StringAndURI | The "alg" (algorithm) header | | | alg | string | StringOrURI | The "alg" (algorithm) header | | |||
| | | | | parameter identifies the | | | | | | parameter identifies the | | |||
| | | | | cryptographic algorithm used | | | | | | cryptographic algorithm used | | |||
| | | | | to secure the JWS. A list of | | | | | | to secure the JWS. A list of | | |||
| | | | | reserved alg values is in | | | | | | reserved alg values is in | | |||
| | | | | Table 3. The processing of | | | | | | Table 3. The processing of | | |||
| | | | | the "alg" (algorithm) header | | | | | | the "alg" (algorithm) header | | |||
| | | | | parameter, if present, | | | | | | parameter, if present, | | |||
| | | | | requires that the value of | | | | | | requires that the value of the | | |||
| | | | | the "alg" header parameter | | | | | | "alg" header parameter MUST be | | |||
| | | | | MUST be one that is both | | | | | | one that is both supported and | | |||
| | | | | supported and for which there | | | | | | for which there exists a key | | |||
| | | | | exists a key for use with | | | | | | for use with that algorithm | | |||
| | | | | that algorithm associated | | | | | | associated with the signer of | | |||
| | | | | with the signer of the | | | | | | the content. The "alg" | | |||
| | | | | content. The "alg" parameter | | | | | | parameter value is case | | |||
| | | | | value is case sensitive. | | | | | | sensitive. This header | | |||
| | | | | This header parameter is | | | | | | parameter is REQUIRED. | | |||
| | | | | REQUIRED. | | | typ | string | String | The "typ" (type) header | | |||
| | typ | string | String | The "typ" (type) header | | | | | | parameter is used to declare | | |||
| | | | | parameter is used to declare | | | | | | the type of the signed | | |||
| | | | | the type of the signed | | | | | | content. The "typ" value is | | |||
| | | | | content. The "typ" value is | | | | | | case sensitive. This header | | |||
| | | | | case sensitive. This header | | | | | | parameter is OPTIONAL. | | |||
| | | | | parameter is OPTIONAL. | | | jku | string | URL | The "jku" (JSON Web Key URL) | | |||
| | jku | string | URL | The "jku" (JSON Key URL) | | | | | | header parameter is an | | |||
| | | | | header parameter is a URL | | | | | | absolute URL that refers to a | | |||
| | | | | that points to JSON-encoded | | | | | | resource for a set of | | |||
| | | | | public keys that can be used | | | | | | JSON-encoded public keys, one | | |||
| | | | | to validate the signature. | | | | | | of which corresponds to the | | |||
| | | | | The keys MUST be encoded as | | | | | | key that was used to sign the | | |||
| | | | | per the JSON Web Key (JWK) | | | | | | JWS. The keys MUST be encoded | | |||
| | | | | [JWK] specification. This | | | | | | as described in the JSON Web | | |||
| | | | | header parameter is OPTIONAL. | | | | | | Key (JWK) [JWK] specification. | | |||
| | kid | string | String | The "kid" (key ID) header | | | | | | The protocol used to acquire | | |||
| | | | | parameter is a hint | | | | | | the resource MUST provide | | |||
| | | | | indicating which specific key | | | | | | integrity protection. An HTTP | | |||
| | | | | owned by the signer should be | | | | | | GET request to retrieve the | | |||
| | | | | used to validate the | | | | | | certificate MUST use TLS RFC | | |||
| | | | | signature. This allows | | | | | | 2818 [RFC2818] RFC 5246 | | |||
| | | | | signers to explicitly signal | | | | | | [RFC5246] with server | | |||
| | | | | a change of key to | | | | | | authentication RFC 6125 | | |||
| | | | | recipients. Omitting this | | | | | | [RFC6125]. This header | | |||
| | | | | parameter is equivalent to | | | | | | parameter is OPTIONAL. | | |||
| | | | | setting it to an empty | | | kid | string | String | The "kid" (key ID) header | | |||
| | | | | string. The interpretation | | | | | | parameter is a hint indicating | | |||
| | | | | of the contents of the "kid" | | | | | | which specific key owned by | | |||
| | | | | parameter is unspecified. | | | | | | the signer should be used to | | |||
| | | | | This header parameter is | | | | | | validate the signature. This | | |||
| | | | | OPTIONAL. | | | | | | allows signers to explicitly | | |||
| | x5u | string | URL | The "x5u" (X.509 URL) header | | | | | | signal a change of key to | | |||
| | | | | parameter is a URL utilizing | | | | | | recipients. The | | |||
| | | | | TLS RFC 5785 [RFC5785] that | | | | | | interpretation of the contents | | |||
| | | | | points to an X.509 public key | | | | | | of the "kid" parameter is | | |||
| | | | | certificate or certificate | | | | | | unspecified. This header | | |||
| | | | | chain that can be used to | | | | | | parameter is OPTIONAL. | | |||
| | | | | validate the signature. This | | | x5u | string | URL | The "x5u" (X.509 URL) header | | |||
| | | | | certificate or certificate | | | | | | parameter is an absolute URL | | |||
| | | | | chain MUST use the PEM | | | | | | that refers to a resource for | | |||
| | | | | encoding RFC 1421 [RFC1421] | | | | | | the X.509 public key | | |||
| | | | | and MUST conform to RFC 5280 | | | | | | certificate or certificate | | |||
| | | | | [RFC5280]. This header | | | | | | chain corresponding to the key | | |||
| | | | | parameter is OPTIONAL. | | | | | | used to sign the JWS. The | | |||
| | x5t | string | String | The "x5t" (x.509 certificate | | | | | | identified resource MUST | | |||
| | | | | thumbprint) header parameter | | | | | | provide a representation of | | |||
| | | | | provides a base64url encoded | | | | | | the certificate or certificate | | |||
| | | | | SHA-1 thumbprint (a.k.a. | | | | | | chain that conforms to RFC | | |||
| | | | | digest) of the DER encoding | | | | | | 5280 [RFC5280] in PEM encoded | | |||
| | | | | of an X.509 certificate that | | | | | | form RFC 1421 [RFC1421]. The | | |||
| | | | | can be used to match the | | | | | | protocol used to acquire the | | |||
| | | | | certificate. This header | | | | | | resource MUST provide | | |||
| | | | | parameter is OPTIONAL. | | | | | | integrity protection. An HTTP | | |||
| +-----------+--------+--------------+-------------------------------+ | | | | | GET request to retrieve the | | |||
| | | | | certificate MUST use TLS RFC | | ||||
| | | | | 2818 [RFC2818] RFC 5246 | | ||||
| | | | | [RFC5246] with server | | ||||
| | | | | authentication RFC 6125 | | ||||
| | | | | [RFC6125]. This header | | ||||
| | | | | parameter is OPTIONAL. | | ||||
| | x5t | string | String | The "x5t" (x.509 certificate | | ||||
| | | | | thumbprint) header parameter | | ||||
| | | | | provides a base64url encoded | | ||||
| | | | | SHA-1 thumbprint (a.k.a. | | ||||
| | | | | digest) of the DER encoding of | | ||||
| | | | | an X.509 certificate that can | | ||||
| | | | | be used to match the | | ||||
| | | | | certificate. This header | | ||||
| | | | | parameter is OPTIONAL. | | ||||
| +-----------+--------+-------------+--------------------------------+ | ||||
| Table 1: Reserved Header Parameter Definitions | Table 1: Reserved Header Parameter Definitions | |||
| Additional reserved header parameter names MAY be defined via the | Additional reserved header parameter names MAY be defined via the | |||
| IANA JSON Web Signature Header Parameters registry, as per Section 8. | IANA JSON Web Signature Header Parameters registry, as per Section 7. | |||
| The syntax values used above are defined as follows: | The syntax values used above are defined as follows: | |||
| +--------------+----------------------------------------------------+ | +-------------+-----------------------------------------------------+ | |||
| | Syntax Name | Syntax Definition | | | Syntax Name | Syntax Definition | | |||
| +--------------+----------------------------------------------------+ | +-------------+-----------------------------------------------------+ | |||
| | IntDate | The number of seconds from 1970-01-01T0:0:0Z as | | | IntDate | The number of seconds from 1970-01-01T0:0:0Z as | | |||
| | | measured in UTC until the desired date/time. See | | | | measured in UTC until the desired date/time. See | | |||
| | | RFC 3339 [RFC3339] for details regarding | | | | RFC 3339 [RFC3339] for details regarding date/times | | |||
| | | date/times in general and UTC in particular. | | | | in general and UTC in particular. | | |||
| | String | Any string value MAY be used. | | | String | Any string value MAY be used. | | |||
| | StringAndURI | Any string value MAY be used but a value | | | StringOrURI | Any string value MAY be used but a value containing | | |||
| | | containing a ":" character MUST be a URI as | | | | a ":" character MUST be a URI as defined in RFC | | |||
| | | defined in RFC 3986 [RFC3986]. | | | | 3986 [RFC3986]. | | |||
| | URL | A URL as defined in RFC 1738 [RFC1738]. | | | URL | A URL as defined in RFC 1738 [RFC1738]. | | |||
| +--------------+----------------------------------------------------+ | +-------------+-----------------------------------------------------+ | |||
| Table 2: Header Parameter Syntax Definitions | Table 2: Header Parameter Syntax Definitions | |||
| 4.2. Public Header Parameter Names | 4.2. Public Header Parameter Names | |||
| Additional header parameter names can be defined by those using JWSs. | Additional header parameter names can be defined by those using JWSs. | |||
| However, in order to prevent collisions, any new header parameter | However, in order to prevent collisions, any new header parameter | |||
| name or algorithm value SHOULD either be defined in the IANA JSON Web | name or algorithm value SHOULD either be defined in the IANA JSON Web | |||
| Signature Header Parameters registry or be defined as a URI that | Signature Header Parameters registry or be defined as a URI that | |||
| contains a collision resistant namespace. In each case, the definer | contains a collision resistant namespace. In each case, the definer | |||
| skipping to change at page 9, line 49 ¶ | skipping to change at page 10, line 49 ¶ | |||
| Section 4.2. Unlike Public Names, these private names are subject to | Section 4.2. Unlike Public Names, these private names are subject to | |||
| collision and should be used with caution. | collision and should be used with caution. | |||
| New header parameters should be introduced sparingly, as they can | New header parameters should be introduced sparingly, as they can | |||
| result in non-interoperable JWSs. | result in non-interoperable JWSs. | |||
| 5. Rules for Creating and Validating a JWS | 5. Rules for Creating and Validating a JWS | |||
| To create a JWS, one MUST follow these steps: | To create a JWS, one MUST follow these steps: | |||
| 1. Create the payload content to be encoded as the Decoded JWS | 1. Create the content to be used as the JWS Payload. | |||
| Payload Input. | ||||
| 2. Base64url encode the Decoded JWS Payload Input. This encoding | 2. Base64url encode the JWS Payload. This encoding becomes the | |||
| becomes the JWS Payload Input. | Encoded JWS Payload. | |||
| 3. Create a JSON object containing a set of desired header | 3. Create a JSON object containing a set of desired header | |||
| parameters. Note that white space is explicitly allowed in the | parameters. Note that white space is explicitly allowed in the | |||
| representation and no canonicalization is performed before | representation and no canonicalization is performed before | |||
| encoding. | encoding. | |||
| 4. Translate this JSON object's Unicode code points into UTF-8, as | 4. Translate this JSON object's Unicode code points into UTF-8, as | |||
| defined in RFC 3629 [RFC3629]. | defined in RFC 3629 [RFC3629]. | |||
| 5. Base64url encode the UTF-8 representation of this JSON object as | 5. Base64url encode the UTF-8 representation of this JSON object as | |||
| defined in this specification (without padding). This encoding | defined in this specification (without padding). This encoding | |||
| becomes the JWS Header Input. | becomes the Encoded JWS Header. | |||
| 6. Compute the JWS Crypto Output in the manner defined for the | 6. Compute the JWS Signature in the manner defined for the | |||
| particular algorithm being used. The JWS Signing Input is always | particular algorithm being used. The JWS Signing Input is always | |||
| the concatenation of the JWS Header Input, a period ('.') | the concatenation of the Encoded JWS Header, a period ('.') | |||
| character, and the JWS Payload Input. The "alg" header parameter | character, and the Encoded JWS Payload. The "alg" header | |||
| MUST be present in the JSON Header Input, with the algorithm | parameter MUST be present in the JSON Header, with the algorithm | |||
| value accurately representing the algorithm used to construct the | value accurately representing the algorithm used to construct the | |||
| JWS Crypto Input. | JWS Signature. | |||
| 7. Base64url encode the representation of the JWS Signature to | ||||
| create the Encoded JWS Signature. | ||||
| When validating a JWS, the following steps MUST be taken. If any of | When validating a JWS, the following steps MUST be taken. If any of | |||
| the listed steps fails, then the signed content MUST be rejected. | the listed steps fails, then the signed content MUST be rejected. | |||
| 1. The JWS Payload Input MUST be successfully base64url decoded | 1. The Encoded JWS Payload MUST be successfully base64url decoded | |||
| following the restriction given in this specification that no | following the restriction given in this specification that no | |||
| padding characters have been used. | padding characters have been used. | |||
| 2. The JWS Header Input MUST be successfully base64url decoded | 2. The Encoded JWS Header MUST be successfully base64url decoded | |||
| following the restriction given in this specification that no | following the restriction given in this specification that no | |||
| padding characters have been used. | padding characters have been used. | |||
| 3. The Decoded JWS Header Input MUST be completely valid JSON syntax | 3. The JWS Header MUST be completely valid JSON syntax conforming to | |||
| conforming to RFC 4627 [RFC4627]. | RFC 4627 [RFC4627]. | |||
| 4. The JWS Crypto Output MUST be successfully base64url decoded | 4. The Encoded JWS Signature MUST be successfully base64url decoded | |||
| following the restriction given in this specification that no | following the restriction given in this specification that no | |||
| padding characters have been used. | padding characters have been used. | |||
| 5. The JWS Header Input MUST be validated to only include parameters | 5. The JWS Header MUST be validated to only include parameters and | |||
| and values whose syntax and semantics are both understood and | values whose syntax and semantics are both understood and | |||
| supported. | supported. | |||
| 6. The JWS Crypto Output MUST be successfully validated against the | 6. The JWS Signature MUST be successfully validated against the JWS | |||
| JWS Header Input and JWS Payload Input in the manner defined for | Header and JWS Payload in the manner defined for the algorithm | |||
| the algorithm being used, which MUST be accurately represented by | being used, which MUST be accurately represented by the value of | |||
| the value of the "alg" header parameter, which MUST be present. | the "alg" header parameter, which MUST be present. | |||
| Processing a JWS inevitably requires comparing known strings to | Processing a JWS inevitably requires comparing known strings to | |||
| values in the header. For example, in checking what the algorithm | values in the header. For example, in checking what the algorithm | |||
| is, the Unicode string encoding "alg" will be checked against the | is, the Unicode string encoding "alg" will be checked against the | |||
| member names in the Decoded JWS Header Input to see if there is a | member names in the JWS Header to see if there is a matching header | |||
| matching header parameter name. A similar process occurs when | parameter name. A similar process occurs when determining if the | |||
| determining if the value of the "alg" header parameter represents a | value of the "alg" header parameter represents a supported algorithm. | |||
| supported algorithm. Comparing Unicode strings, however, has | Comparing Unicode strings, however, has significant security | |||
| significant security implications, as per Section 9. | implications, as per Section 8. | |||
| Comparisons between JSON strings and other Unicode strings MUST be | Comparisons between JSON strings and other Unicode strings MUST be | |||
| performed as specified below: | performed as specified below: | |||
| 1. Remove any JSON applied escaping to produce an array of Unicode | 1. Remove any JSON applied escaping to produce an array of Unicode | |||
| code points. | code points. | |||
| 2. Unicode Normalization [USA15] MUST NOT be applied at any point to | 2. Unicode Normalization [USA15] MUST NOT be applied at any point to | |||
| either the JSON string or to the string it is to be compared | either the JSON string or to the string it is to be compared | |||
| against. | against. | |||
| 3. Comparisons between the two strings MUST be performed as a | 3. Comparisons between the two strings MUST be performed as a | |||
| Unicode code point to code point equality comparison. | Unicode code point to code point equality comparison. | |||
| 6. Base64url encoding as used by JWSs | 6. Signing JWSs with Cryptographic Algorithms | |||
| JWSs make use of the base64url encoding as defined in RFC 4648 | ||||
| [RFC4648]. As allowed by Section 3.2 of the RFC, this specification | ||||
| mandates that base64url encoding when used with JWSs MUST NOT use | ||||
| padding. The reason for this restriction is that the padding | ||||
| character ('=') is not URL safe. | ||||
| For notes on implementing base64url encoding without padding, see | ||||
| Appendix C. | ||||
| 7. Signing JWSs with Cryptographic Algorithms | ||||
| JWSs use specific cryptographic algorithms to sign the contents of | JWSs use specific cryptographic algorithms to sign the contents of | |||
| the JWS Header Input and the JWS Payload Input. The use of the | the JWS Header and the JWS Payload. The use of the following | |||
| following algorithms for producing JWSs is defined in this section. | algorithms for producing JWSs is defined in this section. The table | |||
| The table below is the list of "alg" header parameter values reserved | below is the list of "alg" header parameter values reserved by this | |||
| by this specification, each of which is explained in more detail in | specification, each of which is explained in more detail in the | |||
| the following sections: | following sections: | |||
| +--------------------+----------------------------------------------+ | +--------------------+----------------------------------------------+ | |||
| | Alg Parameter | Algorithm | | | Alg Parameter | Algorithm | | |||
| | Value | | | | Value | | | |||
| +--------------------+----------------------------------------------+ | +--------------------+----------------------------------------------+ | |||
| | HS256 | HMAC using SHA-256 hash algorithm | | | HS256 | HMAC using SHA-256 hash algorithm | | |||
| | HS384 | HMAC using SHA-384 hash algorithm | | | HS384 | HMAC using SHA-384 hash algorithm | | |||
| | HS512 | HMAC using SHA-512 hash algorithm | | | HS512 | HMAC using SHA-512 hash algorithm | | |||
| | RS256 | RSA using SHA-256 hash algorithm | | | RS256 | RSA using SHA-256 hash algorithm | | |||
| | RS384 | RSA using SHA-384 hash algorithm | | | RS384 | RSA using SHA-384 hash algorithm | | |||
| skipping to change at page 12, line 32 ¶ | skipping to change at page 13, line 32 ¶ | |||
| Table 3: JSON Web Signature Reserved Algorithm Values | Table 3: JSON Web Signature Reserved Algorithm Values | |||
| See Appendix B for a table cross-referencing the "alg" values used in | See Appendix B for a table cross-referencing the "alg" values used in | |||
| this specification with the equivalent identifiers used by other | this specification with the equivalent identifiers used by other | |||
| standards and software packages. | standards and software packages. | |||
| Of these algorithms, only HMAC SHA-256 MUST be implemented by | Of these algorithms, only HMAC SHA-256 MUST be implemented by | |||
| conforming implementations. It is RECOMMENDED that implementations | conforming implementations. It is RECOMMENDED that implementations | |||
| also support the RSA SHA-256 and ECDSA P-256 SHA-256 algorithms. | also support the RSA SHA-256 and ECDSA P-256 SHA-256 algorithms. | |||
| Support for other algorithms is OPTIONAL. | Support for other algorithms and key sizes is OPTIONAL. | |||
| The signed content for a JWS is the same for all algorithms: the | The signed content for a JWS is the same for all algorithms: the | |||
| concatenation of the JWS Header Input, a period ('.') character, and | concatenation of the Encoded JWS Header, a period ('.') character, | |||
| the JWS Payload Input. This character sequence is referred to as the | and the Encoded JWS Payload. This character sequence is referred to | |||
| JWS Signing Input. Note that if the JWS represents a JWT, this | as the JWS Signing Input. Note that if the JWS represents a JWT, | |||
| corresponds to the portion of the JWT representation preceding the | this corresponds to the portion of the JWT representation preceding | |||
| second period character. The UTF-8 representation of the JWS Signing | the second period character. The UTF-8 representation of the JWS | |||
| Input is passed to the respective signing algorithms. | Signing Input is passed to the respective signing algorithms. | |||
| 7.1. Creating a JWS with HMAC SHA-256, HMAC SHA-384, or HMAC SHA-512 | 6.1. Creating a JWS with HMAC SHA-256, HMAC SHA-384, or HMAC SHA-512 | |||
| Hash based Message Authentication Codes (HMACs) enable one to use a | Hash based Message Authentication Codes (HMACs) enable one to use a | |||
| secret plus a cryptographic hash function to generate a Message | secret plus a cryptographic hash function to generate a Message | |||
| Authentication Code (MAC). This can be used to demonstrate that the | Authentication Code (MAC). This can be used to demonstrate that the | |||
| MAC matches the hashed content, in this case the JWS Signing Input, | MAC matches the hashed content, in this case the JWS Signing Input, | |||
| which therefore demonstrates that whoever generated the MAC was in | which therefore demonstrates that whoever generated the MAC was in | |||
| possession of the secret. The means of exchanging the shared key is | possession of the secret. The means of exchanging the shared key is | |||
| outside the scope of this specification. | outside the scope of this specification. | |||
| The algorithm for implementing and validating HMACs is provided in | The algorithm for implementing and validating HMACs is provided in | |||
| RFC 2104 [RFC2104]. This section defines the use of the HMAC SHA- | RFC 2104 [RFC2104]. This section defines the use of the HMAC SHA- | |||
| 256, HMAC SHA-384, and HMAC SHA-512 cryptographic hash functions as | 256, HMAC SHA-384, and HMAC SHA-512 cryptographic hash functions as | |||
| defined in FIPS 180-3 [FIPS.180-3]. The reserved "alg" header | defined in FIPS 180-3 [FIPS.180-3]. The reserved "alg" header | |||
| parameter values "HS256", "HS384", and "HS512" are used in the JWS | parameter values "HS256", "HS384", and "HS512" are used in the JWS | |||
| Header Input to indicate that the JWS Crypto Output contains a | Header to indicate that the Encoded JWS Signature contains a | |||
| base64url encoded HMAC value using the respective hash function. | base64url encoded HMAC value using the respective hash function. | |||
| The HMAC SHA-256 MAC is generated as follows: | The HMAC SHA-256 MAC is generated as follows: | |||
| 1. Apply the HMAC SHA-256 algorithm to the UTF-8 representation of | 1. Apply the HMAC SHA-256 algorithm to the UTF-8 representation of | |||
| the JWS Signing Input using the shared key to produce an HMAC. | the JWS Signing Input using the shared key to produce an HMAC. | |||
| 2. Base64url encode the HMAC, as defined in this specification. | 2. Base64url encode the HMAC, as defined in this specification. | |||
| The output is the JWS Crypto Output for that JWS. | The output is the Encoded JWS Signature for that JWS. | |||
| The HMAC SHA-256 MAC for a JWS is validated as follows: | The HMAC SHA-256 MAC for a JWS is validated as follows: | |||
| 1. Apply the HMAC SHA-256 algorithm to the UTF-8 representation of | 1. Apply the HMAC SHA-256 algorithm to the UTF-8 representation of | |||
| the JWS Signing Input of the JWS using the shared key. | the JWS Signing Input of the JWS using the shared key. | |||
| 2. Base64url encode the previously generated HMAC, as defined in | 2. Base64url encode the previously generated HMAC, as defined in | |||
| this specification. | this specification. | |||
| 3. If the JWS Crypto Output and the previously calculated value | 3. If the JWS Signature and the previously calculated value exactly | |||
| exactly match, then one has confirmation that the key was used to | match, then one has confirmation that the key was used to | |||
| generate the HMAC on the JWS and that the contents of the JWS | generate the HMAC on the JWS and that the contents of the JWS | |||
| have not be tampered with. | have not be tampered with. | |||
| 4. If the validation fails, the signed content MUST be rejected. | 4. If the validation fails, the signed content MUST be rejected. | |||
| Signing with the HMAC SHA-384 and HMAC SHA-512 algorithms is | Signing with the HMAC SHA-384 and HMAC SHA-512 algorithms is | |||
| performed identically to the procedure for HMAC SHA-256 - just with | performed identically to the procedure for HMAC SHA-256 - just with | |||
| correspondingly longer key and result values. | correspondingly longer key and result values. | |||
| 7.2. Creating a JWS with RSA SHA-256, RSA SHA-384, or RSA SHA-512 | 6.2. Creating a JWS with RSA SHA-256, RSA SHA-384, or RSA SHA-512 | |||
| This section defines the use of the RSASSA-PKCS1-v1_5 signature | This section defines the use of the RSASSA-PKCS1-v1_5 signature | |||
| algorithm as defined in RFC 3447 [RFC3447], Section 8.2 (commonly | algorithm as defined in RFC 3447 [RFC3447], Section 8.2 (commonly | |||
| known as PKCS#1), using SHA-256, SHA-384, or SHA-512 as the hash | known as PKCS#1), using SHA-256, SHA-384, or SHA-512 as the hash | |||
| function. The RSASSA-PKCS1-v1_5 algorithm is described in FIPS 186-3 | function. The RSASSA-PKCS1-v1_5 algorithm is described in FIPS 186-3 | |||
| [FIPS.186-3], Section 5.5, and the SHA-256, SHA-384, and SHA-512 | [FIPS.186-3], Section 5.5, and the SHA-256, SHA-384, and SHA-512 | |||
| cryptographic hash functions are defined in FIPS 180-3 [FIPS.180-3]. | cryptographic hash functions are defined in FIPS 180-3 [FIPS.180-3]. | |||
| The reserved "alg" header parameter values "RS256", "RS384", and | The reserved "alg" header parameter values "RS256", "RS384", and | |||
| "RS512" are used in the JWS Header Input to indicate that the JWS | "RS512" are used in the JWS Header to indicate that the Encoded JWS | |||
| Crypto Output contains a base64url encoded RSA signature using the | Signature contains a base64url encoded RSA signature using the | |||
| respective hash function. | respective hash function. | |||
| The public keys employed may be retrieved using Header Parameter | The public keys employed may be retrieved using Header Parameter | |||
| methods described in Section 4.1 or may be distributed using methods | methods described in Section 4.1 or may be distributed using methods | |||
| that are outside the scope of this specification. | that are outside the scope of this specification. | |||
| A 2048-bit or longer key length MUST be used with this algorithm. | A 2048-bit or longer key length MUST be used with this algorithm. | |||
| The RSA SHA-256 signature is generated as follows: | The RSA SHA-256 signature is generated as follows: | |||
| 1. Generate a digital signature of the UTF-8 representation of the | 1. Generate a digital signature of the UTF-8 representation of the | |||
| JWS Signing Input using RSASSA-PKCS1-V1_5-SIGN and the SHA-256 | JWS Signing Input using RSASSA-PKCS1-V1_5-SIGN and the SHA-256 | |||
| hash function with the desired private key. The output will be a | hash function with the desired private key. The output will be a | |||
| byte array. | byte array. | |||
| 2. Base64url encode the byte array, as defined in this | 2. Base64url encode the byte array, as defined in this | |||
| specification. | specification. | |||
| The output is the JWS Crypto Output for that JWS. | The output is the Encoded JWS Signature for that JWS. | |||
| The RSA SHA-256 signature for a JWS is validated as follows: | The RSA SHA-256 signature for a JWS is validated as follows: | |||
| 1. Take the JWS Crypto Output and base64url decode it into a byte | 1. Take the Encoded JWS Signature and base64url decode it into a | |||
| array. If decoding fails, the signed content MUST be rejected. | byte array. If decoding fails, the signed content MUST be | |||
| rejected. | ||||
| 2. Submit the UTF-8 representation of the JWS Signing Input and the | 2. Submit the UTF-8 representation of the JWS Signing Input and the | |||
| public key corresponding to the private key used by the signer to | public key corresponding to the private key used by the signer to | |||
| the RSASSA-PKCS1-V1_5-VERIFY algorithm using SHA-256 as the hash | the RSASSA-PKCS1-V1_5-VERIFY algorithm using SHA-256 as the hash | |||
| function. | function. | |||
| 3. If the validation fails, the signed content MUST be rejected. | 3. If the validation fails, the signed content MUST be rejected. | |||
| Signing with the RSA SHA-384 and RSA SHA-512 algorithms is performed | Signing with the RSA SHA-384 and RSA SHA-512 algorithms is performed | |||
| identically to the procedure for RSA SHA-256 - just with | identically to the procedure for RSA SHA-256 - just with | |||
| correspondingly longer key and result values. | correspondingly longer key and result values. | |||
| 7.3. Creating a JWS with ECDSA P-256 SHA-256, ECDSA P-384 SHA-384, or | 6.3. Creating a JWS with ECDSA P-256 SHA-256, ECDSA P-384 SHA-384, or | |||
| ECDSA P-521 SHA-512 | ECDSA P-521 SHA-512 | |||
| The Elliptic Curve Digital Signature Algorithm (ECDSA) is defined by | The Elliptic Curve Digital Signature Algorithm (ECDSA) is defined by | |||
| FIPS 186-3 [FIPS.186-3]. ECDSA provides for the use of Elliptic | FIPS 186-3 [FIPS.186-3]. ECDSA provides for the use of Elliptic | |||
| Curve cryptography, which is able to provide equivalent security to | Curve cryptography, which is able to provide equivalent security to | |||
| RSA cryptography but using shorter key lengths and with greater | RSA cryptography but using shorter key lengths and with greater | |||
| processing speed. This means that ECDSA signatures will be | processing speed. This means that ECDSA signatures will be | |||
| substantially smaller in terms of length than equivalently strong RSA | substantially smaller in terms of length than equivalently strong RSA | |||
| Digital Signatures. | Digital Signatures. | |||
| This specification defines the use of ECDSA with the P-256 curve and | This specification defines the use of ECDSA with the P-256 curve and | |||
| the SHA-256 cryptographic hash function, ECDSA with the P-384 curve | the SHA-256 cryptographic hash function, ECDSA with the P-384 curve | |||
| and the SHA-384 hash function, and ECDSA with the P-521 curve and the | and the SHA-384 hash function, and ECDSA with the P-521 curve and the | |||
| SHA-512 hash function. The P-256, P-384, and P-521 curves are also | SHA-512 hash function. The P-256, P-384, and P-521 curves are also | |||
| defined in FIPS 186-3. The reserved "alg" header parameter values | defined in FIPS 186-3. The reserved "alg" header parameter values | |||
| "ES256", "ES384", and "ES512" are used in the JWS Header Input to | "ES256", "ES384", and "ES512" are used in the JWS Header to indicate | |||
| indicate that the JWS Crypto Output contains a based64url encoded | that the Encoded JWS Signature contains a base64url encoded ECDSA | |||
| ECDSA P-256 SHA-256, ECDSA P-384 SHA-384, or ECDSA P-521 SHA-512 | P-256 SHA-256, ECDSA P-384 SHA-384, or ECDSA P-521 SHA-512 signature, | |||
| signature, respectively. | respectively. | |||
| The public keys employed may be retrieved using Header Parameter | The public keys employed may be retrieved using Header Parameter | |||
| methods described in Section 4.1 or may be distributed using methods | methods described in Section 4.1 or may be distributed using methods | |||
| that are outside the scope of this specification. | that are outside the scope of this specification. | |||
| A JWS is signed with an ECDSA P-256 SHA-256 signature as follows: | A JWS is signed with an ECDSA P-256 SHA-256 signature as follows: | |||
| 1. Generate a digital signature of the UTF-8 representation of the | 1. Generate a digital signature of the UTF-8 representation of the | |||
| JWS Signing Input using ECDSA P-256 SHA-256 with the desired | JWS Signing Input using ECDSA P-256 SHA-256 with the desired | |||
| private key. The output will be the EC point (R, S), where R and | private key. The output will be the EC point (R, S), where R and | |||
| S are unsigned integers. | S are unsigned integers. | |||
| 2. Turn R and S into byte arrays in big endian order. Each array | 2. Turn R and S into byte arrays in big endian order. Each array | |||
| will be 32 bytes long. | will be 32 bytes long. | |||
| 3. Concatenate the two byte arrays in the order R and then S. | 3. Concatenate the two byte arrays in the order R and then S. | |||
| 4. Base64url encode the 64 byte array, as defined in this | 4. Base64url encode the 64 byte array, as defined in this | |||
| specification. | specification. | |||
| The output is the JWS Crypto Output for the JWS. | The output is the Encoded JWS Signature for the JWS. | |||
| The ECDSA P-256 SHA-256 signature for a JWS is validated as follows: | The ECDSA P-256 SHA-256 signature for a JWS is validated as follows: | |||
| 1. Take the JWS Crypto Output and base64url decode it into a byte | 1. Take the Encoded JWS Signature and base64url decode it into a | |||
| array. If decoding fails, the signed content MUST be rejected. | byte array. If decoding fails, the signed content MUST be | |||
| rejected. | ||||
| 2. The output of the base64url decoding MUST be a 64 byte array. | 2. The output of the base64url decoding MUST be a 64 byte array. | |||
| 3. Split the 64 byte array into two 32 byte arrays. The first array | 3. Split the 64 byte array into two 32 byte arrays. The first array | |||
| will be R and the second S. Remember that the byte arrays are in | will be R and the second S. Remember that the byte arrays are in | |||
| big endian byte order; please check the ECDSA validator in use to | big endian byte order; please check the ECDSA validator in use to | |||
| see what byte order it requires. | see what byte order it requires. | |||
| 4. Submit the UTF-8 representation of the JWS Signing Input, R, S | 4. Submit the UTF-8 representation of the JWS Signing Input, R, S | |||
| and the public key (x, y) to the ECDSA P-256 SHA-256 validator. | and the public key (x, y) to the ECDSA P-256 SHA-256 validator. | |||
| skipping to change at page 16, line 14 ¶ | skipping to change at page 17, line 16 ¶ | |||
| digital signature instance. This means that two ECDSA digital | digital signature instance. This means that two ECDSA digital | |||
| signatures using exactly the same input parameters will output | signatures using exactly the same input parameters will output | |||
| different signatures because their K values will be different. The | different signatures because their K values will be different. The | |||
| consequence of this is that one must validate an ECDSA signature by | consequence of this is that one must validate an ECDSA signature by | |||
| submitting the previously specified inputs to an ECDSA validator. | submitting the previously specified inputs to an ECDSA validator. | |||
| Signing with the ECDSA P-384 SHA-384 and ECDSA P-521 SHA-512 | Signing with the ECDSA P-384 SHA-384 and ECDSA P-521 SHA-512 | |||
| algorithms is performed identically to the procedure for ECDSA P-256 | algorithms is performed identically to the procedure for ECDSA P-256 | |||
| SHA-256 - just with correspondingly longer key and result values. | SHA-256 - just with correspondingly longer key and result values. | |||
| 7.4. Additional Algorithms | 6.4. Additional Algorithms | |||
| Additional algorithms MAY be used to protect JWSs with corresponding | Additional algorithms MAY be used to protect JWSs with corresponding | |||
| "alg" header parameter values being defined to refer to them. New | "alg" header parameter values being defined to refer to them. New | |||
| "alg" header parameter values SHOULD either be defined in the IANA | "alg" header parameter values SHOULD either be defined in the IANA | |||
| JSON Web Signature Algorithms registry or be a URI that contains a | JSON Web Signature Algorithms registry or be a URI that contains a | |||
| collision resistant namespace. In particular, the use of algorithm | collision resistant namespace. In particular, the use of algorithm | |||
| identifiers defined in XML DSIG [RFC3275] and related specifications | identifiers defined in XML DSIG [RFC3275] and related specifications | |||
| is permitted. | is permitted. | |||
| 8. IANA Considerations | 7. IANA Considerations | |||
| This specification calls for: | This specification calls for: | |||
| o A new IANA registry entitled "JSON Web Signature Header | o A new IANA registry entitled "JSON Web Signature Header | |||
| Parameters" for reserved header parameter names is defined in | Parameters" for reserved header parameter names is defined in | |||
| Section 4.1. Inclusion in the registry is RFC Required in the RFC | Section 4.1. Inclusion in the registry is RFC Required in the RFC | |||
| 5226 [RFC5226] sense for reserved JWS header parameter names that | 5226 [RFC5226] sense for reserved JWS header parameter names that | |||
| are intended to be interoperable between implementations. The | are intended to be interoperable between implementations. The | |||
| registry will just record the reserved header parameter name and a | registry will just record the reserved header parameter name and a | |||
| pointer to the RFC that defines it. This specification defines | pointer to the RFC that defines it. This specification defines | |||
| inclusion of the header parameter names defined in Table 1. | inclusion of the header parameter names defined in Table 1. | |||
| o A new IANA registry entitled "JSON Web Signature Algorithms" for | o A new IANA registry entitled "JSON Web Signature Algorithms" for | |||
| reserved values used with the "alg" header parameter values is | reserved values used with the "alg" header parameter values is | |||
| defined in Section 7.4. Inclusion in the registry is RFC Required | defined in Section 6.4. Inclusion in the registry is RFC Required | |||
| in the RFC 5226 [RFC5226] sense. The registry will just record | in the RFC 5226 [RFC5226] sense. The registry will just record | |||
| the "alg" value and a pointer to the RFC that defines it. This | the "alg" value and a pointer to the RFC that defines it. This | |||
| specification defines inclusion of the algorithm values defined in | specification defines inclusion of the algorithm values defined in | |||
| Table 3. | Table 3. | |||
| 9. Security Considerations | 8. Security Considerations | |||
| TBD: Lots of work to do here. We need to remember to look into any | TBD: Lots of work to do here. We need to remember to look into any | |||
| issues relating to security and JSON parsing. One wonders just how | issues relating to security and JSON parsing. One wonders just how | |||
| secure most JSON parsing libraries are. Were they ever hardened for | secure most JSON parsing libraries are. Were they ever hardened for | |||
| security scenarios? If not, what kind of holes does that open up? | security scenarios? If not, what kind of holes does that open up? | |||
| Also, we need to walk through the JSON standard and see what kind of | Also, we need to walk through the JSON standard and see what kind of | |||
| issues we have especially around comparison of names. For instance, | issues we have especially around comparison of names. For instance, | |||
| comparisons of header parameter names and other parameters must occur | comparisons of header parameter names and other parameters must occur | |||
| after they are unescaped. Need to also put in text about: Importance | after they are unescaped. Need to also put in text about: Importance | |||
| of keeping secrets secret. Rotating keys. Strengths and weaknesses | of keeping secrets secret. Rotating keys. Strengths and weaknesses | |||
| of the different algorithms. | of the different algorithms. | |||
| TBD: Need to put in text about why strict JSON validation is | TBD: Need to put in text about why strict JSON validation is | |||
| necessary. Basically, that if malformed JSON is received then the | necessary. Basically, that if malformed JSON is received then the | |||
| intent of the sender is impossible to reliably discern. | intent of the sender is impossible to reliably discern. One example | |||
| of malformed JSON that MUST be rejected is an object in which the | ||||
| same member name occurs multiple times. | ||||
| TBD: Write security considerations about the implications of using a | TBD: Write security considerations about the implications of using a | |||
| SHA-1 hash (for compatibility reasons) for the "x5t" (x.509 | SHA-1 hash (for compatibility reasons) for the "x5t" (x.509 | |||
| certificate thumbprint). | certificate thumbprint). | |||
| 9.1. Unicode Comparison Security Issues | When utilizing TLS to retrieve information, the authority providing | |||
| the resource MUST be authenticated and the information retrieved MUST | ||||
| be free from modification. | ||||
| 8.1. Unicode Comparison Security Issues | ||||
| Header parameter names in JWSs are Unicode strings. For security | Header parameter names in JWSs are Unicode strings. For security | |||
| reasons, the representations of these names must be compared verbatim | reasons, the representations of these names must be compared verbatim | |||
| after performing any escape processing (as per RFC 4627 [RFC4627], | after performing any escape processing (as per RFC 4627 [RFC4627], | |||
| Section 2.5). | Section 2.5). | |||
| This means, for instance, that these JSON strings must compare as | This means, for instance, that these JSON strings must compare as | |||
| being equal ("sig", "\u0073ig"), whereas these must all compare as | being equal ("sig", "\u0073ig"), whereas these must all compare as | |||
| being not equal to the first set or to each other ("SIG", "Sig", | being not equal to the first set or to each other ("SIG", "Sig", | |||
| "si\u0047"). | "si\u0047"). | |||
| JSON strings MAY contain characters outside the Unicode Basic | JSON strings MAY contain characters outside the Unicode Basic | |||
| Multilingual Plane. For instance, the G clef character (U+1D11E) may | Multilingual Plane. For instance, the G clef character (U+1D11E) may | |||
| be represented in a JSON string as "\uD834\uDD1E". Ideally, JWS | be represented in a JSON string as "\uD834\uDD1E". Ideally, JWS | |||
| implementations SHOULD ensure that characters outside the Basic | implementations SHOULD ensure that characters outside the Basic | |||
| Multilingual Plane are preserved and compared correctly; | Multilingual Plane are preserved and compared correctly; | |||
| alternatively, if this is not possible due to these characters | alternatively, if this is not possible due to these characters | |||
| exercising limitations present in the underlying JSON implementation, | exercising limitations present in the underlying JSON implementation, | |||
| then input containing them MUST be rejected. | then input containing them MUST be rejected. | |||
| 10. Open Issues and Things To Be Done (TBD) | 9. Open Issues and Things To Be Done (TBD) | |||
| The following items remain to be done in this draft (and related | The following items remain to be done in this draft: | |||
| drafts): | ||||
| o Consider whether there is a better term than "Digital Signature" | o Consider whether there is a better term than "Digital Signature" | |||
| for the concept that includes both HMACs and digital signatures | for the concept that includes both HMACs and digital signatures | |||
| using public keys. | using public keys. | |||
| o Consider whether we really want to allow private header parameter | o Consider whether we really want to allow private header parameter | |||
| names that are not registered with IANA and are not in collision- | names that are not registered with IANA and are not in collision- | |||
| resistant namespaces. Eventually this could result in interop | resistant namespaces. Eventually this could result in interop | |||
| nightmares where you need to have different code to talk to | nightmares where you need to have different code to talk to | |||
| different endpoints that "knows" about each endpoint's private | different endpoints that "knows" about each endpoint's private | |||
| skipping to change at page 18, line 37 ¶ | skipping to change at page 19, line 45 ¶ | |||
| o Since RFC 3447 Section 8 explicitly calls for people NOT to adopt | o Since RFC 3447 Section 8 explicitly calls for people NOT to adopt | |||
| RSASSA-PKCS1 for new applications and instead requests that people | RSASSA-PKCS1 for new applications and instead requests that people | |||
| transition to RSASSA-PSS, we probably need some Security | transition to RSASSA-PSS, we probably need some Security | |||
| Considerations text explaining why RSASSA-PKCS1 is being used | Considerations text explaining why RSASSA-PKCS1 is being used | |||
| (it's what's commonly implemented) and what the potential | (it's what's commonly implemented) and what the potential | |||
| consequences are. | consequences are. | |||
| o Add Security Considerations text on timing attacks. | o Add Security Considerations text on timing attacks. | |||
| o It would be good to have a confirmation method element so it could | ||||
| be used with holder-of-key. | ||||
| o Think about how to best describe the concept currently described | ||||
| as "the bytes of the UTF-8 representation of". Possible terms to | ||||
| use instead of "bytes of" include "byte sequence", "octet series", | ||||
| and "octet sequence". Also consider whether we want to add an | ||||
| overall clarifying statement somewhere in each spec something like | ||||
| "every place we say 'the UTF-8 representation of X', we mean 'the | ||||
| bytes of the UTF-8 representation of X'". That would potentially | ||||
| allow us to omit the "the bytes of" part everywhere else. | ||||
| o Consider whether a media type should be proposed, such as | ||||
| "application/jws". | ||||
| o Finish the Security Considerations section. | o Finish the Security Considerations section. | |||
| o Sort out what to do with the IANA registries if this is first | o Add an example in which the payload is not a base64url encoded | |||
| standardized as an OpenID specification. | JSON object. | |||
| o Finish the companion encryption specification, per the agreements | o Consider having an algorithm that is a MAC using SHA-256 that | |||
| documented at http://self-issued.info/?p=378. | provides content integrity but for which there is no associated | |||
| secret. This would be like the JWT "alg":"none", in that no | ||||
| validation of the authenticity content is provided, but with a | ||||
| checksum provided. | ||||
| 11. References | o Consider whether to define the JWT "alg":"none" here, rather than | |||
| in the JWT spec. | ||||
| 11.1. Normative References | 10. References | |||
| 10.1. Normative References | ||||
| [FIPS.180-3] | [FIPS.180-3] | |||
| National Institute of Standards and Technology, "Secure | National Institute of Standards and Technology, "Secure | |||
| Hash Standard (SHS)", FIPS PUB 180-3, October 2008. | Hash Standard (SHS)", FIPS PUB 180-3, October 2008. | |||
| [FIPS.186-3] | [FIPS.186-3] | |||
| National Institute of Standards and Technology, "Digital | National Institute of Standards and Technology, "Digital | |||
| Signature Standard (DSS)", FIPS PUB 186-3, June 2009. | Signature Standard (DSS)", FIPS PUB 186-3, June 2009. | |||
| [JWK] Jones, M., "JSON Web Key (JWK)", April 2011. | [JWK] Jones, M., "JSON Web Key (JWK)", October 2011. | |||
| [JWT] Jones, M., Balfanz, D., Bradley, J., Goland, Y., Panzer, | ||||
| J., Sakimura, N., and P. Tarjan, "JSON Web Token (JWT)", | ||||
| March 2011. | ||||
| [RFC1421] Linn, J., "Privacy Enhancement for Internet Electronic | [RFC1421] Linn, J., "Privacy Enhancement for Internet Electronic | |||
| Mail: Part I: Message Encryption and Authentication | Mail: Part I: Message Encryption and Authentication | |||
| Procedures", RFC 1421, February 1993. | Procedures", RFC 1421, February 1993. | |||
| [RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform | [RFC1738] Berners-Lee, T., Masinter, L., and M. McCahill, "Uniform | |||
| Resource Locators (URL)", RFC 1738, December 1994. | Resource Locators (URL)", RFC 1738, December 1994. | |||
| [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail | [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail | |||
| Extensions (MIME) Part One: Format of Internet Message | Extensions (MIME) Part One: Format of Internet Message | |||
| Bodies", RFC 2045, November 1996. | Bodies", RFC 2045, November 1996. | |||
| [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- | [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- | |||
| Hashing for Message Authentication", RFC 2104, | Hashing for Message Authentication", RFC 2104, | |||
| February 1997. | February 1997. | |||
| [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate | |||
| Requirement Levels", BCP 14, RFC 2119, March 1997. | Requirement Levels", BCP 14, RFC 2119, March 1997. | |||
| [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. | ||||
| [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the | [RFC3339] Klyne, G., Ed. and C. Newman, "Date and Time on the | |||
| Internet: Timestamps", RFC 3339, July 2002. | Internet: Timestamps", RFC 3339, July 2002. | |||
| [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography | [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography | |||
| Standards (PKCS) #1: RSA Cryptography Specifications | Standards (PKCS) #1: RSA Cryptography Specifications | |||
| Version 2.1", RFC 3447, February 2003. | Version 2.1", RFC 3447, February 2003. | |||
| [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO | [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO | |||
| 10646", STD 63, RFC 3629, November 2003. | 10646", STD 63, RFC 3629, November 2003. | |||
| skipping to change at page 20, line 9 ¶ | skipping to change at page 21, line 36 ¶ | |||
| [RFC4627] Crockford, D., "The application/json Media Type for | [RFC4627] Crockford, D., "The application/json Media Type for | |||
| JavaScript Object Notation (JSON)", RFC 4627, July 2006. | JavaScript Object Notation (JSON)", RFC 4627, July 2006. | |||
| [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data | [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data | |||
| Encodings", RFC 4648, October 2006. | Encodings", RFC 4648, October 2006. | |||
| [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an | [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an | |||
| IANA Considerations Section in RFCs", BCP 26, RFC 5226, | IANA Considerations Section in RFCs", BCP 26, RFC 5226, | |||
| May 2008. | May 2008. | |||
| [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security | ||||
| (TLS) Protocol Version 1.2", RFC 5246, August 2008. | ||||
| [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., | [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., | |||
| Housley, R., and W. Polk, "Internet X.509 Public Key | Housley, R., and W. Polk, "Internet X.509 Public Key | |||
| Infrastructure Certificate and Certificate Revocation List | Infrastructure Certificate and Certificate Revocation List | |||
| (CRL) Profile", RFC 5280, May 2008. | (CRL) Profile", RFC 5280, May 2008. | |||
| [RFC5785] Nottingham, M. and E. Hammer-Lahav, "Defining Well-Known | [RFC5785] Nottingham, M. and E. Hammer-Lahav, "Defining Well-Known | |||
| Uniform Resource Identifiers (URIs)", RFC 5785, | Uniform Resource Identifiers (URIs)", RFC 5785, | |||
| April 2010. | April 2010. | |||
| [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and | ||||
| Verification of Domain-Based Application Service Identity | ||||
| within Internet Public Key Infrastructure Using X.509 | ||||
| (PKIX) Certificates in the Context of Transport Layer | ||||
| Security (TLS)", RFC 6125, March 2011. | ||||
| [USA15] Davis, M., Whistler, K., and M. Duerst, "Unicode | [USA15] Davis, M., Whistler, K., and M. Duerst, "Unicode | |||
| Normalization Forms", Unicode Standard Annex 15, 09 2009. | Normalization Forms", Unicode Standard Annex 15, 09 2009. | |||
| 11.2. Informative References | 10.2. Informative References | |||
| [CanvasApp] | [CanvasApp] | |||
| Facebook, "Canvas Applications", 2010. | Facebook, "Canvas Applications", 2010. | |||
| [JCA] Oracle, "Java Cryptography Architecture", 2011. | [JCA] Oracle, "Java Cryptography Architecture", 2011. | |||
| [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", | [JSS] Bradley, J. and N. Sakimura (editor), "JSON Simple Sign", | |||
| September 2010. | September 2010. | |||
| [JWE] Jones, M., Bradley, J., and N. Sakimura, "JSON Web | [JWE] Jones, M., Bradley, J., and N. Sakimura, "JSON Web | |||
| Encryption (JWE)", March 2011. | Encryption (JWE)", October 2011. | |||
| [JWT] Jones, M., Balfanz, D., Bradley, J., Goland, Y., Panzer, | ||||
| J., Sakimura, N., and P. Tarjan, "JSON Web Token (JWT)", | ||||
| October 2011. | ||||
| [MagicSignatures] | [MagicSignatures] | |||
| Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic | Panzer (editor), J., Laurie, B., and D. Balfanz, "Magic | |||
| Signatures", August 2010. | Signatures", August 2010. | |||
| [RFC3275] Eastlake, D., Reagle, J., and D. Solo, "(Extensible Markup | [RFC3275] Eastlake, D., Reagle, J., and D. Solo, "(Extensible Markup | |||
| Language) XML-Signature Syntax and Processing", RFC 3275, | Language) XML-Signature Syntax and Processing", RFC 3275, | |||
| March 2002. | March 2002. | |||
| Appendix A. JWS Examples | Appendix A. JWS Examples | |||
| skipping to change at page 21, line 4 ¶ | skipping to change at page 22, line 41 ¶ | |||
| Language) XML-Signature Syntax and Processing", RFC 3275, | Language) XML-Signature Syntax and Processing", RFC 3275, | |||
| March 2002. | March 2002. | |||
| Appendix A. JWS Examples | Appendix A. JWS Examples | |||
| This section provides several examples of JWSs. While these examples | This section provides several examples of JWSs. While these examples | |||
| all represent JSON Web Tokens (JWTs) [JWT], the payload can be any | all represent JSON Web Tokens (JWTs) [JWT], the payload can be any | |||
| base64url encoded content. | base64url encoded content. | |||
| A.1. JWS using HMAC SHA-256 | A.1. JWS using HMAC SHA-256 | |||
| A.1.1. Encoding | A.1.1. Encoding | |||
| The following example JSON header object declares that the data | The following example JWS Header declares that the data structure is | |||
| structure is a JSON Web Token (JWT) [JWT] and the JWS Signing Input | a JSON Web Token (JWT) [JWT] and the JWS Signing Input is signed | |||
| is signed using the HMAC SHA-256 algorithm. Note that white space is | using the HMAC SHA-256 algorithm. Note that white space is | |||
| explicitly allowed in Decoded JWS Header Input strings and no | explicitly allowed in JWS Header strings and no canonicalization is | |||
| canonicalization is performed before encoding. | performed before encoding. | |||
| {"typ":"JWT", | {"typ":"JWT", | |||
| "alg":"HS256"} | "alg":"HS256"} | |||
| The following byte array contains the UTF-8 characters for the | The following byte array contains the UTF-8 characters for the JWS | |||
| Decoded JWS Header Input: | Header: | |||
| [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, | [123, 34, 116, 121, 112, 34, 58, 34, 74, 87, 84, 34, 44, 13, 10, 32, | |||
| 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] | 34, 97, 108, 103, 34, 58, 34, 72, 83, 50, 53, 54, 34, 125] | |||
| Base64url encoding this UTF-8 representation yields this JWS Header | Base64url encoding this UTF-8 representation yields this Encoded JWS | |||
| Input value: | Header value: | |||
| eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 | eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 | |||
| The Decoded JWS Payload Input used in this example follows. (Note | The JWS Payload used in this example follows. (Note that the payload | |||
| that the payload can be any base64url encoded content, and need not | can be any base64url encoded content, and need not be a base64url | |||
| be a base64url encoded JSON object.) | encoded JSON object.) | |||
| {"iss":"joe", | {"iss":"joe", | |||
| "exp":1300819380, | "exp":1300819380, | |||
| "http://example.com/is_root":true} | "http://example.com/is_root":true} | |||
| The following byte array contains the UTF-8 characters for the | The following byte array contains the UTF-8 characters for the JWS | |||
| Decoded JWS Payload Input: | Payload: | |||
| [123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, | [123, 34, 105, 115, 115, 34, 58, 34, 106, 111, 101, 34, 44, 13, 10, | |||
| 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, | 32, 34, 101, 120, 112, 34, 58, 49, 51, 48, 48, 56, 49, 57, 51, 56, | |||
| 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, | 48, 44, 13, 10, 32, 34, 104, 116, 116, 112, 58, 47, 47, 101, 120, 97, | |||
| 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, | 109, 112, 108, 101, 46, 99, 111, 109, 47, 105, 115, 95, 114, 111, | |||
| 111, 116, 34, 58, 116, 114, 117, 101, 125] | 111, 116, 34, 58, 116, 114, 117, 101, 125] | |||
| Base64url encoding the above yields the JWS Payload Input value: | Base64url encoding the above yields the Encoded JWS Payload value: | |||
| eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | |||
| Concatenating the JWS Header Input, a period character, and the JWS | Concatenating the Encoded JWS Header, a period character, and the | |||
| Payload Input yields this JWS Signing Input value (with line breaks | Encoded JWS Payload yields this JWS Signing Input value (with line | |||
| for display purposes only): | breaks for display purposes only): | |||
| eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 | eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9 | |||
| . | . | |||
| eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | |||
| The UTF-8 representation of the JWS Signing Input is the following | The UTF-8 representation of the JWS Signing Input is the following | |||
| byte array: | byte array: | |||
| [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, | [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, | |||
| 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, | 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, | |||
| 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, | 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, | |||
| skipping to change at page 22, line 14 ¶ | skipping to change at page 24, line 4 ¶ | |||
| [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, | [101, 121, 74, 48, 101, 88, 65, 105, 79, 105, 74, 75, 86, 49, 81, | |||
| 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, | 105, 76, 65, 48, 75, 73, 67, 74, 104, 98, 71, 99, 105, 79, 105, 74, | |||
| 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, | 73, 85, 122, 73, 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, | |||
| 77, 105, 79, 105, 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, | 77, 105, 79, 105, 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, | |||
| 74, 108, 101, 72, 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, | 74, 108, 101, 72, 65, 105, 79, 106, 69, 122, 77, 68, 65, 52, 77, 84, | |||
| 107, 122, 79, 68, 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, | 107, 122, 79, 68, 65, 115, 68, 81, 111, 103, 73, 109, 104, 48, 100, | |||
| 72, 65, 54, 76, 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, | 72, 65, 54, 76, 121, 57, 108, 101, 71, 70, 116, 99, 71, 120, 108, 76, | |||
| 109, 78, 118, 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, | 109, 78, 118, 98, 83, 57, 112, 99, 49, 57, 121, 98, 50, 57, 48, 73, | |||
| 106, 112, 48, 99, 110, 86, 108, 102, 81] | 106, 112, 48, 99, 110, 86, 108, 102, 81] | |||
| HMACs are generated using keys. This example uses the key | HMACs are generated using keys. This example uses the key | |||
| represented by the following byte array: | represented by the following byte array: | |||
| [3, 35, 53, 75, 43, 15, 165, 188, 131, 126, 6, 101, 119, 123, 166, | [3, 35, 53, 75, 43, 15, 165, 188, 131, 126, 6, 101, 119, 123, 166, | |||
| 143, 90, 179, 40, 230, 240, 84, 201, 40, 169, 15, 132, 178, 210, 80, | 143, 90, 179, 40, 230, 240, 84, 201, 40, 169, 15, 132, 178, 210, 80, | |||
| 46, 191, 211, 251, 90, 146, 210, 6, 71, 239, 150, 138, 180, 195, 119, | 46, 191, 211, 251, 90, 146, 210, 6, 71, 239, 150, 138, 180, 195, 119, | |||
| 98, 61, 34, 61, 46, 33, 114, 5, 46, 79, 8, 192, 205, 154, 245, 103, | 98, 61, 34, 61, 46, 33, 114, 5, 46, 79, 8, 192, 205, 154, 245, 103, | |||
| 208, 128, 163] | 208, 128, 163] | |||
| Running the HMAC SHA-256 algorithm on the UTF-8 representation of the | Running the HMAC SHA-256 algorithm on the UTF-8 representation of the | |||
| JWS Signing Input with this key yields the following byte array: | JWS Signing Input with this key yields the following byte array: | |||
| [116, 24, 223, 180, 151, 153, 224, 37, 79, 250, 96, 125, 216, 173, | [116, 24, 223, 180, 151, 153, 224, 37, 79, 250, 96, 125, 216, 173, | |||
| 187, 186, 22, 212, 37, 77, 105, 214, 191, 240, 91, 88, 5, 88, 83, | 187, 186, 22, 212, 37, 77, 105, 214, 191, 240, 91, 88, 5, 88, 83, | |||
| 132, 141, 121] | 132, 141, 121] | |||
| Base64url encoding the above HMAC output yields the JWS Crypto Output | Base64url encoding the above HMAC output yields the Encoded JWS | |||
| value: | Signature value: | |||
| dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk | dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk | |||
| A.1.2. Decoding | A.1.2. Decoding | |||
| Decoding the JWS first requires removing the base64url encoding from | Decoding the JWS first requires removing the base64url encoding from | |||
| the JWS Header Input, the JWS Payload Input, and the JWS Crypto | the Encoded JWS Header, the Encoded JWS Payload, and the Encoded JWS | |||
| Output. We base64url decode the inputs per Section 6 and turn them | Signature. We base64url decode the inputs and turn them into the | |||
| into the corresponding byte arrays. We translate the header input | corresponding byte arrays. We translate the header input byte array | |||
| byte array containing UTF-8 encoded characters into the Decoded JWS | containing UTF-8 encoded characters into the JWS Header string. | |||
| Header Input string. | ||||
| A.1.3. Validating | A.1.3. Validating | |||
| Next we validate the decoded results. Since the "alg" parameter in | Next we validate the decoded results. Since the "alg" parameter in | |||
| the header is "HS256", we validate the HMAC SHA-256 signature | the header is "HS256", we validate the HMAC SHA-256 signature | |||
| contained in the JWS Crypto Output. If any of the validation steps | contained in the JWS Signature. If any of the validation steps fail, | |||
| fail, the signed content MUST be rejected. | the signed content MUST be rejected. | |||
| First, we validate that the decoded JWS Header Input string is legal | First, we validate that the JWS Header string is legal JSON. | |||
| JSON. | ||||
| To validate the signature, we repeat the previous process of using | To validate the signature, we repeat the previous process of using | |||
| the correct key and the UTF-8 representation of the JWS Signing Input | the correct key and the UTF-8 representation of the JWS Signing Input | |||
| as input to a SHA-256 HMAC function and then taking the output and | as input to a SHA-256 HMAC function and then taking the output and | |||
| determining if it matches the Decoded JWS Crypto Output. If it | determining if it matches the JWS Signature. If it matches exactly, | |||
| matches exactly, the signature has been validated. | the signature has been validated. | |||
| A.2. JWS using RSA SHA-256 | A.2. JWS using RSA SHA-256 | |||
| A.2.1. Encoding | A.2.1. Encoding | |||
| The Decoded JWS Header Input in this example is different from the | The JWS Header in this example is different from the previous example | |||
| previous example in two ways: First, because a different algorithm is | in two ways: First, because a different algorithm is being used, the | |||
| being used, the "alg" value is different. Second, for illustration | "alg" value is different. Second, for illustration purposes only, | |||
| purposes only, the optional "typ" parameter is not used. (This | the optional "typ" parameter is not used. (This difference is not | |||
| difference is not related to the signature algorithm employed.) The | related to the signature algorithm employed.) The JWS Header used | |||
| Decoded JWS Header Input used is: | is: | |||
| {"alg":"RS256"} | {"alg":"RS256"} | |||
| The following byte array contains the UTF-8 characters for the | The following byte array contains the UTF-8 characters for the JWS | |||
| Decoded JWS Header Input: | Header: | |||
| [123, 34, 97, 108, 103, 34, 58, 34, 82, 83, 50, 53, 54, 34, 125] | [123, 34, 97, 108, 103, 34, 58, 34, 82, 83, 50, 53, 54, 34, 125] | |||
| Base64url encoding this UTF-8 representation yields this JWS Header | Base64url encoding this UTF-8 representation yields this Encoded JWS | |||
| Input value: | Header value: | |||
| eyJhbGciOiJSUzI1NiJ9 | eyJhbGciOiJSUzI1NiJ9 | |||
| The Decoded JWS Payload Input used in this example, which follows, is | The JWS Payload used in this example, which follows, is the same as | |||
| the same as in the previous example. Since the JWS Payload Input | in the previous example. Since the Encoded JWS Payload will | |||
| will therefore be the same, its computation is not repeated here. | therefore be the same, its computation is not repeated here. | |||
| {"iss":"joe", | {"iss":"joe", | |||
| "exp":1300819380, | "exp":1300819380, | |||
| "http://example.com/is_root":true} | "http://example.com/is_root":true} | |||
| Concatenating the JWS Header Input, a period character, and the JWS | Concatenating the Encoded JWS Header, a period character, and the | |||
| Payload Input yields this JWS Signing Input value (with line breaks | Encoded JWS Payload yields this JWS Signing Input value (with line | |||
| for display purposes only): | breaks for display purposes only): | |||
| eyJhbGciOiJSUzI1NiJ9 | eyJhbGciOiJSUzI1NiJ9 | |||
| . | . | |||
| eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | |||
| The UTF-8 representation of the JWS Signing Input is the following | The UTF-8 representation of the JWS Signing Input is the following | |||
| byte array: | byte array: | |||
| [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73, | [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73, | |||
| 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, | 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, | |||
| 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, | 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, | |||
| skipping to change at page 26, line 33 ¶ | skipping to change at page 28, line 33 ¶ | |||
| | | 46, 176, 47, 158, 58, 65, 214, 18, 202, 173, 21, 145, | | | | 46, 176, 47, 158, 58, 65, 214, 18, 202, 173, 21, 145, | | |||
| | | 18, 115, 160, 95, 35, 185, 232, 56, 250, 175, 132, 157, | | | | 18, 115, 160, 95, 35, 185, 232, 56, 250, 175, 132, 157, | | |||
| | | 105, 132, 41, 239, 90, 30, 136, 121, 130, 54, 195, 212, | | | | 105, 132, 41, 239, 90, 30, 136, 121, 130, 54, 195, 212, | | |||
| | | 14, 96, 69, 34, 165, 68, 200, 242, 122, 122, 45, 184, 6, | | | | 14, 96, 69, 34, 165, 68, 200, 242, 122, 122, 45, 184, 6, | | |||
| | | 99, 209, 108, 247, 202, 234, 86, 222, 64, 92, 178, 33, | | | | 99, 209, 108, 247, 202, 234, 86, 222, 64, 92, 178, 33, | | |||
| | | 90, 69, 178, 194, 85, 102, 181, 90, 193, 167, 72, 160, | | | | 90, 69, 178, 194, 85, 102, 181, 90, 193, 167, 72, 160, | | |||
| | | 112, 223, 200, 163, 42, 70, 149, 67, 208, 25, 238, 251, | | | | 112, 223, 200, 163, 42, 70, 149, 67, 208, 25, 238, 251, | | |||
| | | 71] | | | | 71] | | |||
| +--------+----------------------------------------------------------+ | +--------+----------------------------------------------------------+ | |||
| Base64url encoding the signature produces this value for the JWS | Base64url encoding the signature produces this value for the Encoded | |||
| Crypto Output: | JWS Signature: | |||
| cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw | cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqvhJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrBp0igcN_IoypGlUPQGe77Rw | |||
| A.2.2. Decoding | A.2.2. Decoding | |||
| Decoding the JWS from this example requires processing the JWS Header | Decoding the JWS from this example requires processing the Encoded | |||
| Input and JWS Payload Input exactly as done in the first example. | JWS Header and Encoded JWS Payload exactly as done in the first | |||
| example. | ||||
| A.2.3. Validating | A.2.3. Validating | |||
| Since the "alg" parameter in the header is "RS256", we validate the | Since the "alg" parameter in the header is "RS256", we validate the | |||
| RSA SHA-256 signature contained in the JWS Crypto Output. If any of | RSA SHA-256 signature contained in the JWS Signature. If any of the | |||
| the validation steps fail, the signed content MUST be rejected. | validation steps fail, the signed content MUST be rejected. | |||
| First, we validate that the decoded JWS Header Input string is legal | First, we validate that the JWS Header string is legal JSON. | |||
| JSON. | ||||
| Validating the JWS Crypto Output is a little different from the | Validating the JWS Signature is a little different from the previous | |||
| previous example. First, we base64url decode the JWS Crypto Output | example. First, we base64url decode the Encoded JWS Signature to | |||
| to produce a signature S to check. We then pass (n, e), S and the | produce a signature S to check. We then pass (n, e), S and the UTF-8 | |||
| UTF-8 representation of the JWS Signing Input to an RSA signature | representation of the JWS Signing Input to an RSA signature verifier | |||
| verifier that has been configured to use the SHA-256 hash function. | that has been configured to use the SHA-256 hash function. | |||
| A.3. JWS using ECDSA P-256 SHA-256 | A.3. JWS using ECDSA P-256 SHA-256 | |||
| A.3.1. Encoding | A.3.1. Encoding | |||
| The Decoded JWS Header Input for this example differs from the | The JWS Header for this example differs from the previous example | |||
| previous example because a different algorithm is being used. The | because a different algorithm is being used. The JWS Header used is: | |||
| Decoded JWS Header Input used is: | ||||
| {"alg":"ES256"} | {"alg":"ES256"} | |||
| The following byte array contains the UTF-8 characters for the | The following byte array contains the UTF-8 characters for the JWS | |||
| Decoded JWS Header Input: | Header: | |||
| [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 50, 53, 54, 34, 125] | [123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 50, 53, 54, 34, 125] | |||
| Base64url encoding this UTF-8 representation yields this JWS Header | Base64url encoding this UTF-8 representation yields this Encoded JWS | |||
| Input value: | Header value: | |||
| eyJhbGciOiJFUzI1NiJ9 | eyJhbGciOiJFUzI1NiJ9 | |||
| The Decoded JWS Payload Input used in this example, which follows, is | The JWS Payload used in this example, which follows, is the same as | |||
| the same as in the previous examples. Since the JWS Payload Input | in the previous examples. Since the Encoded JWS Payload will | |||
| will therefore be the same, its computation is not repeated here. | therefore be the same, its computation is not repeated here. | |||
| {"iss":"joe", | {"iss":"joe", | |||
| "exp":1300819380, | "exp":1300819380, | |||
| "http://example.com/is_root":true} | "http://example.com/is_root":true} | |||
| Concatenating the JWS Header Input, a period character, and the JWS | Concatenating the Encoded JWS Header, a period character, and the | |||
| Payload Input yields this JWS Signing Input value (with line breaks | Encoded JWS Payload yields this JWS Signing Input value (with line | |||
| for display purposes only): | breaks for display purposes only): | |||
| eyJhbGciOiJFUzI1NiJ9 | eyJhbGciOiJFUzI1NiJ9 | |||
| . | . | |||
| eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ | |||
| The UTF-8 representation of the JWS Signing Input is the following | The UTF-8 representation of the JWS Signing Input is the following | |||
| byte array: | byte array: | |||
| [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 73, | [101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 70, 85, 122, 73, | |||
| 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, | 49, 78, 105, 74, 57, 46, 101, 121, 74, 112, 99, 51, 77, 105, 79, 105, | |||
| 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, | 74, 113, 98, 50, 85, 105, 76, 65, 48, 75, 73, 67, 74, 108, 101, 72, | |||
| skipping to change at page 28, line 43 ¶ | skipping to change at page 30, line 42 ¶ | |||
| +--------+----------------------------------------------------------+ | +--------+----------------------------------------------------------+ | |||
| | R | [14, 209, 33, 83, 121, 99, 108, 72, 60, 47, 127, 21, 88, | | | R | [14, 209, 33, 83, 121, 99, 108, 72, 60, 47, 127, 21, 88, | | |||
| | | 7, 212, 2, 163, 178, 40, 3, 58, 249, 124, 126, 23, 129, | | | | 7, 212, 2, 163, 178, 40, 3, 58, 249, 124, 126, 23, 129, | | |||
| | | 154, 195, 22, 158, 166, 101] | | | | 154, 195, 22, 158, 166, 101] | | |||
| | S | [197, 10, 7, 211, 140, 60, 112, 229, 216, 241, 45, 175, | | | S | [197, 10, 7, 211, 140, 60, 112, 229, 216, 241, 45, 175, | | |||
| | | 8, 74, 84, 128, 166, 101, 144, 197, 242, 147, 80, 154, | | | | 8, 74, 84, 128, 166, 101, 144, 197, 242, 147, 80, 154, | | |||
| | | 143, 63, 127, 138, 131, 163, 84, 213] | | | | 143, 63, 127, 138, 131, 163, 84, 213] | | |||
| +--------+----------------------------------------------------------+ | +--------+----------------------------------------------------------+ | |||
| Concatenating the S array to the end of the R array and base64url | Concatenating the S array to the end of the R array and base64url | |||
| encoding the result produces this value for the JWS Crypto Output: | encoding the result produces this value for the Encoded JWS | |||
| Signature: | ||||
| DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q | DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q | |||
| A.3.2. Decoding | A.3.2. Decoding | |||
| Decoding the JWS from this example requires processing the JWS Header | Decoding the JWS from this example requires processing the Encoded | |||
| Input and JWS Payload Input exactly as done in the first example. | JWS Header and Encoded JWS Payload exactly as done in the first | |||
| example. | ||||
| A.3.3. Validating | A.3.3. Validating | |||
| Since the "alg" parameter in the header is "ES256", we validate the | Since the "alg" parameter in the header is "ES256", we validate the | |||
| ECDSA P-256 SHA-256 signature contained in the JWS Crypto Output. If | ECDSA P-256 SHA-256 signature contained in the JWS Signature. If any | |||
| any of the validation steps fail, the signed content MUST be | of the validation steps fail, the signed content MUST be rejected. | |||
| rejected. | ||||
| First, we validate that the decoded JWS Header Input string is legal | First, we validate that the JWS Header string is legal JSON. | |||
| JSON. | ||||
| Validating the JWS Crypto Output is a little different from the first | Validating the JWS Signature is a little different from the first | |||
| example. First, we base64url decode the JWS Crypto Output as in the | example. First, we base64url decode the Encoded JWS Signature as in | |||
| previous examples but we then need to split the 64 member byte array | the previous examples but we then need to split the 64 member byte | |||
| that must result into two 32 byte arrays, the first R and the second | array that must result into two 32 byte arrays, the first R and the | |||
| S. We then pass (x, y), (R, S) and the UTF-8 representation of the | second S. We then pass (x, y), (R, S) and the UTF-8 representation of | |||
| JWS Signing Input to an ECDSA signature verifier that has been | the JWS Signing Input to an ECDSA signature verifier that has been | |||
| configured to use the P-256 curve with the SHA-256 hash function. | configured to use the P-256 curve with the SHA-256 hash function. | |||
| As explained in Section 7.3, the use of the k value in ECDSA means | As explained in Section 6.3, the use of the k value in ECDSA means | |||
| that we cannot validate the correctness of the signature in the same | that we cannot validate the correctness of the signature in the same | |||
| way we validated the correctness of the HMAC. Instead, | way we validated the correctness of the HMAC. Instead, | |||
| implementations MUST use an ECDSA validator to validate the | implementations MUST use an ECDSA validator to validate the | |||
| signature. | signature. | |||
| Appendix B. Algorithm Identifier Cross-Reference | Appendix B. Algorithm Identifier Cross-Reference | |||
| This appendix contains a table cross-referencing the "alg" values | This appendix contains a table cross-referencing the "alg" values | |||
| used in this specification with the equivalent identifiers used by | used in this specification with the equivalent identifiers used by | |||
| other standards and software packages. See XML DSIG [RFC3275] and | other standards and software packages. See XML DSIG [RFC3275] and | |||
| skipping to change at page 33, line 7 ¶ | skipping to change at page 35, line 7 ¶ | |||
| A-z_4ME | A-z_4ME | |||
| Appendix D. Acknowledgements | Appendix D. Acknowledgements | |||
| Solutions for signing JSON content were previously explored by Magic | Solutions for signing JSON content were previously explored by Magic | |||
| Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas | Signatures [MagicSignatures], JSON Simple Sign [JSS], and Canvas | |||
| Applications [CanvasApp], all of which influenced this draft. | Applications [CanvasApp], all of which influenced this draft. | |||
| Appendix E. Document History | Appendix E. Document History | |||
| -03 | ||||
| o Simplified terminology to better match JWE, where the terms "JWS | ||||
| Header" and "Encoded JWS Header", are now used, for instance, | ||||
| rather than the previous terms "Decoded JWS Header Input" and "JWS | ||||
| Header Input". Likewise the terms "JWS Payload" and "JWS | ||||
| Signature" are now used, rather than "JWS Payload Input" and "JWS | ||||
| Crypto Output". | ||||
| o The "jku" and "x5u" URLs are now required to be absolute URLs. | ||||
| o Removed this unnecessary language from the "kid" description: | ||||
| "Omitting this parameter is equivalent to setting it to an empty | ||||
| string". | ||||
| o Changed StringAndURI to StringOrURI. | ||||
| -02 | -02 | |||
| o Reference the JSON Web Key (JWK) specification from the "jku" | o Reference the JSON Web Key (JWK) specification from the "jku" | |||
| header parameter. | header parameter. | |||
| -01 | -01 | |||
| o Changed RSA SHA-256 from MUST be supported to RECOMMENDED that it | o Changed RSA SHA-256 from MUST be supported to RECOMMENDED that it | |||
| be supported. Rationale: Several people have objected to the | be supported. Rationale: Several people have objected to the | |||
| requirement for implementing RSA SHA-256, some because they will | requirement for implementing RSA SHA-256, some because they will | |||
| End of changes. 114 change blocks. | ||||
| 367 lines changed or deleted | 427 lines changed or added | |||
This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ | ||||