Re: [Suit] Code generation from CDDL descriptions

Brendan Moran <Brendan.Moran@arm.com> Tue, 11 February 2020 20:29 UTC

Return-Path: <Brendan.Moran@arm.com>
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 87651120ABD; Tue, 11 Feb 2020 12:29:03 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.901
X-Spam-Level:
X-Spam-Status: No, score=-1.901 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.b=pYrxhm0q; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.b=pYrxhm0q
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 sTnQufZ-cBjE; Tue, 11 Feb 2020 12:28:56 -0800 (PST)
Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2054.outbound.protection.outlook.com [40.107.22.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 110B1120ABA; Tue, 11 Feb 2020 12:28:54 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H9DPyNdiUr963xWNgEHj4otPvpOoxzHN5fAW3tt+OxU=; b=pYrxhm0q6NuTcFGj7bokJNeT222GbMmfVC1BwzWVgmxmSnDnlN+sT1yubQ4MsWLG4amPANkdIiEO/2wzU8hBXvl75R35gi13vFT4rSmchBzeBK8FQSNzI77Qdm4zPP9PmO/hzeeVOevBPi7RYzejQci4zvoQBOsIcNGA/2SZoo4=
Received: from VI1PR08CA0181.eurprd08.prod.outlook.com (2603:10a6:800:d2::11) by AM6PR08MB3125.eurprd08.prod.outlook.com (2603:10a6:209:46::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.21; Tue, 11 Feb 2020 20:28:52 +0000
Received: from DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::204) by VI1PR08CA0181.outlook.office365.com (2603:10a6:800:d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.22 via Frontend Transport; Tue, 11 Feb 2020 20:28:52 +0000
Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; ietf.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;ietf.org; dmarc=bestguesspass action=none header.from=arm.com;
Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com;
Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT020.mail.protection.outlook.com (10.152.20.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.18 via Frontend Transport; Tue, 11 Feb 2020 20:28:51 +0000
Received: ("Tessian outbound 3a0cbd311638:v42"); Tue, 11 Feb 2020 20:28:51 +0000
X-CheckRecipientChecked: true
X-CR-MTA-CID: 5a2b222c63eaf9bd
X-CR-MTA-TID: 64aa7808
Received: from 9cad79a9bce8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D6DC5D42-C0CF-49A3-9247-AB25B5CB07F5.1; Tue, 11 Feb 2020 20:28:46 +0000
Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9cad79a9bce8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Feb 2020 20:28:46 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PNyeIiDYhglCGMnUrUVolMrcykGtCN2VgLUnyqkKm0P/KOgFuy3gQgEKqzJFWl7YokUa57o8h/wWKTf2Ka/CFcz+xVklz1ZxrhpKyBzSsBOKrBHazXdv1g7WaoJpnASjNVTZTWp75tbPdYp/Ed1iHw6yI9aLGUcdkijf97MaTGY7idGyWJVg2sZcqaqE9s6Lpx8nMWV/PS29V9C8SVdSiRUJaLpk+VQUt3MMo4OM4DTzqs8I1zApJQ1JVppTQSS1ZnlP5rznq4aNUkVpasU6pL1c5Wlb0xv/s0mLLL82j2cssIbYF/FDQhsWuCZ1YL6SZX7FBjQ8/oApuzMVIm4iVw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H9DPyNdiUr963xWNgEHj4otPvpOoxzHN5fAW3tt+OxU=; b=eXL+H4UAyDdJOXreSkI1aCk0TvK/lQ5rzaW7GtknxQuK5EM79rcU3iOIo5SzdI7zE1mrHzMuh+21m419HnyoevFtYkXSWPF/8mXn1KnO9rx2f0QH4u3e/Y1y5NMuOSK6wW6KuKaNBhOKUkYjdXRCO5khU7w8AfsvFcRjA/jvUj5GWA2i7wj46eXstlBaf26E8XsGHNlbq/pCuNMVi1C3NUgq3DuNgmYgtX2U0T90Y+dp2dmhJuUGm+SmAIa/s2GXdq4UNhb8Zuh7x6xR2CgC06ul9Er+l0a12mqsunej+Kx394K9E9Ann6ewk4H1xHSptxNC/V5gzbQcCG+g5Mi9mQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H9DPyNdiUr963xWNgEHj4otPvpOoxzHN5fAW3tt+OxU=; b=pYrxhm0q6NuTcFGj7bokJNeT222GbMmfVC1BwzWVgmxmSnDnlN+sT1yubQ4MsWLG4amPANkdIiEO/2wzU8hBXvl75R35gi13vFT4rSmchBzeBK8FQSNzI77Qdm4zPP9PmO/hzeeVOevBPi7RYzejQci4zvoQBOsIcNGA/2SZoo4=
Received: from AM6PR08MB4738.eurprd08.prod.outlook.com (10.255.99.138) by AM6PR08MB3784.eurprd08.prod.outlook.com (20.178.89.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.22; Tue, 11 Feb 2020 20:28:44 +0000
Received: from AM6PR08MB4738.eurprd08.prod.outlook.com ([fe80::99bb:dd46:a0a0:562a]) by AM6PR08MB4738.eurprd08.prod.outlook.com ([fe80::99bb:dd46:a0a0:562a%7]) with mapi id 15.20.2707.030; Tue, 11 Feb 2020 20:28:44 +0000
From: Brendan Moran <Brendan.Moran@arm.com>
To: Carsten Bormann <cabo@tzi.org>
CC: Øyvind Rønningstad <Oyvind.Ronningstad@nordicsemi.no>, "cbor@ietf.org" <cbor@ietf.org>, "suit@ietf.org" <suit@ietf.org>
Thread-Topic: [Suit] Code generation from CDDL descriptions
Thread-Index: AdXhAKGtseWPUAvhTxuGUxLUSCGinwAFbeQAAADgHQA=
Date: Tue, 11 Feb 2020 20:28:43 +0000
Message-ID: <D20E35B2-7221-456B-BE8E-9D43FBE47D33@arm.com>
References: <AM0PR05MB4339B8704E1792CC224FC92A88180@AM0PR05MB4339.eurprd05.prod.outlook.com> <184BC92C-5780-4AC4-81C6-BF28E068ABFF@tzi.org>
In-Reply-To: <184BC92C-5780-4AC4-81C6-BF28E068ABFF@tzi.org>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-mailer: Apple Mail (2.3601.0.10)
Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Brendan.Moran@arm.com;
x-originating-ip: [81.101.7.188]
x-ms-publictraffictype: Email
X-MS-Office365-Filtering-HT: Tenant
X-MS-Office365-Filtering-Correlation-Id: 36c16d98-7e07-4b6c-697b-08d7af310219
X-MS-TrafficTypeDiagnostic: AM6PR08MB3784:|AM6PR08MB3125:
X-Microsoft-Antispam-PRVS: <AM6PR08MB312580058A7A7111C7FFD490EA180@AM6PR08MB3125.eurprd08.prod.outlook.com>
x-checkrecipientrouted: true
nodisclaimer: true
x-ms-oob-tlc-oobclassifiers: OLM:10000;OLM:10000;
x-forefront-prvs: 0310C78181
X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(376002)(396003)(346002)(136003)(366004)(199004)(189003)(186003)(81156014)(6916009)(2616005)(8676002)(26005)(316002)(33656002)(6506007)(81166006)(8936002)(54906003)(53546011)(91956017)(76116006)(71200400001)(4326008)(66574012)(5660300002)(66946007)(6512007)(66556008)(2906002)(64756008)(66476007)(86362001)(66446008)(36756003)(6486002)(478600001)(966005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB3784; H:AM6PR08MB4738.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1;
received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts)
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam-Untrusted: BCL:0;
X-Microsoft-Antispam-Message-Info-Original: xiXc9Mp24FvDPoMIYH8a6gzLiB4DCQz0piUC+OQ5689pzIN8ie/pepKOjGTJzwjctfaBIkjV5pe3VXtTf+IDpt4fOTRKUonE8Uhx4UtPsriHqdoOMau6wRb+T12q66JaQoQ2zjswiPxNlKW1KaRdJO4jBpi7ieiPrl4NEmiX8NIVSgSpGLOXv1PDHt2UhLcYdGWgss/UNtRGUj0Htfp781rME3sFH9ObSy+ATKKDf5bXu/bIjXxcGSZ8EemLKEbxq5BzZP4sSevEc32mSQgRHDLVB0kKIfAWmLwlPqaJjG6WL4d5E1MO+DzQ+uT3uOgMFFmv3Vi0lRCoLL1MwoLRSxuCo724o4z+AYu2tyV62fkKvWaCx5CFBDkCFDXpz9xEhcyN/+WWIxtGeonoJK3anGF1RQ4RpCJWqisLO/0fwYK/R6zoXcgkdNwB8c86zIKWcpw1Wi5uLDPfcE5PccP6GXbf4ZlHRPUlCX1jqd8v3CF4Gg0dSbnPuNPxUKi++toLxCHMWTU1zpsura6+m3wlHg==
x-ms-exchange-antispam-messagedata: L88SIPM7+0/koX/IGTj7khiMB+dPKdAsTFrktkpDmZRBPBzq6SaxpaLgru3op7U+K2hQpvlByjbmKSBggxulHhcR7YEIBNv5toZ8Y5f4Q466abE+jFgLct22z46zCuFh3uxzR+Ufl/EDc2U7toMZTw==
x-ms-exchange-transport-forked: True
Content-Type: text/plain; charset="utf-8"
Content-ID: <8BAEF8864A376A4DA9220E03D29834A9@eurprd08.prod.outlook.com>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3784
Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Brendan.Moran@arm.com;
X-EOPAttributedMessage: 0
X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com
X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(136003)(346002)(396003)(199004)(189003)(26826003)(478600001)(336012)(966005)(36756003)(5660300002)(33656002)(2616005)(70206006)(70586007)(316002)(54906003)(8676002)(81156014)(8936002)(81166006)(6486002)(86362001)(356004)(6862004)(66574012)(4326008)(2906002)(6506007)(6512007)(53546011)(450100002)(26005)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB3125; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Pass; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1;
X-MS-Office365-Filtering-Correlation-Id-Prvs: 377f1fbb-13f0-4627-5efd-08d7af30fd64
X-Forefront-PRVS: 0310C78181
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: bnIs551BOyefR0+nJVAaTSv4r9PMQ8gvcEkVeDVmCDZTb8Uqxcockootbvb1C9uzVuTutwiN+W5E6vrnGdtXjmsJhMm9IFsNuN7+9U/vWUTeuFbV1nBTe5qEf8+tTgCnsCkKGhStpucr2zPkOOt2qFJpj29MU5l9Lmn1EwyIa8wX3tyrQ4qXST77eVXSCMWsi6GKw8vK1dvZDBW6JurcIJkVk2i4wyNgigIRqE2VQKv86IPImt3oWl9BM0qtXWpmOhl2B3gwAE5kexhGp77J2+dwgfPKQFaa68Yl7ysfiECobbm5eryaActlsGPovBH3XRVcEVaC2/+Kp4SAxNt4Q/jxmhmZnA0IvZUpYl0EUp/Pk7RDrOtQdLGrUABUduJx8M2G6D86XtIGWuUse+Tb9AMmgx+K9ArTHrEAolL6YxXuPedd7TsOd7IEr177ldQQegP3FmVvdokkPtqREa5uZlHgNWtofrFTVKyolSfYMxv/kOr+mNJP969iX9N72NGy/BAw4INc1xn+sQjHIUdyPw==
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2020 20:28:51.9002 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 36c16d98-7e07-4b6c-697b-08d7af310219
X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d
X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com]
X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3125
Archived-At: <https://mailarchive.ietf.org/arch/msg/suit/50b41gzChUfd6I8He4Nlpylyaf4>
Subject: Re: [Suit] Code generation from CDDL descriptions
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, 11 Feb 2020 20:29:04 -0000

Hi Øyvind,

That’s great work! I can’t wait to see what people do with it.

I have also posted a sample parser implementation, but I will send a separate mail about that.

Best Regards,
Brendan


> On 11 Feb 2020, at 20:03, Carsten Bormann <cabo@tzi.org> wrote:
>
> 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
>
> _______________________________________________
> Suit mailing list
> Suit@ietf.org
> https://www.ietf.org/mailman/listinfo/suit

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.