draft-ietf-cbor-sequence-00.txt   draft-ietf-cbor-sequence-01.txt 
Network Working Group C. Bormann Network Working Group C. Bormann
Internet-Draft Universitaet Bremen TZI Internet-Draft Universitaet Bremen TZI
Intended status: Standards Track August 13, 2019 Intended status: Standards Track August 31, 2019
Expires: February 14, 2020 Expires: March 3, 2020
Concise Binary Object Representation (CBOR) Sequences Concise Binary Object Representation (CBOR) Sequences
draft-ietf-cbor-sequence-00 draft-ietf-cbor-sequence-01
Abstract Abstract
This document describes the Concise Binary Object Representation This document describes the Concise Binary Object Representation
(CBOR) Sequence format and associated media type "application/cbor- (CBOR) Sequence format and associated media type "application/cbor-
seq". A CBOR Sequence consists of any number of encoded CBOR data seq". A CBOR Sequence consists of any number of encoded CBOR data
items, simply concatenated in sequence. items, simply concatenated in sequence.
Structured syntax suffixes for media types allow other media types to Structured syntax suffixes for media types allow other media types to
build on them and make it explicit that they are built on an existing build on them and make it explicit that they are built on an existing
skipping to change at page 1, line 39 skipping to change at page 1, line 39
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on February 14, 2020. This Internet-Draft will expire on March 3, 2020.
Copyright Notice Copyright Notice
Copyright (c) 2019 IETF Trust and the persons identified as the Copyright (c) 2019 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of (https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 2, line 18 skipping to change at page 2, line 18
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Conventions Used in This Document . . . . . . . . . . . . 3 1.1. Conventions Used in This Document . . . . . . . . . . . . 3
2. CBOR Sequence Format . . . . . . . . . . . . . . . . . . . . 3 2. CBOR Sequence Format . . . . . . . . . . . . . . . . . . . . 3
3. The "+cbor-seq" Structured Syntax Suffix . . . . . . . . . . 4 3. The "+cbor-seq" Structured Syntax Suffix . . . . . . . . . . 4
4. Practical Considerations . . . . . . . . . . . . . . . . . . 4 4. Practical Considerations . . . . . . . . . . . . . . . . . . 4
4.1. Specifying CBOR Sequences in CDDL . . . . . . . . . . . . 4 4.1. Specifying CBOR Sequences in CDDL . . . . . . . . . . . . 4
4.2. Optimizing CBOR Sequences for Skipping Elements . . . . . 5 4.2. Diagnostic Notation . . . . . . . . . . . . . . . . . . . 5
5. Security Considerations . . . . . . . . . . . . . . . . . . . 5 4.3. Optimizing CBOR Sequences for Skipping Elements . . . . . 5
6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 5 5. Security Considerations . . . . . . . . . . . . . . . . . . . 6
6.1. Media Type . . . . . . . . . . . . . . . . . . . . . . . 5 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 6
6.2. CoAP Content-Format Registration . . . . . . . . . . . . 6 6.1. Media Type . . . . . . . . . . . . . . . . . . . . . . . 6
6.2. CoAP Content-Format Registration . . . . . . . . . . . . 7
6.3. Structured Syntax Suffix . . . . . . . . . . . . . . . . 7 6.3. Structured Syntax Suffix . . . . . . . . . . . . . . . . 7
7. References . . . . . . . . . . . . . . . . . . . . . . . . . 8 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 9
7.1. Normative References . . . . . . . . . . . . . . . . . . 8 7.1. Normative References . . . . . . . . . . . . . . . . . . 9
7.2. Informative References . . . . . . . . . . . . . . . . . 9 7.2. Informative References . . . . . . . . . . . . . . . . . 9
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 9 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 10
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 9 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 10
1. Introduction 1. Introduction
The Concise Binary Object Representation (CBOR) [RFC7049] can be used The Concise Binary Object Representation (CBOR) [RFC7049] can be used
for serialization of data in the JSON [RFC8259] data model or in its for serialization of data in the JSON [RFC8259] data model or in its
own, somewhat expanded data model. When serializing a sequence of own, somewhat expanded data model. When serializing a sequence of
such values, it is sometimes convenient to have a format where these such values, it is sometimes convenient to have a format where these
sequences can simply be concatenated to obtain a serialization of the sequences can simply be concatenated to obtain a serialization of the
concatenated sequence of values, or to encode a sequence of values concatenated sequence of values, or to encode a sequence of values
that might grow at the end by just appending further CBOR data items. that might grow at the end by just appending further CBOR data items.
This document describes the concept and format of "CBOR Sequences", This document describes the concept and format of "CBOR Sequences",
which are composed of zero or more encoded CBOR data items. CBOR which are composed of zero or more encoded CBOR data items. CBOR
Sequences can be consumed (and produced) incrementally without Sequences can be consumed (and produced) incrementally without
requiring a streaming CBOR parser that is able to deliver requiring a streaming CBOR parser that is able to deliver
substructures of a data item incrementally (or a streaming encoder substructures of a data item incrementally (or a streaming encoder
able to encode from substructures incrementally). able to encode from substructures incrementally).
This document defines and registers the "application/cbor-seq" media This document defines and registers the "application/cbor-seq" media
type in the media type registry. Media type structured syntax type in the media type registry, along with a CoAP Content-Format
suffixes [RFC6838] were introduced as a way for a media type to identifier. Media type structured syntax suffixes [RFC6838] were
signal that it is based on another media type as its foundation. introduced as a way for a media type to signal that it is based on
CBOR [RFC7049] defines the "+cbor" structured syntax suffix. This another media type as its foundation. CBOR [RFC7049] defines the
document defines and registers the "+cbor-seq" structured syntax "+cbor" structured syntax suffix. This document defines and
suffix in the "Structured Syntax Suffix Registry". registers the "+cbor-seq" structured syntax suffix in the "Structured
Syntax Suffix Registry".
1.1. Conventions Used in This Document 1.1. Conventions Used in This Document
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in "OPTIONAL" in this document are to be interpreted as described in
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
In this specification, the term "byte" is used in its now-customary In this specification, the term "byte" is used in its now-customary
skipping to change at page 3, line 29 skipping to change at page 3, line 31
Formally, a CBOR Sequence is a sequence of bytes that is recursively Formally, a CBOR Sequence is a sequence of bytes that is recursively
defined as either defined as either
o an empty (zero-length) sequence of bytes o an empty (zero-length) sequence of bytes
o the sequence of bytes making up an encoded CBOR data item o the sequence of bytes making up an encoded CBOR data item
[RFC7049], followed by a CBOR Sequence. [RFC7049], followed by a CBOR Sequence.
In short, concatenating zero or more encoded CBOR data items In short, concatenating zero or more encoded CBOR data items
generates a CBOR Sequence. generates a CBOR Sequence. (Consequently, concatenating zero or more
CBOR Sequences also results in a CBOR Sequence.)
There is no end of sequence indicator. (If one is desired, CBOR- There is no end of sequence indicator. (If one is desired, CBOR-
encoding an array of the CBOR data model values being encoded -- encoding an array of the CBOR data model values being encoded --
employing either a definite or an indefinite length encoding -- as a employing either a definite or an indefinite length encoding -- as a
single CBOR data item may actually be the more appropriate single CBOR data item may actually be the more appropriate
representation.) representation.)
This specification makes use of the fact that CBOR data items are CBOR Sequences, unlike JSON Text Sequences [RFC7464], do not use a
self-delimiting (there is no delimiter used between items, as there marker between items. This is possible because CBOR encoded data
is in JSON Text Sequences [RFC7464]). items are self-delimiting and the end can always be calculated.
(Note that, while the early object/array-only form of JSON was self-
delimiting as well, this stopped being the case when simple values
such as single numbers were made valid JSON documents.)
Decoding a CBOR Sequence works as follows: Decoding a CBOR Sequence works as follows:
o If the CBOR Sequence is an empty sequence of bytes, the result is o If the CBOR Sequence is an empty sequence of bytes, the result is
an empty sequence of CBOR data model values. an empty sequence of CBOR data model values.
o Otherwise, decode a single CBOR data item from the bytes of the o Otherwise, decode a single CBOR data item from the bytes of the
CBOR sequence, and insert the resulting CBOR data model value at CBOR sequence, and insert the resulting CBOR data model value at
the start of the result of decoding the rest of the bytes as a the start of the result of decoding the rest of the bytes as a
CBOR sequence. (A streaming decoder would therefore simply CBOR sequence. (A streaming decoder would therefore simply
deliver a sequence of CBOR data model values, each of which as deliver zero or more CBOR data model values, each of which as soon
soon as the bytes making it up are available.) as the bytes making it up are available.)
This means that if any data item in the sequence is not well-formed, This means that if any data item in the sequence is not well-formed,
it is not possible to reliably decode the rest of the sequence. (An it is not possible to reliably decode the rest of the sequence. (An
implementation may be able to recover from some errors in a sequence implementation may be able to recover from some errors in a sequence
of bytes that is almost, but not entirely a well-formed encoded CBOR of bytes that is almost, but not entirely a well-formed encoded CBOR
data item. Handling malformed data is outside the scope of this data item. Handling malformed data is outside the scope of this
specification.) specification.)
This also means that the CBOR Sequence format can reliably detect This also means that the CBOR Sequence format can reliably detect
truncation of the bytes making up the last CBOR data item in the truncation of the bytes making up the last CBOR data item in the
skipping to change at page 5, line 14 skipping to change at page 5, line 24
; This defines an array, the elements of which are to be used ; This defines an array, the elements of which are to be used
; in a CBOR sequence: ; in a CBOR sequence:
my-sequence = [* my-element] my-sequence = [* my-element]
my-element = my-foo / my-bar my-element = my-foo / my-bar
(Future versions of CDDL may provide a notation for top-level CBOR (Future versions of CDDL may provide a notation for top-level CBOR
sequences, e.g. by using a group as the top-level rule in a CDDL sequences, e.g. by using a group as the top-level rule in a CDDL
specification.) specification.)
4.2. Optimizing CBOR Sequences for Skipping Elements 4.2. Diagnostic Notation
CBOR diagnostic notation (see Section 6 of [RFC7049]) or extended
diagnostic notation (Appendix G of [RFC8610]) also does not provide
for unadorned CBOR Sequences at this time (the latter does provide
for CBOR Sequences embedded in a byte string in Appendix G.3 of
[RFC8610]).
In a similar spirit to the recommendation for CDDL above, this
specification recommends enclosing the CBOR data items in an array.
In a more informal setting, where the boundaries within which the
notation is used are obvious, it is also possible to leave off the
outer brackets for this array, as shown in these two examples:
[1, 2, 3]
1, 2, 3
Note that it is somewhat difficult to discuss zero-length CBOR
Sequences in the latter form.
4.3. Optimizing CBOR Sequences for Skipping Elements
In certain applications, being able to efficiently skip an element In certain applications, being able to efficiently skip an element
without the need for decoding its substructure, or efficiently without the need for decoding its substructure, or efficiently
fanning out elements to multi-threaded decoding processes, is of the fanning out elements to multi-threaded decoding processes, is of the
utmost importance. For these applications, byte strings (which carry utmost importance. For these applications, byte strings (which carry
length information in bytes) containing embedded CBOR can be used as length information in bytes) containing embedded CBOR can be used as
the elements of a CBOR sequence: the elements of a CBOR sequence:
; This defines an array of CBOR byte strings, the elements of which ; This defines an array of CBOR byte strings, the elements of which
; are to be used in a CBOR sequence: ; are to be used in a CBOR sequence:
 End of changes. 11 change blocks. 
26 lines changed or deleted 53 lines changed or added

This html diff was produced by rfcdiff 1.47. The latest version is available from http://tools.ietf.org/tools/rfcdiff/