[Cbor] CDDL spec should specify how CBOR items match types

Jeffrey Yasskin <jyasskin@chromium.org> Thu, 06 July 2017 23:01 UTC

Return-Path: <jyasskin@google.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 804E112F17A for <cbor@ietfa.amsl.com>; Thu, 6 Jul 2017 16:01:32 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.001
X-Spam-Level:
X-Spam-Status: No, score=-2.001 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=google.com header.b=b6+t2HcF; dkim=pass (1024-bit key) header.d=chromium.org header.b=UX2tPdOl
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 VUZhi2MWytZb for <cbor@ietfa.amsl.com>; Thu, 6 Jul 2017 16:01:31 -0700 (PDT)
Received: from mail-wr0-x229.google.com (mail-wr0-x229.google.com [IPv6:2a00:1450:400c:c0c::229]) (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 C257E12EC34 for <cbor@ietf.org>; Thu, 6 Jul 2017 16:01:30 -0700 (PDT)
Received: by mail-wr0-x229.google.com with SMTP id r103so22950374wrb.0 for <cbor@ietf.org>; Thu, 06 Jul 2017 16:01:30 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=q+KjCMZrTzz8REx2zaFd0hkyHnNj14ew8cKjSX4JNhg=; b=b6+t2HcFUu+dYO48LIVhhUEWm5L3KdKoFHxF5pXQwCJ9Q6qsKAGzUHa3x12R7+fqL3 UsC37PJYvq8ZLRS7m7zX3X9jPbJ9yr8J3nUb2e9G1r4c/IzRQlmkrp7xN8XMH+gJy4+e w3xbRCLrSXgMPQuv9T8F2m/6SYnk/988JSpvySPsgoA35Mm0aPtyJjmAG0ErQ+73rap2 +QvxKHcXst9rRg3EUOga3MHxqBcaY/l7AkuM2oKkiJPSkgQmGlq61gOwWOOA/cNjBOT5 DDKfvZDkVY5Ac68ppOo1JXWiYwJytoQc/Xm+C5GwWTMI6N0vrNK50dOIcx4K35vHkg9G 6OCg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:from:date:message-id:subject:to; bh=q+KjCMZrTzz8REx2zaFd0hkyHnNj14ew8cKjSX4JNhg=; b=UX2tPdOlPScroxrUcJDd+0pkoUFPffZTDRs6W+dakJYbEo9WuRpdk2WGOQqd8JlHCv dWdxX7xkxpvOvxbszaDSoFlp5LspSogGueIdQZfBL0vtqKweMuOK+VcUqj8zZPEQ+vmI zscohlktztiPuFtzu/LJxi11jby1qu34j3R98=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=q+KjCMZrTzz8REx2zaFd0hkyHnNj14ew8cKjSX4JNhg=; b=qLkAjhBPPALxxF5PEAAva/ih6ZCrSOrjLKcJeTVbCM7GRaaqDrzdu8Z5yU7bJbnWn5 kl+jtJdRGIFakPZ/pixBuTwCfcc6OUzEu/NNNoOyJUpsEj59l+7fGHgHjn4/LtvsjNub YI16JT0uLkOMAzrpLwcbCkBFDQKyF1aju9DV8GyVDZzy4+2REaTajDvWsd99AbbumADN HOXnQv8RG+HApseiqeApHU+5SrO9C4S68cH4PcFdlRaq1GMkB/iRap1nnqrjQrB/NfEr KUC3vD9SrbUJAzWwfLp/Fo0Ji/wO8Cr5b00Rp7ILTGFC9SsySdXRS2DO0ypRvvKpGpgG wdbQ==
X-Gm-Message-State: AKS2vOxCYCS4fPluZDXHgixONYZc9ugdcs/id3+jIud6clFboWlf48mJ srenvs1Oxksd/SUh/+dLfxBWrqZNsP9A/MY=
X-Received: by 10.223.171.3 with SMTP id q3mr41584489wrc.12.1499382087815; Thu, 06 Jul 2017 16:01:27 -0700 (PDT)
MIME-Version: 1.0
Sender: jyasskin@google.com
Received: by 10.28.97.6 with HTTP; Thu, 6 Jul 2017 16:01:06 -0700 (PDT)
From: Jeffrey Yasskin <jyasskin@chromium.org>
Date: Thu, 06 Jul 2017 16:01:06 -0700
X-Google-Sender-Auth: ZQ0GzNRqyssKz_JcynsC6eb_dPk
Message-ID: <CANh-dXm=Ks-iSHnwz=hZ8_7qshQxmynLQ7jFwcrbs+vP=cHZuQ@mail.gmail.com>
To: cbor@ietf.org
Content-Type: text/plain; charset="UTF-8"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/ANfdjpI8wQh-dKvobkkUgEdtsjE>
Subject: [Cbor] CDDL spec should specify how CBOR items match types
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.22
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, 06 Jul 2017 23:01:32 -0000

Apologies if I'm just reading
https://tools.ietf.org/html/draft-greevenbosch-appsawg-cbor-cddl-11
badly, but I don't see a specification of which CBOR items match which
types.

Sections like https://tools.ietf.org/html/draft-greevenbosch-appsawg-cbor-cddl-11#section-3.4
(Arrays) specify how to write an array type, but I don't see a
normative statement that '82 01 02' is an instance of [*uint] or that
'01' and '42 01 02' aren't.

I also don't see a definition of '#' in order to ground the meaning of
the prelude. "How this is used should be evident from the prelude
(Appendix E)." from 2.2.3. Representation Types isn't really
sufficient to specify it.

I think this lack of specification is at the root of Kevin Braun's set
of bugs in https://mailarchive.ietf.org/arch/msg/cbor/Z1XcZSTLbTDnqA9HP8UXjeUOspE.

I'd be inclined to fix this by specifying each CDDL type as a
recursive parser, which accepts or rejects either CBOR items or byte
strings. I think the choice of item vs bytes comes down to where we
want to put the serialization constraints (like
"indefinite-containers") described in
https://mailarchive.ietf.org/arch/msg/cbor/Pv191TJRBiG1QOJbJL8iVHjUDuE,
but it could also have some implications for how parsers return data
from unfinished byte streams.

Jeffrey