Re: [Cbor] [COSE] CBOR magic number, file format and tags

Laurence Lundblade <lgl@island-resort.com> Sat, 23 January 2021 20:36 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 DC0913A0D9D for <cbor@ietfa.amsl.com>; Sat, 23 Jan 2021 12:36:15 -0800 (PST)
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, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=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 88MCZ_D3Gzvk for <cbor@ietfa.amsl.com>; Sat, 23 Jan 2021 12:36:11 -0800 (PST)
Received: from p3plsmtpa11-02.prod.phx3.secureserver.net (p3plsmtpa11-02.prod.phx3.secureserver.net [68.178.252.103]) (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 A017D3A0CC1 for <cbor@ietf.org>; Sat, 23 Jan 2021 12:36:11 -0800 (PST)
Received: from [192.168.1.81] ([76.167.193.86]) by :SMTPAUTH: with ESMTPA id 3PdilVYVxadtz3Pdjl4NSU; Sat, 23 Jan 2021 13:36:11 -0700
X-CMAE-Analysis: v=2.4 cv=He3R8gI8 c=1 sm=1 tr=0 ts=600c88bb a=t2DvPg6iSvRzsOFYbaV4uQ==:117 a=t2DvPg6iSvRzsOFYbaV4uQ==:17 a=gKmFwSsBAAAA:8 a=wh29FQHvAAAA:8 a=48vgC7mUAAAA:8 a=2mlRVy4LF0kdu59ZuA8A:9 a=ejogz6UW6PrXvIFk:21 a=DrZspXItkYScIyNf:21 a=QEXdDO2ut3YA:10 a=M0GNvqWmc-bWtbJt:21 a=TLt5vWk0PBTPL1Yn:21 a=VO86ReMV8Kmn-hOJ:21 a=_W_S_7VecoQA:10 a=nnPW6aIcBuj1ljLj_o6Q:22 a=VXYcH7iyBJRhg1WiYCsm:22 a=w1C3t2QeGrPiZgrLijVG:22
X-SECURESERVER-ACCT: lgl@island-resort.com
From: Laurence Lundblade <lgl@island-resort.com>
Message-Id: <0C79FC37-0720-4C5F-B52D-C46ADD0EFB37@island-resort.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_BC78565B-2B25-4295-839C-9D7D84B8ABDC"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\))
Date: Sat, 23 Jan 2021 12:36:10 -0800
In-Reply-To: <3DD6CB17-103F-48BF-A4EF-B2AEF1573C93@tzi.org>
Cc: "Dale R. Worley" <worley@ariadne.com>, cbor@ietf.org, Michael Richardson <mcr@sandelman.ca>, doug@ewellic.org
To: Carsten Bormann <cabo@tzi.org>
References: <87wnw49wez.fsf@hobgoblin.ariadne.com> <3DD6CB17-103F-48BF-A4EF-B2AEF1573C93@tzi.org>
X-Mailer: Apple Mail (2.3445.104.17)
X-CMAE-Envelope: MS4xfHbgXLg/pK8xQWlw5/LoCw8UG2j725OvTiPfuZURVkkV1Tfs+1rBICm47tq+XKiiK/u9M+cqqESjE2+KQiW9tsue5/BRxlyShwF+927GbTZKE0NL4Dj0 vakfbTMMuKi+4QxzfQja1dm63cEWPYgoRbMnf1UFOYfQKaNvr2lHdWQG2nSVVfmogXnEcsAeY+ok9nSkdqL0YklQ62nRmHAzKLctrG6rzY59bhxh+XrLwUaU p1yL+dfcxP8PLW9U6IDbHczrd+LeDeVXPl40kd++83Wt1KjpsDI5t0q05nBPcNay
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/n5iF-HhK7VsvnnyxU1KYLxv31kY>
Subject: Re: [Cbor] [COSE] CBOR magic number, file format 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: Sat, 23 Jan 2021 20:36:16 -0000

My choice would be to parallel what is done for COSE, CWT and most other CBOR protocols I’ve seen:

1) Make the compressed CBOR certs an array instead of a sequence for all use. This makes it one byte bigger, but it makes it work just like the other CBOR protocols that have been defined. I see the use of CBOR sequence here as an outlier, somewhat confusing and burdensome. It is burdensome because you can’t just drop them into other CBOR protocols and because a tag for it has to be special. As far as I can tell the only reason this is a sequence and not an an array is to save the one byte. 

2) Assign a tag that indicates compressed CBOR cert and use it just like the tags for COSE and CWT or any other protocol with an identifying tag. Or said another way, most CBOR protocols have an identifying tag. Compressed CBOR certs should have one too.

3) When you put it in a file, use the 55799 magic number to indicate it is CBOR and then the compressed CBOR cert tag to indicate it is a compressed CBOR cert. If the tag number was 48 then the first bytes of the file would be:

d9 d9 f7 d8 30 8b … 

You could take d9 d9 f7 d8 30 to be the magic number for a compressed CBOR cert. The 8b is to open the array for step 1) above. When you want to put the compressed CBOR cert into a protocol message field that needs no tagging you can just exclude those five bytes. When you take it out of a protocol message and put it in a file, you add those five bytes.

This mechanism would work for CWTs and COSEs in files too.  Similarly a COSE_Sign1 CWT in a file would be:

d9 d9 f7 d8 3d d2 84

This is three nested tags 55799(61(18(…))), a COSE_Sign1 in a CWT in a 55799. You can treat d9 d9 f7 d8 3d d2 the magic number.

Or take d9 d9 f7, the 55799 tag, to be the magic number indicating CBOR causing a general CBOR dispatcher to be started. That dispatcher looks for a second tag. Based on a second tag it dispatched to the handler for the compressed cert, the CWT, the COSE, the CoSWID, the UCCS...

LL


> On Jan 23, 2021, at 5:07 AM, Carsten Bormann <cabo@tzi.org> wrote:
> 
> 
> 
>> On 2021-01-23, at 04:14, Dale R. Worley <worley@ariadne.com> wrote:
>> 
>> Here's an alternative.  It is aligned with the magic number tag of CBOR
>> itself (55799) and the CBOR way of doing things.  Specifically, reserve
>> a large range of tags (such as 55800 to 65000, or 100000 to 109999) for
>> use as magic numbers; the CBOR object has the appropriate magic number
>> tag applied to that, and optionally, the CBOR magic number tag 55799
>> applied to that.  That can leave the generic CBOR magic number visible
>> at the start of the file, immediately followed by the bytes of the
>> specific magic number for the object type.
> 
> Right.  Something like this would probably make sense as an alternative to the primary approach proposed, which is based on CBOR sequences.  If you want to keep the magic-numbered file a single data item, this is the way to go.
> 
> Two issues:
> 
> — This should probably be a 1+4-byte tag.  The range you mention leads to a zero byte in the magic number.  Not sure if that is a bug or a feature.  (It is also way too small.)
> 
> — As I mentioned before, we don’t have a good way to assign a purpose to a range and then let IANA do the allocation within the range.
> 
> Grüße, Carsten
> 
> _______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor