Subject: [Suit] CBOR and Firmware Word Alignment

From: Paul Lambert <[email-masked]>
Date: Tue, 26 Jun 2018 18:20:53 +0000

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.

Paul

---

From: Carsten Bormann <[email-masked]>
Date: Wed, 27 Jun 2018 00:01:06 +0200

Hi Paul,

CBOR does not have a padding feature (although it would be easy to add one).
Of course you can fake one by including a byte string in front of the to-be-aligned data and dimensioning this just right.
I am not aware of CBOR implementations that support this today, but it should not be too hard to add this.
Alternatively, the word-aligned firmware image could be kept separate from the manifest itself.

Grüße, Carsten

> On Jun 26, 2018, at 20:20, Paul Lambert <[email-masked]> wrote:
> 
> _______________________________________________
> Suit mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/suit
>

---

From: Michael Richardson <[email-masked]>
Date: Tue, 26 Jun 2018 19:32:41 -0400

> 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.

AFAIK, the firmware image is not *in* the manifest, so the actual firmware
alignment does not depend upon any feature of the manifest.
The firmware image can be put anywhere one likes.
I find it unlikely that the manifest contents will need any specific
alignment for a bulk operation.  If so, it's small enough to copy around the
place.

Over on the mcuboot list, it seems that they currently putting their image
TLV at the end of the firmware image, and they will place the manifest
there.  That would seem to align the firmware image nicely.

--
Michael Richardson <[email-masked]>, Sandelman Software Works
 -= IPv6 IoT consulting =-

---

From: Rønningstad, Øyvind <[email-masked]>
Date: Wed, 27 Jun 2018 06:46:58 +0000

> -----Original Message-----
> From: Suit [mailto:[email-masked]] On Behalf Of Michael
> Richardson
> Sent: 27. juni 2018 01:33
> To: suit <[email-masked]>
> Subject: Re: [Suit] CBOR and Firmware Word Alignment
> 
> 
> AFAIK, the firmware image is not *in* the manifest, so the actual
> firmware alignment does not depend upon any feature of the manifest.
> alignment for a bulk operation.  If so, it's small enough to copy around
> the place.
> 

In some cases it makes sense to concatenate the payload after the manifest to simplify delivery, In which case I think it would be useful to have the option of padding. There could be a bstr padding entry at the end of the manifest, or maybe a padding extension.

---

From: Carsten Bormann <[email-masked]>
Date: Wed, 27 Jun 2018 10:27:21 +0200

So what is the container format for delivering manifest and image?  You could solve the problem there. (eg, round up before spending the next thing.)

Sent from mobile

> On 27. Jun 2018, at 08:46, Rønningstad, Øyvind <[email-masked]> wrote:
> 
> 
>

---

From: David Brown <[email-masked]>
Date: Wed, 27 Jun 2018 12:32:55 -0600

>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

---

From: Rønningstad, Øyvind <[email-masked]>
Date: Thu, 28 Jun 2018 06:59:06 +0000

Definitely. I’m not entirely convinced we need a container format though. The order of blobs in the stream could be implicit, and size information is already present in the manifests.

From: Carsten Bormann [mailto:[email-masked]]
Sent: 27. juni 2018 10:27
To: Rønningstad, Øyvind <[email-masked]>
Cc: Michael Richardson <[email-masked]>; suit <[email-masked]>
Subject: Re: [Suit] CBOR and Firmware Word Alignment

On 27. Jun 2018, at 08:46, Rønningstad, Øyvind <[email-masked]<mailto:[email-masked]>> wrote:

-----Original Message-----
From: Suit [mailto:[email-masked]] On Behalf Of Michael
Richardson
Sent: 27. juni 2018 01:33
To: suit <[email-masked]<mailto:[email-masked]>>
Subject: Re: [Suit] CBOR and Firmware Word Alignment

Paul Lambert <[email-masked]<mailto:[email-masked]>> 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.

_______________________________________________
Suit mailing list
[email-masked]<mailto:[email-masked]>
https://www.ietf.org/mailman/listinfo/suit