[Cbor] CDDL style questions

Jim Hague <jim@sinodun.com> Thu, 22 November 2018 14:23 UTC

Return-Path: <jim@sinodun.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 46E03130EFE for <cbor@ietfa.amsl.com>; Thu, 22 Nov 2018 06:23:55 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.3
X-Spam-Level:
X-Spam-Status: No, score=-4.3 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_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=sinodun.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 GhfIDor_adux for <cbor@ietfa.amsl.com>; Thu, 22 Nov 2018 06:23:49 -0800 (PST)
Received: from haggis.mythic-beasts.com (haggis.mythic-beasts.com [IPv6:2a00:1098:0:86:1000:0:2:1]) (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 1F42F130EE3 for <cbor@ietf.org>; Thu, 22 Nov 2018 06:23:49 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sinodun.com ; s=haggis-2018; h=Date:Subject:From:To; bh=57IkbCz4DIxaKyTK+3ELIm02LbRI9/F07Fq3o6jg5mc=; b=xBGCto5w03n1OFKDkbFnu4x5Hb ytCA2oDy0l3T8EgceDgkUimZZ96Syk4TZLYjzfzMyZQbv/TP3N4by0JXNJsF0OkJizOj9qHINvJEM GZ+FjyRjvmrFGsLEanOaSc7d+VoOMaYq0txEZIqPhSTHJE6RY8shqNs5YoqYGMLIJSXpKAZvg8ZyN uCzOrbXFzhfhNLdnLO0u97NWoSKNar8jaGvUayECQFB3y6r1DyJl84RmvO8toWc6N/LEGHirYuYIJ 9tQvA8AuFsnoSAdKq/xdQQK4lBh5KhGrsAOL4WZjUOtRK/jIyloWNeq0WwaKf/BooWSIpEYS+TWU0 UeCzaZ4Q==;
Received: from [2001:b98:204:102:fff1::11] (port=63445 helo=Jims-iMac.local) by haggis.mythic-beasts.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <jim@sinodun.com>) id 1gPptT-0005lI-Jj for cbor@ietf.org; Thu, 22 Nov 2018 14:23:47 +0000
To: "cbor@ietf.org" <cbor@ietf.org>
From: Jim Hague <jim@sinodun.com>
Openpgp: preference=signencrypt
Autocrypt: addr=jim@sinodun.com; prefer-encrypt=mutual; keydata= xsFNBFjma08BEADHz5x1FKpV7GGMzaXlnC88O+f9iJjkajqdk8YJFS9GBB4X0RnJvew5Ek/Q yTbalhhg8lkMcDkJlW6/l+XPuwTeChLdF83c8yUW49gJ1xN2YP0pew38JzXUpeHC/JLY1FYb canohDqWojY/chE4tscGKehmmHRkneTdtZgreCNMi4cpqu4PsWiJkbBLwRlTTtq0eIUBLCcF 3/Q8Um3SXuKcXhO9XVSNIP/wHUKkZcIBJ2ZWIQYHefuos56BAZOuaV5lPkgaAcb/o72hyU+l yKF87J/srK0PIXK9WcyOYW77N8XDjr9z9W9YIPVrYfX/9DuwibJd9KfdN36T7MbYZW4sensn FsJ9SRhv7cCAcpYCLQtzVYaJ8d8OY4UJSpV3uXH/TZ0lmIH2h0M9m+5LxjyFkoeR1Dbb+OO5 P7X+lx+7kNz34fbwFoXgSWqCPOtJLHR4qejUG3oXGgfi4rBC2336Fv26og27j7TVwRlLeYF1 79/drAcsNS2SiH4v2/Frf44nKh0f6GlufcZVJSnXviMzubD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TFWklIgOWIiDrq8taSS5VXiOzxWmG0/CK XUXRviyrZ7ATwI+CqJvnbKVat1Tzu2AjtsY/jtCOpDsfwNrESQllrh4LIclNi5EojBC+h5H9 6bByZCh2/UszlhlEewHglNXSAXElQJRmC/R8ON0uHU30ZcWTzS1ohTTz1Rzo2Y27A54OxXRM IjMZr6g+IfF9Ya5kMWMIK/+c7y0Q2YWmpCO0cAWQjYN0TPWSQ0H08pfNFG9P
Organization: Sinodun Internet Technologies Ltd.
Message-ID: <5073d637-0608-7503-b323-2e37a644b445@sinodun.com>
Date: Thu, 22 Nov 2018 14:23:41 +0000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Language: en-GB
Content-Transfer-Encoding: 8bit
X-BlackCat-Spam-Score: 0
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/xuXqZIqjq4p_Sf7d1uWKRo5I8us>
Subject: [Cbor] CDDL style questions
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: Thu, 22 Nov 2018 14:23:55 -0000

A couple of CDDL style questions arising from the progress of our C-DNS
draft, which includes a CDDL spec. I'm not asking for any 'right'
answer, more curious to know whether there is such a thing as an
emerging consensus on CDDL style. Or just whether CDDL users out there
Have Opinions.

o Specifying fields with constant values. Should field types be explicit
or implicit?

FileHeader = {
    "identifier1" => "A string",
    "identifier2" => tstr .eq "Another string",
    "value1" => 1,
    "value2" => uint .eq 2,
}

I'm torn on this at the moment. Assuming the implementer of the format
is not a CDDL/CBOR sophisticate, including explicit types may be
valuable. But implicit is pleasingly succinct.

o Use of .size and ranges to restrict contents of fields.

The C-DNS file format obviously includes a lot of IP and DNS specific
quantities. In the main, I have not attempted to specify value
ranges/storage sizes for these - apart from anything else, I started on
this before the necessary facilities were added to CDDL:

    ? server-port           => uint,
    ? query-opcode          => uint,
    ? query-rcode           => uint,

The exception is for IP addresses where we take our lead from the CDDL
draft:

    IPv4Address = bstr .size 4
    IPv6Address = bstr .size 16
    IPAddress = IPv4Address / IPv6Address

I think my motivation here is to try minimise 'magic numbers' and define
a type rather than have 'bstr .size 16' all over the place.

It's been suggested, though, that we could:

    Port = uint .size 2
    OpCode = 0..15
    RCode = 0..15
    ....
    ? server-port           => Port,
    ? query-opcode          => OpCode,
    ? query-rcode           => RCode,

My initial reaction was that this isn't a clear-cut win; it feels like
I'm duplicating IP/DNS protocol definitions which are specified
elsewhere. However, the more I look at it, the more I wonder if the
extra info is in fact valuable to an implementer.
-- 
Jim Hague - jim@sinodun.com          Never trust a computer you can't lift.