Re: [Cbor] Review of draft-bormann-cbor-sequence

Felipe Gasper <> Mon, 22 July 2019 21:35 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 4987E1200A3; Mon, 22 Jul 2019 14:35:31 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Status: No, score=-2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: (amavisd-new); dkim=pass (2048-bit key)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id Gp6Pjq5fqFJi; Mon, 22 Jul 2019 14:35:28 -0700 (PDT)
Received: from ( []) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPS id B057412001B; Mon, 22 Jul 2019 14:35:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;; s=default; h=To:References:Message-Id: Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Subject:Mime-Version: Content-Type:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/ooiJjFZ1HiXhNGOSuU5d+2Uw3b8aFGG/RVM6z4DBLY=; b=faZTdtwcf0yVdmdXJLLeqNvX2 MzeQ/yOQZc99XtmUXRxilU1Anc9leP53PXx22/krFNRpTFcu2xBBm0MJ1WPDFDzZOoQ9+LJF2cqD4 GSIl57lIzaVdTdBAlNajCavOA68X2Cr7zJM1J40DmGUStPs5KNpr5gkCEC9LrK+js4aC2EELKRF4w tlVQv2VOE0OdO4af5etn+6JW0rO5jStyHNu8aQZCCxlKyW85PGaKWUlu8SDHSfJ21QDuNs6bp/XJe Hlwx0M+Y1wFxYWo1FI9fNp64PtS44q/OdxbpOHIfEhc1UeOgxKZM0wGgWk7IlTM+F4a4C/d+JbhCn 8mUFyB1qA==;
Received: from [] (port=21859 helo=[]) by with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from <>) id 1hpfxt-00CraG-Bw; Mon, 22 Jul 2019 16:35:26 -0500
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (1.0)
From: Felipe Gasper <>
X-Mailer: iPhone Mail (16F203)
In-Reply-To: <>
Date: Mon, 22 Jul 2019 17:35:24 -0400
Cc: Jim Schaad <>,,, Carsten Bormann <>
Content-Transfer-Encoding: quoted-printable
Message-Id: <>
References: <01f201d50ac9$d6b1abd0$84150370$> <> <0e8901d52f6c$08291060$187b3120$> <> <0eb801d52faa$f118fc70$d34af550$> <> <>
To: Sean Leonard <>
X-OutGoing-Spam-Status: No, score=-0.2
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname -
X-AntiAbuse: Original Domain -
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain -
X-Get-Message-Sender-Via: authenticated_id: fgasper/from_h
X-From-Rewrite: unmodified, already matched
Archived-At: <>
Subject: Re: [Cbor] Review of draft-bormann-cbor-sequence
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Mon, 22 Jul 2019 21:35:32 -0000

Given that, as you observe, simple concatenation differs from an indefinite-length array only in the leading/trailing bytes, I still don’t see the use case for a stream of CBOR items that doesn’t indicate either a start or an end. It seems like it would be analogous to WebSocket without a close handshake: what is the advantage, versus having a built-in mechanism that defines the end of the stream?

An advantage of defining sequences as merely a special case of indefinite-length arrays (maybe with a tag) is that an ordinary CBOR encoder and decoder can then parse/encode the stream: either per item if it’s capable, or as a single blob otherwise. The same workflow as for an indefinite-length array—fork off processing per item in the decoder, chunked output in the encoder—will serve the sequence use case.


> On Jul 22, 2019, at 17:15, Sean Leonard <> wrote:
> Basically, I believe it’s because you want to enable simple concatenation semantics to add more stuff to the sequence. A sequence is potentially multiple CBOR items strung together. An indefinite-length CBOR array with a terminating byte is a single CBOR item; it can’t be augmented by streaming more data at the end (then, naturally, the data becomes multiple CBOR items).
> You can turn a CBOR sequence into a single CBOR data item by prepending the array tag of definite length, or prepending the array tag of indefinite length and appending the terminating byte. This is cheap because it’s just part of “initializing” and “finalizing” the decoder. But when the data is coming across ad infinitum on the wire, you never actually want that terminating byte in the data stream. (At the same time, once you get a single CBOR data item, you want to fork off processing of that single data item rather than keeping the top-level decoder running, looking for said terminating byte.)
> Sean
>> On Jul 1, 2019, at 4:11 AM, Felipe Gasper <> wrote:
>> Sorry, I was asking a more general question about the proposed CBOR sequence format rather than engaging your point.
>> I realize I should have started a new thread--my apologies for the confusion.
>> I’m just a bit surprised that CBOR sequences are (proposed to be) defined this way. It seems to me that CBOR has no real need for such a standard, precisely because of the indefinite-length arrays that the format itself includes. I would have thought it more logical to define a specific tag that indicates such a structure; thus, a CBOR sequence would itself also be a valid CBOR data object.
>> Thank you!
>> -FG
>>> On Jun 30, 2019, at 9:18 PM, Jim Schaad <> wrote:
>>> This is the text I was referring to
>>> An
>>> 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
>>> data item.
>>> -----Original Message-----
>>> From: CBOR <> On Behalf Of Felipe Gasper
>>> Sent: Sunday, June 30, 2019 2:56 PM
>>> To: Jim Schaad <>
>>> Cc:;; Carsten Bormann <>
>>> Subject: Re: [Cbor] Review of draft-bormann-cbor-sequence
>>> What is the advantage of defining a CBOR data sequence as a simple concatenation versus a tagged CBOR array of indefinite length?
>>> Thank you!
>>> -FG
>>>> On Jun 30, 2019, at 1:48 PM, Jim Schaad <> wrote:
>>>> See below.
>>>> -----Original Message-----
>>>> From: Carsten Bormann <>
>>>> Sent: Sunday, June 23, 2019 9:53 AM
>>>> To: Jim Schaad <>
>>>> Cc:;
>>>> Subject: Re: Review of draft-bormann-cbor-sequence
>>>> Hi Jim,
>>>> except for items 3 and 5 below, where I don’t quite agree, I believe I have addressed all your comments as well as the other items that popped up for -00 in Prague and on the mailing list.
>>>> Please enjoy at:
>>>> Status:
>>>> Htmlized:
>>>> Diff2:
>>>> Grüße, Carsten
>>>>> On May 15, 2019, at 04:56, Jim Schaad <> wrote:
>>>>> […]
>>>>> 3.  Section 2 - I think that I would remove the parenthesis in the 
>>>>> third paragraph.  This is almost the entire paragraph.
>>>> I believe that is useful information, so I don’t think the parenthesis should be removed.
>>>> [JLS] I am not suggesting that the sentence be removed, just the parenthesis characters.
>>>>> […]
>>>>> 5.  Section 2 - A program, not the decoder, may also be able to 
>>>>> recover by decoding individual fields looking for a pattern that 
>>>>> matches an expected structure.  As an example, looking for a byte 
>>>>> which corresponds to an array of 3 items and then test decoding to 
>>>>> see if it works and continue from that point.
>>>> The specific recovery actions are out of scope (and the text says so).
>>>> I don’t think we should give advice here for diagnostic tools beyond what is needed for a true decoder.
>>>> [JLS] The problem I have with this argument is that you are actually giving an example - should that example then be deleted?
>>>> _______________________________________________
>>>> CBOR mailing list
>>> _______________________________________________
>>> CBOR mailing list
>> _______________________________________________
>> CBOR mailing list