-
Notifications
You must be signed in to change notification settings - Fork 1
/
draft-miller-json-constrained-representation-00.txt
1064 lines (716 loc) · 39.5 KB
/
draft-miller-json-constrained-representation-00.txt
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
Network Working Group J. Miller
Internet-Draft
Intended status: Standards Track P. Saint-Andre
Expires: July 17, 2018 January 13, 2018
JSON Constrained Representation (JCOR)
draft-miller-json-constrained-representation-00
Abstract
This specification addresses the challenges of using JavaScript
Object Notation (JSON) with constrained devices by providing a
standard set of mapping rules to Concise Binary Object Representation
(CBOR) that preserve all semantic information, such that the original
JSON string can be identically re-created. JSON Constrained
Representation (JCOR) can also be used by devices as a native data
format, which can then be represented as JSON when necessary for
diagnostics, compatibility, and ease of integration with higher-level
systems.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on July 17, 2018.
Copyright Notice
Copyright (c) 2018 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
Miller & Saint-Andre Expires July 17, 2018 [Page 1]
Internet-Draft JCOR January 2018
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 4
2. CBOR Encoding . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1. Structured Types . . . . . . . . . . . . . . . . . . . . 4
2.2. Primitive Types . . . . . . . . . . . . . . . . . . . . . 5
2.2.1. Boolean and Null . . . . . . . . . . . . . . . . . . 5
2.2.2. Numbers . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.3. Strings . . . . . . . . . . . . . . . . . . . . . . . 5
3. Reference Sets . . . . . . . . . . . . . . . . . . . . . . . 6
4. Canonical Form . . . . . . . . . . . . . . . . . . . . . . . 7
4.1. Formatting-only Whitespace . . . . . . . . . . . . . . . 7
4.2. String Escapes . . . . . . . . . . . . . . . . . . . . . 9
5. Constrained API . . . . . . . . . . . . . . . . . . . . . . . 10
6. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6.1. JSON . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6.1.1. Input . . . . . . . . . . . . . . . . . . . . . . . . 10
6.1.2. Optimized JCOR Encoding . . . . . . . . . . . . . . . 11
6.1.3. Un-optimized JCOR Encoding . . . . . . . . . . . . . 13
6.2. JSON Web Token . . . . . . . . . . . . . . . . . . . . . 15
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16
7.1. CBOR Tags . . . . . . . . . . . . . . . . . . . . . . . . 16
7.2. JCOR Reference Sets Registry . . . . . . . . . . . . . . 17
8. Security Considerations . . . . . . . . . . . . . . . . . . . 17
9. References . . . . . . . . . . . . . . . . . . . . . . . . . 17
9.1. Normative References . . . . . . . . . . . . . . . . . . 17
9.2. Informative References . . . . . . . . . . . . . . . . . 18
9.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Appendix A. Acknowledgements . . . . . . . . . . . . . . . . . . 18
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 19
1. Introduction
Although JavaScript Object Notation (JSON) [RFC7159] has been widely
adopted in traditional networking and software environments, its use
in embedded and constrained environments has been more limited
because of the minimal storage and network capacities inherent in
low-cost and low-power devices (see [RFC7228]).
This specification addresses the challenges of using JSON with
constrained devices by defining a set of mapping rules to Concise
Binary Object Representation (CBOR) [RFC7049] that preserve all
Miller & Saint-Andre Expires July 17, 2018 [Page 2]
Internet-Draft JCOR January 2018
semantic information, such that the original JSON string can be
identically re-created. JSON Constrained Representation (JCOR) can
be used directly by devices as a native data format, which can be
represented as JSON when necessary for diagnostics, compatibility,
and ease of integration with higher-level systems.
A primary goal of JCOR is to enable all JSON Object Signing and
Encryption (JOSE) standards ([RFC7515], [RFC7516], [RFC7517],
[RFC7518], [RFC7519]) to be used unmodified in constrained
environments. One result is that OpenID Connect [1] (which utilizes
JSON Web Tokens [RFC7519]) can more easily be adopted as an identity
management solution for the Internet of Things.
JCOR is designed to leverage, not replace, CBOR. Instead, JCOR
specifies rules for re-coding JSON structures by mapping them to
their CBOR parallels whenever possible, and then increasing the
efficiency through introspection and replacement of well-known
strings with compact references.
All transcoding software MUST operate on a UTF-8 JSON string whenever
complete round-trip compatibility to and from JSON is required,
including mapping any contained non-structural whitespace (such as
with JWTs for signature validation). If a transcoder is only
operating with an already parsed JSON value (the result of
"JSON.parse()" in JavaScript for instance), the round-trip can only
guarantee semantic compatibility of the values as represented in that
parsed context (only the JavaScript object will always match).
A significant reduction in space is also provided in JCOR when the
device and application contexts can make use of built-in or shared
UTF-8 string references. These references provide a mapping of
common JSON string values to an integer that used to replace the
string in the resulting CBOR during re-coding. JSON string values
are also introspected for data that has a more compact CBOR type
(such as base64url and hexadecimal encoding).
The use of this specification can ensure that a UTF-8 JSON string
before and after re-coding will be byte-for-byte identical across
implementations, whereas the CBOR encoding is not designed to have
this property and MAY vary based on implementation choices and
reference sets available. There are basic API rules defined for
constrained software such that directly accessing the CBOR data
values will always provide a uniform view to an application across
variations in the underlying CBOR representation.
Miller & Saint-Andre Expires July 17, 2018 [Page 3]
Internet-Draft JCOR January 2018
1.1. Terminology
Many terms used in this document are defined in the specifications
for JSON [RFC7159] and CBOR [RFC7049]. This specification defines
the following additional terms:
o Constrained JSON Tag
* The CBOR tag registered in this specification to indicate an
array that contains JSON data encoded as CBOR according to this
specification.
o Reference
* A pointer within JCOR data that refers to a well-known UTF-8
string by using a CBOR byte string of length one, where the
byte value is the lookup identifier for the Reference.
o Reference Set
* A CBOR array of UTF-8 strings that are used to replace any
Reference within any JCOR data, where the Reference identifier
is the array offset to the replacement string and the first
position in the array identifies the Reference Set.
o Canonical Hints
* A CBOR array of integers that indicate positional offsets for
JSON string escape sequences or structural formatting
whitespace strings (, "\n", "\r", and "\t") such that when any
CBOR encoded data is stringified into JSON it can also
optionally be corrected to exactly match the original JSON
string.
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 RFC 2119 [RFC2119].
2. CBOR Encoding
JCOR encodes JSON data types to CBOR data types as described in the
following sections.
2.1. Structured Types
JSON defines two structured types: arrays and objects. These are
serialized to CBOR major type 4 (array) and type 5 (map),
Miller & Saint-Andre Expires July 17, 2018 [Page 4]
Internet-Draft JCOR January 2018
respectively. Ordering of key/value pairs in JSON objects and CBOR
maps MUST be preserved.
2.2. Primitive Types
2.2.1. Boolean and Null
The JSON literal names "false", "true", and "null" are serialized to
the CBOR major type 7 simple values 20, 21, and 22 respectively.
2.2.2. Numbers
A JCOR encoder attempts to encode a JSON number as a CBOR unsigned
integer (type 0), negative integer (type 1), or float (type 7) and
then test for compatibility by round-tripping the CBOR data item back
to a JSON number. If the resulting JSON number is not equivalent to
the input number, the encoder MUST instead encode it as a CBOR
Bigfloat (tag 5).
The JSON exponent value (if any) is encoded as a CBOR exponent (tag
4). If the contained "e" symbol is upper case in JSON, the "Upper
Case Modifier" tag defined below MUST be included.
2.2.3. Strings
A JSON string is normally encoded as an un-escaped CBOR UTF-8 string
(type 3), i.e., as a series of UTF-8 [RFC3629] characters (e.g., the
word "one" is encoded as "6F6E65") without any backspace escaping for
control or unicode characters.
2.2.3.1. Base64 / Base16 Encoded
A JCOR encoder MUST round-trip test all JSON strings for possible
encodings (base64url, base64, and hexadecimal) by attempting to
decode and re-encode them. If identical byte strings result, the
decoded value is tagged in CBOR with the encoding format (tags 21,
22, and 23). For hexadecimal, the "Upper Case Modifier" tag defined
below MUST be included if the hexadecimal letters A-F are upper case
in the original JSON string.
A JCOR encoder MUST perform introspection on the resulting decoded
byte string to determine if it begins with a JSON structure byte of
'{' or '['. The encoder SHOULD then round-trip test the string as a
possible JSON object or array so that it can encode the string more
efficiently into a CBOR data item instead of a byte string (this
pattern is common in the JOSE specification).
Miller & Saint-Andre Expires July 17, 2018 [Page 5]
Internet-Draft JCOR January 2018
3. Reference Sets
The Constrained JSON Tag is followed by an array whose second item
identifies the Reference Set used in the data. This is either a
Reference Set identifier or an array that defines an inline Reference
Set.
A Reference Set identifier is a unique integer that maps to a
Reference Set known to applications using the set. Public, well-
known reference sets can be registered as described in the IANA
Considerations section of this document.
The Reference Set definition is encoded as a JCOR array, where the
first value is the Reference Set identifier followed by all of the
UTF-8 string keys. A key's position in the array is the byte value
with which it is replaced.
Any Reference Set can include another Reference Set by encoding the
second set's identifer in the JCOR array that defines the first
Reference Set. Any byte strings in the definition array are then
replaced with the key from the references contained in the second
Reference Set.
JSON UTF-8 strings representing keys or values are first checked
against all active references (if any) for possible replacement. A
replacement is always a CBOR byte string (type 2) of length 1, where
the single byte represents the index value of the key in the
references array from 1-255. Value 0 and byte lengths greater than 1
are reserved for future use.
When a JCOR decoder generates JSON values from CBOR and it encounters
a CBOR byte string (type 2), single byte value MUST match the array
offset of the active references to be used as the replacement for
that byte string.
The following is the encoded form of a Reference Set as defined by
the JSON array of "[1,"map","value","array","one","two","three","bool
","neg","simple","ints"]":
Miller & Saint-Andre Expires July 17, 2018 [Page 6]
Internet-Draft JCOR January 2018
D4 # tag(20)
81 # array(1)
8B # array(11)
01 # unsigned(1)
63 # text(3)
6D6170 # "map"
65 # text(5)
76616C7565 # "value"
65 # text(5)
6172726179 # "array"
63 # text(3)
6F6E65 # "one"
63 # text(3)
74776F # "two"
65 # text(5)
7468726565 # "three"
64 # text(4)
626F6F6C # "bool"
63 # text(3)
6E6567 # "neg"
66 # text(6)
73696D706C65 # "simple"
64 # text(4)
696E7473 # "ints"
4. Canonical Form
This specification directly supports use-cases such as JSON Web
Tokens ([RFC7518]) where the canonical form of UTF-8 JSON strings
always needs to be available for validation. This is accomplished by
optionally including any additional information to reproduce the
exact UTF-8 string as an array of Canonical Hints included with the
Constrained JSON Tag.
These hints are not typically necessary as most machine-generated
JSON does not include any extra insignificant bytes by default, even
when included they do not need to be processed unless the original
canonical form is requested. When required, these additional hints
also take a highly constrained form and are independently additive to
the contained CBOR data values such that those values remain uniform
to any constrained application.
4.1. Formatting-only Whitespace
When a Constrained JSON tag is present and the first item in the
tagged array is a CBOR structure (map or array), a third optional
item in the tagged array is a set of canonical whitespace hints for
Miller & Saint-Andre Expires July 17, 2018 [Page 7]
Internet-Draft JCOR January 2018
any non-structural whitespace characters contained in the original
UTF-8 representation of the JSON object or array.
o Whitespace hints are contained in an array of integers that
indicate offsets of the locations of whitespace characters in an
original JSON string, and lookup values identifying which
whitespace characters were there.
o Each offset integer is relative to the position of the previous
offset such that all integers are of small values.
o A negative integer offset indicates a single ASCII space character
(0x20) at the offset of the positive value of that integer.
o An unsigned integer offset is followed by another integer, where
unsigned values (0-23) indicate a whitespace string in the pre-
defined lookup table, and negative values specify the number of
space characters (0x20) to repeat.
o When re-inserting whitespace characters to a JSON string, the
array MUST be applied sequentially so that each new offset matches
the original JSON string position.
The following 24 whitespace character hexadecimal sequences are used
as the shared reference lookup table by row (0-23) when processing
whitespace hints. This table is constructed to minimize the number
of references commonly required while also allowing any possible
whitespace character sequences to be identified.
Miller & Saint-Andre Expires July 17, 2018 [Page 8]
Internet-Draft JCOR January 2018
0a
0a2020
0a20202020
0a202020202020
0a2020202020202020
0a20202020202020202020
0a202020202020202020202020
0a2020202020202020202020202020
09
0a09
0a0909
0a090909
0a09090909
0a0909090909
0a090909090909
0a09090909090909
0a0909090909090909
0d
0d0a
0d0a2020
0d0a20202020
0d0a09
0d0a0909
0d0a090909
4.2. String Escapes
JSON string values MAY contain escaped characters (as defined in
Section 7 of [RFC7159]) that become un-escaped in the process of re-
coding them into a CBOR UTF-8 string. When the canonical form is
being preserved and any escaped characters are detected in the
process of converting them from JSON to CBOR, those string values
MUST be individually tagged as Constrained JSON where the first
element in the tagged array is the CBOR UTF-8 string value and the
second value is an array of positional integers similar to the
whitespace hints.
When the position is an unsigned integer it indicates the UTF-8
character at that position is to be escaped with the "\uXXXX" form
with lower-case hexadecimal characters. When it is a negative
integer it indicates that it is to be escaped with the "\X" form and
MUST be in the set of JSON escaped control characters.
When the original escaping in the "\uXXXX" form was with upper case
hexadecimal characters the entire array MUST be tagged with Upper
Case Modifier. In the unlikely case that the original escaping
contained mixed-case hexadecimal, then the positional integer will
instead itself be an array of length two with the position being the
Miller & Saint-Andre Expires July 17, 2018 [Page 9]
Internet-Draft JCOR January 2018
first element and a 4-byte UTF-8 string of the mixed-case hexadecimal
value being the second element.
5. Constrained API
In order to ease the use of JCOR in constrained environments, an
implementation SHOULD make data values available both as native CBOR
types and as JSON strings; this enables a constrained application to
choose either format regardless of how the data is represented in
CBOR.
For example, when the original JSON string value is encoded as a CBOR
base64url tag plus byte string, a constrained application accessing
the value as a string MUST receive the base64url encoded value and
not the decoded byte value. If the constrained application instead
accesses the value as a byte array it MUST get the decoded value if
available.
The representation of the value in CBOR SHOULD NOT alter behavior of
the application, a string value encoded as tag plus byte array SHOULD
NOT be used as an indication that it is a binary value and only the
application can make this determination based on external context.
6. Examples
6.1. JSON
6.1.1. Input
Consider the following JSON as input to a JCOR encoder.
Miller & Saint-Andre Expires July 17, 2018 [Page 10]
Internet-Draft JCOR January 2018
{
"map": "value",
"array": [
"one",
"two",
"three",
42
],
"bool": true,
"neg": -42,
"simple": [
false,
null,
""
],
"ints": [
0,
1,
23,
24,
255,
256,
65535,
65536,
4294967295,
4294967296,
281474976710656,
-281474976710656
]
}
6.1.2. Optimized JCOR Encoding
An optimized encoding would remove whitespace and use a Reference
Set. Here the references would be:
"[1,"map","value","array","one","two","three","bool","neg","simple","
ints"]"
The resulting JCOR encoding is 90 bytes compared to 318 bytes for the
JSON input.
Miller & Saint-Andre Expires July 17, 2018 [Page 11]
Internet-Draft JCOR January 2018
D4 # tag(20)
82 # array(2)
A6 # map(6)
41 # bytes(1)
01 # "\x01"
41 # bytes(1)
02 # "\x02"
41 # bytes(1)
03 # "\x03"
84 # array(4)
41 # bytes(1)
04 # "\x04"
41 # bytes(1)
05 # "\x05"
41 # bytes(1)
06 # "\x06"
18 2A # unsigned(42)
41 # bytes(1)
07 # "\a"
F5 # primitive(21)
41 # bytes(1)
08 # "\b"
38 29 # negative(41)
41 # bytes(1)
09 # "\t"
83 # array(3)
F4 # primitive(20)
F6 # primitive(22)
60 # text(0)
# ""
41 # bytes(1)
0A # "\n"
8C # array(12)
00 # unsigned(0)
01 # unsigned(1)
17 # unsigned(23)
18 18 # unsigned(24)
19 00FF # unsigned(255)
19 0100 # unsigned(256)
19 FFFF # unsigned(65535)
1A 00010000 # unsigned(65536)
1B 00000000FFFFFFFF # unsigned(4294967295)
1B 0000000100000000 # unsigned(4294967296)
1B 0001000000000000 # unsigned(281474976710656)
3B 0000FFFFFFFFFFFF # negative(281474976710655)
01 # unsigned(1)
Miller & Saint-Andre Expires July 17, 2018 [Page 12]
Internet-Draft JCOR January 2018
6.1.3. Un-optimized JCOR Encoding
An un-optimized encoding would not use a Reference Set and would
preserve whitespace. The un-optimized encoding would reduce the data
from the 318 bytes (JSON) to 187 bytes (JCOR).
D4 # tag(20)
83 # array(3)
A6 # map(6)
63 # text(3)
6D6170 # "map"
65 # text(5)
76616C7565 # "value"
65 # text(5)
6172726179 # "array"
84 # array(4)
63 # text(3)
6F6E65 # "one"
63 # text(3)
74776F # "two"
65 # text(5)
7468726565 # "three"
18 2A # unsigned(42)
64 # text(4)
626F6F6C # "bool"
F5 # primitive(21)
63 # text(3)
6E6567 # "neg"
38 29 # negative(41)
66 # text(6)
73696D706C65 # "simple"
83 # array(3)
F4 # primitive(20)
F6 # primitive(22)
60 # text(0)
# ""
64 # text(4)
696E7473 # "ints"
8C # array(12)
00 # unsigned(0)
01 # unsigned(1)
17 # unsigned(23)
18 18 # unsigned(24)
19 00FF # unsigned(255)
19 0100 # unsigned(256)
19 FFFF # unsigned(65535)
1A 00010000 # unsigned(65536)
1B 00000000FFFFFFFF # unsigned(4294967295)
Miller & Saint-Andre Expires July 17, 2018 [Page 13]
Internet-Draft JCOR January 2018
1B 0000000100000000 # unsigned(4294967296)
1B 0001000000000000 # unsigned(281474976710656)
3B 0000FFFFFFFFFFFF # negative(281474976710655)
00 # unsigned(0)
98 40 # array(64)
01 # unsigned(1)
01 # unsigned(1)
26 # negative(6)
08 # unsigned(8)
01 # unsigned(1)
28 # negative(8)
01 # unsigned(1)
02 # unsigned(2)
06 # unsigned(6)
02 # unsigned(2)
06 # unsigned(6)
02 # unsigned(2)
08 # unsigned(8)
02 # unsigned(2)
02 # unsigned(2)
01 # unsigned(1)
02 # unsigned(2)
01 # unsigned(1)
27 # negative(7)
05 # unsigned(5)
01 # unsigned(1)
26 # negative(6)
04 # unsigned(4)
01 # unsigned(1)
29 # negative(9)
01 # unsigned(1)
02 # unsigned(2)
06 # unsigned(6)
02 # unsigned(2)
05 # unsigned(5)
02 # unsigned(2)
02 # unsigned(2)
01 # unsigned(1)
02 # unsigned(2)
01 # unsigned(1)
27 # negative(7)
01 # unsigned(1)
02 # unsigned(2)
02 # unsigned(2)
02 # unsigned(2)
02 # unsigned(2)
02 # unsigned(2)
03 # unsigned(3)
Miller & Saint-Andre Expires July 17, 2018 [Page 14]
Internet-Draft JCOR January 2018
02 # unsigned(2)
03 # unsigned(3)
02 # unsigned(2)
04 # unsigned(4)
02 # unsigned(2)
04 # unsigned(4)
02 # unsigned(2)
06 # unsigned(6)
02 # unsigned(2)
06 # unsigned(6)
02 # unsigned(2)
0B # unsigned(11)
02 # unsigned(2)
0B # unsigned(11)
02 # unsigned(2)
10 # unsigned(16)
02 # unsigned(2)
10 # unsigned(16)
01 # unsigned(1)
01 # unsigned(1)
00 # unsigned(0)
6.2. JSON Web Token
Consider the following JSON Web Token [RFC7519], which natively is
149 bytes (line endings are not significant):
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiO
iIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWR
taW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZ
geFONFh7HgQ
In a JSON encoding, the JWT would be 191 bytes (line endings are not
significant):
{"protected":
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
"payload":"eyJzdWIiOiIxMjM0NTY3ODkwIiwib
mFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9",
"signature":
"TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh
7HgQ"}
Using a Reference Set of "[1,"payload","signature","protected","alg",
"HS256","sub","name","admin"]", the JCOR encoding would be 80 bytes.
Miller & Saint-Andre Expires July 17, 2018 [Page 15]
Internet-Draft JCOR January 2018
D4 # tag(20)
82 # array(2)
A3 # map(3)
41 # bytes(1)
03 # "\x03"
D5 # tag(21)
A2 # map(2)
41 # bytes(1)
04 # "\x04"
41 # bytes(1)
05 # "\x05"
41 # bytes(1)
06 # "\x06"
41 # bytes(1)
07 # "\a"
41 # bytes(1)
01 # "\x01"
D5 # tag(21)
A3 # map(3)
41 # bytes(1)
08 # "\b"
D7 # tag(23)
45 # bytes(5)
1234567890 # "\x124Vx\x90"
41 # bytes(1)
09 # "\t"
68 # text(8)
4A6F686E20446F65 # "John Doe"
41 # bytes(1)
0A # "\n"
F5 # primitive(21)
41 # bytes(1)
02 # "\x02"
D5 # tag(21)
58 20 # bytes(32)
4C9540F793AB33B13670169BDF444C1EB1C37047F18
E861981E14E34587B1E04 # "L\x95@\xF7\x93\xAB3
\xB16p\x16\x9B\xDFDL\x1E\xB1\xC3pG\xF1\x8E
\x86\x19\x81\xE1N4X{\x1E\x04"
01 # unsigned(1)
7. IANA Considerations
7.1. CBOR Tags
The IANA is requested to assign the following tags from the "CBOR
Tags" registry defined in RFC 7049 [RFC7049]:
Miller & Saint-Andre Expires July 17, 2018 [Page 16]
Internet-Draft JCOR January 2018
o Assign the tag "Constrained JSON" in the 1 to 23 value range (one
byte in length when encoded).
o Assign the tag "Upper Case Modifier" in the 24 to 255 value range
(two bytes in length when encoded).
The tags to be assigned are described below.
Tag 20 (Constrained JSON)
Data Item array
Semantics The first value in the array is a constrained
JSON data item encoded using JCOR, optionally
followed by an integer or array identifying any
embedded references, and then an optional array
of canonical hints (if any).
Reference http://quartzjer.github.io/JCOR
Contact Jeremie Miller <jeremie.miller@gmail.com>
Tag 31 (Upper Case Modifier)
Data Item multiple
Semantics Indicates that the data item following contains
values where the upper case is semantically
important when interpreted in a UTF-8 string
context.
Reference http://quartzjer.github.io/JCOR
Contact Jeremie Miller <jeremie.miller@gmail.com>
7.2. JCOR Reference Sets Registry
A future version of this document will request creation of a registry
for JCOR Reference Sets and provide initial registrations for the
existing JOSE JWE, JWS, and JWA RFCs.
8. Security Considerations
TODO
9. References
9.1. Normative References
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, <https://www.rfc-
editor.org/info/rfc2119>.
Miller & Saint-Andre Expires July 17, 2018 [Page 17]
Internet-Draft JCOR January 2018
[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO
10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November
2003, <https://www.rfc-editor.org/info/rfc3629>.
[RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object
Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049,
October 2013, <https://www.rfc-editor.org/info/rfc7049>.
[RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March
2014, <https://www.rfc-editor.org/info/rfc7159>.
[RFC7515] Jones, M., Bradley, J., and N. Sakimura, "JSON Web
Signature (JWS)", RFC 7515, DOI 10.17487/RFC7515, May
2015, <https://www.rfc-editor.org/info/rfc7515>.
[RFC7516] Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)",
RFC 7516, DOI 10.17487/RFC7516, May 2015,
<https://www.rfc-editor.org/info/rfc7516>.
[RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517,
DOI 10.17487/RFC7517, May 2015, <https://www.rfc-
editor.org/info/rfc7517>.
[RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518,
DOI 10.17487/RFC7518, May 2015, <https://www.rfc-
editor.org/info/rfc7518>.
[RFC7519] Jones, M., Bradley, J., and N. Sakimura, "JSON Web Token
(JWT)", RFC 7519, DOI 10.17487/RFC7519, May 2015,
<https://www.rfc-editor.org/info/rfc7519>.
9.2. Informative References
[RFC7228] Bormann, C., Ersue, M., and A. Keranen, "Terminology for
Constrained-Node Networks", RFC 7228,
DOI 10.17487/RFC7228, May 2014, <https://www.rfc-
editor.org/info/rfc7228>.
9.3. URIs
[1] http://openid.net/connect/
Appendix A. Acknowledgements