Re: [Cbor] Interactions of packed CBOR and tags

Carsten Bormann <cabo@tzi.org> Thu, 27 August 2020 21:32 UTC

Return-Path: <cabo@tzi.org>
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 449223A138B; Thu, 27 Aug 2020 14:32:27 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.897
X-Spam-Level:
X-Spam-Status: No, score=-1.897 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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 ZnwfxzQCRAmc; Thu, 27 Aug 2020 14:32:24 -0700 (PDT)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 0F44F3A1389; Thu, 27 Aug 2020 14:32:23 -0700 (PDT)
Received: from client-0051.vpn.uni-bremen.de (client-0051.vpn.uni-bremen.de [134.102.107.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4BcwtD23Krz100g; Thu, 27 Aug 2020 23:32:20 +0200 (CEST)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <00c101d67cb5$2588b790$709a26b0$@augustcellars.com>
Date: Thu, 27 Aug 2020 23:32:19 +0200
Cc: draft-bormann-cbor-packed@ietf.org, cbor@ietf.org
X-Mao-Original-Outgoing-Id: 620256739.813588-3ee99f684967157e218ac5249f0ecc41
Content-Transfer-Encoding: quoted-printable
Message-Id: <E30F54B6-1A63-48AC-89AE-61983654B5A9@tzi.org>
References: <00c101d67cb5$2588b790$709a26b0$@augustcellars.com>
To: Jim Schaad <ietf@augustcellars.com>
X-Mailer: Apple Mail (2.3608.120.23.2.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/nm-ft1oV2ZZKnChA_LAKtmCLaOY>
Subject: Re: [Cbor] Interactions of packed CBOR and tags
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: Thu, 27 Aug 2020 21:32:27 -0000


> On 2020-08-27, at 23:00, Jim Schaad <ietf@augustcellars.com> wrote:
> 
> While building a test library of strings for evaluating my algorithm, I
> ended up with a question of how tags interact with the idea of CBOR packing.
> Specifically, if I use a standard date/time string with tag 0, should that
> text string be considered as a candidate for packing?
> 
> 0("1970-01-01T00:00Z") could potentially be compressed to 0(simple(3))
> 
> The problem is that this is no longer a valid CBOR encoding so it would not
> seem to be a legal thing to do.
> 
> Question:  Must packed CBOR be valid CBOR or does that requirement only
> apply to unpacked CBOR?

Great question.

The cop-out could be: either.
Since CBOR-valid packed CBOR is a subset of (just well-formed) packed CBOR, it could be a parameter given to the compressor whether that is allowed to use compression opportunities like the above or not.

What are the benefits/drawbacks:

* (just well-formed) packed CBOR may lead to trouble with a generic decoder that cannot handle (present to the application) invalid constructs like 0(simple(3)).
The application can decide whether it wants to live with this limitation or not.

* the structural coherence of the packed structure (that this draft is about) will be expressed as a validity constraint.  It is a bit weird to then relax validity of what goes in there, but not entirely without precedent (e.g., tag 24, even though there is a more explicit firewall here).

* not using those compression opportunities can be wasteful, not just for the example given above (tag 0), but also for tags like 32.

I think I would emphasize the (just well-formed) packed CBOR, but still introduce CBOR-valid packed CBOR as a selectable additional constraint for applications that need to work with pre-packed (designed before packed was invented) generic decoders.

Do we need to encode this selection?  (E.g., via different top-level tags.)  Probably not.

Grüße, Carsten