Re: [Cbor] [netmod] CBOR YANG encoding of union & bits [draft-ietf-core-yang-cbor-12]

Carsten Bormann <cabo@tzi.org> Fri, 08 May 2020 10:05 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 9793C3A0993 for <cbor@ietfa.amsl.com>; Fri, 8 May 2020 03:05:19 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, 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 DftH4sgcxDxF for <cbor@ietfa.amsl.com>; Fri, 8 May 2020 03:05:14 -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 DCF183A0985 for <cbor@ietf.org>; Fri, 8 May 2020 03:05:13 -0700 (PDT)
Received: from [172.16.42.112] (p548DCD70.dip0.t-ipconnect.de [84.141.205.112]) (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 49JQtb38Fqz161N; Fri, 8 May 2020 12:05:11 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <5dac70881c52c6fde0fc80c87363386e@mothers-arms.co.uk>
Date: Fri, 08 May 2020 12:05:10 +0200
Cc: cbor@ietf.org
X-Mao-Original-Outgoing-Id: 610625110.855669-663979bd12a37db540ad56744cb7b8d6
Content-Transfer-Encoding: quoted-printable
Message-Id: <CB09ED21-23E2-44A7-879F-D94DBCE9BDDE@tzi.org>
References: <BY5PR11MB4355C26250C9CF46713C9956B5A40@BY5PR11MB4355.namprd11.prod.outlook.com> <6ACF0CA3-59C4-4CE1-9344-81B43C75BAF4@tzi.org> <269a22c2b07ee953a09b48c535b28791@mothers-arms.co.uk> <853DC97D-91C7-4188-ADE1-AFC2431EFD3B@tzi.org> <5dac70881c52c6fde0fc80c87363386e@mothers-arms.co.uk>
To: Kio Smallwood <kio@mothers-arms.co.uk>
X-Mailer: Apple Mail (2.3608.80.23.2.2)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/jDgBmI27hTHpLk4h8ivCMiiKinM>
Subject: Re: [Cbor] [netmod] CBOR YANG encoding of union & bits [draft-ietf-core-yang-cbor-12]
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, 08 May 2020 10:05:20 -0000

On 2020-05-08, at 11:37, Kio Smallwood <kio@mothers-arms.co.uk> wrote:
> 
> - the next offset (must be strictly larger than the offset + length of previous data item)
> 
> - the next byte(s)
> 
> - etc.
> 
> e.g.
> 
> 2020([0, h'0107', 500000000, h'15'])
> 
> The following example should result in an error:
> 
> 2020([0, h'0107', 1, h'01'])
> 
> A case should be made that each offset+byte pair should have at least one set bit. So this would be a valid bitfield that's all zeros:
> 
> 2020([])

Looks good.  Even better: make sure that an overlap cannot even be encoded.
The numbers in the array could be the number of bytes not sent that are presumed all zero.

So your first example would become:

2020([0, h'0107', 499999998, h'15’])

Or, actually, since the first zero becomes redundant now, 

2020([h'0107', 499999998, h'15’])

So the contents of the array would be byte strings or numbers that indicate gaps by giving the number of zero bytes.

Numbers should probably be positive (non-zero), and we could forbid adjacent numbers or trailing numbers.  Or we could just make that the preferred encoding and still allow them (including zeros); I don’t have a strong opinion.  (I’m not motivated enough to think about c14n now…)

[ASN.1 has the ability to indicate that the last byte in a bit string isn’t completely part of the bit string.  A trailing negative number could indicate that.  But I still haven’t seen a true use case for ASN.1 bit strings since I thought about that in 2013…]

Grüße, Carsten