[Cbor] tag 24, CBOR sequence and non-CBOR sequence

Laurence Lundblade <lgl@island-resort.com> Fri, 05 June 2020 15:13 UTC

Return-Path: <lgl@island-resort.com>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 5C38E3A078C for <cbor@ietfa.amsl.com>; Fri, 5 Jun 2020 08:13:07 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.895
X-Spam-Level:
X-Spam-Status: No, score=-1.895 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cJ7UvWekgQ3K for <cbor@ietfa.amsl.com>; Fri, 5 Jun 2020 08:13:06 -0700 (PDT)
Received: from p3plsmtpa12-06.prod.phx3.secureserver.net (p3plsmtpa12-06.prod.phx3.secureserver.net [68.178.252.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 559F33A078A for <cbor@ietf.org>; Fri, 5 Jun 2020 08:13:06 -0700 (PDT)
Received: from [192.168.1.78] ([76.167.193.86]) by :SMTPAUTH: with ESMTPA id hE1pjEFZMOBCghE1pjzMBw; Fri, 05 Jun 2020 08:13:05 -0700
X-CMAE-Analysis: v=2.3 cv=RoC70xuK c=1 sm=1 tr=0 a=t2DvPg6iSvRzsOFYbaV4uQ==:117 a=t2DvPg6iSvRzsOFYbaV4uQ==:17 a=VkA9zdAzIxSP5rL2CGsA:9 a=QEXdDO2ut3YA:10 a=zIIKu-7Qwl4Dx_hJ:21 a=_W_S_7VecoQA:10 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=jd6J4Gguk5HxikPWLKER:22
X-SECURESERVER-ACCT: lgl@island-resort.com
From: Laurence Lundblade <lgl@island-resort.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_8C08CB1D-15C6-414A-9735-0162E36A8A64"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
Message-Id: <1811F0B6-3105-4904-987A-72D0BC14D719@island-resort.com>
Date: Fri, 05 Jun 2020 08:13:04 -0700
To: cbor@ietf.org
X-Mailer: Apple Mail (2.3445.104.11)
X-CMAE-Envelope: MS4wfM/LUCfvXfxauzAPo7EpaasY4oyNYF9HGw1178z3hvF6rzUBIBq9DdnG/PZh2/OMsKwiuQXXhI6sai6gUGJJRJMAkHXR/ih8sUK9K6h7Jxgf8IAHZ3gO 6JBYf4clafzsJIqQ2CokaBDGx8G1v4eZzkYHIWU85Dxjo9J6UZTwi5XM
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/uK3K748DOW6zB2xnjpxnzHScEh0>
Subject: [Cbor] tag 24, CBOR sequence and non-CBOR sequence
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 05 Jun 2020 15:13:07 -0000

Here’s some example of CBOR sequence (e.g., application/cbor-seq) and CBOR that is not a sequence (e.g., application/cbor)

0x00 
This is a legal sequence or non-sequence

0x00 0x00
This is a legal sequence, but not non-sequence. A non-sequence can contain only one data item, this contains two.

0x82 0x00 0x00
This is a legal sequence or non-sequence. It is how you encode two zeros as a non-sequence.

Looks to me that tag 24 cannot contain a CBOR sequence. It says “a data item”. The use of “a” implies one data item and thus not a sequence. That means a decoder should always consider a sequence in the contents of a tag 24 invalid.

This seems overly restrictive and unfortunate to me.  Would it be wrong for a generic decoder to allow this?

The wording for tag 55799 avoids the issue of sequence or not.


Technically, it seems that something labeled application/cbor or in a file named foo.cbor can’t contain the CBOR 0x00 0x00 because it is not a legal non-sequence. That might implies a generic decoder should have a sequence mode and a non-sequence mode. In practice this doesn’t seem like a very useful restriction. What is useful is whether the encoded CBOR is legal for the protocol being implemented.


From what I’ve experienced, it seems easier if everything is just a CBOR sequence and no distinction is made. Individual CBOR protocols can decide on their own structure either deciding to bind things together in an array or not. Am I missing something?

LL