[Iot-directorate] Segmented strings (Re: [Rats] [Last-Call] EAT profiles (was Re: Iotdir last call review of draft-ietf-rats-eat-13))

Carsten Bormann <cabo@tzi.org> Thu, 09 June 2022 07:52 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: iot-directorate@ietfa.amsl.com
Delivered-To: iot-directorate@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 46D13C157B43; Thu, 9 Jun 2022 00:52:11 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.909
X-Spam-Level:
X-Spam-Status: No, score=-1.909 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
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 Up738EbFAhS4; Thu, 9 Jun 2022 00:52:07 -0700 (PDT)
Received: from gabriel-smtp.zfn.uni-bremen.de (gabriel-smtp.zfn.uni-bremen.de [134.102.50.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 2035AC157B58; Thu, 9 Jun 2022 00:52:00 -0700 (PDT)
Received: from [192.168.217.118] (p5089ad4f.dip0.t-ipconnect.de [80.137.173.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-smtp.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4LJbs85RpjzDCcV; Thu, 9 Jun 2022 09:51:56 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <9E4661C8-DFB7-4BC3-A7B5-150C774917F0@island-resort.com>
Date: Thu, 09 Jun 2022 09:51:56 +0200
Cc: Eliot Lear <lear@cisco.com>, iot-directorate@ietf.org, draft-ietf-rats-eat.all@ietf.org, last-call@ietf.org, rats@ietf.org, cbor@ietf.org
X-Mao-Original-Outgoing-Id: 676453915.694796-44558fb6ec40277c956114046a69027b
Content-Transfer-Encoding: quoted-printable
Message-Id: <8C044EB7-92CF-4306-9025-FD667E1B0F22@tzi.org>
References: <165443386776.35361.12898474920348394274@ietfa.amsl.com> <E267AEDE-D1DB-415B-B28F-DD78A517D27A@island-resort.com> <A38F37B7-2E81-451F-86BA-0A041760EB7E@tzi.org> <9E4661C8-DFB7-4BC3-A7B5-150C774917F0@island-resort.com>
To: Laurence Lundblade <lgl@island-resort.com>
X-Mailer: Apple Mail (2.3608.120.23.2.7)
Archived-At: <https://mailarchive.ietf.org/arch/msg/iot-directorate/AJILG2JprE7ge-A0KBFNphEJX30>
Subject: [Iot-directorate] Segmented strings (Re: [Rats] [Last-Call] EAT profiles (was Re: Iotdir last call review of draft-ietf-rats-eat-13))
X-BeenThere: iot-directorate@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Mailing list for the IoT Directorate Members <iot-directorate.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/iot-directorate>, <mailto:iot-directorate-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/iot-directorate/>
List-Post: <mailto:iot-directorate@ietf.org>
List-Help: <mailto:iot-directorate-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/iot-directorate>, <mailto:iot-directorate-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 09 Jun 2022 07:52:11 -0000

On 2022-06-08, at 21:26, Laurence Lundblade <lgl@island-resort.com> wrote:
> 
> The decoding of indefinite length strings requires a memory allocator or some strategy to coalesce string chunks. The COSE payload, which must be hashed, could be many independent string chunks. COSE header parameter values could be lots of string chunks. However you do the coalescing or processing, it is going to be more code and it is something people may not always implement. My t_cose implementation of COSE doesn’t support indefinite length strings yet.

OK, you are focusing on indefinite length encoded strings.
(I couldn’t imagine why you would want to discuss indefinite length encoded arrays or maps.)
Let’s simplify this term to “segmented strings”.

Segmented strings were not part of the original CBOR design, but were added after loud arguments from the “streaming” part of the community.
For an implementation, segmented strings are important when a string is not all available
— at the same place in memory (“scatter-gather”), or
— at the same time (“streaming”).

They are a trade-off:
They were added to allow generators (encoders) to generate encoded CBOR from segmented inputs without having to require to ship that encoded CBOR internally as a segmented list of strings (e.g., in “ropes”), and more importantly without having the entire segmented input available to compute the string lengths.
Why would one want to do that:

— when the input is too large to fit in memory, and length information is not known ahead of time (“streaming”, performance critical environments, constrained devices);
— as a convenience when the input is already in segmented form (constrained devices, removing the need for allocation and copying).

This convenience for the generator turns to an inconvenience for the consumer.
A generic encoder would have to offer the decoded data in a segmented form (“scatter-gather”) or, as you say, copy (gather) it into separately allocated space.

As you notice, some applications of COSE could be in a space where “streaming” (segmented processing) is natural or even the only way to do things.  So it probably doesn’t make sense to disallow segmented strings for COSE in general.

For EAT, you may want to make the decision that you don’t support segmented processing, alleviating the intrusion of segmentation into the decoder API.

That is indeed a valid decision you may want to make.  But note that this is less of an interoperability decision than a decision to simplify some parts of your systems as a tradeoff to decreased performance or capability in other parts of the system — which decrease you may want to consider insignificant.  It is a bit like deciding that floating point values cannot be used in an EAT, except that this decision is not visible at the data model level.

Grüße, Carsten