Re: [Cbor] [Suit] Code generation from CDDL descriptions

Carsten Bormann <cabo@tzi.org> Tue, 11 February 2020 20:03 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 EE671120837; Tue, 11 Feb 2020 12:03:49 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.2
X-Spam-Level:
X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-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 VL2tCq-1Kgg0; Tue, 11 Feb 2020 12:03:45 -0800 (PST)
Received: from gabriel-vm-2.zfn.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 7E93A12082C; Tue, 11 Feb 2020 12:03:45 -0800 (PST)
Received: from [172.16.42.112] (p548DC4D8.dip0.t-ipconnect.de [84.141.196.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 48HDHK4KRfz10rC; Tue, 11 Feb 2020 21:03:41 +0100 (CET)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <AM0PR05MB4339B8704E1792CC224FC92A88180@AM0PR05MB4339.eurprd05.prod.outlook.com>
Date: Tue, 11 Feb 2020 21:03:38 +0100
Cc: "suit@ietf.org" <suit@ietf.org>, cbor@ietf.org
X-Mao-Original-Outgoing-Id: 603144218.293945-75424a8e2c3f0393f7e26a3030b91d94
Content-Transfer-Encoding: quoted-printable
Message-Id: <184BC92C-5780-4AC4-81C6-BF28E068ABFF@tzi.org>
References: <AM0PR05MB4339B8704E1792CC224FC92A88180@AM0PR05MB4339.eurprd05.prod.outlook.com>
To: "\"Rønningstad, Øyvind\"" <Oyvind.Ronningstad@nordicsemi.no>
X-Mailer: Apple Mail (2.3608.60.0.2.5)
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/S2YAk6wtCg_Y1YlUMvW1rScEIIc>
Subject: Re: [Cbor] [Suit] Code generation from CDDL descriptions
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, 11 Feb 2020 20:03:50 -0000

Hi Øyvind,

This is very interesting!

What is the license on this code?

Grüße, Carsten


> On 2020-02-11, at 20:26, Rønningstad, Øyvind <Oyvind.Ronningstad@nordicsemi.no> wrote:
> 
> Hi everyone.
> 
> I’ve created a python script that parses CDDL descriptions and generates C code that decodes and validates CBOR against the description.
> 
> The repo is here: https://github.com/oyvindronningstad/cddl_gen
> 
> I created it with SUIT in mind, and I’ve added the current (not updated for -03 yet) and earlier manifest formats as test cases in https://github.com/oyvindronningstad/cddl_gen/tree/master/tests/cbor_decode.
> 
> If you want to see it in the wild, I opened a PR to MCUboot for using it in their serial recovery functionality here: https://github..com/JuulLabs-OSS/mcuboot/pull/660                                                                                                                                                                                                                                           
> 
>  
> 
> Some numbers:
> 
> The MCUboot PR reduces the code size by 1100+ bytes compared to using TinyCBOR.
> 
> The current SUIT format can be completely decoded with ~7700 bytes of code, where 652 is from the handwritten library, while the rest comes from the generated code. These numbers are taken from the test case “test2_suit”.
> 
> The generated code decodes the data into a struct. The OuterWrapper (containing everything, except SUIT_Command_Sequences) struct is 808 bytes, while a SUIT_Command_Sequence struct is 3684 bytes.
> 
> Remember that this is for the entire format. My thought is that a SUIT implementation will strip the CDDL to match whatever it supports.
> 
> I have not benchmarked runtime.
> 
>  
> 
> Any feedback, ideas, thoughts, questions are appreciated.
> 
> Thanks,
> 
> Øyvind
> 
> _______________________________________________
> Suit mailing list
> Suit@ietf.org
> https://www.ietf.org/mailman/listinfo/suit