Re: [Cbor] [COSE] [Rats] RAM requirements for COSE/CWT

Carsten Bormann <cabo@tzi.org> Tue, 01 March 2022 10:16 UTC

Return-Path: <cabo@tzi.org>
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 3F3FA3A1A1D; Tue, 1 Mar 2022 02:16:22 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.908
X-Spam-Level:
X-Spam-Status: No, score=-1.908 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, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 G7Ruy4glNwwC; Tue, 1 Mar 2022 02:16:17 -0800 (PST)
Received: from gabriel-smtp.zfn.uni-bremen.de (gabriel-smtp.zfn.uni-bremen.de [IPv6:2001:638:708:32::15]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id BC8623A0BD2; Tue, 1 Mar 2022 02:16:17 -0800 (PST)
Received: from smtpclient.apple (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 4K7Cnn40PZzDCcV; Tue, 1 Mar 2022 11:16:13 +0100 (CET)
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <PH0PR02MB725651111833AC489B2D8175F2029@PH0PR02MB7256.namprd02.prod.outlook.com>
Date: Tue, 1 Mar 2022 11:16:13 +0100
Cc: Laurence Lundblade <lgl@island-resort.com>, "rats@ietf.org" <rats@ietf.org>, "cbor@ietf.org" <cbor@ietf.org>, "cose@ietf.org" <cose@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-Id: <D21EF88D-4A27-40AB-874A-83608FB995FD@tzi.org>
References: <e8995f0c-ad85-f702-da6b-051ffdc4cb08@gmail.com> <DBBPR08MB5915B874FD16107A7B0105AAFA3A9@DBBPR08MB5915.eurprd08.prod.outlook.com> <1a16c80d-40cd-baba-b1ce-2033dd0db294@gmail.com> <D22D0D63-F76C-48B3-A034-F8B5B2BB6005@tzi.org> <2c8be442-9899-d117-155c-f6f2096b7055@gmail.com> <92C7CF7C-ED23-41B3-AB32-8438C4C88C20@tzi.org> <14c8d106-3b4b-f973-94b8-018852ff4769@gmail.com> <8C2C6592-D5B9-430A-B878-E1009E9BCF22@tzi.org> <AB9F0C55-9C23-43F1-A83F-91D4159C888F@island-resort.com> <59939C29-5370-4385-AE61-A21ADDC0D194@tzi.org> <ED025590-3CA0-42B8-B50E-030D94FA88D6@island-resort.com> <E74C7303-E7D5-45EA-886C-158DB6D83844@tzi.org> <E5AD55D7-33B2-4E50-83EA-5BD1C1462F01@island-resort.com> <2A13AF29-6309-4FA3-9A84-59D4E0C8F089@tzi.org> <33373B82-D46C-498B-A0EB-78E34870C8A7@island-resort.com> <PH0PR02MB725651111833AC489B2D8175F2029@PH0PR02MB7256.namprd02.prod.outlook.com>
To: Jeremy O'Donoghue <jodonogh@qti.qualcomm.com>
X-Mailer: Apple Mail (2.3693.60.0.1.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/dXP2C6Gb8qI4jPqMYdlO3bFazmY>
Subject: Re: [Cbor] [COSE] [Rats] RAM requirements for COSE/CWT
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: Tue, 01 Mar 2022 10:16:23 -0000

On 1. Mar 2022, at 10:41, Jeremy O'Donoghue <jodonogh@qti.qualcomm.com> wrote:
> 
> One thing I would really like to see, and haven’t found so far, is a reliable mechanism to determine the preferred encoding for floats. Currently my implementations require the caller to decide on the float encoding (float16, float32, float64) as I haven’t been able to find a reference that explains how to straightforwardly determine the most efficient *encoding* for a float without loss of precision.

Ready for copying:

https://github.com/cabo/cbor-ruby/blob/master/ext/cbor/packer.h#L138

(Don’t be confused by the “msgpack” prefixes; this code was adapted from the msgpack implementation, and to enable updates from upstream, the renaming is done with a bunch of #defines in renamer.h.)

Note the magic lines

 float fv = v;
  if (fv == v) {     … encode as binary16 or binary32 instead of binary64

Which do all the work here.

Unfortunately C doesn’t have a portable way to say the same for binary16, so there is some more extensive code following.

Grüße, Carsten