Re: [Suit] self-describing format vs fixed/binary manifest structure

David Brown <david.brown@linaro.org> Wed, 19 December 2018 17:07 UTC

Return-Path: <david.brown@linaro.org>
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 20D22130E62 for <suit@ietfa.amsl.com>; Wed, 19 Dec 2018 09:07:35 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.001
X-Spam-Level:
X-Spam-Status: No, score=-2.001 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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=linaro.org
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 G3dgUwG1L5LW for <suit@ietfa.amsl.com>; Wed, 19 Dec 2018 09:07:32 -0800 (PST)
Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 497D2130E66 for <suit@ietf.org>; Wed, 19 Dec 2018 09:07:32 -0800 (PST)
Received: by mail-qt1-x831.google.com with SMTP id l12so21112856qtf.8 for <suit@ietf.org>; Wed, 19 Dec 2018 09:07:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DSmzkE1l2abvvmFvwklhiWjFUBggbImTQBW7GbERWS4=; b=L4m9yFo3MvS1H3LGJ6uQ6J2kKa/CBLwueDIrUQHKtC+8+lJK22WV0EWOwRYZq7LmCx SVjXrJcjfa/hlnG75IZV+LYTkfec+zj3jekAnvw7yU5+OSG/dO+RG897SEnzBqpVFBwF ZLJ0G+IHBX1P7PvW2zw3BNmFRkYhzvtNndTbU=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DSmzkE1l2abvvmFvwklhiWjFUBggbImTQBW7GbERWS4=; b=svpsLyeJ9dQA4jh7y0Ugr9hUXUsJpUgU7qOGJ/cIb61wM624XomZkdutWHbevQ4Srv x4mKP4P/I2xP2MLGWcYVniRzAEKMqs2+XANZ1jfrtHTdg8xQ0NFd2aiY9yhDX29YExF6 FOGX82pU5RsAEISZu/8ybd7jhS2uctRMs2AqAY23RrNwo6Fk9Me+kGB3jFE063o3H53T EDYw5djrKGV4DOyuMGa8wuVlygfFWex8ML6XsRUryXerQ9cT4poyY2iUr+wOKToXDD/X CRDTI4C9fQGX5iBv5d69k5X3aXEFT8+Jt3TXCKskY9txjXqhYUcH5FfB894cA22tN3BT q2Rg==
X-Gm-Message-State: AA+aEWZ4nRrTb5XJZL/Cy6MqarY3dtg3BlocovuAuGlg6uTbSLM9IRSl SFxmJ3e+TQAeQauhz00E5zlqeoY0SzAb1w==
X-Google-Smtp-Source: AFSGD/WOlhQ9jYx2Gp/c36VZGnQMNWqqcaab04fvquqTUrt4sdhOfgeMxKnn9X1IXljFd6mD9PaNeg==
X-Received: by 2002:ac8:fd4:: with SMTP id f20mr23506033qtk.63.1545239251301; Wed, 19 Dec 2018 09:07:31 -0800 (PST)
Received: from davidb.org (cn-co-b07400e8c3-142422-1.tingfiber.com. [64.98.48.55]) by smtp.gmail.com with ESMTPSA id y4sm2240476qtc.47.2018.12.19.09.07.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Dec 2018 09:07:30 -0800 (PST)
Date: Wed, 19 Dec 2018 10:07:22 -0700
From: David Brown <david.brown@linaro.org>
To: Martin Pagel <Martin.Pagel=40microsoft.com@dmarc.ietf.org>
Cc: Michael Richardson <mcr+ietf@sandelman.ca>, "suit@ietf.org" <suit@ietf.org>, "dev-mcuboot@lists.runtime.co" <dev-mcuboot@lists.runtime.co>
Message-ID: <20181219170722.GA4018@davidb.org>
References: <DM5PR21MB069822F40B3F5CC8DBD5F6C69DA70@DM5PR21MB0698.namprd21.prod.outlook.com> <9919.1544647801@localhost> <DM5PR21MB06986BEC8A8DA5AF9137404A9DA00@DM5PR21MB0698.namprd21.prod.outlook.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format="flowed"
Content-Disposition: inline
In-Reply-To: <DM5PR21MB06986BEC8A8DA5AF9137404A9DA00@DM5PR21MB0698.namprd21.prod.outlook.com>
User-Agent: Mutt/1.10.1 (2018-07-13)
Archived-At: <https://mailarchive.ietf.org/arch/msg/suit/6IagjpecPEZwfMRYZOkNEPuathc>
Subject: Re: [Suit] self-describing format vs fixed/binary manifest structure
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: Wed, 19 Dec 2018 17:07:35 -0000

On Thu, Dec 13, 2018 at 11:22:07PM +0000, Martin Pagel wrote:

>In general I actually agree with your assessment. If you have many
>options, a well defined format like CBOR is much better than custom C
>structures as you can use a standard, already vetted parsing library.
>The standard parser library turns the CBOR data into a data
>structure, in IoT usually a pretty complex C structure. As the
>generic parser does not understand the semantics of the fields (only
>the syntax as defined by the CDDL), the developer still has to write
>code to verify a complex data structure and enforce semantics and you
>still have to test/verify such code.

There has been some good discussion on list about pull vs push
parsing.  What you are describing is known as a push parser.  The
parser parses the CBOR and converts it into a fairly rich data
structure that describes the contents of the CBOR.  This is a common
approach, and is quite useful on "powerful" computers, such as
host-side tooling to process the data.

However, in a highly-resource-constrained device, this is not
typically how it is done.  Usually a "pull" parser is used, which will
have entry points to effectively expect a specific (and likely
limited) variant of the manifest, and simply abort if it see what is
unexpected.  The data is not converted to another structure, but
directly parsed/used in place.  For this kind of use, CBOR works very
well.  Draft 3 of the manifest document has an accompanied example
parser that works this way.

As a comparitive example, MCUboot uses a custom encoding format for
the data in its manifest.  It consists of a small amount of data in a
fixed structure (with defined byte ordering and packing), and a set of
tag-length-value items (effectively a single CBOR map, with integer
keys and all values as bstrs).  This is parsed with a similar custom
parser for the data expected.  I expect the parser for the SUIT
manifest to be somewhat larger than this, but within a similar
magnitude.  Even this simple case of a single map, there is enough
variation that a plain struct would not be appropriate to represent
this information.

David