Re: [Cbor] Serialization choices vs. CDDL (Re: CDDL optionality and choices and optionality in CBOR and CDDL)

Rohan Mahy <rohan.mahy@gmail.com> Sat, 13 April 2024 06:42 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 C0359C14F73F for <cbor@ietfa.amsl.com>; Fri, 12 Apr 2024 23:42:35 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.094
X-Spam-Level:
X-Spam-Status: No, score=-7.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_DNSWL_HI=-5, 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 fOWys2tC8K94 for <cbor@ietfa.amsl.com>; Fri, 12 Apr 2024 23:42:31 -0700 (PDT)
Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (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 87D2EC14F68B for <cbor@ietf.org>; Fri, 12 Apr 2024 23:42:31 -0700 (PDT)
Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a51aac16b6eso80342166b.1 for <cbor@ietf.org>; Fri, 12 Apr 2024 23:42:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712990549; x=1713595349; darn=ietf.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=U44qUZ9BMXk57FqNtoZqxXi0JVy1AE6o1+0DP6athRc=; b=Gh4RUOAR1smMBBJzhNUQG0C2QdV3OQTS4Yn4vAIfScnWJa2HnmDMrVvQUfJOIheevt nmktXYc323DicrLpfK56Yjg3Nj5oZ/3l1Su+MML41vIAwCtsTt5JEO7HevmWSULC+qnv kFkA5GGcJ+OY1mPhWMqxp8s8Evq21i9SWVCYc6fcR/7kusSZ8FgpAGzc7TiMye+HarQh 0QolX5jkiwp7BX1UXlfRfVQD8R/kHFS8T5gKgP6HYYoxY9urgXNHUmq0l6hEHsgTuazv Ln6A9LGMSJ2DuVqtn1MWoS2LRPiJ3xyb/f1omymdQ8hiFCPTsf4Ky3UUCZN5ptFxrALA L3Wg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712990549; x=1713595349; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U44qUZ9BMXk57FqNtoZqxXi0JVy1AE6o1+0DP6athRc=; b=qNBZ/F1HNbuk4Mvu1YQ0wuy0ejRLO9zaE8wNr4rJw1uf6Jd8FG7KqNbNkDY5eSWD0V zr00ias3q3DEP4DYnED4ak17kXTE6V3MZuY3ZOTlI7uNrTFjpbMnDArVEUca/uvbeX4L PrfWPq18ODp2rXFlyknrq0MPn7L8n0HA35roxMxZDcELtN/hjIrrItQ/dmre7f8MJ8ef E8eEGcYYGt/yt69vuKWGrfolmlZ0PyqR9Uz0FtAriM5uxhdw6x9Q1ojY+nt3VHVQJval rb5pn0RswtjVbvAxV1mzU3eN8YzzdVdFtzXC9BGdjepsncth1uuzVjKC/Q/epS/tYqtk 0/eg==
X-Gm-Message-State: AOJu0YwQUffJkTi7Kk+YjjLtwFj4p5SQS33ECe6on/E5t6y3ztipkoct Tq37LjCTljC7WTSxYJJa5IrpuSse4H2s1NzUlHwdAR0ICXlCHHt2h3IeVKBACskrOGfrqtWjUD8 p6g1piGsjdhWVQQaUmMDuz8rUIvL7gg==
X-Google-Smtp-Source: AGHT+IHM6mwwVQaSHD7yKPaW4uwT8+FD1BQRbHkpDUHde/gi5J71cY2JQr9SGh6pVCQvnGB7UjbLIOCU1gYmQJ+Caww=
X-Received: by 2002:a50:9989:0:b0:56e:a76:b79a with SMTP id m9-20020a509989000000b0056e0a76b79amr4196384edb.7.1712990548707; Fri, 12 Apr 2024 23:42:28 -0700 (PDT)
MIME-Version: 1.0
References: <CAKoiRubb4GMm1sTq_1XRZt3+-hy+Z8ZXD21DpK5voneXFRcW6A@mail.gmail.com> <AFF12C56-CB02-43C8-9EFA-5656CAEF9E9A@tzi.org>
In-Reply-To: <AFF12C56-CB02-43C8-9EFA-5656CAEF9E9A@tzi.org>
From: Rohan Mahy <rohan.mahy@gmail.com>
Date: Fri, 12 Apr 2024 23:42:17 -0700
Message-ID: <CAKoiRubmXLAYx9HvXF2P2SPKEudobSMoBHFDZURSgZ49bAym8g@mail.gmail.com>
To: Carsten Bormann <cabo@tzi.org>
Cc: cbor@ietf.org
Content-Type: multipart/alternative; boundary="00000000000028d4df0615f4b194"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/v2WpIci3kHxpWCE9joCiEkoB9Iw>
Subject: Re: [Cbor] Serialization choices vs. CDDL (Re: CDDL optionality and choices and optionality in CBOR and 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 06:42:35 -0000

Hi Carsten,

Asking for more clarification inline please.

On Fri, Apr 12, 2024, 22:55 Carsten Bormann <cabo@tzi.org> wrote:

> On 13. Apr 2024, at 02:49, Rohan Mahy <rohan.mahy@gmail.com> wrote:
> >
> > I interpret the CDDL spec to mean that the encoding of the first item in
> the array is either F6 (null);  or 58 20 followed by 32 octets. Did I
> interpret the CDDL spec correctly?
>
> CDDL operates on the data model level, not on the representation format
> level.
>

sure. but if a tool is using a CDDL model to validate a CBOR instance
document, does the CDDL model below mean "an array of two items, the first
of which is either a null or a bstr, the second of which is a tstr"?

foo = [
  item1 = null / bstr,
  item2 = tstr
]

If so, it should validate an instance document whose first array item is a
null, yes?

The .size control operator on an integer is a convenient way to limit the
> range of an integer based on what the maximum value for the minimum
> encoding size for that integer is, not the actual size in the
> representation format.
>

It sounds like you are saying that I can't apply the .size operator to a
byte string? (I was not asking about setting the size of an integer). I
want a 32 octet byte string, not a 4 octet uint32.

Thanks,
-rohan


The latter is usually set by the encoder according to the rules for
> preferred serialization (Section 4.1 of RFC 8949 [1]), but it is allowed to
> choose other serialization variants (unless it actually intends to provide
> deterministic encoding, Section 4.2 of RFC 8949 [2] and draft-ietf-cbor-cde
> [3]).
>
> I understand that you are looking at providing a fixed size header for a
> data format.
> You may want to look at the fixed-size representations we have in the
> tagged array specification [4], where most of the tags defined give an
> interpretation to byte strings (here: as an array of numbers).
>
> Grüße, Carsten
>
> [1]:
> https://www.rfc-editor.org/rfc/rfc8949.html#name-preferred-serialization
> [2]:
> https://www.rfc-editor.org/rfc/rfc8949.html#name-deterministically-encoded-c
> [3]: https://www.ietf.org/archive/id/draft-ietf-cbor-cde-02.html
> [4]: https://www.rfc-editor.org/rfc/rfc8746.html