Re: [Suit] CBOR pull parsing vs. packed binary format extraction

Rønningstad, Øyvind <Oyvind.Ronningstad@nordicsemi.no> Tue, 13 November 2018 13:16 UTC

Return-Path: <Oyvind.Ronningstad@nordicsemi.no>
X-Original-To: suit@ietfa.amsl.com
Delivered-To: suit@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 4AE44129619 for <suit@ietfa.amsl.com>; Tue, 13 Nov 2018 05:16:09 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.902
X-Spam-Level:
X-Spam-Status: No, score=-1.902 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nordicsemi.onmicrosoft.com
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 iXb6pt2QWWJK for <suit@ietfa.amsl.com>; Tue, 13 Nov 2018 05:16:05 -0800 (PST)
Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40041.outbound.protection.outlook.com [40.107.4.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id DA6B9126DBF for <suit@ietf.org>; Tue, 13 Nov 2018 05:16:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nordicsemi.onmicrosoft.com; s=selector1-nordicsemi-no; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dCzbO+RgoFo0hR0gSU7OYLDNMMSTwRb53LZwg3HynBg=; b=iRRYgHMMbxPsLD6asUi1QvhZXa+I9rMsJDH87T7sf3603/e3s9VpPh9TE3wjfBvPgkiOCAna8N/dCKUqWz69M07zIHLPQ/tkWPA9oMg8SwPmDhRtTWXIVcOUkrz1MYizdHqWOOSiVmXU6HMBxRWjz2Jopcg+L1OIGHEsjIenTRY=
Received: from HE1PR05MB3228.eurprd05.prod.outlook.com (10.170.243.14) by HE1PR05MB1547.eurprd05.prod.outlook.com (10.164.49.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.20; Tue, 13 Nov 2018 13:16:01 +0000
Received: from HE1PR05MB3228.eurprd05.prod.outlook.com ([fe80::8db6:ec65:c2f6:b231]) by HE1PR05MB3228.eurprd05.prod.outlook.com ([fe80::8db6:ec65:c2f6:b231%4]) with mapi id 15.20.1294.045; Tue, 13 Nov 2018 13:16:01 +0000
From: "Rønningstad, Øyvind" <Oyvind.Ronningstad@nordicsemi.no>
To: Brendan Moran <Brendan.Moran@arm.com>, suit <suit@ietf.org>
Thread-Topic: CBOR pull parsing vs. packed binary format extraction
Thread-Index: AQHUe0vLj/vkzYlH5UqFZoje4UGxS6VNpOFw
Date: Tue, 13 Nov 2018 13:16:01 +0000
Message-ID: <HE1PR05MB3228C0FF8CC75A2B6C9F8DCE88C20@HE1PR05MB3228.eurprd05.prod.outlook.com>
References: <77A2FE52-4828-481A-AA09-F20FCF0C3605@arm.com>
In-Reply-To: <77A2FE52-4828-481A-AA09-F20FCF0C3605@arm.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
authentication-results: spf=none (sender IP is ) smtp.mailfrom=Oyvind.Ronningstad@nordicsemi.no;
x-originating-ip: [2001:8c0:5140:12:b914:dad0:8ed2:2bfc]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; HE1PR05MB1547; 6:ywEXollQL0sWv8OebAWnMKRh1mYJpK81aeK4VvKyW2ehs3No4nnXZO9qa5kxkrB9FV3L+fS8mwaFlNaEnveoronQCRPfF8KI/pG4Kry3xJ2PMPdZJI3FO0ErBuxAXIeTzxExaOG9PfFTz1rLlh9e/YB2h27lpuAezHGPvg55ra0U4XCPIHZzku7N1eu7osb+CYKjJcI3U6iUVpBS/UK0ei1oOG1YVWMxM/D0qFHlf0Mo4DIfgZe68EQhw5omqAURbFMbCEBrigNWu+Xd+CRtnV8NyKepauMwONlVQtkKcyBfCy7dBLgTKcoxP+k8RGBeHrKXRJw9BApdoaIDKGdiyYnIjS7QAav9rCDnfGPNJFKCOsjTN6YEXH002+I3ZJ3XoH0l01fNUCINC3ExPq9LlDlQPfc+Q/QA2hvML0qcKwZJjwPIDEvg0fy//RCTPuuy0Zs/D3Z332kXYK/+4KXGzQ==; 5:3H8BbULwmk5Cv7qiV0fJivoyWqg37PtbpSZOTfarhm0JUCtskegYA1fsSj8Tge2UBadvXZuHs+bDm+NX7HSL4eakZI5U/fUFqY97aveE/IR+NWt+jjNtyCBBKfZyPvAXEGKXUpJrkUzvjU1n7q6PAThzm3yxMLhCevIh5zRFOyQ=; 7:RBpbuVfc1K8HSC2A7naz6irhgxdZTAadNJgo6uTTAEEBP0LZqhTlY/SaymoKxAO4EsZFFTP/BVjRylw1SO6g/Nd759xdxwuhk1VXpHiC+oI9jM0H/D5RKVq8l+u5mZMhgRP2JTS+S1FV28t5dX2ljQ==
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-correlation-id: fe4dbcdd-e436-4cf6-baee-08d6496a28a7
x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390060)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:HE1PR05MB1547;
x-ms-traffictypediagnostic: HE1PR05MB1547:
x-microsoft-antispam-prvs: <HE1PR05MB15474783CFFCCDFF5CA751F288C20@HE1PR05MB1547.eurprd05.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(131327999870524)(166708455590820);
x-ms-exchange-senderadcheck: 1
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231382)(944501410)(52105112)(3002001)(148016)(149066)(150057)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:HE1PR05MB1547; BCL:0; PCL:0; RULEID:; SRVR:HE1PR05MB1547;
x-forefront-prvs: 085551F5A8
x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(396003)(346002)(39850400004)(376002)(136003)(366004)(189003)(13464003)(199004)(71190400001)(71200400001)(72206003)(74316002)(7736002)(25786009)(76176011)(8676002)(81166006)(81156014)(74482002)(8936002)(97736004)(102836004)(2900100001)(6506007)(305945005)(7696005)(966005)(14454004)(86362001)(53546011)(99286004)(9686003)(229853002)(478600001)(46003)(11346002)(14444005)(256004)(476003)(486006)(6246003)(68736007)(53936002)(5024004)(105586002)(110136005)(316002)(33656002)(106356001)(446003)(186003)(55016002)(6116002)(5660300001)(2906002)(6436002)(6306002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR05MB1547; H:HE1PR05MB3228.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1;
received-spf: None (protection.outlook.com: nordicsemi.no does not designate permitted sender hosts)
x-microsoft-antispam-message-info: AZSUggZM2yyQvQu37ffxBh/kacP+J0T5BexhGS0rezQc6SUZ21AGEtXIkEIfJVxLI+9AKZuWGHsUk6pqi/HwYUJLaGJlyJ2pv+7LmCjiGu+I6/kIkHD4R7s/oiOvGqO/Ce2MyaPfkLp9Z38h9JZWMGASpTIcYYbjBHON9qJn2UDxZOTnU4mbdPYO/YDTAy9Rz7GwBlZJ8WXz2deISu36a1H+eV20oddor3oMeq0X9tlqiubNRvSQ7LOPsxAPqdCjrXL9l+jV/ljILmTAIDmULNUo86jxYeYmwmKreCTUFfZ57wm1oR1WEF96e+AxexdqYNj61Gk5mZMQK4N6uBATWmFGRCsx2Hi0Qv5X22qyUes=
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-OriginatorOrg: nordicsemi.no
X-MS-Exchange-CrossTenant-Network-Message-Id: fe4dbcdd-e436-4cf6-baee-08d6496a28a7
X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Nov 2018 13:16:01.5244 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 28e5afa2-bf6f-419a-8cf6-b31c6e9e5e8d
X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB1547
Archived-At: <https://mailarchive.ietf.org/arch/msg/suit/74_0cYTz0Dcu6WrO-tQ2IGejoxg>
Subject: Re: [Suit] CBOR pull parsing vs. packed binary format extraction
X-BeenThere: suit@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Software Updates for Internet of Things <suit.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/suit>, <mailto:suit-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/suit/>
List-Post: <mailto:suit@ietf.org>
List-Help: <mailto:suit-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/suit>, <mailto:suit-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 13 Nov 2018 13:16:09 -0000

Thanks for sharing!

Your code seems to assume a specific order of map elements, but as far as I know, CDDL (or even CBOR?) doesn't guarantee deterministic ordering.
Am I missing something?

Also, a full implementation will require the ability to fetch of most or all present elements (if not, why are the elements present?), so in practice the size will be larger, right?

Øyvind

> -----Original Message-----
> From: Suit <suit-bounces@ietf.org> On Behalf Of Brendan Moran
> Sent: 13. november 2018 13:24
> To: suit <suit@ietf.org>
> Subject: [Suit] CBOR pull parsing vs. packed binary format extraction
> 
> I have worked up an example pull parser for Class 1 devices. It is
> published in the suit-manifest-generator repo:
> 
> https://github.com/ARMmbed/suit-manifest-
> generator/tree/master/parser-example
> 
> This repo demonstrates constructing a highly specialised parser for the
> draft-moran-suit-manifest-03 draft (with one small modification that will
> be included in the 04 draft) as detailed in README.md.
> 
> The parser has been built for ARM Cortex-M4 to evaluate size:
> 
> The parser consumes 560 bytes of flash, uses only a single pointer of
> state between function calls, returns interpreted integers and references
> to byte strings to save memory when called, and uses no dynamic
> memory. It is guaranteed not to issue unaligned accesses, since all
> accesses are explicitly byte-wise.
> 
> The parser can be used in a low-resource mode, consuming 333 bytes of
> flash, but giving up structural validation of the CBOR, and assuming that
> any fixed components (such as containers) of the manifest are correct
> 
> 
> I have also provided, for comparison, an unserialised binary structure
> using the same information and the same parser API. In this instance, the
> parser consumes 102 bytes of flash. This is not the manifest as defined in
> draft-pagel-suit-manifest-00.
> 
> Martin, would you be able to offer an implementation of an updater for
> class 1 devices using your manifest draft so that we can compare the
> compiled size?
> 
> Best Regards,
> Brendan
> 
> IMPORTANT NOTICE: The contents of this email and any attachments
> are confidential and may also be privileged. If you are not the intended
> recipient, please notify the sender immediately and do not disclose the
> contents to any other person, use it for any purpose, or store or copy the
> information in any medium. Thank you.
> 
> _______________________________________________
> Suit mailing list
> Suit@ietf.org
> https://www.ietf.org/mailman/listinfo/suit