-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrfc7518.xml
5290 lines (4832 loc) · 182 KB
/
rfc7518.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 tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc rfcedstyle="yes"?>
<rfc submissionType="IETF" category="std" consensus="yes" ipr="trust200902" number="7518">
<front>
<title>JSON Web Algorithms (JWA)</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>
<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>
This specification registers
cryptographic algorithms and identifiers to be used with the
JSON Web Signature (JWS),
JSON Web Encryption (JWE), and
JSON Web Key (JWK) specifications.
It defines several IANA registries for these identifiers.
</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="Introduction">
<t>
This specification registers
cryptographic algorithms and identifiers to be used with the
JSON Web Signature (JWS) <xref target="JWS"/>,
JSON Web Encryption (JWE) <xref target="JWE"/>, and
JSON Web Key (JWK) <xref target="JWK"/> specifications.
It defines several IANA registries for these identifiers.
All these specifications utilize
JSON-based <xref target="RFC7159"/>
data structures.
This specification also describes the semantics and operations
that are specific to these algorithms and key types.
</t>
<t>
Registering the algorithms and identifiers here,
rather than in the JWS, JWE, and JWK
specifications, is intended to allow them to remain unchanged
in the face of changes in the set of Required, Recommended,
Optional, and Deprecated algorithms over time.
This also allows changes to the JWS, JWE, and JWK specifications
without changing this document.
</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 Section 2 of <xref target="JWS" />.
</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>
The terms
"JSON Web Signature (JWS)",
"Base64url Encoding",
"Header Parameter",
"JOSE Header",
"JWS Payload",
"JWS Protected Header",
"JWS Signature",
"JWS Signing Input",
and "Unsecured JWS" are defined by
the JWS specification <xref target="JWS"/>.
</t>
<t>
The terms "JSON Web Encryption (JWE)",
"Additional Authenticated Data (AAD)",
"Authentication Tag",
"Content Encryption Key (CEK)",
"Direct Encryption",
"Direct Key Agreement",
"JWE Authentication Tag",
"JWE Ciphertext",
"JWE Encrypted Key",
"JWE Initialization Vector",
"JWE Protected Header",
"Key Agreement with Key Wrapping",
"Key Encryption",
"Key Management Mode",
and "Key Wrapping" are defined by
the JWE specification <xref target="JWE"/>.
</t>
<t>
The terms "JSON Web Key (JWK)" and
"JWK Set" are defined by
the JWK specification <xref target="JWK"/>.
</t>
<t>
The terms
"Ciphertext",
"Digital Signature", "Initialization Vector",
"Message Authentication Code (MAC)",
and "Plaintext" are defined by
the <xref target="RFC4949">"Internet Security Glossary, Version 2"</xref>.
</t>
<t>
This term is defined by this specification:
</t>
<t>
<list style="hanging">
<t hangText="Base64urlUInt">
<vspace/>
The representation of a positive or zero integer value
as the base64url encoding of the value's
unsigned big-endian representation as an octet sequence.
The octet sequence MUST utilize the minimum
number of octets needed to represent the value.
Zero is represented as BASE64URL(single zero-valued octet), which is "AA".
</t>
</list>
</t>
</section>
<section title="Cryptographic Algorithms for Digital Signatures and MACs" anchor="SigningAlgs">
<t>
JWS uses cryptographic algorithms to digitally sign or
create a MAC of the contents
of the JWS Protected Header and the JWS Payload.
</t>
<section title='"alg" (Algorithm) Header Parameter Values for JWS' anchor="JWSAlgValues">
<t>
The table below is the set of
<spanx style="verb">alg</spanx> (algorithm) Header
Parameter values defined by this specification for use with JWS, each of which
is explained in more detail in the following sections:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">Digital Signature or MAC Algorithm</ttcol>
<ttcol align="left" width="22%">Implementation Requirements</ttcol>
<c>HS256</c>
<c>HMAC using SHA-256</c>
<c>Required</c>
<c>HS384</c>
<c>HMAC using SHA-384</c>
<c>Optional</c>
<c>HS512</c>
<c>HMAC using SHA-512</c>
<c>Optional</c>
<c>RS256</c>
<c>RSASSA-PKCS1-v1_5 using SHA-256</c>
<c>Recommended</c>
<c>RS384</c>
<c>RSASSA-PKCS1-v1_5 using SHA-384</c>
<c>Optional</c>
<c>RS512</c>
<c>RSASSA-PKCS1-v1_5 using SHA-512</c>
<c>Optional</c>
<c>ES256</c>
<c>ECDSA using P-256 and SHA-256</c>
<c>Recommended+</c>
<c>ES384</c>
<c>ECDSA using P-384 and SHA-384</c>
<c>Optional</c>
<c>ES512</c>
<c>ECDSA using P-521 and SHA-512</c>
<c>Optional</c>
<c>PS256</c>
<c>RSASSA-PSS using SHA-256 and MGF1 with SHA-256</c>
<c>Optional</c>
<c>PS384</c>
<c>RSASSA-PSS using SHA-384 and MGF1 with SHA-384</c>
<c>Optional</c>
<c>PS512</c>
<c>RSASSA-PSS using SHA-512 and MGF1 with SHA-512</c>
<c>Optional</c>
<c>none</c>
<c>No digital signature or MAC performed</c>
<c>Optional</c>
</texttable>
<t>
The use of "+" in the Implementation Requirements column
indicates that the requirement strength is likely
to be increased in a future version of the specification.
</t>
<t>
See <xref target="SigAlgXref" /> for a table cross-referencing the
JWS digital signature and MAC <spanx style="verb">alg</spanx> (algorithm)
values defined in this specification with the equivalent identifiers
used by other standards and software packages.
</t>
</section>
<section title="HMAC with SHA-2 Functions" anchor="DefiningHMAC">
<t>
Hash-based Message Authentication Codes (HMACs) enable one to
use a secret plus a cryptographic hash function to generate a
MAC. This can be used to
demonstrate that whoever generated the MAC was in possession of the MAC key.
The algorithm for implementing and validating HMACs is
provided in <xref target="RFC2104">RFC 2104</xref>.
</t>
<t>
A key of the same size as the hash output (for instance, 256
bits for <spanx style="verb">HS256</spanx>) or larger MUST
be used with this algorithm.
(This requirement is based on Section 5.3.4 (Security Effect of the HMAC Key)
of <xref target="NIST.800-107">NIST SP 800-117</xref>, which states that the
effective security strength is the minimum of the security strength of the key
and two times the size of the internal hash value.)
</t>
<t>
The HMAC SHA-256 MAC is generated per RFC 2104,
using SHA-256 as the hash algorithm "H",
using the JWS Signing Input as the "text" value,
and using the shared key.
The HMAC output value is the JWS Signature.
</t>
<t>
The following <spanx style="verb">alg</spanx> (algorithm)
Header Parameter values are used to indicate that the JWS Signature
is an HMAC value computed using the corresponding algorithm:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">MAC Algorithm</ttcol>
<c>HS256</c>
<c>HMAC using SHA-256</c>
<c>HS384</c>
<c>HMAC using SHA-384</c>
<c>HS512</c>
<c>HMAC using SHA-512</c>
</texttable>
<t>
The HMAC SHA-256 MAC for a JWS is validated by computing an HMAC value per RFC 2104,
using SHA-256 as the hash algorithm "H",
using the received JWS Signing Input as the "text" value,
and using the shared key.
This computed HMAC value is then compared to the result of
base64url decoding the received encoded JWS Signature value.
The comparison of the computed HMAC value to the JWS Signature value
MUST be done in a constant-time manner to thwart timing attacks.
Alternatively, the computed HMAC value can be base64url encoded
and compared to the received encoded JWS Signature value
(also in a constant-time manner),
as this comparison produces the same result as comparing
the unencoded values.
In either case, if the values match, the HMAC has been validated.
</t>
<t>
Securing content and validation with the HMAC SHA-384 and HMAC SHA-512
algorithms is performed identically to the procedure for
HMAC SHA-256 --
just using the corresponding hash algorithms
with correspondingly larger minimum key sizes and result values:
384 bits each for HMAC SHA-384 and 512 bits each for HMAC SHA-512.
</t>
<t>
An example using this algorithm is shown in
Appendix A.1 of <xref target="JWS"/>.
</t>
</section>
<section title="Digital Signature with RSASSA-PKCS1-v1_5" anchor="DefiningRSA">
<t>
This section defines the use of the RSASSA-PKCS1-v1_5
digital signature algorithm as defined in
Section 8.2 of <xref target="RFC3447">RFC 3447</xref>
(commonly known as PKCS #1),
using SHA-2 <xref target="SHS"/> hash functions.
</t>
<t>
A key of size 2048 bits or larger MUST be used with these algorithms.
</t>
<t>
The RSASSA-PKCS1-v1_5 SHA-256 digital signature is generated as follows:
generate a digital signature of the JWS Signing Input
using RSASSA-PKCS1-v1_5-SIGN
and the SHA-256 hash function
with the desired private key.
This is the JWS Signature value.
</t>
<t>
The following <spanx style="verb">alg</spanx> (algorithm)
Header Parameter values are used to indicate that the JWS Signature
is a digital signature value computed using the corresponding algorithm:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">Digital Signature Algorithm</ttcol>
<c>RS256</c>
<c>RSASSA-PKCS1-v1_5 using SHA-256</c>
<c>RS384</c>
<c>RSASSA-PKCS1-v1_5 using SHA-384</c>
<c>RS512</c>
<c>RSASSA-PKCS1-v1_5 using SHA-512</c>
</texttable>
<t>
The RSASSA-PKCS1-v1_5 SHA-256 digital signature for a JWS is validated as follows:
submit the JWS Signing Input,
the JWS Signature,
and the 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 function.
</t>
<t>
Signing and validation with the RSASSA-PKCS1-v1_5 SHA-384 and RSASSA-PKCS1-v1_5 SHA-512
algorithms is performed identically to the procedure for
RSASSA-PKCS1-v1_5 SHA-256 --
just using the corresponding hash algorithms
instead of SHA-256.
</t>
<t>
An example using this algorithm is shown in
Appendix A.2 of <xref target="JWS"/>.
</t>
</section>
<section title="Digital Signature with ECDSA" anchor="DefiningECDSA">
<t>
The Elliptic Curve Digital Signature Algorithm (ECDSA) <xref target="DSS"/>
provides for the use of Elliptic Curve Cryptography, which is
able to provide equivalent security to RSA cryptography but
using shorter key sizes and with greater processing
speed for many operations.
This means that ECDSA digital signatures will be substantially
smaller in terms of length than equivalently strong RSA
digital signatures.
</t>
<t>
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 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
defined in <xref target="DSS"/>.
</t>
<t>
The ECDSA P-256 SHA-256 digital signature is generated as follows:
<list style="numbers">
<t>
Generate a digital signature of the JWS Signing Input
using ECDSA P-256 SHA-256 with
the desired private key. The output will be the pair
(R, S), where R and S are 256-bit unsigned integers.
</t>
<t>
Turn R and S into octet sequences in big-endian order,
with each array being be 32 octets long.
The octet sequence representations MUST NOT be shortened
to omit any leading zero octets contained in the values.
</t>
<t>
Concatenate the two octet sequences in the order R and then S.
(Note that many ECDSA implementations will directly produce
this concatenation as their output.)
</t>
<t>
The resulting 64-octet sequence is the JWS Signature value.
</t>
</list>
</t>
<t>
The following <spanx style="verb">alg</spanx> (algorithm)
Header Parameter values are used to indicate that the JWS Signature
is a digital signature value computed using the corresponding algorithm:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">Digital Signature Algorithm</ttcol>
<c>ES256</c>
<c>ECDSA using P-256 and SHA-256</c>
<c>ES384</c>
<c>ECDSA using P-384 and SHA-384</c>
<c>ES512</c>
<c>ECDSA using P-521 and SHA-512</c>
</texttable>
<t>
The ECDSA P-256 SHA-256 digital signature for a JWS is validated as follows:
<list style="numbers">
<t>
The JWS Signature value MUST be a 64-octet sequence.
If it is not a 64-octet sequence, the validation has failed.
</t>
<t>
Split the 64-octet sequence into two 32-octet sequences. The first
octet sequence represents R and the second S.
The values R and S are represented as octet sequences
using the Integer-to-OctetString Conversion defined in
Section 2.3.7 of <xref target="SEC1">SEC1</xref>
(in big-endian octet order).
</t>
<t>
Submit the JWS Signing Input,
R, S, and the public key (x, y) to the ECDSA P-256
SHA-256 validator.
</t>
</list>
</t>
<t>
Signing and validation with the ECDSA P-384 SHA-384 and ECDSA P-521 SHA-512
algorithms is performed identically to the procedure for
ECDSA P-256 SHA-256 --
just using the corresponding hash algorithms
with correspondingly larger result values.
For ECDSA P-384 SHA-384, R and S will be 384 bits each,
resulting in a 96-octet sequence.
For ECDSA P-521 SHA-512, R and S will be 521 bits each,
resulting in a 132-octet sequence.
(Note that the Integer-to-OctetString Conversion defined in
Section 2.3.7 of <xref target="SEC1">SEC1</xref>
used to represent R and S as octet sequences adds zero-valued high-order
padding bits when needed to round the size up to a multiple of 8 bits;
thus, each 521-bit integer is represented using 528 bits in 66 octets.)
</t>
<t>
Examples using these algorithms are shown in
Appendices A.3 and A.4 of <xref target="JWS"/>.
</t>
</section>
<section title="Digital Signature with RSASSA-PSS" anchor="DefiningPSS">
<t>
This section defines the use of the RSASSA-PSS
digital signature algorithm as defined in
Section 8.1 of <xref target="RFC3447">RFC 3447</xref>
with the MGF1 mask generation function and SHA-2 hash functions,
always using the
same hash function for both the RSASSA-PSS hash function
and the MGF1 hash function.
The size of the salt value is the same size as the hash function output.
All other algorithm parameters use the defaults specified
in Appendix A.2.3 of RFC 3447.
</t>
<t>
A key of size 2048 bits or larger MUST be used with this algorithm.
</t>
<t>
The RSASSA-PSS SHA-256 digital signature is generated as follows:
generate a digital signature of the JWS Signing Input
using RSASSA-PSS-SIGN,
the SHA-256 hash function, and
the MGF1 mask generation function with SHA-256
with the desired private key.
This is the JWS Signature value.
</t>
<t>
The following <spanx style="verb">alg</spanx> (algorithm)
Header Parameter values are used to indicate that the JWS Signature
is a digital signature value computed using the corresponding algorithm:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">Digital Signature Algorithm</ttcol>
<c>PS256</c>
<c>RSASSA-PSS using SHA-256 and MGF1 with SHA-256</c>
<c>PS384</c>
<c>RSASSA-PSS using SHA-384 and MGF1 with SHA-384</c>
<c>PS512</c>
<c>RSASSA-PSS using SHA-512 and MGF1 with SHA-512</c>
</texttable>
<t>
The RSASSA-PSS SHA-256 digital signature for a JWS is validated as follows:
submit the JWS Signing Input,
the JWS Signature,
and the public key corresponding to the private key used
by the signer to the RSASSA-PSS-VERIFY algorithm
using SHA-256 as the hash function and using
MGF1 as the mask generation function with SHA-256.
</t>
<t>
Signing and validation with the RSASSA-PSS SHA-384 and RSASSA-PSS SHA-512
algorithms is performed identically to the procedure for
RSASSA-PSS SHA-256 --
just using the alternative hash algorithm in both roles.
</t>
</section>
<section title='Using the Algorithm "none"' anchor="UsingNone">
<t>
JWSs MAY also be created that do not provide integrity protection.
Such a JWS is called an Unsecured JWS.
An Unsecured JWS uses the <spanx style="verb">alg</spanx>
value <spanx style="verb">none</spanx> and is formatted
identically to other JWSs, but
MUST use the empty octet sequence as its JWS Signature value.
Recipients MUST verify that the JWS Signature value is the empty octet sequence.
</t>
<t>
Implementations that support Unsecured JWSs
MUST NOT accept such objects as valid unless the application
specifies that it is acceptable for a specific object to not be
integrity protected.
Implementations MUST NOT accept Unsecured JWSs by default.
In order to mitigate downgrade attacks, applications MUST NOT signal
acceptance of Unsecured JWSs at a global level,
and SHOULD signal acceptance on a per-object basis.
See <xref target="NoneSecCon"/> for security considerations
associated with using this algorithm.
</t>
</section>
</section>
<section title="Cryptographic Algorithms for Key Management" anchor="KeyManagementAlgs">
<t>
JWE uses cryptographic algorithms to encrypt or determine the
Content Encryption Key (CEK).
</t>
<section title='"alg" (Algorithm) Header Parameter Values for JWE' anchor="JWEAlgValues">
<t>
The table below is the set of <spanx
style="verb">alg</spanx> (algorithm) Header Parameter values
that are defined by this specification for use with JWE.
These algorithms are used to encrypt the CEK, producing the
JWE Encrypted Key, or to use key agreement to agree upon the CEK.
</t>
<texttable>
<ttcol align="left" width="13%">"alg" Param Value</ttcol>
<ttcol align="left">Key Management Algorithm</ttcol>
<ttcol align="left">More Header Params</ttcol>
<ttcol align="left" width="22%">Implementation Requirements</ttcol>
<c>RSA1_5</c>
<c>RSAES-PKCS1-v1_5</c>
<c>(none)</c>
<c>Recommended-</c>
<c>RSA-OAEP</c>
<c>RSAES OAEP using default parameters</c>
<c>(none)</c>
<c>Recommended+</c>
<c>RSA-OAEP-256</c>
<c>RSAES OAEP using SHA-256 and MGF1 with SHA-256</c>
<c>(none)</c>
<c>Optional</c>
<c>A128KW</c>
<c>AES Key Wrap with default initial value using 128-bit key</c>
<c>(none)</c>
<c>Recommended</c>
<c>A192KW</c>
<c>AES Key Wrap with default initial value using 192-bit key</c>
<c>(none)</c>
<c>Optional</c>
<c>A256KW</c>
<c>AES Key Wrap with default initial value using 256-bit key</c>
<c>(none)</c>
<c>Recommended</c>
<c>dir</c>
<c>Direct use of a shared symmetric key as the CEK</c>
<c>(none)</c>
<c>Recommended</c>
<c>ECDH-ES</c>
<c>Elliptic Curve Diffie-Hellman Ephemeral Static
key agreement using Concat KDF
</c>
<c>
<spanx style="verb">epk</spanx>,
<spanx style="verb">apu</spanx>,
<spanx style="verb">apv</spanx>
</c>
<c>Recommended+</c>
<c>ECDH-ES+A128KW</c>
<c>ECDH-ES using Concat KDF and CEK wrapped with
<spanx style="verb">A128KW</spanx></c>
<c>
<spanx style="verb">epk</spanx>,
<spanx style="verb">apu</spanx>,
<spanx style="verb">apv</spanx>
</c>
<c>Recommended</c>
<c>ECDH-ES+A192KW</c>
<c>ECDH-ES using Concat KDF and CEK wrapped with
<spanx style="verb">A192KW</spanx></c>
<c>
<spanx style="verb">epk</spanx>,
<spanx style="verb">apu</spanx>,
<spanx style="verb">apv</spanx>
</c>
<c>Optional</c>
<c>ECDH-ES+A256KW</c>
<c>ECDH-ES using Concat KDF and CEK wrapped with
<spanx style="verb">A256KW</spanx></c>
<c>
<spanx style="verb">epk</spanx>,
<spanx style="verb">apu</spanx>,
<spanx style="verb">apv</spanx>
</c>
<c>Recommended</c>
<c>A128GCMKW</c>
<c>Key wrapping with AES GCM using 128-bit key</c>
<c>
<spanx style="verb">iv</spanx>,
<spanx style="verb">tag</spanx>
</c>
<c>Optional</c>
<c>A192GCMKW</c>
<c>Key wrapping with AES GCM using 192-bit key</c>
<c>
<spanx style="verb">iv</spanx>,
<spanx style="verb">tag</spanx>
</c>
<c>Optional</c>
<c>A256GCMKW</c>
<c>Key wrapping with AES GCM using 256-bit key</c>
<c>
<spanx style="verb">iv</spanx>,
<spanx style="verb">tag</spanx>
</c>
<c>Optional</c>
<c>PBES2-HS256+A128KW</c>
<c>
PBES2 with HMAC SHA-256
and <spanx style="verb">A128KW</spanx> wrapping
</c>
<c>
<spanx style="verb">p2s</spanx>,
<spanx style="verb">p2c</spanx>
</c>
<c>Optional</c>
<c>PBES2-HS384+A192KW</c>
<c>
PBES2 with HMAC SHA-384
and <spanx style="verb">A192KW</spanx> wrapping
</c>
<c>
<spanx style="verb">p2s</spanx>,
<spanx style="verb">p2c</spanx>
</c>
<c>Optional</c>
<c>PBES2-HS512+A256KW</c>
<c>
PBES2 with HMAC SHA-512
and <spanx style="verb">A256KW</spanx> wrapping
</c>
<c>
<spanx style="verb">p2s</spanx>,
<spanx style="verb">p2c</spanx>
</c>
<c>Optional</c>
</texttable>
<t>
The More Header Params column indicates what
additional Header Parameters are used by the algorithm,
beyond <spanx style="verb">alg</spanx>, which all use.
All but <spanx style="verb">dir</spanx> and
<spanx style="verb">ECDH-ES</spanx> also produce a JWE Encrypted Key value.
</t>
<t>
The use of "+" in the Implementation Requirements column
indicates that the requirement strength is likely
to be increased in a future version of the specification. The use of "-" indicates that the requirement strength is likely to be decreased in a future version of the specification.
</t>
<t>
See <xref target="EncAlgXref" /> for a table cross-referencing the
JWE <spanx style="verb">alg</spanx> (algorithm)
values defined in this specification with the equivalent identifiers
used by other standards and software packages.
</t>
</section>
<section title="Key Encryption with RSAES-PKCS1-v1_5" anchor="KeyEncryptionRSA15">
<t>
This section defines the specifics of encrypting a JWE CEK with
RSAES-PKCS1-v1_5 <xref target="RFC3447"/>.
The <spanx style="verb">alg</spanx> (algorithm) Header Parameter value
<spanx style="verb">RSA1_5</spanx> is used for this algorithm.
</t>
<t>
A key of size 2048 bits or larger MUST be used with this algorithm.
</t>
<t>
An example using this algorithm is shown in
Appendix A.2 of <xref target="JWE"/>.
</t>
</section>
<section title="Key Encryption with RSAES OAEP" anchor="KeyEncryptionRSAOAEP">
<t>
This section defines the specifics of encrypting a JWE CEK with
RSAES using Optimal Asymmetric Encryption Padding (OAEP)
<xref target="RFC3447"/>.
Two sets of parameters for using OAEP are defined,
which use different hash functions.
In the first case,
the default parameters specified in Appendix A.2.1 of RFC 3447 are used.
(Those default parameters are the SHA-1 hash function and
the MGF1 with SHA-1 mask generation function.)
In the second case, the SHA-256 hash function and
the MGF1 with SHA-256 mask generation function are used.
</t>
<t>
The following <spanx style="verb">alg</spanx> (algorithm)
Header Parameter values are used to indicate that the JWE Encrypted Key
is the result of encrypting the CEK
using the corresponding algorithm:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">Key Management Algorithm</ttcol>
<c>RSA-OAEP</c>
<c>RSAES OAEP using default parameters</c>
<c>RSA-OAEP-256</c>
<c>RSAES OAEP using SHA-256 and MGF1 with SHA-256</c>
</texttable>
<t>
A key of size 2048 bits or larger MUST be used with these algorithms.
(This requirement is based on Table 4 (Security-strength time frames)
of <xref target="NIST.800-57">NIST SP 800-57</xref>,
which requires 112 bits of security for new uses,
and Table 2 (Comparable strengths) of the same,
which states that 2048-bit RSA keys provide 112 bits of security.)
</t>
<t>
An example using RSAES OAEP with the default parameters is shown in
Appendix A.1 of <xref target="JWE"/>.
</t>
</section>
<section title="Key Wrapping with AES Key Wrap" anchor="KeyEncryptionAESKW">
<t>
This section defines the specifics of encrypting a JWE CEK with
the Advanced Encryption Standard (AES) Key Wrap Algorithm
<xref target="RFC3394"/>
using the default initial value specified in Section 2.2.3.1 of that document.
</t>
<t>
The following <spanx style="verb">alg</spanx> (algorithm)
Header Parameter values are used to indicate that the JWE Encrypted Key
is the result of encrypting the CEK
using the corresponding algorithm and key size:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">Key Management Algorithm</ttcol>
<c>A128KW</c>
<c>AES Key Wrap with default initial value using 128-bit key</c>
<c>A192KW</c>
<c>AES Key Wrap with default initial value using 192-bit key</c>
<c>A256KW</c>
<c>AES Key Wrap with default initial value using 256-bit key</c>
</texttable>
<t>
An example using this algorithm is shown in
Appendix A.3 of <xref target="JWE"/>.
</t>
</section>
<section title="Direct Encryption with a Shared Symmetric Key" anchor="DirectEncryption">
<t>
This section defines the specifics of directly performing symmetric key
encryption without performing a key wrapping step. In this case,
the shared symmetric key is used directly as the Content Encryption Key (CEK)
value for the <spanx style="verb">enc</spanx> algorithm.
An empty octet sequence is used as the JWE Encrypted Key value.
The <spanx style="verb">alg</spanx> (algorithm) Header Parameter value
<spanx style="verb">dir</spanx>
is used in this case.
</t>
<t>
Refer to the security considerations on key lifetimes
in <xref target="KeyLifetimes"/> and AES GCM in <xref target="GCMSecCon"/>
when considering utilizing direct encryption.
</t>
</section>
<section title="Key Agreement with Elliptic Curve Diffie-Hellman Ephemeral Static (ECDH-ES)" anchor="ECDHES">
<t>
This section defines the specifics of key agreement with
Elliptic Curve Diffie-Hellman Ephemeral Static <xref target="RFC6090"/>,
in combination with the
Concat KDF, as defined in Section 5.8.1 of <xref target="NIST.800-56A" />.
The key agreement result can be used in one of two ways:
<list style='numbers'>
<t>
directly as the Content Encryption Key (CEK) for the
<spanx style="verb">enc</spanx> algorithm, in the Direct Key Agreement mode, or
</t>
<t>
as a symmetric key used to wrap the CEK with the
<spanx style="verb">A128KW</spanx>,
<spanx style="verb">A192KW</spanx>,
or <spanx style="verb">A256KW</spanx>
algorithms, in the Key Agreement with Key Wrapping mode.
</t>
</list>
</t>
<t>
A new ephemeral public key
value MUST be generated for each key agreement operation.
</t>
<t>
In Direct Key Agreement mode,
the output of the Concat KDF MUST be a key of the
same length as that used by the
<spanx style="verb">enc</spanx> algorithm.
In this case, the empty octet sequence is used as the JWE Encrypted Key value.
The <spanx style="verb">alg</spanx> (algorithm) Header Parameter value
<spanx style="verb">ECDH-ES</spanx>
is used in the Direct Key Agreement mode.
</t>
<t>
In Key Agreement with Key Wrapping mode,
the output of the Concat KDF MUST be a key of the
length needed for the specified key wrapping algorithm.
In this case, the JWE Encrypted Key is the CEK wrapped with the agreed-upon key.
</t>
<t>
The following <spanx style="verb">alg</spanx> (algorithm)
Header Parameter values are used to indicate that the JWE Encrypted Key
is the result of encrypting the CEK
using the result of the key agreement algorithm
as the key encryption key for the corresponding key wrapping algorithm:
</t>
<texttable>
<ttcol align="left">"alg" Param Value</ttcol>
<ttcol align="left">Key Management Algorithm</ttcol>
<c>ECDH-ES+A128KW</c>
<c>ECDH-ES using Concat KDF and CEK wrapped with
<spanx style="verb">A128KW</spanx></c>
<c>ECDH-ES+A192KW</c>
<c>ECDH-ES using Concat KDF and CEK wrapped with
<spanx style="verb">A192KW</spanx></c>
<c>ECDH-ES+A256KW</c>
<c>ECDH-ES using Concat KDF and CEK wrapped with
<spanx style="verb">A256KW</spanx></c>
</texttable>
<section title="Header Parameters Used for ECDH Key Agreement" anchor="ParamsECDHES">
<t>
The following Header Parameter names
are used for key agreement as defined below.
</t>
<section title='"epk" (Ephemeral Public Key) Header Parameter' anchor="epkDef">
<t>
The <spanx style="verb">epk</spanx> (ephemeral public key)
value created by the originator for the use in key agreement algorithms.
This key is represented as a JSON Web Key <xref target="JWK" />
public key value.
It MUST contain only public key parameters and
SHOULD contain only the minimum JWK parameters necessary to represent the key;
other JWK parameters included can be checked for consistency and honored, or they can be ignored.
This Header Parameter MUST be present and MUST be understood and processed
by implementations when these algorithms are used.
</t>
</section>
<section title='"apu" (Agreement PartyUInfo) Header Parameter' anchor="apuDef">
<t>
The <spanx style="verb">apu</spanx> (agreement PartyUInfo)
value for key agreement algorithms using it
(such as <spanx style="verb">ECDH-ES</spanx>),
represented as a base64url-encoded string.
When used, the PartyUInfo value contains information about the producer.
Use of this Header Parameter is OPTIONAL.