-
Notifications
You must be signed in to change notification settings - Fork 2
/
draft-ietf-jose-json-web-encryption-14.xml
3425 lines (3210 loc) · 122 KB
/
draft-ietf-jose-json-web-encryption-14.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="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='http://xml.resource.org/authoring/rfc2629.xslt' ?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" ipr="trust200902" docName="draft-ietf-jose-json-web-encryption-14">
<front>
<title abbrev="JWE">JSON Web Encryption (JWE)</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="Eric Rescorla" initials="E." surname="Rescorla">
<organization abbrev="RTFM">RTFM, Inc.</organization>
<address>
<email>[email protected]</email>
</address>
</author>
<author fullname="Joe Hildebrand" initials="J." surname="Hildebrand">
<organization abbrev="Cisco">Cisco Systems, Inc.</organization>
<address>
<email>[email protected]</email>
</address>
</author>
<date day="29" month="July" year="2013" />
<area>Security</area>
<workgroup>JOSE Working Group</workgroup>
<keyword>RFC</keyword>
<keyword>Request for Comments</keyword>
<keyword>I-D</keyword>
<keyword>Internet-Draft</keyword>
<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 Encryption (JWE) is a means of representing encrypted
content using JavaScript Object Notation (JSON) based data structures.
Cryptographic algorithms and identifiers for use with this
specification are described in the separate
JSON Web Algorithms (JWA) specification.
Related digital signature and MAC capabilities are described
in the separate JSON Web Signature (JWS) specification.
</t>
</abstract>
</front>
<middle>
<section title="Introduction" anchor="Introduction">
<t>
JSON Web Encryption (JWE) is a means of representing encrypted
content using JavaScript Object Notation (JSON) <xref target="RFC4627"/>
based data structures.
The JWE cryptographic mechanisms encrypt and provide integrity protection for
arbitrary sequences of octets.
</t>
<t>
Two closely related representations for JWE objects are defined.
The JWE Compact Serialization is a compact, URL-safe representation
intended for space constrained environments such as HTTP
Authorization headers and URI query parameters.
The JWE JSON Serialization represents JWE objects as JSON objects and
enables the same content to be encrypted to multiple parties.
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.
Related digital signature and MAC capabilities are described
in the separate JSON Web Signature (JWS) <xref target="JWS" />
specification.
</t>
<section title="Notational Conventions" anchor="NotationalConventions">
<t>
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 <xref target='RFC2119' />.
</t>
</section>
</section>
<section title="Terminology" anchor="Terminology">
<t>
<list style="hanging">
<t hangText="JSON Web Encryption (JWE)">
A data structure representing an encrypted message.
The structure represents five values:
the JWE Header, the JWE Encrypted Key,
the JWE Initialization Vector, the JWE Ciphertext, and
the JWE Authentication Tag.
</t>
<t hangText="Authenticated Encryption with Associated Data (AEAD)">
An AEAD algorithm is one that encrypts the Plaintext,
allows Additional Authenticated Data to be specified,
and provides an integrated content integrity check
over the Ciphertext and Additional Authenticated Data.
AEAD algorithms accept two inputs, the Plaintext and the
Additional Authenticated Data value, and produce two outputs,
the Ciphertext and the Authentication Tag value.
AES Galois/Counter Mode (GCM) is one such algorithm.
</t>
<t hangText="Plaintext">
The sequence of octets to be encrypted -- a.k.a., the message.
The plaintext can contain an arbitrary sequence of octets.
</t>
<t hangText="Ciphertext">
An encrypted representation of the Plaintext.
</t>
<t hangText="Additional Authenticated Data (AAD)">
An input to an AEAD operation that
is integrity protected but not encrypted.
</t>
<t hangText="Authentication Tag">
An output of an AEAD operation that
ensures the integrity of
the Ciphertext
and the Additional Authenticated Data.
Note that some algorithms may not use an Authentication Tag,
in which case this value is the empty octet sequence.
</t>
<t hangText="Content Encryption Key (CEK)">
A symmetric key for the AEAD algorithm
used to encrypt the Plaintext for the
recipient to produce the Ciphertext and the Authentication Tag.
</t>
<t hangText="JSON Text Object">
A UTF-8 <xref target="RFC3629"/>
encoded text string representing a JSON object;
the syntax of JSON objects is defined in
Section 2.2 of <xref target="RFC4627"/>.
</t>
<t hangText="JWE Header">
A JSON Text Object
(or JSON Text Objects, when using the JWE JSON Serialization)
that describes the
encryption operations applied to create the JWE Encrypted
Key, the JWE Ciphertext, and the JWE Authentication Tag.
The members of the JWE Header object(s) are Header Parameters.
</t>
<t hangText="JWE Encrypted Key">
The result of encrypting the Content Encryption Key (CEK) with the
intended recipient's key using the specified algorithm.
Note that for some algorithms, the JWE Encrypted Key
value is specified as being the empty octet sequence.
</t>
<t hangText="JWE Initialization Vector">
A sequence of octets containing the Initialization Vector used
when encrypting the Plaintext.
Note that some algorithms may not use an Initialization Vector,
in which case this value is the empty octet sequence.
</t>
<t hangText="JWE Ciphertext">
A sequence of octets containing the Ciphertext for a JWE.
</t>
<t hangText="JWE Authentication Tag">
A sequence of octets containing the Authentication Tag for a JWE.
</t>
<t hangText="JWE Protected Header">
A JSON Text Object that contains the portion of the
JWE Header that is integrity protected.
For the JWE Compact Serialization, this comprises the entire JWE Header.
For the JWE JSON Serialization, this is one component of the JWE Header.
</t>
<t hangText="Header Parameter">
A name/value pair that is member of the JWE Header.
</t>
<t hangText="Header Parameter Name">
The name of a member of the JWE Header.
</t>
<t hangText="Header Parameter Value">
The value of a member of the JWE Header.
</t>
<t hangText="Base64url Encoding">
The URL- and filename-safe Base64 encoding
described in <xref target="RFC4648">RFC 4648</xref>,
Section 5, with the (non URL-safe) '=' padding characters
omitted, as permitted by Section 3.2. (See Appendix C of
<xref target="JWS" /> for notes on implementing base64url
encoding without padding.)
</t>
<t hangText="Encoded JWE Header">
Base64url encoding of the JWE Protected Header.
</t>
<t hangText="Encoded JWE Encrypted Key">
Base64url encoding of the JWE Encrypted Key.
</t>
<t hangText="Encoded JWE Initialization Vector">
Base64url encoding of the JWE Initialization Vector.
</t>
<t hangText="Encoded JWE Ciphertext">
Base64url encoding of the JWE Ciphertext.
</t>
<t hangText="Encoded JWE Authentication Tag">
Base64url encoding of the JWE Authentication Tag.
</t>
<t hangText="JWE Compact Serialization">
A representation of the JWE as the concatenation of
the Encoded JWE Header,
the Encoded JWE Encrypted Key,
the Encoded JWE Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings being separated
by four period ('.') characters.
This representation is compact and URL-safe.
</t>
<t hangText="JWE JSON Serialization">
A representation of the JWE as a JSON structure containing
JWE Header,
Encoded JWE Encrypted Key,
Encoded JWE Initialization Vector,
Encoded JWE Ciphertext, and
Encoded JWE Authentication Tag values.
Unlike the JWE Compact Serialization,
the JWE JSON Serialization
enables the same content to be encrypted to multiple parties.
This representation is neither compact nor URL-safe.
</t>
<t hangText="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)
<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">
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>
<t hangText="Key Management Mode">
A method of determining the Content Encryption Key (CEK) value to use.
Each algorithm used for determining the CEK value uses a specific Key Management Mode.
Key Management Modes employed by this specification are
Key Encryption,
Key Wrapping,
Direct Key Agreement,
Key Agreement with Key Wrapping, and
Direct Encryption.
</t>
<t hangText="Key Encryption">
A Key Management Mode in which the Content Encryption Key (CEK) value
is encrypted to the intended recipient using an asymmetric encryption algorithm.
</t>
<t hangText="Key Wrapping">
A Key Management Mode in which the Content Encryption Key (CEK) value
is encrypted to the intended recipient using a symmetric key wrapping algorithm.
</t>
<t hangText="Direct Key Agreement">
A Key Management Mode in which a key agreement algorithm is used to agree upon
the Content Encryption Key (CEK) value.
</t>
<t hangText="Key Agreement with Key Wrapping">
A Key Management Mode in which a key agreement algorithm is used to agree upon
a symmetric key used to encrypt the Content Encryption Key (CEK) value
to the intended recipient using a symmetric key wrapping algorithm.
</t>
<t hangText="Direct Encryption">
A Key Management Mode in which the Content Encryption Key (CEK) value
used is the secret symmetric key value shared between the parties.
</t>
</list>
</t>
</section>
<section title="JSON Web Encryption (JWE) Overview" anchor="Overview">
<t>
JWE represents encrypted content using JSON data
structures and base64url encoding.
Five values are represented in a JWE:
the JWE Header,
the JWE Encrypted Key,
the JWE Initialization Vector,
the JWE Ciphertext, and
the JWE Authentication Tag.
In the Compact Serialization, the five values are
base64url-encoded for transmission, and represented
as the concatenation of the encoded strings in that order,
with the five strings being separated by four period ('.') characters.
A JSON Serialization for this information is also defined in
<xref target="JSONSerialization"/>.
</t>
<t>
JWE utilizes authenticated encryption to ensure the confidentiality
and integrity of the Plaintext and the integrity of the JWE Protected Header.
</t>
<section title="Example JWE" anchor="OAEPGCMIntro">
<t>
This example encrypts the plaintext
"The true sign of intelligence is not knowledge but imagination."
to the recipient using RSAES OAEP for key encryption
and AES GCM for content encryption.
</t>
<t>
The following example JWE Header declares that:
<list style="symbols">
<t>
the Content Encryption Key is encrypted to the recipient
using the RSAES OAEP algorithm to produce
the JWE Encrypted Key and
</t>
<t>
the Plaintext is encrypted using the AES GCM
algorithm with a 256 bit key to produce the Ciphertext.
</t>
</list>
</t>
<figure><artwork><![CDATA[
{"alg":"RSA-OAEP","enc":"A256GCM"}
]]></artwork></figure>
<t>
Base64url encoding the octets of the UTF-8 representation of
the JWE Header yields this Encoded JWE Header value:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ
]]></artwork></figure>
<t>
The remaining steps to finish creating this JWE are:
<list style="symbols">
<t>
Generate a random Content Encryption Key (CEK).
</t>
<t>
Encrypt the CEK with the recipient's public key using the RSAES OAEP
algorithm to produce the JWE Encrypted Key.
</t>
<t>
Base64url encode the JWE Encrypted Key to produce
the Encoded JWE Encrypted Key.
</t>
<t>
Generate a random JWE Initialization Vector.
</t>
<t>
Base64url encode the JWE Initialization Vector to produce the Encoded JWE Initialization Vector.
</t>
<t>
Let the Additional Authenticated Data encryption parameter be
the octets of the ASCII representation of
the Encoded JWE Header value.
</t>
<t>
Encrypt the Plaintext with AES GCM
using the CEK as the encryption key,
the JWE Initialization Vector,
and the Additional Authenticated Data value,
requesting a 128 bit Authentication Tag output.
</t>
<t>
Base64url encode the Ciphertext to create the Encoded JWE Ciphertext.
</t>
<t>
Base64url encode the Authentication Tag to create
the Encoded JWE Authentication Tag.
</t>
<t>
Assemble the final representation:
The Compact Serialization of this result is the
concatenation of
the Encoded JWE Header,
the Encoded JWE Encrypted Key,
the Encoded JWE Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings
being separated by four period ('.') characters.
</t>
</list>
The final result in this example
(with line breaks for display purposes only) is:
</t>
<figure><artwork><![CDATA[
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ.
OKOawDo13gRp2ojaHV7LFpZcgV7T6DVZKTyKOMTYUmKoTCVJRgckCL9kiMT03JGe
ipsEdY3mx_etLbbWSrFr05kLzcSr4qKAq7YN7e9jwQRb23nfa6c9d-StnImGyFDb
Sv04uVuxIp5Zms1gNxKKK2Da14B8S4rzVRltdYwam_lDp5XnZAYpQdb76FdIKLaV
mqgfwX7XWRxv2322i-vDxRfqNzo_tETKzpVLzfiwQyeyPGLBIO56YJ7eObdv0je8
1860ppamavo35UgoRdbYaBcoh9QcfylQr66oc6vFWXRcZ_ZT2LawVCWTIy3brGPi
6UklfCpIMfIjf7iGdXKHzg.
48V1_ALb6US04U3b.
5eym8TW_c8SuK0ltJ3rpYIzOeDQz7TALvtu6UG9oMo4vpzs9tX_EFShS8iB7j6ji
SdiwkIr3ajwQzaBtQD_A.
XFBoMYUZodetZdvTiFvSkQ
]]></artwork></figure>
<t>
See <xref target="OAEPGCMExample"/> for the complete details of computing this JWE.
See <xref target="JWEExamples"/> for additional examples.
</t>
</section>
</section>
<section title="JWE Header" anchor="Header">
<t>
The members of the JSON object(s) representing the JWE Header
describe the encryption applied to the Plaintext and optionally
additional properties of the JWE.
The Header Parameter Names within the JWE Header MUST be unique;
recipients MUST either reject JWEs 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:
Reserved Header Parameter Names, Public Header Parameter Names,
and Private Header Parameter Names.
</t>
<section title="Reserved Header Parameter Names" anchor="ReservedHeaderParameterName">
<t>
The following Header Parameter Names are reserved
with meanings as defined below.
All the names are short because a core goal of this specification
is for the resulting representations
using the JWE Compact Serialization to be compact.
</t>
<t>
Additional reserved Header Parameter Names can be defined
via the IANA
JSON Web Signature and Encryption Header Parameters registry
<xref target="JWS" />.
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 a cryptographic algorithm used to
encrypt or determine the value of the Content Encryption Key (CEK).
The recipient MUST reject the JWE if the <spanx style="verb">alg</spanx>
value does not represent a supported algorithm, or if the recipient does
not have a key that can be used with that algorithm.
<spanx style="verb">alg</spanx> values SHOULD either be
registered in the IANA
JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" /> or be
a value that contains a Collision Resistant Namespace.
The <spanx style="verb">alg</spanx> value is a case sensitive string
containing a StringOrURI value.
Use of this header parameter is REQUIRED.
This header parameter MUST be understood by implementations.
</t>
<t>
A list of defined <spanx style="verb">alg</spanx> values can be found
in the IANA JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" />;
the initial contents of this registry are the values defined in
Section 4.1 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
</t>
</section>
<section title='"enc" (Encryption Method) Header Parameter' anchor="encDef">
<t>
The <spanx style="verb">enc</spanx> (encryption method)
header parameter identifies the content encryption algorithm
used to encrypt the Plaintext to produce the Ciphertext.
This algorithm MUST be an AEAD algorithm with a specified key length.
The recipient MUST reject the JWE if the <spanx style="verb">enc</spanx>
value does not represent a supported algorithm.
<spanx style="verb">enc</spanx> values SHOULD either be
registered in the IANA
JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" /> or be
a value that contains a Collision Resistant Namespace.
The <spanx style="verb">enc</spanx> value is a case sensitive string
containing a StringOrURI value.
Use of this header parameter is REQUIRED.
This header parameter MUST be understood by implementations.
</t>
<t>
A list of defined <spanx style="verb">enc</spanx> values can be found
in the IANA JSON Web Signature and Encryption Algorithms registry
<xref target="JWA" />;
the initial contents of this registry are the values defined in
Section 4.2 of the
JSON Web Algorithms (JWA) <xref target="JWA" /> specification.
</t>
</section>
<section title='"zip" (Compression Algorithm) Header Parameter' anchor="zipDef">
<t>
The <spanx style="verb">zip</spanx> (compression algorithm)
applied to the Plaintext before encryption, if any.
If present, the value of the <spanx style="verb">zip</spanx>
header parameter MUST be the case sensitive string "DEF".
Compression is performed with the
DEFLATE <xref target="RFC1951" /> algorithm.
If no <spanx style="verb">zip</spanx> parameter is present,
no compression is applied to the Plaintext before encryption.
This header parameter MUST be integrity protected, and therefore
MUST occur only with the JWE Protected Header, when used.
Use of this header parameter is OPTIONAL.
This header parameter MUST be understood by implementations.
</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
is the key
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
The keys MUST be encoded as a JSON Web Key Set (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 TLS <xref target="RFC2818"/> <xref target="RFC5246"/>;
the identity of the server MUST be validated, as per
Section 3.1 of HTTP Over TLS <xref target='RFC2818'/>.
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
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
This key is represented as a JSON Web Key <xref target="JWK" />.
Use of this header parameter is OPTIONAL.
</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"/>
containing the key
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
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
<xref target="RFC1421"/>.
The certificate containing the public key
to which the JWE was encrypted
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"/>;
the identity of the server MUST be validated, as per
Section 3.1 of HTTP Over TLS <xref target='RFC2818'/>.
Use of this header parameter is OPTIONAL.
</t>
</section>
<section title='"x5t" (X.509 Certificate Thumbprint) Header Parameter' anchor="x5tDef">
<t>
The <spanx style="verb">x5t</spanx> (X.509 Certificate 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"/>
containing the key
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
Use of this header parameter is OPTIONAL.
</t>
<t>
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 <spanx style="verb">x5t#S256</spanx> (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 <xref target="JWS" />.
</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"/>
containing the key
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
The certificate or certificate chain is represented as
a JSON array of certificate value strings.
Each string in the array is a base64 encoded
(<xref target="RFC4648"/> Section 4 -- not base64url encoded)
DER <xref target="ITU.X690.1994"/> PKIX certificate value.
The certificate containing the public key
to which the JWE was encrypted
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.
Use of this header parameter is OPTIONAL.
</t>
<t>
See Appendix B of <xref target="JWS"/> for an example
<spanx style="verb">x5c</spanx> value.
</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
to which the JWE was encrypted;
this can be used to determine the private key needed to decrypt the JWE.
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 <spanx style="verb">kid</spanx>
value, they SHOULD treat that condition as an error.
The interpretation of the
<spanx style="verb">kid</spanx> value is unspecified.
Its value MUST be a string.
Use of this header parameter is OPTIONAL.
</t>
<t>
When used with a JWK, the <spanx style="verb">kid</spanx>
value can be used to match a JWK <spanx style="verb">kid</spanx>
parameter value.
</t>
</section>
<section title='"typ" (Type) Header Parameter' anchor="typDef">
<t>
The <spanx style="verb">typ</spanx> (type) header
parameter MAY be used to declare the type of
this complete JWE object
in an application-specific manner
in contexts where this is useful to the application.
This parameter has no effect upon the JWE processing.
The type value <spanx style="verb">JOSE</spanx> MAY 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 type value <spanx style="verb">JOSE+JSON</spanx> MAY 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 MAY be used, and if not understood, SHOULD be ignored.
The <spanx style="verb">typ</spanx> value is a case sensitive string.
Use of this header parameter is OPTIONAL.
</t>
<t>
MIME Media Type <xref target="RFC2046"/>
values MAY be used as <spanx style="verb">typ</spanx> values.
</t>
<t>
<spanx style="verb">typ</spanx> values SHOULD either be
registered in the IANA
JSON Web Signature and Encryption Type Values registry
<xref target="JWS" /> or be
a value that contains a Collision Resistant Namespace.
</t>
</section>
<section title='"cty" (Content Type) Header Parameter' anchor="ctyDef">
<t>
The <spanx style="verb">cty</spanx> (content type) header
parameter MAY be used to declare the type of
the encrypted content (the Plaintext)
in an application-specific manner
in contexts where this is useful to the application.
This parameter has no effect upon the JWE processing.
Content type values that are not understood SHOULD be ignored.
The <spanx style="verb">cty</spanx> value is a case sensitive string.
Use of this header parameter is OPTIONAL.
</t>
<t>
The values used for the <spanx style="verb">cty</spanx>
header parameter come from the same value space as the
<spanx style="verb">typ</spanx> header parameter,
with the same rules applying.
</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 ]] are being used
that MUST be understood and processed.
Its value is an array listing the header parameter names defined
by those extensions that are used in the JWE Header.
If any of the listed extension header parameters are not
understood and supported by the receiver, it MUST reject the JWE.
Senders MUST NOT include header parameter names defined by
[[ this specification ]] or by <xref target="JWA" /> for use with JWE,
duplicate names, or
names that do not occur as header parameter names within the JWE Header
in the <spanx style="verb">crit</spanx> list.
Senders MUST not use the empty list <spanx style="verb">[]</spanx>
as the <spanx style="verb">crit</spanx> value.
Recipients MAY reject the JWE if the critical list
contains any header parameter names defined by [[ this specification ]]
or by <xref target="JWA" /> for use with JWE,
or any other constraints on its use are violated.
This header parameter MUST be integrity protected, and therefore
MUST occur only with the JWE Protected Header, when used.
Use of this header parameter is OPTIONAL.
This header parameter MUST be understood 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":"RSA-OAEP",
"enc":"A256GCM",
"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 JWEs. 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
<xref target="JWS" /> or be a Public Name:
a value 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.
</t>
<t>
New header parameters should be introduced sparingly, as
they can result in non-interoperable JWEs.
</t>
</section>
<section title="Private Header Parameter Names" anchor="PrivateHeaderParameterName">
<t>
A producer and consumer of a JWE may agree to use Header Parameter Names
that are Private Names: names that are
not Reserved Names <xref target="ReservedHeaderParameterName"></xref>
or Public Names <xref target="PublicHeaderParameterName"></xref>.
Unlike Public Names, Private Names are subject to collision and
should be used with caution.
</t>
</section>
</section>
<section title="Producing and Consuming JWEs" anchor="JWERules">
<section title="Message Encryption" anchor="Encryption">
<t>
The message encryption process is as follows.
The order of the steps is not significant in cases where
there are no dependencies between the inputs and outputs of the steps.
</t>
<t>
<list style="numbers">
<t>
Determine the Key Management Mode employed by the algorithm
used to determine the Content Encryption Key (CEK) value.
(This is the algorithm recorded in the
<spanx style="verb">alg</spanx> (algorithm)
header parameter of the resulting JWE.)
</t>
<t>
When Key Wrapping, Key Encryption,
or Key Agreement with Key Wrapping are employed,
generate a random Content Encryption Key (CEK) value.
See <xref target="RFC4086">RFC 4086</xref> for
considerations on generating random values.
The CEK MUST have a length equal to that
required for the content encryption algorithm.
</t>
<t>
When Direct Key Agreement or Key Agreement with Key Wrapping
are employed, use the key agreement algorithm
to compute the value of the agreed upon key.
When Direct Key Agreement is employed,
let the Content Encryption Key (CEK) be the agreed upon key.
When Key Agreement with Key Wrapping is employed,
the agreed upon key will be used to wrap the CEK.
</t>
<t>
When Key Wrapping, Key Encryption,
or Key Agreement with Key Wrapping are employed,
encrypt the CEK to the recipient and let the result be the
JWE Encrypted Key.
</t>
<t>
Otherwise, when Direct Key Agreement or Direct Encryption are employed,
let the JWE Encrypted Key be the empty octet sequence.
</t>
<t>
When Direct Encryption is employed,
let the Content Encryption Key (CEK) be the shared symmetric key.
</t>
<t>
Base64url encode the JWE Encrypted Key to create the
Encoded JWE Encrypted Key.
</t>
<t>
If the JWE JSON Serialization is being used, repeat this process
for each recipient.
</t>
<t>
Generate a random JWE Initialization Vector of the correct size
for the content encryption algorithm (if required for the algorithm);
otherwise, let the JWE Initialization Vector be the empty octet sequence.
</t>
<t>
Base64url encode the JWE Initialization Vector to create the
Encoded JWE Initialization Vector.
</t>
<t>
Compress the Plaintext if a <spanx
style="verb">zip</spanx> parameter was included.
</t>
<t>
Serialize the (compressed) Plaintext into an octet sequence M.
</t>
<t>
Create a JWE Header containing the encryption
parameters used.
Note that white space is explicitly allowed
in the representation and no canonicalization need be performed
before encoding.
</t>
<t>
Base64url encode the octets of the UTF-8 representation of
the JWE Protected Header to create the Encoded JWE Header.
If the JWE Protected Header is not present
(which can only happen when using the JWE JSON Serialization
and no <spanx style="verb">protected</spanx> member is present),
let the Encoded JWE Header be the empty string.
</t>
<t>
Let the Additional Authenticated Data encryption parameter be
the octets of the ASCII representation of
the Encoded JWE Header value.
</t>
<t>
Encrypt M using the CEK, the JWE Initialization Vector, and
the Additional Authenticated Data value
using the specified content encryption algorithm
to create the JWE Ciphertext value and the JWE Authentication Tag
(which is the Authentication Tag output from the encryption operation).
</t>
<t>
Base64url encode the JWE Ciphertext to create the Encoded JWE Ciphertext.
</t>
<t>
Base64url encode the JWE Authentication Tag to create the
Encoded JWE Authentication Tag.
</t>
<t>
The five encoded parts are result values used in both the
JWE Compact Serialization and the JWE JSON Serialization representations.
</t>
<t>
Create the desired serialized output.
The JWE Compact Serialization of this result is the
concatenation of
the Encoded JWE Header,
the Encoded JWE Encrypted Key,
the Encoded JWE Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag
in that order, with the five strings
being separated by four period ('.') characters.
The JWE JSON Serialization is described in <xref target="JSONSerialization"/>.
</t>
</list>
</t>
</section>
<section title="Message Decryption" anchor="Decryption">
<t>
The message decryption process is the reverse of the
encryption process.
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 these steps fails, the JWE MUST be rejected.
</t>
<t>
<list style="numbers">
<t>
Parse the serialized input to determine the values of
the JWE Header,
the Encoded JWE Encrypted Key,
the Encoded JWE Initialization Vector,
the Encoded JWE Ciphertext, and
the Encoded JWE Authentication Tag.