-
Notifications
You must be signed in to change notification settings - Fork 2
/
rfc7515.xml
3806 lines (3455 loc) · 136 KB
/
rfc7515.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='http://xml2rfc.tools.ietf.org/authoring/rfc2629.xslt' ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc rfcedstyle="yes"?>
<rfc number="7515" category="std" ipr="trust200902" submissionType="IETF"
consensus="yes">
<front>
<title>JSON Web Signature (JWS)</title>
<author fullname="Michael B. Jones" initials="M.B." surname="Jones">
<organization>Microsoft</organization>
<address>
<email>[email protected]</email>
<uri>http://self-issued.info/</uri>
</address>
</author>
<author fullname="John Bradley" initials="J." surname="Bradley">
<organization abbrev="Ping Identity">Ping Identity</organization>
<address>
<email>[email protected]</email>
<uri>http://www.thread-safe.com/</uri>
</address>
</author>
<author fullname="Nat Sakimura" initials="N." surname="Sakimura">
<organization abbrev="NRI">Nomura Research Institute</organization>
<address>
<email>[email protected]</email>
<uri>http://nat.sakimura.org/</uri>
</address>
</author>
<date month="May" year="2015"/>
<area>Security</area>
<workgroup>JOSE Working Group</workgroup>
<keyword>JavaScript Object Notation</keyword>
<keyword>JSON</keyword>
<keyword>JSON Object Signing and Encryption</keyword>
<keyword>JOSE</keyword>
<keyword>JSON Web Signature</keyword>
<keyword>JWS</keyword>
<keyword>JSON Web Encryption</keyword>
<keyword>JWE</keyword>
<keyword>JSON Web Key</keyword>
<keyword>JWK</keyword>
<keyword>JSON Web Algorithms</keyword>
<keyword>JWA</keyword>
<abstract>
<t>
JSON Web Signature (JWS) represents
content secured with digital signatures or
Message Authentication Codes (MACs)
using JSON-based data structures.
Cryptographic algorithms and identifiers for use with this
specification are described in the separate
JSON Web Algorithms (JWA) specification
and an IANA registry defined by that specification.
Related encryption capabilities are described in the separate
JSON Web Encryption (JWE) specification.
</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="Introduction">
<t>
JSON Web Signature (JWS) represents
content secured with digital signatures or
Message Authentication Codes (MACs)
using JSON-based <xref target="RFC7159"/>
data structures.
The JWS cryptographic mechanisms provide integrity protection for
an arbitrary sequence of octets.
See <xref target="SignaturesAndMacs"/> for a discussion on
the differences between digital signatures and MACs.
</t>
<t>
Two closely related serializations for JWSs are defined.
The JWS Compact Serialization is a compact, URL-safe representation
intended for space-constrained environments such as HTTP
Authorization headers and URI query parameters.
The JWS JSON Serialization represents JWSs as JSON objects and
enables multiple signatures and/or MACs to be applied to the same content.
Both share the same cryptographic underpinnings.
</t>
<t>
Cryptographic algorithms and identifiers for use with this
specification are described in the separate
JSON Web Algorithms (JWA) <xref target="JWA" /> specification
and an IANA registry defined by that specification.
Related encryption capabilities are described in the separate
JSON Web Encryption (JWE) <xref target="JWE" /> specification.
</t>
<t>
Names defined by this specification are short because a core goal is
for the resulting representations to be compact.
</t>
<section title="Notational Conventions" anchor="NotationalConventions">
<t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "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" <xref target='RFC2119' />.
The interpretation should only be applied when the terms appear in all capital
letters.
</t>
<t>
BASE64URL(OCTETS) denotes the base64url encoding of OCTETS,
per <xref target="Terminology"/>.
</t>
<t>
UTF8(STRING) denotes the octets of the
UTF-8 <xref target="RFC3629"/> representation of STRING,
where STRING is a sequence of zero or more Unicode <xref target="UNICODE"/> characters.
</t>
<t>
ASCII(STRING) denotes the octets of the
ASCII <xref target="RFC20"/> representation of STRING,
where STRING is a sequence of zero or more ASCII characters.
</t>
<t>
The concatenation of two values A and B
is denoted as A || B.
</t>
</section>
</section>
<section title="Terminology" anchor="Terminology">
<t>
These terms are defined by this specification:
</t>
<t>
<list style="hanging">
<t hangText="JSON Web Signature (JWS)">
<vspace/>
A data structure representing a digitally signed or MACed message.
</t>
<t hangText="JOSE Header">
<vspace/>
JSON object containing the parameters
describing the cryptographic operations and parameters employed.
The JOSE (JSON Object Signing and Encryption) Header is comprised
of a set of Header Parameters.
</t>
<t hangText="JWS Payload">
<vspace/>
The sequence of octets to be secured -- a.k.a. the message.
The payload can contain an arbitrary sequence of octets.
</t>
<t hangText="JWS Signature">
<vspace/>
Digital signature or MAC over
the JWS Protected Header and the JWS Payload.
</t>
<t hangText="Header Parameter">
<vspace/>
A name/value pair that is member of the JOSE Header.
</t>
<t hangText="JWS Protected Header">
<vspace/>
JSON object that contains the Header Parameters that are
integrity protected by
the JWS Signature digital signature or MAC operation.
For the JWS Compact Serialization, this comprises the entire JOSE Header.
For the JWS JSON Serialization, this is one component of the JOSE Header.
</t>
<t hangText="JWS Unprotected Header">
<vspace/>
JSON object that contains the Header Parameters that are not
integrity protected.
This can only be present when using the JWS JSON Serialization.
</t>
<t hangText="Base64url Encoding">
<vspace/>
Base64 encoding using the URL- and filename-safe
character set defined in Section 5 of <xref target="RFC4648">RFC 4648</xref>,
with all trailing '=' characters omitted (as permitted by Section 3.2)
and without the inclusion of any line breaks, whitespace, or other additional characters.
Note that the base64url encoding of the empty octet sequence
is the empty string.
(See <xref target="base64urlnotes" /> for notes on
implementing base64url encoding without padding.)
</t>
<t hangText="JWS Signing Input">
<vspace/>
The input to the digital signature or MAC computation.
Its value is
ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || BASE64URL(JWS Payload)).
</t>
<t hangText="JWS Compact Serialization">
<vspace/>
A representation of the JWS as a compact, URL-safe string.
</t>
<t hangText="JWS JSON Serialization">
<vspace/>
A representation of the JWS as a JSON object.
Unlike the JWS Compact Serialization,
the JWS JSON Serialization
enables multiple digital signatures and/or MACs to
be applied to the same content.
This representation is neither optimized for compactness nor URL-safe.
</t>
<t hangText="Unsecured JWS">
<vspace/>
A JWS that provides no integrity protection.
Unsecured JWSs use the <spanx style="verb">alg</spanx>
value <spanx style="verb">none</spanx>.
</t>
<t hangText="Collision-Resistant Name">
<vspace/>
A name in a namespace that enables names to be allocated in a manner
such that they are highly unlikely to collide with other names.
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)
<xref target="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.
</t>
<t hangText="StringOrURI">
<vspace/>
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
<xref target="RFC3986"/>.
StringOrURI values are compared as case-sensitive strings
with no transformations or canonicalizations applied.
</t>
</list>
</t>
<t>
The terms "JSON Web Encryption (JWE)",
"JWE Compact Serialization",
and "JWE JSON Serialization" are defined by
the JWE specification <xref target="JWE"/>.
</t>
<t>
The terms "Digital Signature"
and "Message Authentication Code (MAC)" are defined by
the <xref target="RFC4949">"Internet Security Glossary, Version 2"</xref>.
</t>
</section>
<section title="JSON Web Signature (JWS) Overview" anchor="Overview">
<t>
JWS represents digitally signed or MACed content using JSON data
structures and base64url encoding.
These JSON data structures MAY contain whitespace and/or line breaks
before or after any JSON values or structural characters,
in accordance with Section 2 of <xref target="RFC7159">RFC 7159</xref>.
A JWS represents these logical values
(each of which is defined in <xref target="Terminology"/>):
</t>
<t>
<?rfc subcompact="yes"?>
<list style="symbols">
<t>JOSE Header</t>
<t>JWS Payload</t>
<t>JWS Signature</t>
</list>
<?rfc subcompact="no"?>
</t>
<t>
For a JWS,
the JOSE Header members are the union of the members of these values
(each of which is defined in <xref target="Terminology"/>):
</t>
<t>
<?rfc subcompact="yes"?>
<list style="symbols">
<t>JWS Protected Header</t>
<t>JWS Unprotected Header</t>
</list>
<?rfc subcompact="no"?>
</t>
<t>
This document defines two serializations for JWSs:
a compact, URL-safe serialization called the JWS Compact Serialization
and a JSON serialization called the JWS JSON Serialization.
In both serializations, the
JWS Protected Header,
JWS Payload, and
JWS Signature
are base64url encoded,
since JSON lacks a way to directly represent arbitrary octet sequences.
</t>
<section title="JWS Compact Serialization Overview" anchor="CompactSerializationOverview">
<t>
In the JWS Compact Serialization, no JWS Unprotected Header is used.
In this case, the JOSE Header and the JWS Protected Header are the same.
</t>
<t>
In the JWS Compact Serialization, a JWS is represented as the
concatenation:
</t>
<t>
<?rfc subcompact="yes"?>
<list style="empty">
<t>BASE64URL(UTF8(JWS Protected Header)) || '.' ||</t>
<t>BASE64URL(JWS Payload) || '.' ||</t>
<t>BASE64URL(JWS Signature)</t>
</list>
<?rfc subcompact="no"?>
</t>
<t>
See <xref target="CompactSerialization"/> for more information
about the JWS Compact Serialization.
</t>
</section>
<section title="JWS JSON Serialization Overview" anchor="JSONSerializationOverview">
<t>
In the JWS JSON Serialization, one or both of the JWS Protected Header
and JWS Unprotected Header MUST be present.
In this case, the members of the JOSE Header are the union of
the members of the JWS Protected Header and the JWS Unprotected Header
values that are present.
</t>
<t>
In the JWS JSON Serialization, a JWS is represented as a JSON object
containing some or all of these four members:
<?rfc subcompact="yes"?>
<list style="symbols">
<t><spanx style="verb">protected</spanx>, with the value BASE64URL(UTF8(JWS Protected Header))</t>
<t><spanx style="verb">header</spanx>, with the value JWS Unprotected Header</t>
<t><spanx style="verb">payload</spanx>, with the value BASE64URL(JWS Payload)</t>
<t><spanx style="verb">signature</spanx>, with the value
BASE64URL(JWS Signature)</t>
</list>
<?rfc subcompact="no"?>
</t>
<t>
The three base64url-encoded result strings
and the JWS Unprotected Header value
are represented as members within a JSON object.
The inclusion of some of these values is OPTIONAL.
The JWS JSON Serialization can also represent
multiple signature and/or MAC values, rather than just one.
See <xref target="JSONSerialization"/> for more information
about the JWS JSON Serialization.
</t>
</section>
<section title="Example JWS" anchor="ExampleJWS">
<t>
This section provides an example of a JWS.
Its computation is described in more detail in <xref target="HS256Example"/>,
including specifying the exact octet sequences representing the JSON values used
and the key value used.
</t>
<t>
The following example JWS Protected Header declares that the
encoded object is a JSON Web Token <xref target="JWT"/>
and the JWS Protected Header and the JWS Payload are
secured using the HMAC SHA-256
<xref target="RFC2104"/> <xref target="SHS"/>
algorithm:
</t>
<figure><artwork><![CDATA[
{"typ":"JWT",
"alg":"HS256"}
]]></artwork></figure>
<t>
Encoding this JWS Protected Header as
BASE64URL(UTF8(JWS Protected Header)) gives this value:
</t>
<figure><artwork><![CDATA[
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
]]></artwork></figure>
<t>
The UTF-8 representation of the following JSON object is used as the JWS Payload.
(Note that the payload can be any
content and need not be a representation of a JSON object.)
</t>
<figure><artwork><![CDATA[
{"iss":"joe",
"exp":1300819380,
"http://example.com/is_root":true}
]]></artwork></figure>
<t>
Encoding this JWS Payload as
BASE64URL(JWS Payload) gives this value
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
]]></artwork></figure>
<t>
Computing the HMAC of the JWS Signing Input
ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || BASE64URL(JWS Payload))
with the HMAC SHA-256 algorithm
using the key specified in <xref target="HS256Example" />
and base64url-encoding the result
yields this BASE64URL(JWS Signature) value:
</t>
<figure><artwork><![CDATA[
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
]]></artwork></figure>
<t>
Concatenating these values in the order
Header.Payload.Signature with period ('.') characters between the
parts yields this complete JWS representation
using the JWS Compact Serialization
(with line breaks for display purposes only):
</t>
<figure><artwork><![CDATA[
eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9
.
eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFt
cGxlLmNvbS9pc19yb290Ijp0cnVlfQ
.
dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
]]></artwork></figure>
<t>
See <xref target="JWSExamples"/> for additional examples,
including examples using the JWS JSON Serialization
in Sections <xref target="JSONSerializationExample" format="counter"/>
and <xref target="FlattenedJSONSerializationExample" format="counter"/>.
</t>
</section>
</section>
<section title="JOSE Header" anchor="Header">
<t>
For a JWS,
the members of the JSON object(s) representing the JOSE Header describe the
digital signature or MAC applied to the
JWS Protected Header and the JWS Payload and optionally
additional properties of the JWS.
The Header Parameter names within the JOSE Header MUST be unique;
JWS parsers MUST either reject JWSs with duplicate Header Parameter names
or use a JSON parser that returns only the lexically last duplicate member name,
as specified in Section 15.12 ("The JSON Object") of
ECMAScript 5.1 <xref target="ECMAScript"/>.
</t>
<t>
Implementations are required to understand
the specific Header Parameters defined by this specification
that are designated as "MUST be understood"
and process them in the manner defined in this specification.
All other Header Parameters defined by this specification that
are not so designated MUST be ignored when not understood.
Unless listed as a critical Header Parameter, per <xref target="critDef"/>,
all Header Parameters not defined by this specification
MUST be ignored when not understood.
</t>
<t>
There are three classes of Header Parameter names:
Registered Header Parameter names, Public Header Parameter names,
and Private Header Parameter names.
</t>
<section title="Registered Header Parameter Names" anchor="RegisteredHeaderParameterName">
<t>
The following Header Parameter names for use in JWSs are registered
in the IANA
"JSON Web Signature and Encryption Header Parameters" registry
established by
<xref target="HdrReg"/>,
with meanings as defined in the subsections below.
</t>
<t>
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.
</t>
<section title='"alg" (Algorithm) Header Parameter' anchor="algDef">
<t>
The <spanx style="verb">alg</spanx> (algorithm) Header Parameter
identifies the cryptographic algorithm used to
secure the JWS.
The JWS Signature value is not valid if the <spanx style="verb">alg</spanx>
value does not represent a supported algorithm or if there is not a
key for use with that algorithm associated with the
party that digitally signed or MACed the content.
<spanx style="verb">alg</spanx> values should either be
registered in the IANA
"JSON Web Signature and Encryption Algorithms" registry
established by
<xref target="JWA" /> or be
a value that contains a Collision-Resistant Name.
The <spanx style="verb">alg</spanx> value is a case-sensitive ASCII string
containing a StringOrURI value.
This Header Parameter MUST be present
and MUST be understood and processed by implementations.
</t>
<t>
A list of defined <spanx style="verb">alg</spanx> values
for this use can be found
in the IANA "JSON Web Signature and Encryption Algorithms" registry
established by
<xref target="JWA"/>;
the initial contents of this registry are the values defined in
Section 3.1 of
<xref target="JWA"/>.
</t>
</section>
<section title='"jku" (JWK Set URL) Header Parameter' anchor="jkuDef">
<t>
The <spanx style="verb">jku</spanx> (JWK Set URL)
Header Parameter is a URI <xref target="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 JWK Set <xref target="JWK" />.
The protocol used to acquire the resource MUST provide
integrity protection; an HTTP GET request to retrieve the
JWK Set MUST use Transport Layer Security (TLS)
<xref target="RFC2818"/> <xref target="RFC5246"/>; and
the identity of the server MUST be validated, as per
Section 6 of <xref target="RFC6125">RFC 6125</xref>.
Also, see <xref target="TLS_requirements"/> on TLS requirements.
Use of this Header Parameter is OPTIONAL.
</t>
</section>
<section title='"jwk" (JSON Web Key) Header Parameter' anchor="jwkDef">
<t>
The <spanx style="verb">jwk</spanx> (JSON Web Key)
Header Parameter is the public key
that corresponds to the key
used to digitally sign the JWS.
This key is represented as a JSON Web Key <xref target="JWK" />.
Use of this Header Parameter is OPTIONAL.
</t>
</section>
<section title='"kid" (Key ID) Header Parameter' anchor="kidDef">
<t>
The <spanx style="verb">kid</spanx> (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.
The structure of the
<spanx style="verb">kid</spanx> value is unspecified.
Its value MUST be a case-sensitive string.
Use of this Header Parameter is OPTIONAL.
</t>
<t>
When used with a JWK, the <spanx style="verb">kid</spanx>
value is used to match a JWK <spanx style="verb">kid</spanx>
parameter value.
</t>
</section>
<section title='"x5u" (X.509 URL) Header Parameter' anchor="x5uDef">
<t>
The <spanx style="verb">x5u</spanx> (X.509 URL) Header Parameter
is a URI <xref target="RFC3986"/> that refers to a resource for
the X.509 public key certificate or certificate chain <xref target="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
<xref target="RFC5280">RFC 5280</xref> in PEM-encoded form,
with each certificate delimited as specified in
Section 6.1 of <xref target="RFC4945">RFC 4945</xref>.
The certificate containing the public key
corresponding to the key
used to digitally sign 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
<xref target="RFC2818"/> <xref target="RFC5246"/>; and
the identity of the server MUST be validated, as per
Section 6 of <xref target="RFC6125">RFC 6125</xref>.
Also, see <xref target="TLS_requirements"/> on TLS requirements.
Use of this Header Parameter is OPTIONAL.
</t>
</section>
<section title='"x5c" (X.509 Certificate Chain) Header Parameter' anchor="x5cDef">
<t>
The <spanx style="verb">x5c</spanx> (X.509 certificate chain)
Header Parameter contains the X.509 public key
certificate or certificate chain <xref target="RFC5280"/>
corresponding to the key
used to digitally sign the JWS.
The certificate or certificate chain is represented as
a JSON array of certificate value strings.
Each string in the array is a base64-encoded
(Section 4 of <xref target="RFC4648"/> -- not base64url-encoded)
DER <xref target="ITU.X690.2008"/> PKIX certificate value.
The certificate containing the public key
corresponding to the key
used to digitally sign 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 validate the certificate chain according
to <xref target="RFC5280">RFC 5280</xref> and
consider the certificate or certificate chain to be invalid if any
validation failure occurs.
Use of this Header Parameter is OPTIONAL.
</t>
<t>
See <xref target="x5cExample"/> for an example
<spanx style="verb">x5c</spanx> value.
</t>
</section>
<section title='"x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter' anchor="x5tDef">
<t>
The <spanx style="verb">x5t</spanx> (X.509 certificate SHA-1 thumbprint)
Header Parameter is a base64url-encoded
SHA-1 thumbprint (a.k.a. digest) of the DER encoding of
the X.509 certificate <xref target="RFC5280"/>
corresponding to the key
used to digitally sign the JWS.
Note that certificate thumbprints are also sometimes known as certificate fingerprints.
Use of this Header Parameter is OPTIONAL.
</t>
</section>
<section title='"x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header Parameter' anchor="x5tS256Def">
<t>
The <spanx style="verb">x5t#S256</spanx> (X.509 certificate SHA-256 thumbprint)
Header Parameter is a base64url-encoded
SHA-256 thumbprint (a.k.a. digest) of the DER encoding of
the X.509 certificate <xref target="RFC5280"/>
corresponding to the key
used to digitally sign the JWS.
Note that certificate thumbprints are also sometimes known as certificate fingerprints.
Use of this Header Parameter is OPTIONAL.
</t>
</section>
<section title='"typ" (Type) Header Parameter' anchor="typDef">
<t>
The <spanx style="verb">typ</spanx> (type) Header Parameter
is used by JWS applications to declare the
media type <xref target="IANA.MediaTypes"/>
of this complete JWS.
This is intended for use by the application when
more than one kind of object could be present in
an application data structure that can contain a JWS;
the application can use this value to disambiguate among
the different kinds of objects that might be present.
It will typically not be used by applications when
the kind of object is already known.
This parameter is ignored by JWS implementations;
any processing of this parameter is performed by the JWS application.
Use of this Header Parameter is OPTIONAL.
</t>
<t>
Per <xref target="RFC2045">RFC 2045</xref>, all media type values,
subtype values, and parameter names are case insensitive.
However, parameter values are case sensitive unless
otherwise specified for the specific parameter.
</t>
<t>
To keep messages compact in common situations,
it is RECOMMENDED that producers omit an "application/" prefix
of a media type value in a <spanx style="verb">typ</spanx>
Header Parameter when no other '/' appears in the media type value.
A recipient using the media type value MUST treat it as if
"application/" were prepended to any
<spanx style="verb">typ</spanx> value not containing a '/'.
For instance, a <spanx style="verb">typ</spanx> value of
<spanx style="verb">example</spanx> SHOULD be used to represent
the <spanx style="verb">application/example</spanx> media type,
whereas the media type
<spanx style="verb">application/example;part="1/2"</spanx> cannot
be shortened to <spanx style="verb">example;part="1/2"</spanx>.
</t>
<t>
The <spanx style="verb">typ</spanx> value
<spanx style="verb">JOSE</spanx> can be used by applications
to indicate that this object is a JWS or JWE using
the JWS Compact Serialization or the JWE Compact Serialization.
The <spanx style="verb">typ</spanx> value
<spanx style="verb">JOSE+JSON</spanx> can be used by applications
to indicate that this object is a JWS or JWE using
the JWS JSON Serialization or the JWE JSON Serialization.
Other type values can also be used by applications.
</t>
</section>
<section title='"cty" (Content Type) Header Parameter' anchor="ctyDef">
<t>
The <spanx style="verb">cty</spanx> (content type) Header Parameter
is used by JWS applications to declare the
media type <xref target="IANA.MediaTypes"/>
of the secured content (the payload).
This is intended for use by the application when
more than one kind of object could be present in
the JWS Payload;
the application can use this value to disambiguate among
the different kinds of objects that might be present.
It will typically not be used by applications when
the kind of object is already known.
This parameter is ignored by JWS implementations;
any processing of this parameter is performed by the JWS application.
Use of this Header Parameter is OPTIONAL.
</t>
<t>
Per <xref target="RFC2045">RFC 2045</xref>, all media type values,
subtype values, and parameter names are case insensitive.
However, parameter values are case sensitive unless
otherwise specified for the specific parameter.
</t>
<t>
To keep messages compact in common situations,
it is RECOMMENDED that producers omit an "application/" prefix
of a media type value in a <spanx style="verb">cty</spanx>
Header Parameter when no other '/' appears in the media type value.
A recipient using the media type value MUST treat it as if
"application/" were prepended to any
<spanx style="verb">cty</spanx> value not containing a '/'.
For instance, a <spanx style="verb">cty</spanx> value of
<spanx style="verb">example</spanx> SHOULD be used to represent
the <spanx style="verb">application/example</spanx> media type,
whereas the media type
<spanx style="verb">application/example;part="1/2"</spanx> cannot
be shortened to <spanx style="verb">example;part="1/2"</spanx>.
</t>
</section>
<section title='"crit" (Critical) Header Parameter' anchor="critDef">
<t>
The <spanx style="verb">crit</spanx> (critical) Header Parameter
indicates that extensions to
this specification and/or <xref target="JWA"/> are being used
that MUST be understood and processed.
Its value is an array listing the Header Parameter names
present in the JOSE Header that use those extensions.
If any of the listed extension Header Parameters are not
understood and supported by the recipient, then the JWS is invalid.
Producers MUST NOT include Header Parameter names defined by
this specification or <xref target="JWA"/> for use with JWS,
duplicate names, or
names that do not occur as Header Parameter names within the JOSE Header
in the <spanx style="verb">crit</spanx> list.
Producers MUST NOT use the empty list <spanx style="verb">[]</spanx>
as the <spanx style="verb">crit</spanx> value.
Recipients MAY consider the JWS to be invalid if the critical list
contains any Header Parameter names defined by
this specification or <xref target="JWA"/> for use with JWS
or if any other constraints on its use are violated.
When used, this Header Parameter MUST be integrity protected;
therefore, it MUST occur only within the JWS Protected Header.
Use of this Header Parameter is OPTIONAL.
This Header Parameter MUST be understood and processed by implementations.
</t>
<t>
<figure>
<preamble>
An example use, along with a hypothetical
<spanx style="verb">exp</spanx> (expiration time) field is:
</preamble>
<artwork><![CDATA[
{"alg":"ES256",
"crit":["exp"],
"exp":1363284000
}
]]></artwork>
</figure>
</t>
</section>
</section>
<section title="Public Header Parameter Names" anchor="PublicHeaderParameterName">
<t>
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
established by
<xref target="HdrReg" /> or be a Public Name
(a value that contains a Collision-Resistant Name).
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.
</t>
<t>
New Header Parameters should be introduced sparingly, as
they can result in non-interoperable JWSs.
</t>
</section>
<section title="Private Header Parameter Names" anchor="PrivateHeaderParameterName">
<t>
A producer and consumer of a JWS may agree to use Header Parameter names
that are Private Names (names that are
not Registered Header Parameter names (<xref target="RegisteredHeaderParameterName"/>))
or Public Header Parameter names (<xref target="PublicHeaderParameterName"/>).
Unlike Public Header Parameter names,
Private Header Parameter names are subject to collision and
should be used with caution.
</t>
</section>
</section>
<section title="Producing and Consuming JWSs" anchor="JWSRules">
<section title="Message Signature or MAC Computation" anchor="MessageSignature">
<t>
To create a JWS, the following steps are performed.
The order of the steps is not significant in cases where
there are no dependencies between the inputs and outputs of the steps.
<list style="numbers">
<t>
Create the content to be used as the JWS Payload.
</t>
<t>
Compute the encoded payload value BASE64URL(JWS Payload).
</t>
<t>
Create the JSON object(s) containing the desired set of Header Parameters,
which together comprise the JOSE Header
(the JWS Protected Header and/or the JWS Unprotected Header).
</t>
<t>
Compute the encoded header value BASE64URL(UTF8(JWS Protected Header)).
If the JWS Protected Header is not present
(which can only happen when using the JWS JSON Serialization
and no <spanx style="verb">protected</spanx> member is present),
let this value be the empty string.
</t>
<t>
Compute the JWS Signature in the manner defined for
the particular algorithm being used over the JWS Signing Input
ASCII(BASE64URL(UTF8(JWS Protected Header)) || '.' || BASE64URL(JWS Payload)).
The <spanx style="verb">alg</spanx> (algorithm) Header Parameter MUST be
present in the JOSE Header, with the algorithm value
accurately representing the algorithm used to construct
the JWS Signature.
</t>
<t>
Compute the encoded signature value BASE64URL(JWS Signature).
</t>
<t>
If the JWS JSON Serialization is being used, repeat this process
(steps 3-6)
for each digital signature or MAC operation being performed.
</t>
<t>
Create the desired serialized output.
The JWS Compact Serialization of this result is
BASE64URL(UTF8(JWS Protected Header))
|| '.' || BASE64URL(JWS Payload)
|| '.' || BASE64URL(JWS Signature).
The JWS JSON Serialization is described in <xref target="JSONSerialization"/>.
</t>
</list>
</t>
</section>
<section title="Message Signature or MAC Validation" anchor="MessageValidation">
<t>
When validating a JWS, the following steps are performed.
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 signature or MAC cannot be validated.
</t>
<t>
When there are multiple JWS Signature values,
it is an application decision which of the JWS Signature values
must successfully validate for the JWS to be accepted.
In some cases, all must successfully validate, or the JWS will be considered invalid.
In other cases, only a specific JWS Signature value
needs to be successfully validated.
However, in all cases, at least one JWS Signature value
MUST successfully validate, or the JWS MUST be considered invalid.
</t>
<t>
<list style="numbers">
<t>
Parse the JWS representation to extract the serialized values
for the components of the JWS.
When using the JWS Compact Serialization,
these components are
the base64url-encoded representations of
the JWS Protected Header,
the JWS Payload, and
the JWS Signature,
and when using the JWS JSON Serialization,
these components also include the unencoded JWS Unprotected Header value.
When using the JWS Compact Serialization,
the JWS Protected Header,
the JWS Payload, and
the JWS Signature
are represented as base64url-encoded values in that order,
with each value being separated from the next by a single period ('.') character,
resulting in exactly two delimiting period characters being used.
The JWS JSON Serialization
is described in <xref target="JSONSerialization"/>.
</t>
<t>
Base64url-decode the encoded representation of the
JWS Protected Header,
following the restriction that no line breaks, whitespace, or
other additional characters have been used.
</t>
<t>
Verify that the resulting octet sequence
is a UTF-8-encoded representation of
a completely valid JSON object
conforming to <xref target="RFC7159">RFC 7159</xref>;
let the JWS Protected Header be this JSON object.
</t>
<t>
If using the JWS Compact Serialization, let the JOSE Header be the
JWS Protected Header.
Otherwise, when using the JWS JSON Serialization,
let the JOSE Header be the union of
the members of the corresponding JWS Protected Header
and JWS Unprotected Header,
all of which must be completely valid JSON objects.
During this step,
verify that the resulting JOSE Header does not contain duplicate
Header Parameter names.
When using the JWS JSON Serialization, this restriction includes
that the same Header Parameter name also MUST NOT occur in
distinct JSON object values that together comprise the JOSE Header.
</t>
<t>
Verify that the implementation understands and can process
all fields that it is required to support,
whether required by this specification,
by the algorithm being used,
or by the <spanx style="verb">crit</spanx> Header Parameter value,