JOSE Working Group M. Jones
Internet-Draft Microsoft
Intended status: Standards Track J. Bradley
Expires: April 18, 2013 Ping Identity
N. Sakimura
NRI
October 15, 2012
JSON Web Signature (JWS)draft-ietf-jose-json-web-signature-06
Abstract
JSON Web Signature (JWS) is a means of representing content secured
with digital signatures or Message Authentication Codes (MACs) using
JavaScript Object Notation (JSON) data structures. Cryptographic
algorithms and identifiers for use with this specification are
described in the separate JSON Web Algorithms (JWA) specification.
Related encryption capabilities are described in the separate JSON
Web Encryption (JWE) specification.
Status of this Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on April 18, 2013.
Copyright Notice
Copyright (c) 2012 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
Jones, et al. Expires April 18, 2013 [Page 1]

Internet-Draft JSON Web Signature (JWS) October 20121. Introduction
JSON Web Signature (JWS) is a compact format for representing content
secured with digital signatures or Message Authentication Codes
(MACs) intended for space constrained environments such as HTTP
Authorization headers and URI query parameters. It represents this
content using JavaScript Object Notation (JSON) [RFC4627] based data
structures. The JWS cryptographic mechanisms provide integrity
protection for arbitrary sequences of bytes.
Cryptographic algorithms and identifiers for use with this
specification are described in the separate JSON Web Algorithms (JWA)
[JWA] specification. Related encryption capabilities are described
in the separate JSON Web Encryption (JWE) [JWE] specification.
1.1. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in Key words for use in
RFCs to Indicate Requirement Levels [RFC2119].
2. Terminology
JSON Web Signature (JWS) A data structure cryptographically securing
a JWS Header and a JWS Payload with a JWS Signature value.
JWS Header A string representing a JSON object that describes the
digital signature or MAC operation applied to create the JWS
Signature value.
JWS Payload The bytes to be secured -- a.k.a., the message. The
payload can contain an arbitrary sequence of bytes.
JWS Signature A byte array containing the cryptographic material
that secures the JWS Header and the JWS Payload.
Base64url Encoding The URL- and filename-safe Base64 encoding
described in RFC 4648[RFC4648], Section 5, with the (non URL-
safe) '=' padding characters omitted, as permitted by Section 3.2.
(See Appendix C for notes on implementing base64url encoding
without padding.)
Encoded JWS Header Base64url encoding of the bytes of the UTF-8
[RFC3629] representation of the JWS Header.
Jones, et al. Expires April 18, 2013 [Page 4]

Internet-Draft JSON Web Signature (JWS) October 2012
Encoded JWS Payload Base64url encoding of the JWS Payload.
Encoded JWS Signature Base64url encoding of the JWS Signature.
JWS Secured Input The concatenation of the Encoded JWS Header, a
period ('.') character, and the Encoded JWS Payload.
Header Parameter Name The name of a member of the JSON object
representing a JWS Header.
Header Parameter Value The value of a member of the JSON object
representing a JWS Header.
JWS Compact Serialization A representation of the JWS as the
concatenation of the Encoded JWS Header, the Encoded JWS Payload,
and the Encoded JWS Signature in that order, with the three
strings being separated by two period ('.') characters.
Collision Resistant Namespace A namespace that allows names to be
allocated in a manner such that they are highly unlikely to
collide with other names. For instance, collision resistance can
be achieved through administrative delegation of portions of the
namespace or through use of collision-resistant name allocation
functions. Examples of Collision Resistant Namespaces include:
Domain Names, Object Identifiers (OIDs) as defined in the ITU-T
X.660 and X.670 Recommendation series, and Universally Unique
IDentifiers (UUIDs) [RFC4122]. When using an administratively
delegated namespace, the definer of a name needs to take
reasonable precautions to ensure they are in control of the
portion of the namespace they use to define the name.
StringOrURI A JSON string value, with the additional requirement
that while arbitrary string values MAY be used, any value
containing a ":" character MUST be a URI [RFC3986]. StringOrURI
values are compared as case-sensitive strings with no
transformations or canonicalizations applied.
3. JSON Web Signature (JWS) Overview
JWS represents digitally signed or MACed content using JSON data
structures and base64url encoding. The representation consists of
three parts: the JWS Header, the JWS Payload, and the JWS Signature.
In the Compact Serialization, the three parts are base64url-encoded
for transmission, and represented as the concatenation of the encoded
strings in that order, with the three strings being separated by two
period ('.') characters. (A JSON Serialization for this information
is defined in the separate JSON Web Signature JSON Serialization
Jones, et al. Expires April 18, 2013 [Page 5]

Internet-Draft JSON Web Signature (JWS) October 2012
(JWS-JS) [JWS-JS] specification.)
The JWS Header describes the signature or MAC method and parameters
employed. The JWS Payload is the message content to be secured. The
JWS Signature ensures the integrity of both the JWS Header and the
JWS Payload.
3.1. Example JWS
The following example JWS Header declares that the encoded object is
a JSON Web Token (JWT) [JWT] and the JWS Header and the JWS Payload
are secured using the HMAC SHA-256 algorithm:
{"typ":"JWT",
"alg":"HS256"}
Base64url encoding the bytes of the UTF-8 representation of the JWS
Header yields this Encoded JWS Header value:
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
The following is an example of a JSON object that can be used as a
JWS Payload. (Note that the payload can be any content, and need not
be a representation of a JSON object.)
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
Base64url encoding the bytes of the UTF-8 representation of the JSON
object yields the following Encoded JWS Payload (with line breaks for
display purposes only):
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
Computing the HMAC of the bytes of the ASCII [USASCII] representation
of the JWS Secured Input (the concatenation of the Encoded JWS
Header, a period ('.') character, and the Encoded JWS Payload) with
the HMAC SHA-256 algorithm using the key specified in Appendix A.1
and base64url encoding the result yields this Encoded JWS Signature
value:
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
Concatenating these parts in the order Header.Payload.Signature with
period ('.') characters between the parts yields this complete JWS
representation (with line breaks for display purposes only):
Jones, et al. Expires April 18, 2013 [Page 6]

Internet-Draft JSON Web Signature (JWS) October 2012
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
.
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
This computation is illustrated in more detail in Appendix A.1.
4. JWS Header
The members of the JSON object represented by the JWS Header describe
the digital signature or MAC applied to the Encoded JWS Header and
the Encoded JWS Payload and optionally additional properties of the
JWS. The Header Parameter Names within this object MUST be unique;
JWSs with duplicate Header Parameter Names MUST be rejected.
Implementations MUST understand the entire contents of the header;
otherwise, the JWS MUST be rejected.
There are three classes of Header Parameter Names: Reserved Header
Parameter Names, Public Header Parameter Names, and Private Header
Parameter Names.
4.1. Reserved Header Parameter Names
The following header parameter names are reserved with meanings as
defined below. All the names are short because a core goal of JWSs
is for the representations to be compact.
Additional reserved header parameter names MAY be defined via the
IANA JSON Web Signature and Encryption Header Parameters registry
Section 7.1. As indicated by the common registry, JWSs and JWEs
share a common header parameter space; when a parameter is used by
both specifications, its usage must be compatible between the
specifications.
4.1.1. "alg" (Algorithm) Header Parameter
The "alg" (algorithm) header parameter identifies the cryptographic
algorithm used to secure the JWS. The algorithm specified by the
"alg" value MUST be supported by the implementation and there MUST be
a key for use with that algorithm associated with the party that
digitally signed or MACed the content or the JWS MUST be rejected.
"alg" values SHOULD either be registered in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA] or be a URI that
contains a Collision Resistant Namespace. The "alg" value is a case
sensitive string containing a StringOrURI value. This header
Jones, et al. Expires April 18, 2013 [Page 7]

Internet-Draft JSON Web Signature (JWS) October 2012
parameter is REQUIRED.
A list of defined "alg" values can be found in the IANA JSON Web
Signature and Encryption Algorithms registry [JWA]; the initial
contents of this registry are the values defined in Section 3.1 of
the JSON Web Algorithms (JWA) [JWA] specification.
4.1.2. "jku" (JWK Set URL) Header Parameter
The "jku" (JWK Set URL) header parameter is a URI [RFC3986] that
refers to a resource for a set of JSON-encoded public keys, one of
which corresponds to the key used to digitally sign the JWS. The
keys MUST be encoded as a JSON Web Key Set (JWK Set) [JWK]. The
protocol used to acquire the resource MUST provide integrity
protection; an HTTP GET request to retrieve the certificate MUST use
TLS [RFC2818] [RFC5246]; the identity of the server MUST be
validated, as per Section 3.1 of HTTP Over TLS [RFC2818]. This
header parameter is OPTIONAL.
4.1.3. "jwk" (JSON Web Key) Header Parameter
The "jwk" (JSON Web Key) header parameter is a public key that
corresponds to the key used to digitally sign the JWS. This key is
represented as a JSON Web Key [JWK]. This header parameter is
OPTIONAL.
4.1.4. "x5u" (X.509 URL) Header Parameter
The "x5u" (X.509 URL) header parameter is a URI [RFC3986] that refers
to a resource for the X.509 public key certificate or certificate
chain [RFC5280] corresponding to the key used to digitally sign the
JWS. The identified resource MUST provide a representation of the
certificate or certificate chain that conforms to RFC 5280 [RFC5280]
in PEM encoded form [RFC1421]. The certificate containing the public
key of the entity that digitally signed the JWS MUST be the first
certificate. This MAY be followed by additional certificates, with
each subsequent certificate being the one used to certify the
previous one. The protocol used to acquire the resource MUST provide
integrity protection; an HTTP GET request to retrieve the certificate
MUST use TLS [RFC2818] [RFC5246]; the identity of the server MUST be
validated, as per Section 3.1 of HTTP Over TLS [RFC2818]. This
header parameter is OPTIONAL.
4.1.5. "x5t" (X.509 Certificate Thumbprint) Header Parameter
The "x5t" (X.509 Certificate Thumbprint) header parameter provides a
base64url encoded SHA-1 thumbprint (a.k.a. digest) of the DER
encoding of the X.509 certificate [RFC5280] corresponding to the key
Jones, et al. Expires April 18, 2013 [Page 8]

Internet-Draft JSON Web Signature (JWS) October 2012
used to digitally sign the JWS. This header parameter is OPTIONAL.
If, in the future, certificate thumbprints need to be computed using
hash functions other than SHA-1, it is suggested that additional
related header parameters be defined for that purpose. For example,
it is suggested that a new "x5t#S256" (X.509 Certificate Thumbprint
using SHA-256) header parameter could be defined by registering it in
the IANA JSON Web Signature and Encryption Header Parameters registry
Section 7.1.
4.1.6. "x5c" (X.509 Certificate Chain) Header Parameter
The "x5c" (X.509 Certificate Chain) header parameter contains the
X.509 public key certificate or certificate chain [RFC5280]
corresponding to the key used to digitally sign the JWS. The
certificate or certificate chain is represented as an array of
certificate value strings. Each string is a base64 encoded
([RFC4648] Section 4 -- not base64url encoded) DER [ITU.X690.1994]
PKIX certificate value. The certificate containing the public key of
the entity that digitally signed the JWS MUST be the first
certificate. This MAY be followed by additional certificates, with
each subsequent certificate being the one used to certify the
previous one. The recipient MUST verify the certificate chain
according to [RFC5280] and reject the JWS if any validation failure
occurs. This header parameter is OPTIONAL.
See Appendix B for an example "x5c" value.
4.1.7. "kid" (Key ID) Header Parameter
The "kid" (key ID) header parameter is a hint indicating which key
was used to secure the JWS. This parameter allows originators to
explicitly signal a change of key to recipients. Should the
recipient be unable to locate a key corresponding to the "kid" value,
they SHOULD treat that condition as an error. The interpretation of
the "kid" value is unspecified. Its value MUST be a string. This
header parameter is OPTIONAL.
When used with a JWK, the "kid" value MAY be used to match a JWK
"kid" parameter value.
4.1.8. "typ" (Type) Header Parameter
The "typ" (type) header parameter is used to declare the type of this
object. The type value "JWS" MAY be used to indicate that this
object is a JWS. The "typ" value is a case sensitive string. This
header parameter is OPTIONAL.
Jones, et al. Expires April 18, 2013 [Page 9]

Internet-Draft JSON Web Signature (JWS) October 2012
MIME Media Type [RFC2046] values MAY be used as "typ" values.
"typ" values SHOULD either be registered in the IANA JSON Web
Signature and Encryption Type Values registry Section 7.2 or be a URI
that contains a Collision Resistant Namespace.
4.1.9. "cty" (Content Type) Header Parameter
The "cty" (content type) header parameter is used to declare the type
of the secured content (the Payload). The "cty" value is a case
sensitive string. This header parameter is OPTIONAL.
The values used for the "cty" header parameter come from the same
value space as the "typ" header parameter, with the same rules
applying.
4.2. Public Header Parameter Names
Additional header parameter names can be defined by those using JWSs.
However, in order to prevent collisions, any new header parameter
name SHOULD either be registered in the IANA JSON Web Signature and
Encryption Header Parameters registry Section 7.1 or be a URI that
contains a Collision Resistant Namespace. In each case, the definer
of the name or value needs to take reasonable precautions to make
sure they are in control of the part of the namespace they use to
define the header parameter name.
New header parameters should be introduced sparingly, as they can
result in non-interoperable JWSs.
4.3. Private Header Parameter Names
A producer and consumer of a JWS may agree to any header parameter
name that is not a Reserved Name Section 4.1 or a Public Name
Section 4.2. Unlike Public Names, these private names are subject to
collision and should be used with caution.
5. Rules for Creating and Validating a JWS
To create a JWS, one MUST perform these steps. The order of the
steps is not significant in cases where there are no dependencies
between the inputs and outputs of the steps.
1. Create the content to be used as the JWS Payload.
2. Base64url encode the bytes of the JWS Payload. This encoding
becomes the Encoded JWS Payload.
Jones, et al. Expires April 18, 2013 [Page 10]

Internet-Draft JSON Web Signature (JWS) October 2012
3. Create a JWS Header containing the desired set of header
parameters. Note that white space is explicitly allowed in the
representation and no canonicalization need be performed before
encoding.
4. Base64url encode the bytes of the UTF-8 representation of the JWS
Header to create the Encoded JWS Header.
5. Compute the JWS Signature in the manner defined for the
particular algorithm being used. The JWS Secured Input is always
the concatenation of the Encoded JWS Header, a period ('.')
character, and the Encoded JWS Payload. The "alg" (algorithm)
header parameter MUST be present in the JSON Header, with the
algorithm value accurately representing the algorithm used to
construct the JWS Signature.
6. Base64url encode the representation of the JWS Signature to
create the Encoded JWS Signature.
7. The three encoded parts, taken together, are the result. The
Compact Serialization of this result is the concatenation of the
Encoded JWS Header, the Encoded JWS Payload, and the Encoded JWS
Signature in that order, with the three strings being separated
by two period ('.') characters.
When validating a JWS, the following steps MUST be taken. The order
of the steps is not significant in cases where there are no
dependencies between the inputs and outputs of the steps. If any of
the listed steps fails, then the JWS MUST be rejected.
1. Parse the three parts of the input (which are separated by period
('.') characters when using the JWS Compact Serialization) into
the Encoded JWS Header, the Encoded JWS Payload, and the Encoded
JWS Signature.
2. The Encoded JWS Header MUST be successfully base64url decoded
following the restriction given in this specification that no
padding characters have been used.
3. The resulting JWS Header MUST be completely valid JSON syntax
conforming to RFC 4627 [RFC4627].
4. The resulting JWS Header MUST be validated to only include
parameters and values whose syntax and semantics are both
understood and supported.
5. The Encoded JWS Payload MUST be successfully base64url decoded
following the restriction given in this specification that no
Jones, et al. Expires April 18, 2013 [Page 11]

Internet-Draft JSON Web Signature (JWS) October 2012
padding characters have been used.
6. The Encoded JWS Signature MUST be successfully base64url decoded
following the restriction given in this specification that no
padding characters have been used.
7. The JWS Signature MUST be successfully validated against the JWS
Secured Input (the concatenation of the Encoded JWS Header, a
period ('.') character, and the Encoded JWS Payload) in the
manner defined for the algorithm being used, which MUST be
accurately represented by the value of the "alg" (algorithm)
header parameter, which MUST be present.
Processing a JWS inevitably requires comparing known strings to
values in the header. For example, in checking what the algorithm
is, the Unicode string encoding "alg" will be checked against the
member names in the JWS Header to see if there is a matching header
parameter name. A similar process occurs when determining if the
value of the "alg" header parameter represents a supported algorithm.
Comparisons between JSON strings and other Unicode strings MUST be
performed as specified below:
1. Remove any JSON applied escaping to produce an array of Unicode
code points.
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
against.
3. Comparisons between the two strings MUST be performed as a
Unicode code point to code point equality comparison.
6. Securing JWSs with Cryptographic Algorithms
JWS uses cryptographic algorithms to digitally sign or MAC the JWS
Header and the JWS Payload. The JSON Web Algorithms (JWA) [JWA]
specification describes a set of cryptographic algorithms and
identifiers to be used with this specification. Specifically,
Section 3.1 specifies a set of "alg" (algorithm) header parameter
values intended for use this specification. It also describes the
semantics and operations that are specific to these algorithms and
algorithm families.
Public keys employed for digital signing can be identified using the
Header Parameter methods described in Section 4.1 or can be
distributed using methods that are outside the scope of this
Jones, et al. Expires April 18, 2013 [Page 12]

Internet-Draft JSON Web Signature (JWS) October 2012
specification.
7. IANA Considerations
The following registration procedure is used for all the registries
established by this specification.
Values are registered with a Specification Required [RFC5226] after a
two-week review period on the [TBD]@ietf.org mailing list, on the
advice of one or more Designated Experts. However, to allow for the
allocation of values prior to publication, the Designated Expert(s)
may approve registration once they are satisfied that such a
specification will be published.
Registration requests must be sent to the [TBD]@ietf.org mailing list
for review and comment, with an appropriate subject (e.g., "Request
for access token type: example"). [[ Note to RFC-EDITOR: The name of
the mailing list should be determined in consultation with the IESG
and IANA. Suggested name: jose-reg-review. ]]
Within the review period, the Designated Expert(s) will either
approve or deny the registration request, communicating this decision
to the review list and IANA. Denials should include an explanation
and, if applicable, suggestions as to how to make the request
successful.
IANA must only accept registry updates from the Designated Expert(s)
and should direct all requests for registration to the review mailing
list.
7.1. JSON Web Signature and Encryption Header Parameters Registry
This specification establishes the IANA JSON Web Signature and
Encryption Header Parameters registry for reserved JWS and JWE header
parameter names. The registry records the reserved header parameter
name and a reference to the specification that defines it. The same
Header Parameter Name may be registered multiple times, provided that
the parameter usage is compatible between the specifications.
7.1.1. Registration Template
Header Parameter Name:
The name requested (e.g., "example"). This name is case
sensitive. Names that match other registered names in a case
insensitive manner SHOULD NOT be accepted.
Jones, et al. Expires April 18, 2013 [Page 13]

Internet-Draft JSON Web Signature (JWS) October 2012
o Specification Document(s): Section 4.1.8 of [[ this document ]]
o Header Parameter Name: "cty"
o Change Controller: IETF
o Specification Document(s): Section 4.1.9 of [[ this document ]]
7.2. JSON Web Signature and Encryption Type Values Registry
This specification establishes the IANA JSON Web Signature and
Encryption Type Values registry for values of the JWS and JWE "typ"
(type) header parameter. It is RECOMMENDED that all registered "typ"
values also include a MIME Media Type [RFC2046] value that the
registered value is a short name for. The registry records the "typ"
value, the MIME type value that it is an abbreviation for (if any),
and a reference to the specification that defines it.
MIME Media Type [RFC2046] values MUST NOT be directly registered as
new "typ" values; rather, new "typ" values MAY be registered as short
names for MIME types.
7.2.1. Registration Template
"typ" Header Parameter Value:
The name requested (e.g., "example"). This name is case
sensitive. Names that match other registered names in a case
insensitive manner SHOULD NOT be accepted.
Abbreviation for MIME Type:
The MIME type that this name is an abbreviation for (e.g.,
"application/example").
Change Controller:
For Standards Track RFCs, state "IETF". For others, give the name
of the responsible party. Other details (e.g., postal address,
email address, home page URI) may also be included.
Specification Document(s):
Reference to the document(s) that specify the parameter,
preferably including URI(s) that can be used to retrieve copies of
the document(s). An indication of the relevant sections may also
be included but is not required.
7.2.2. Initial Registry Contents
This specification registers the "JWS" type value in this registry:
Jones, et al. Expires April 18, 2013 [Page 15]

Internet-Draft JSON Web Signature (JWS) October 2012
All the security considerations in XML DSIG 2.0
[W3C.CR-xmldsig-core2-20120124], also apply to this specification,
other than those that are XML specific. Likewise, many of the best
practices documented in XML Signature Best Practices
[W3C.WD-xmldsig-bestpractices-20110809] also apply to this
specification, other than those that are XML specific.
Keys are only as strong as the amount of entropy used to generate
them. A minimum of 128 bits of entropy should be used for all keys,
and depending upon the application context, more may be required. In
particular, it may be difficult to generate sufficiently random
values in some browsers and application environments.
When utilizing TLS to retrieve information, the authority providing
the resource MUST be authenticated and the information retrieved MUST
be free from modification.
When cryptographic algorithms are implemented in such a way that
successful operations take a different amount of time than
unsuccessful operations, attackers may be able to use the time
difference to obtain information about the keys employed. Therefore,
such timing differences must be avoided.
A SHA-1 hash is used when computing "x5t" (x.509 certificate
thumbprint) values, for compatibility reasons. Should an effective
means of producing SHA-1 hash collisions be developed, and should an
attacker wish to interfere with the use of a known certificate on a
given system, this could be accomplished by creating another
certificate whose SHA-1 hash value is the same and adding it to the
certificate store used by the intended victim. A prerequisite to
this attack succeeding is the attacker having write access to the
intended victim's certificate store.
If, in the future, certificate thumbprints need to be computed using
hash functions other than SHA-1, it is suggested that additional
related header parameters be defined for that purpose. For example,
it is suggested that a new "x5t#S256" (X.509 Certificate Thumbprint
using SHA-256) header parameter could be defined and used.
8.2. JSON Security Considerations
Strict JSON validation is a security requirement. If malformed JSON
is received, then the intent of the sender is impossible to reliably
discern. Ambiguous and potentially exploitable situations could
arise if the JSON parser used does not reject malformed JSON syntax.
Section 2.2 of the JavaScript Object Notation (JSON) specification
[RFC4627] states "The names within an object SHOULD be unique",
Jones, et al. Expires April 18, 2013 [Page 17]

Internet-Draft JSON Web Signature (JWS) October 2012
whereas this specification states that "Header Parameter Names within
this object MUST be unique; JWSs with duplicate Header Parameter
Names MUST be rejected". Thus, this specification requires that the
Section 2.2 "SHOULD" be treated as a "MUST". Ambiguous and
potentially exploitable situations could arise if the JSON parser
used does not enforce the uniqueness of member names.
8.3. Unicode Comparison Security Considerations
Header parameter names and algorithm names are Unicode strings. For
security reasons, the representations of these names must be compared
verbatim after performing any escape processing (as per RFC 4627[RFC4627], Section 2.5). This means, for instance, that these JSON
strings must 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", "si\u0047").
JSON strings MAY contain characters outside the Unicode Basic
Multilingual Plane. For instance, the G clef character (U+1D11E) may
be represented in a JSON string as "\uD834\uDD1E". Ideally, JWS
implementations SHOULD ensure that characters outside the Basic
Multilingual Plane are preserved and compared correctly;
alternatively, if this is not possible due to these characters
exercising limitations present in the underlying JSON implementation,
then input containing them MUST be rejected.
9. References9.1. Normative References
[ITU.X690.1994]
International Telecommunications Union, "Information
Technology - ASN.1 encoding rules: Specification of Basic
Encoding Rules (BER), Canonical Encoding Rules (CER) and
Distinguished Encoding Rules (DER)", ITU-T Recommendation
X.690, 1994.
[JWA] Jones, M., "JSON Web Algorithms (JWA)", October 2012.
[JWK] Jones, M., "JSON Web Key (JWK)", October 2012.
[RFC1421] Linn, J., "Privacy Enhancement for Internet Electronic
Mail: Part I: Message Encryption and Authentication
Procedures", RFC 1421, February 1993.
[RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail
Extensions (MIME) Part Two: Media Types", RFC 2046,
Jones, et al. Expires April 18, 2013 [Page 18]

Internet-Draft JSON Web Signature (JWS) October 2012
To validate the HMAC value, we repeat the previous process of using
the correct key and the ASCII representation of the JWS Secured Input
as input to the HMAC SHA-256 function and then taking the output and
determining if it matches the JWS Signature. If it matches exactly,
the HMAC has been validated.
A.2. JWS using RSA SHA-256A.2.1. Encoding
The JWS Header in this example is different from the previous example
in two ways: First, because a different algorithm is being used, the
"alg" value is different. Second, for illustration purposes only,
the optional "typ" parameter is not used. (This difference is not
related to the algorithm employed.) The JWS Header used is:
{"alg":"RS256"}
The following byte array contains the UTF-8 representation of the JWS
Header:
[123, 34, 97, 108, 103, 34, 58, 34, 82, 83, 50, 53, 54, 34, 125]
Base64url encoding these bytes yields this Encoded JWS Header value:
eyJhbGciOiJSUzI1NiJ9
The JWS Payload used in this example, which follows, is the same as
in the previous example. Since the Encoded JWS Payload will
therefore be the same, its computation is not repeated here.
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
Concatenating the Encoded JWS Header, a period ('.') character, and
the Encoded JWS Payload yields this JWS Secured Input value (with
line breaks for display purposes only):
eyJhbGciOiJSUzI1NiJ9
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
The ASCII representation of the JWS Secured Input is the following
byte array:
[101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 122, 73,
Jones, et al. Expires April 18, 2013 [Page 23]

Internet-Draft JSON Web Signature (JWS) October 2012
251, 71]
Base64url encoding the digital signature produces this value for the
Encoded JWS Signature (with line breaks for display purposes only):
cC4hiUPoj9Eetdgtv3hF80EGrhuB__dzERat0XF9g2VtQgr9PJbu3XOiZj5RZmh7
AAuHIm4Bh-0Qc_lF5YKt_O8W2Fp5jujGbds9uJdbF9CUAr7t1dnZcAcQjbKBYNX4
BAynRFdiuB--f_nZLgrnbyTyWzO75vRK5h6xBArLIARNPvkSjtQBMHlb1L07Qe7K
0GarZRmB_eSN9383LcOLn6_dO--xi12jzDwusC-eOkHWEsqtFZESc6BfI7noOPqv
hJ1phCnvWh6IeYI2w9QOYEUipUTI8np6LbgGY9Fs98rqVt5AXLIhWkWywlVmtVrB
p0igcN_IoypGlUPQGe77Rw
A.2.2. Decoding
Decoding the JWS requires base64url decoding the Encoded JWS Header,
Encoded JWS Payload, and Encoded JWS Signature to produce the JWS
Header, JWS Payload, and JWS Signature byte arrays. The byte array
containing the UTF-8 representation of the JWS Header is decoded into
the JWS Header string.
A.2.3. Validating
Since the "alg" parameter in the header is "RS256", we validate the
RSA SHA-256 digital signature contained in the JWS Signature. If any
of the validation steps fail, the JWS MUST be rejected.
First, we validate that the JWS Header string is legal JSON.
Validating the JWS Signature is a little different from the previous
example. First, we base64url decode the Encoded JWS Signature to
produce a digital signature S to check. We then pass (n, e), S and
the bytes of the ASCII representation of the JWS Secured Input to an
RSA signature verifier that has been configured to use the SHA-256
hash function.
A.3. JWS using ECDSA P-256 SHA-256A.3.1. Encoding
The JWS Header for this example differs from the previous example
because a different algorithm is being used. The JWS Header used is:
{"alg":"ES256"}
The following byte array contains the UTF-8 representation of the JWS
Header:
[123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 50, 53, 54, 34, 125]
Jones, et al. Expires April 18, 2013 [Page 26]

Internet-Draft JSON Web Signature (JWS) October 2012
example. First, we base64url decode the Encoded JWS Signature as in
the previous examples but we then need to split the 64 member byte
array that must result into two 32 byte arrays, the first R and the
second S. We then pass (x, y), (R, S) and the bytes of the ASCII
representation of the JWS Secured Input to an ECDSA signature
verifier that has been configured to use the P-256 curve with the
SHA-256 hash function.
As explained in Section 3.4 of the JSON Web Algorithms (JWA) [JWA]
specification, the use of the K value in ECDSA means that we cannot
validate the correctness of the digital signature in the same way we
validated the correctness of the HMAC. Instead, implementations MUST
use an ECDSA validator to validate the digital signature.
A.4. JWS using ECDSA P-521 SHA-512A.4.1. Encoding
The JWS Header for this example differs from the previous example
because a different ECDSA curve and hash function are used. The JWS
Header used is:
{"alg":"ES512"}
The following byte array contains the UTF-8 representation of the JWS
Header:
[123, 34, 97, 108, 103, 34, 58, 34, 69, 83, 53, 49, 50, 34, 125]
Base64url encoding these bytes yields this Encoded JWS Header value:
eyJhbGciOiJFUzUxMiJ9
The JWS Payload used in this example, is the ASCII string "Payload".
The representation of this string is the byte array:
[80, 97, 121, 108, 111, 97, 100]
Base64url encoding these bytes yields the Encoded JWS Payload value:
UGF5bG9hZA
Concatenating the Encoded JWS Header, a period ('.') character, and
the Encoded JWS Payload yields this JWS Secured Input value:
eyJhbGciOiJFUzUxMiJ9.UGF5bG9hZA
The ASCII representation of the JWS Secured Input is the following
Jones, et al. Expires April 18, 2013 [Page 29]

Internet-Draft JSON Web Signature (JWS) October 2012
verifier that has been configured to use the P-521 curve with the
SHA-512 hash function.
As explained in Section 3.4 of the JSON Web Algorithms (JWA) [JWA]
specification, the use of the K value in ECDSA means that we cannot
validate the correctness of the digital signature in the same way we
validated the correctness of the HMAC. Instead, implementations MUST
use an ECDSA validator to validate the digital signature.
A.5. Example Plaintext JWS
The following example JWS Header declares that the encoded object is
a Plaintext JWS:
{"alg":"none"}
Base64url encoding the bytes of the UTF-8 representation of the JWS
Header yields this Encoded JWS Header:
eyJhbGciOiJub25lIn0
The JWS Payload used in this example, which follows, is the same as
in the previous examples. Since the Encoded JWS Payload will
therefore be the same, its computation is not repeated here.
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
The Encoded JWS Signature is the empty string.
Concatenating these parts in the order Header.Payload.Signature with
period ('.') characters between the parts yields this complete JWS
(with line breaks for display purposes only):
eyJhbGciOiJub25lIn0
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
.
Appendix B. "x5c" (X.509 Certificate Chain) Example
The JSON array below is an example of a certificate chain that could
be used as the value of an "x5c" (X.509 Certificate Chain) header
parameter, per Section 4.1.6. Note that since these strings contain
base64 encoded (not base64url encoded) values, they are allowed to
Jones, et al. Expires April 18, 2013 [Page 32]

Internet-Draft JSON Web Signature (JWS) October 2012
Thanks to Axel Nennker for his early implementation and feedback on
the JWS and JWE specifications.
Jim Schaad and Karen O'Donoghue chaired the JOSE working group and
Sean Turner and Stephen Farrell served as Security area directors
during the creation of this specification.
Appendix E. Open Issues
[[ to be removed by the RFC editor before publication as an RFC ]]
The following items remain to be considered or done in this draft:
o Should we define optional nonce, timestamp, and/or uninterpreted
string header parameter(s)?
Appendix F. Document History
[[ to be removed by the RFC editor before publication as an RFC ]]
-06
o Changed "x5c" (X.509 Certificate Chain) representation from being
a single string to being an array of strings, each containing a
single base64 encoded DER certificate value, representing elements
of the certificate chain.
o Applied changes made by the RFC Editor to RFC 6749's registry
language to this specification.
-05
o Added statement that "StringOrURI values are compared as case-
sensitive strings with no transformations or canonicalizations
applied".
o Indented artwork elements to better distinguish them from the body
text.
-04
o Completed JSON Security Considerations section, including
considerations about rejecting input with duplicate member names.
o Completed security considerations on the use of a SHA-1 hash when
computing "x5t" (x.509 certificate thumbprint) values.
Jones, et al. Expires April 18, 2013 [Page 36]

Internet-Draft JSON Web Signature (JWS) October 2012
o Refer to the registries as the primary sources of defined values
and then secondarily reference the sections defining the initial
contents of the registries.
o Normatively reference XML DSIG 2.0 [W3C.CR-xmldsig-core2-20120124]
for its security considerations.
o Added this language to Registration Templates: "This name is case
sensitive. Names that match other registered names in a case
insensitive manner SHOULD NOT be accepted."
o Reference draft-jones-jose-jws-json-serialization instead of
draft-jones-json-web-signature-json-serialization.
o Described additional open issues.
o Applied editorial suggestions.
-03
o Added the "cty" (content type) header parameter for declaring type
information about the secured content, as opposed to the "typ"
(type) header parameter, which declares type information about
this object.
o Added "Collision Resistant Namespace" to the terminology section.
o Reference ITU.X690.1994 for DER encoding.
o Added an example JWS using ECDSA P-521 SHA-512. This has
particular illustrative value because of the use of the 521 bit
integers in the key and signature values. This is also an example
in which the payload is not a base64url encoded JSON object.
o Added an example "x5c" value.
o No longer say "the UTF-8 representation of the JWS Secured Input
(which is the same as the ASCII representation)". Just call it
"the ASCII representation of the JWS Secured Input".
o Added Registration Template sections for defined registries.
o Added Registry Contents sections to populate registry values.
o Changed name of the JSON Web Signature and Encryption "typ" Values
registry to be the JSON Web Signature and Encryption Type Values
registry, since it is used for more than just values of the "typ"
parameter.
Jones, et al. Expires April 18, 2013 [Page 37]

Internet-Draft JSON Web Signature (JWS) October 2012
o Moved registries JSON Web Signature and Encryption Header
Parameters and JSON Web Signature and Encryption Type Values to
the JWS specification.
o Numerous editorial improvements.
-02
o Clarified that it is an error when a "kid" value is included and
no matching key is found.
o Removed assumption that "kid" (key ID) can only refer to an
asymmetric key.
o Clarified that JWSs with duplicate Header Parameter Names MUST be
rejected.
o Clarified the relationship between "typ" header parameter values
and MIME types.
o Registered application/jws MIME type and "JWS" typ header
parameter value.
o Simplified JWK terminology to get replace the "JWK Key Object" and
"JWK Container Object" terms with simply "JSON Web Key (JWK)" and
"JSON Web Key Set (JWK Set)" and to eliminate potential confusion
between single keys and sets of keys. As part of this change, the
header parameter name for a public key value was changed from
"jpk" (JSON Public Key) to "jwk" (JSON Web Key).
o Added suggestion on defining additional header parameters such as
"x5t#S256" in the future for certificate thumbprints using hash
algorithms other than SHA-1.
o Specify RFC 2818 server identity validation, rather than RFC 6125
(paralleling the same decision in the OAuth specs).
o Generalized language to refer to Message Authentication Codes
(MACs) rather than Hash-based Message Authentication Codes (HMACs)
unless in a context specific to HMAC algorithms.
o Reformatted to give each header parameter its own section heading.
-01
o Moved definition of Plaintext JWSs (using "alg":"none") here from
the JWT specification since this functionality is likely to be
useful in more contexts that just for JWTs.
Jones, et al. Expires April 18, 2013 [Page 38]

Internet-Draft JSON Web Signature (JWS) October 2012
o Added "jpk" and "x5c" header parameters for including JWK public
keys and X.509 certificate chains directly in the header.
o Clarified that this specification is defining the JWS Compact
Serialization. Referenced the new JWS-JS spec, which defines the
JWS JSON Serialization.
o Added text "New header parameters should be introduced sparingly
since an implementation that does not understand a parameter MUST
reject the JWS".
o Clarified that the order of the creation and validation steps is
not significant in cases where there are no dependencies between
the inputs and outputs of the steps.
o Changed "no canonicalization is performed" to "no canonicalization
need be performed".
o Corrected the Magic Signatures reference.
o Made other editorial improvements suggested by JOSE working group
participants.
-00
o Created the initial IETF draft based upon
draft-jones-json-web-signature-04 with no normative changes.
o Changed terminology to no longer call both digital signatures and
HMACs "signatures".
Authors' Addresses
Michael B. Jones
Microsoft
Email: mbj@microsoft.com
URI: http://self-issued.info/
John Bradley
Ping Identity
Email: ve7jtb@ve7jtb.com
Jones, et al. Expires April 18, 2013 [Page 39]