[Cbor] Simple values in CDDL (draft-ietf-cbor-update-8610-grammar)

Carsten Bormann <cabo@tzi.org> Mon, 26 February 2024 08:49 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 92015C14F6FC for <cbor@ietfa.amsl.com>; Mon, 26 Feb 2024 00:49:00 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.909
X-Spam-Level:
X-Spam-Status: No, score=-1.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dBKgNL7dYCjC for <cbor@ietfa.amsl.com>; Mon, 26 Feb 2024 00:48:56 -0800 (PST)
Received: from smtp.zfn.uni-bremen.de (smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1B2A1C14F736 for <cbor@ietf.org>; Mon, 26 Feb 2024 00:48:54 -0800 (PST)
Received: from eduroam-pool10-028.wlan.uni-bremen.de (eduroam-pool10-028.wlan.uni-bremen.de [134.102.90.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4TjvRS6SbxzDCcF; Mon, 26 Feb 2024 09:48:52 +0100 (CET)
From: Carsten Bormann <cabo@tzi.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Mao-Original-Outgoing-Id: 730630132.282528-7d069e0533ae83b3ba85a6bca08e5b2e
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
Date: Mon, 26 Feb 2024 09:48:52 +0100
Message-Id: <BAAD4C74-CD11-47A2-B571-8B0A9B344A6E@tzi.org>
To: cbor@ietf.org
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/8GO72OdMt0FM3yzTyLhz_fhm3cU>
Subject: [Cbor] Simple values in CDDL (draft-ietf-cbor-update-8610-grammar)
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
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: Mon, 26 Feb 2024 08:49:00 -0000

I just wanted to write a test for simple values in the cddl tool and noticed that we are missing something here.

In the prelude, we say:

                  float16 = #7.25
                  float32 = #7.26
                  float64 = #7.27

                  false = #7.20
                  true = #7.21
                  nil = #7.22
                  undefined = #7.23

This works fine: #7.0 to #7.23 are simple values, and #7.25/26/27 are floating point values.  The number after the dot (I’ll call it the additional number) is an ai (additional information) as for other major types except 6.

However, what we are missing is a way to specify simple values 32 to 255.  We haven’t registered one of these yet, so nobody needed this, which led to the situation that nobody noticed the omission in practice.

I propose to fill this in by enabling the notation #7.32 to #7.255; this is similar to how the number behind the dot works in #6.
I have implemented this in the cddl tool in 0.10.7, in case you want to play with this (gem update cddl).

This whole thing is a bit weird: In #0..#5, the additional number always is an ai, and in #6 it is always the argument.  With #7, the difference does not matter for 0 to 23, *needs* to be ai for at least 25 to 27 (I’d make that 24 to 31), and is an argument for 32 to 255.

Luckily, we punched a hole into simple values from 24 to 31 in Section 3.3 of RFC 8949 (beyond 0..23, we say “(To minimize confusion, only the values 32 to 255 are used.)”), so this back-and-forth jumping actually works.

It *is* weird, but then the whole #N construct is a bit weird (and the exception we already have for #6 already is not much less bad than the new one would be for #7); the whole thing is normally hidden in the prelude except for registered values (tag numbers and simple values), which would now look the same for #6 and #7.

In draft-ietf-cbor-update-8610-grammar, we don’t need to change the ABNF grammar, just to add a sentence that explains the way the number is interpreted for #7.

Unless we want to allow something like

simple-packed-reference-value = 0..15
simple-packed-reference = #7.<simple-packed-reference>

like we now do for #6 (“non-literal tag numbers”); then we need to add something like

      / "#” "7" ["." simple-number]

to type2 and add

simple-number = uint / ("<" type ">")

(or merge this rule with tag-number, which looks the same).

Do we want to allow #7.<type>?

Grüße, Carsten