Skip to main content

Manifest

Struct Manifest 

Source
pub struct Manifest {
    pub structure_version: u8,
    pub sequence: u64,
    pub vendor_id: [u8; 16],
    pub class_id: [u8; 16],
    pub format: PayloadFormat,
    pub storage: u8,
    pub digest: [u8; 32],
    pub size: u32,
    pub expires: u64,
}
Expand description

What an update claims about itself.

§Examples

use pamoja_security::DeviceIdentity;
use pamoja_update::{Envelope, Manifest, PayloadFormat, ENVELOPE_MAX};

let author = DeviceIdentity::from_seed(&[1u8; 32]);
let manifest = Manifest {
    structure_version: pamoja_update::STRUCTURE_VERSION,
    sequence: 7,
    vendor_id: [0xab; 16],
    class_id: [0xcd; 16],
    format: PayloadFormat::Raw,
    storage: 0,
    digest: [0x11; 32],
    size: 4096,
    expires: 0,
};

let mut buf = [0u8; ENVELOPE_MAX];
let written = manifest.sign(&author, &mut buf).unwrap();

let envelope = Envelope::decode(&buf[..written]).unwrap();
let checked = envelope.verify(&author.public()).unwrap();
assert_eq!(checked.sequence, 7);

Fields§

§structure_version: u8

Which iteration of the manifest format this is.

§sequence: u64

Rises with every release. A device refuses anything not above what it runs, which is what stops a captured older image being replayed at it.

§vendor_id: [u8; 16]

Who built the image.

§class_id: [u8; 16]

Which kind of device it is for.

§format: PayloadFormat

How the payload is encoded.

§storage: u8

Which slot the payload belongs in.

§digest: [u8; 32]

The SHA-256 of the payload. Every other guarantee rests on this one.

§size: u32

The payload’s length in bytes, known before a single byte is accepted.

§expires: u64

When this release stops being offered, in seconds since the Unix epoch, or 0 to never expire.

A sequence number alone cannot protect a device that has been offline for a long time: an attacker can hand it a release that is genuinely newer than the one it runs, but old enough to have a known flaw, and the device has no way to know a better one exists. An expiry bounds how long such a release stays usable. Setting one requires the device to have a clock.

Implementations§

Source§

impl Manifest

Source

pub fn encode(&self, buf: &mut [u8]) -> Result<usize>

Encodes the manifest body, which is the part a signature covers.

§Arguments
§Returns

How many bytes were written.

§Errors

Returns Refusal::Malformed if buf is too small.

Source

pub fn decode(bytes: &[u8]) -> Result<Self>

Decodes a manifest body.

§Arguments
  • bytes - an encoded manifest body.
§Returns

The manifest.

§Errors

Returns Refusal::Malformed if the encoding is not a well-formed manifest with its keys in order, or Refusal::UnsupportedVersion if it announces a structure version or payload format this build cannot apply.

Source

pub fn sign(&self, author: &DeviceIdentity, buf: &mut [u8]) -> Result<usize>

Encodes the manifest and signs it, producing an envelope.

§Arguments
  • author - the identity releasing the update.
  • buf - the destination, at least ENVELOPE_MAX bytes.
§Returns

How many bytes of buf the envelope occupies.

§Errors

Returns Refusal::Malformed if buf is too small.

Trait Implementations§

Source§

impl Clone for Manifest

Source§

fn clone(&self) -> Manifest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Manifest

Source§

impl Debug for Manifest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Manifest

Source§

impl PartialEq for Manifest

Source§

fn eq(&self, other: &Manifest) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Manifest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.