Re: [Suit] CBOR and Firmware Word Alignment

David Brown <david.brown@linaro.org> Wed, 27 June 2018 18:33 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 E60F8130E93 for <suit@ietfa.amsl.com>; Wed, 27 Jun 2018 11:33:00 -0700 (PDT)
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 PZB_awBNhZlP for <suit@ietfa.amsl.com>; Wed, 27 Jun 2018 11:32:59 -0700 (PDT)
Received: from mail-it0-x243.google.com (mail-it0-x243.google.com [IPv6:2607:f8b0:4001:c0b::243]) (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 57E32130E74 for <suit@ietf.org>; Wed, 27 Jun 2018 11:32:59 -0700 (PDT)
Received: by mail-it0-x243.google.com with SMTP id 188-v6so8827345ita.5 for <suit@ietf.org>; Wed, 27 Jun 2018 11:32:59 -0700 (PDT)
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=j1TNW/mOyHnrUaijeiuyg2kZH15eRG0af1ehth+tp9M=; b=V0LJIgkuO1/K1IM2gMSgXKe8/dawXf1nWOB8RqXbtkkJ/WEeBt7ANj3s/JssLTDXPV eTYa94cV0SyDGPtB7tmstKzkDQm+V8gST36aAoq4spPk6tGbZoYZgxyLa1DP/tM1o1Bo 2iUOCjUx5UUGliaYsycbTThNPJUcRLD6nDvlA=
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=j1TNW/mOyHnrUaijeiuyg2kZH15eRG0af1ehth+tp9M=; b=qPB1HdUw4GllMKIDCVyeak6qrXvGqgxd8aTt2ogh/IR7wjnbyh2o0+r1FWD1CJUA2P voISJo1AnKuPbTcgHLBNdtuhtMRNmsNrvEh+bm3sHt7HwVuy3FLzGOS47G7KmqShtZWb RKGFNP2MwDNXpLsa/6wp2jZyN/rXuKZMh8slJOel4j2p66XGwMnAjFdKXQm5vGraHjag Y5u7a52ww22tnZuzlnECF1U+Uwr1MryXlKBkrthnr2U41xjC004ilmdnbghgd3EUyvze JmwJ2k/79XgY0H2RULZ3bukAlMNj4QwKrSNkNDz7zC231wIiLL3XDTmU2PaDVC71RE4y 5FSQ==
X-Gm-Message-State: APt69E0GbvkwgGiokiLrI0SRvNl33xbouQuYY998qHZ366x/4rMrn71Z Cixp0RSiQSpTZd/u83W9sN1e0vDgx2Y=
X-Google-Smtp-Source: AAOMgpccyFhE4llIuvZHJ5k60chmEHLR5Y0EmHYQMv8MkhJa9baWafx6ObRlINKxFr1q4GouKOtb6Q==
X-Received: by 2002:a24:dec5:: with SMTP id d188-v6mr3334603itg.123.1530124378521; Wed, 27 Jun 2018 11:32:58 -0700 (PDT)
Received: from davidb.org ([2601:283:4300:987c::9]) by smtp.gmail.com with ESMTPSA id o20-v6sm2073507ioa.83.2018.06.27.11.32.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 11:32:57 -0700 (PDT)
Date: Wed, 27 Jun 2018 12:32:55 -0600
From: David Brown <david.brown@linaro.org>
To: Paul Lambert <paul.lambert@intrinsic-id.com>
Cc: suit <suit@ietf.org>
Message-ID: <20180627183255.GA30443@davidb.org>
References: <5DF0B5F0-85E2-4681-9581-E28A3F0A5446@intrinsic-id.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format="flowed"
Content-Disposition: inline
In-Reply-To: <5DF0B5F0-85E2-4681-9581-E28A3F0A5446@intrinsic-id.com>
User-Agent: Mutt/1.9.4 (2018-02-28)
Archived-At: <https://mailarchive.ietf.org/arch/msg/suit/kE6w8-XYhxFiRSQsVMHFK97TrRA>
Subject: Re: [Suit] CBOR and Firmware Word Alignment
X-BeenThere: suit@ietf.org
X-Mailman-Version: 2.1.26
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, 27 Jun 2018 18:33:01 -0000

On Tue, Jun 26, 2018 at 06:20:53PM +0000, Paul Lambert wrote:

>Has any thought gone into word alignment issues?

>Many platforms require firmware or other data objects to be word
>aligned. It waould be especially desirable to have large objects
>(like the firmware) be packaged such that the data does not have to
>be copied to a new location just to ensure word alignment. Word
>alignment would also facilitate in-place decryption of the firmeare.

What we do today in MCUboot is something like:

     +--------------------+
     | Header             |
     +--------------------+
     | Padding            |
     +--------------------+
     | XIP firmware image |
     +--------------------+
     | Manifest           |
     +--------------------+

where the header contains a length field to make finding the manifest
easy.

Because the images are execute in place (XIP), they have to be
compiled and linked at a specific address.  This precludes placing
them after the manifest, since the information there is variable (even
some signature encodings aren't deterministic in length).

The constraints on this image are fairly specific:

  - It is XIP, and therefore must be placed at an address known at
    compile/link time.

  - The start address must be aligned to a particular alignment,
    depending on the particular hardware (for Cortex M, it is a power
    of two greater or equal to the size of the interrupt vector table,
    typically 256 or 512 bytes).

It would be possible to insert 1 or more tags of some type into a CBOR
stream in order to pad data, and this could possibly be standardized
to one of the small values, so that this tag is only a single byte.

We haven't determine how the image and manifest will be delivered,
currently it seems like the manifest will be a separate file, but the
image file that is then downloaded, will also already have the
manifest appended to it.

David