Re: [Cbor] Chunks with tags inside indefinite-length string (major type 2 and 3)

Jeffrey Yasskin <jyasskin@chromium.org> Thu, 05 December 2019 19:18 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 132D2120090 for <cbor@ietfa.amsl.com>; Thu, 5 Dec 2019 11:18:32 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -9.25
X-Spam-Level:
X-Spam-Status: No, score=-9.25 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5] autolearn=no autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org
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 WCaDg5Bi-5Eu for <cbor@ietfa.amsl.com>; Thu, 5 Dec 2019 11:18:30 -0800 (PST)
Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) (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 87C7E12006B for <cbor@ietf.org>; Thu, 5 Dec 2019 11:18:30 -0800 (PST)
Received: by mail-qk1-x72e.google.com with SMTP id d202so4354738qkb.1 for <cbor@ietf.org>; Thu, 05 Dec 2019 11:18:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1RoRorZZcjb+NbXjiQk+pyRUxs4o3h3lxUrZf+ooTo8=; b=cC5rF/qLkPUzRMT/ldTOfP/MscJSPgTWH5kK9d7b98LdTYqhNLD5MuFN4DU8uIgQXJ 2W8digUbQ5y1/q4c6J0kqkSMmDIFqZ24VajiqxgjcqGb97Aj//xCwyV+AXWIfC8gozUq 1ZGjgs0cI1FHuG/k9A+AuvCSAR8zEebP9y5ZA=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1RoRorZZcjb+NbXjiQk+pyRUxs4o3h3lxUrZf+ooTo8=; b=YXVhTbNxSf4KIHt1g2wzzY7rOhLukwTKHACD9jqoxeMY1S+MBoOlHhCpz9cI2TNiKV bPACY4PPyKvpnbvLhN3KNDMV0UFBZGQ0SEj0QYmHRU5hT9+JrJJrvb3HHItSOlvUhfHM 01ncNZBEgPI2T2G7FcsGG1/0DNL97qFs1NLA716YaeA+gloKmEhljpO8qOVYr6GPWoxj HL6zQ0qrO+R7YtYNTvGQZHQVnEwO1LNzG+tcrnuxXGjI9R8n8DPomf1P0CW/b965VefF npKcGQBMGhqhmhegmrHj660UQT2h/O+5fGdNNJjvOi5PliLJdYPby2I9uMhbwKQUJ8QX KR2Q==
X-Gm-Message-State: APjAAAWM24EMvGujf8j3RlS+05hHIyQLIkcr7BDtUYO25/JDC78Kgaam aWZLu+vwLwgebali3wZ9IXYZqTtuVzVa6RUNuVup9Q==
X-Google-Smtp-Source: APXvYqy/PYYyC8DdDto73RpXdC4SPgpA4j2RYebww2M3GSIc8krpAJn90ItQYg+5rNgqp/KLQz9aawN0xjOkOtMTWic=
X-Received: by 2002:ae9:c318:: with SMTP id n24mr10368032qkg.38.1575573508938; Thu, 05 Dec 2019 11:18:28 -0800 (PST)
MIME-Version: 1.0
References: <CA+qCGhv_d=uJxnPrnbRO_iN9nVhwPf0Qa8EvtqqXZS6pMaCyBw@mail.gmail.com>
In-Reply-To: <CA+qCGhv_d=uJxnPrnbRO_iN9nVhwPf0Qa8EvtqqXZS6pMaCyBw@mail.gmail.com>
From: Jeffrey Yasskin <jyasskin@chromium.org>
Date: Thu, 05 Dec 2019 11:18:17 -0800
Message-ID: <CANh-dXnHnm2wxYPJfYJXmhHhOBJobnmFmwT5E=55PGcVv0ttPg@mail.gmail.com>
To: Faye Amacker <faye.github@gmail.com>
Cc: cbor@ietf.org
Content-Type: multipart/alternative; boundary="00000000000051da2b0598f9cbc0"
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/xCMlXGAuutsYYmpAnwxwwgf7wDg>
Subject: Re: [Cbor] Chunks with tags inside indefinite-length string (major type 2 and 3)
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, 05 Dec 2019 19:18:32 -0000

I *think*
https://cbor-wg.github.io/CBORbis/draft-ietf-cbor-7049bis.html#indefinite-length-byte-strings-and-text-strings
is
pretty clear that the contained things have to have the same major type as
the indefinite-length string, and tags have a different major type. e.g. "a
series of zero or more byte or text strings" doesn't include the
possibility of tags, and "If any item between the indefinite-length string
indicator (0b010_11111 or 0b011_11111) and the “break” stop code is not a
definite-length string item of the same major type, the string is not
well-formed." says any other content is not well-formed.

The pseudocode includes

if (it != mt)           // need finite-length chunk
          fail();               //    of same type

which I think also rejects tags inside indefinite strings. What am I
missing?

Jeffrey

On Thu, Dec 5, 2019 at 7:27 AM Faye Amacker <faye.github@gmail.com> wrote:

> While implementing support for tags, I ran into a scenario that might be
> errata or could use some clarification in 7049bis.
>
> Section 3.2.3 states:
>
> > Indefinite-length strings are represented by a byte containing the major
> type and additional information value of 31, followed by a series of zero
> or more byte or text strings (“chunks”) that have definite lengths,
> followed by the “break” stop code (Section 3.2.1). The data item
> represented by the indefinite-length string is the concatenation of the
> chunks (i.e., the empty byte or text string, respectively, if no chunk is
> present).
>
> And the pseudocode in Appendix C allows tags for chunks inside
> indefinite-length strings.
>
> Chunks are simply fragments to be concatenated, so tags applied to chunks
> doesn't seem intuitive.  Chunks are not intended for independent access
> like array elements.  Some tags (like #2 and #3) transform byte string into
> bignum which makes sense for arrays, not chunks.
>
> If tags must be applied to each chunk, there should be some text
> mentioning that because library authors might think it should be rejected
> or applied to the concatenated string rather than chunk.
>
> However, if the tag for a chunk applies to the entire concatenated string,
> then what happens when there are multiple chunks with different tags? Which
> tag wins?
>
> A simpler way forward is to treat tags on chunks as malformed.  If this is
> the way to go, then the pseudocode in Appendix C needs to be updated and an
> example could be added to Appendix G.
>
> GitHub issue for RFC 7049bis:
> https://github.com/cbor-wg/CBORbis/issues/148
> GitHub issue for my CBOR library:
> https://github.com/fxamacker/cbor/issues/44
> _______________________________________________
> CBOR mailing list
> CBOR@ietf.org
> https://www.ietf.org/mailman/listinfo/cbor
>