Re: [Cbor] correctness of implied top level array?

Joe Hildebrand <jhildebrand@mozilla.com> Wed, 27 February 2019 16:30 UTC

Return-Path: <jhildebrand@mozilla.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 59DA0130FF0 for <cbor@ietfa.amsl.com>; Wed, 27 Feb 2019 08:30:51 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Level:
X-Spam-Status: No, score=-2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=mozilla.com
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 fX1MyK35F8uo for <cbor@ietfa.amsl.com>; Wed, 27 Feb 2019 08:30:44 -0800 (PST)
Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id ECDD0130FFF for <cbor@ietf.org>; Wed, 27 Feb 2019 08:30:43 -0800 (PST)
Received: by mail-ed1-x533.google.com with SMTP id j89so14393250edb.9 for <cbor@ietf.org>; Wed, 27 Feb 2019 08:30:43 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mozilla.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=PUcb7/QYCEzT9/W2B8xafG35/X/uD01tJka4OEJMxQU=; b=MY57BdVVlmuRm9Ut25CxQ6kDrk5jEM7Lj/BeNxSziRPn8tU1gyLTTAPZe9b7L10OS5 /7Opv6tQZf3D2+tPiD++yHoSjXpLbU94fnR1Cr81ztNLsDsmmhFXO4guMpIPSyQOgeTU 8C/AoiXLDeJrxsZb1femIc/YdAcNdeeqP4Jho=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=PUcb7/QYCEzT9/W2B8xafG35/X/uD01tJka4OEJMxQU=; b=pmfsT/COAccUeOMmoeYAAbujYtxXzhDp1opmqP4fjHYKFsW+NFmZlrQ6etqsfoW6SF G6v6QmsMnSyAZIBImA1x8XGU00i2jeW3oF1l4bGNbbv+n1qVaSAM3tPu1JHcII1nYCf0 uAjlz9luOer6wqAPKlsgMO5yas3X6cZRGT2SyQ/msZuJjARRDeBXwqLZmSEwCOWAjea3 4J6VuND1kNjqszDm/rw8c3ITsrMd5b7sh+qkPRo6w8VydlG4ixfj4jet8Ux+WkU0oyd2 KvFn7c1pAVvxGWW7npxem37lC+s3dJJSoDu3318qq/083T3zWY3y73Ph9Rjg1O5oYUFe mR5w==
X-Gm-Message-State: AHQUAubjnsBjcT8ql9iMoCGlLlLXwUfrkiSZklFCNmlXPP4R/wVVotti 72WSpmR2EXsR9e1W5PEdPaoodQ==
X-Google-Smtp-Source: AHgI3IaGz+YvmxOUc34XVqdD24lGFPixDHoH4JvQfVTGvZGe7Blffcfj6KSx7p/A2aNDpj8aGY5fqQ==
X-Received: by 2002:a50:cac8:: with SMTP id f8mr3062315edi.212.1551285042165; Wed, 27 Feb 2019 08:30:42 -0800 (PST)
Received: from [10.6.18.59] ([207.126.127.114]) by smtp.gmail.com with ESMTPSA id a14sm2738736ejn.24.2019.02.27.08.30.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 08:30:41 -0800 (PST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\))
From: Joe Hildebrand <jhildebrand@mozilla.com>
In-Reply-To: <F0A06813-3F1F-4D53-80A1-4CBBBB91DC64@island-resort.com>
Date: Wed, 27 Feb 2019 09:30:38 -0700
Cc: Carsten Bormann <cabo@tzi.org>, cbor@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <0A96C82A-85DB-411D-812D-5A3479A8EA87@mozilla.com>
References: <81789050-5133-48B0-BEE7-4F1E0BBB4C06@island-resort.com> <40A3B694-80A4-4AD7-A2A6-C071C6E88D2D@tzi.org> <F0A06813-3F1F-4D53-80A1-4CBBBB91DC64@island-resort.com>
To: Laurence Lundblade <lgl@island-resort.com>
X-Mailer: Apple Mail (2.3445.102.3)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/185XNvXZDvDkqePBbiLN9DBFKuA>
Subject: Re: [Cbor] correctness of implied top level array?
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: Wed, 27 Feb 2019 16:30:51 -0000

I've always assumed that I would eventually write an XMPP-like protocol that used a stream of CBOR items without further delineation, and node-cbor reflects that, perhaps to the detriment of other use cases.  I *think* you could trick it into reading one CBOR item from a stream and stopping with the rest of the bytes still intact, but I'd have to write a few tests to be sure.

However, in my opinion both of the above cases are instances of protocols built on top of CBOR, not inherent in the CBOR design itself.

— 
Joe Hildebrand



> On Feb 26, 2019, at 9:11 PM, Laurence Lundblade <lgl@island-resort.com> wrote:
> 
> Hi Carsten,
> 
> So wouldn’t that mean application/cbor is required to consist of one and only one data item with no extra data? And maybe we need a section that says when you design a CBOR protocol you should be clear whether it carries a CBOR sequence or a CBOR data item. Maybe say the preferred encoding the CBOR data item because to be similar to JSON where you can’t have loose name/value pairs?
> 
> LL
> 
>> On Feb 24, 2019, at 4:36 AM, Carsten Bormann <cabo@tzi.org> wrote:
>> 
>> Hi Laurence,
>> 
>> the construction you describe is different from a CBOR data item:
>> It is a CBOR Sequence.  You piqued me to finally write it up, see below.
>> 
>> More generally speaking, an encoded CBOR data item followed by residual data is a very valid construction, for instance for a piece of metadata tacked on as a header to a binary blob.  CBOR’s self-delimiting is all you need here.
>> The metadata part doesn’t stop to be well-formed by being followed by that binary blob.
>> But of course the whole thing *is* not, but still *has* a well-formed encoded CBOR data item.
>> 
>> Unfortunately, not very many CBOR libraries have an API that allows isolating that metadata header from its residual data.  Maybe it’s worth writing a draft about suggested API functionality as well.  (One other thing that recently came up and is supported by too few CBOR library APIs is using an already encoded CBOR data item during encoding an array, map, or Tag.)
>> 
>> Grüße, Carsten
>> 
>> 
>> Name:		draft-bormann-cbor-sequence
>> Revision:	00
>> Title:		Concise Binary Object Representation (CBOR) Sequences
>> Document date:	2019-02-24
>> Group:		Individual Submission
>> Pages:		8
>> URL:            https://www.ietf.org/internet-drafts/draft-bormann-cbor-sequence-00.txt
>> Status:         https://datatracker.ietf.org/doc/draft-bormann-cbor-sequence/
>> Htmlized:       https://tools.ietf.org/html/draft-bormann-cbor-sequence-00
>> Htmlized:       https://datatracker.ietf.org/doc/html/draft-bormann-cbor-sequence
>> 
>> 
>> Abstract:
>> This document describes the Concise Binary Object Representation
>> (CBOR) Sequence format and associated media type "application/cbor-
>> seq".  A CBOR Sequence consists of any number of encoded CBOR data
>> items, simply concatenated in sequence.
>> 
>> Structured syntax suffixes for media types allow other media types to
>> build on them and make it explicit that they are built on an existing
>> media type as their foundation.  This specification defines and
>> registers "+cbor-seq" as a structured syntax suffix for CBOR
>> Sequences.
>> 
>> 
> 
> _______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor