[Cbor] extensible enumerations, ignoring unknown values in CDDL

Rohan Mahy <rohan.mahy@gmail.com> Sat, 13 April 2024 21:45 UTC

Return-Path: <rohan.mahy@gmail.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 6EC38C14F5F1 for <cbor@ietfa.amsl.com>; Sat, 13 Apr 2024 14:45:36 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.094
X-Spam-Level:
X-Spam-Status: No, score=-2.094 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bqjlsnOeMjUA for <cbor@ietfa.amsl.com>; Sat, 13 Apr 2024 14:45:32 -0700 (PDT)
Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 9B420C14F5EC for <cbor@ietf.org>; Sat, 13 Apr 2024 14:45:32 -0700 (PDT)
Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2d4886a1cb4so21948841fa.0 for <cbor@ietf.org>; Sat, 13 Apr 2024 14:45:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713044730; x=1713649530; darn=ietf.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=sJ341uMFpG6JohTXsJuFzNEtB3hlw1Awr6UmIIr8I1o=; b=ad6cvpwQmpR5eQPozqgUgnaJzvtgSaRHHth4pcXtYFAw+Q0sFNLUq3SuyAWN5Dyw24 06SBjMjRS2LGtID7JWLXGfqmbiX06MW0OiSSe9oVEpyjd88AWRmwwsCVyUX/P8VZ4WUR xpm5gZtzcT9tOfBYu/tKjD46iH2nGNCiEPajNUPpa3AL/oyU1WOVjxgSUdtLXmZWrM8b ouA1+X/VDjhcODbaX06AdtVm60hqIYiFuhyAljvNrKYkCzCiNg/zsJ/HCB4b71yM0lUU bgG+vn+cNyfgddPXP5TCwgmShKOHCsFB6qv4uph8S87AHR35dmzs7rNUt1JYdVkf4bq4 16uw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713044730; x=1713649530; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=sJ341uMFpG6JohTXsJuFzNEtB3hlw1Awr6UmIIr8I1o=; b=tpoo0wY3HaBawN0Ef4S7UJRcXaz+vVxlGx0LLxJOZrh1LaICDZOWpIQT1oRZ2PWQBl FGqnng8d8Nv+Yj/9C1kq60Kp9j6r/F+6g+WmnUnHXnTq7z5+ygUngvBUVJLR4dxgA/a6 ekv+4QdHRFDuqCB77Ds6fe5rqPIrFNOFX12so65dV6ZZUC9Epwy8cahcJMJtgonKqDL6 Coo+zk+2fULzBydbFFn54z3eZ7szuzMDAafbToziBoufY+MAjC34IICgYFkMGi56IOJj Uv2iNkvdDqsf8vKk9O4WUdfABWwvPjtM/G8dFEPtnKHS6FEBqpXPj21n01MQbiCBBwcN ESiA==
X-Gm-Message-State: AOJu0YzoyrwwwajzOsF6t1V632s60uLl8qOeL0xNTZF3GZhMVeSMmjwh 1k02bUQTYbS/knY2ArmriBAA5i1RJwDskehooOSb/tZT9c97uz6GSpJVITCAAu4zE6Ijo8efYsM a9guxwjXoST+rOSP6DF51uwhVUn2MrMyu
X-Google-Smtp-Source: AGHT+IF/xUrbK2ZXsuJvTfLn7MQNyEPodN/xH/PW9u+ofDwjyI7Bh+4OxTLIMuxPNXr94lHHCO6Jm/DxXBCSSn2cXGQ=
X-Received: by 2002:a05:651c:1502:b0:2d8:e978:e38d with SMTP id e2-20020a05651c150200b002d8e978e38dmr5226438ljf.10.1713044730185; Sat, 13 Apr 2024 14:45:30 -0700 (PDT)
MIME-Version: 1.0
From: Rohan Mahy <rohan.mahy@gmail.com>
Date: Sat, 13 Apr 2024 14:45:18 -0700
Message-ID: <CAKoiRua7YXqw4T2zOfoQG7LkaUZ6he1jTsniWC0EPFnunsSzkw@mail.gmail.com>
To: cbor@ietf.org
Content-Type: multipart/alternative; boundary="000000000000a099940616014eb5"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/gO3zhVllZNUfrZR76Sp7WI1F-1U>
Subject: [Cbor] extensible enumerations, ignoring unknown values in CDDL
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.39
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, 13 Apr 2024 21:45:36 -0000

Hi,

In the MIMI content draft [1], I used C structs as a placeholder for a
concrete syntax, which I am now converting into TLS Presentation Language
and CBOR.

One of the enums we are using, "Disposition" should have a valid range from
0 to 255, but only the values from 0 to 8 have known values. The intent is
that new values between 9 and 255 inclusive will be valid, and if unknown
they will be treated as if they had the default disposition (render).

enum Disposition {
    unspecified = 0,
    render = 1,
    reaction = 2,
    profile = 3,
    inline = 4,
    icon = 5,
    attachment = 6,
    session = 7,
    preview = 8
};

I am currently just expressing this inside as "disposition: uint .size 1",
but I'd like to be more expressive if possible.

If I only wanted to allow these predefined values but allow them to be
extended later I could use a choice now (Disposition = render / reaction /
etc.) and add to that later with "Disposition /= foo / bar", but I still
want to allow unknown values <= 255. It doesn't look like I could define
this, then later redefine unknown-dispo:
Disposition = render / .. / preview / unknown-dispo
unknown-dispo = 9..255

Does anyone have a good way to accomplish this in CDDL?

(I have read draft-bormann-cbor-e-ref and while adjacent didn't seem to
solve this problem).

Thanks,
-rohan

[1]
https://www.ietf.org/archive/id/draft-ietf-mimi-content-02.html#section-4.3