Skip to main content

Pouf1

Struct Pouf1 

Source
pub struct Pouf1;
Expand description

TUF POUF-1 implementation.

§Schema

§Common Entities

NATURAL_NUMBER is an integer in the range [1, 2**32).

EXPIRES is an ISO-8601 date time in format YYYY-MM-DD'T'hh:mm:ss'Z'.

KEY_ID is the hex encoded value of sha256(cjson(pub_key)).

PUB_KEY is the following:

{
  "type": KEY_TYPE,
  "scheme": SCHEME,
  "value": PUBLIC
}

PUBLIC is a base64url encoded SubjectPublicKeyInfo DER public key.

KEY_TYPE is a string (ed25519 is the only one currently supported).

SCHEME is a string (ed25519 is the only one currently supported).

HASH_VALUE is a hex encoded hash value.

SIG_VALUE is a hex encoded signature value.

METADATA_DESCRIPTION is the following:

{
  "version": NATURAL_NUMBER,
  "length": NATURAL_NUMBER,
  "hashes": {
    HASH_ALGORITHM: HASH_VALUE
    ...
  }
}

§SignedMetadata

{
  "signatures": [SIGNATURE],
  "signed": SIGNED
}

SIGNATURE is:

{
  "keyid": KEY_ID,
  "signature": SIG_VALUE
}

SIGNED is one of:

  • RootMetadata
  • SnapshotMetadata
  • TargetsMetadata
  • TimestampMetadata

The the elements of signatures must have unique key_ids.

§RootMetadata

{
  "_type": "root",
  "version": NATURAL_NUMBER,
  "expires": EXPIRES,
  "keys": [PUB_KEY, ...]
  "roles": {
    "root": ROLE_DESCRIPTION,
    "snapshot": ROLE_DESCRIPTION,
    "targets": ROLE_DESCRIPTION,
    "timestamp": ROLE_DESCRIPTION
  }
}

ROLE_DESCRIPTION is the following:

{
  "threshold": NATURAL_NUMBER,
  "keyids": [KEY_ID, ...]
}

§SnapshotMetadata

{
  "_type": "snapshot",
  "version": NATURAL_NUMBER,
  "expires": EXPIRES,
  "meta": {
    META_PATH: METADATA_DESCRIPTION
  }
}

META_PATH is a string.

§TargetsMetadata

{
  "_type": "timestamp",
  "version": NATURAL_NUMBER,
  "expires": EXPIRES,
  "targets": {
    TARGET_PATH: TARGET_DESCRIPTION
    ...
  },
  "delegations": DELEGATIONS
}

DELEGATIONS is optional and is described by the following:

{
  "keys": [PUB_KEY, ...]
  "roles": {
    ROLE: DELEGATION,
    ...
  }
}

DELEGATION is:

{
  "name": ROLE,
  "threshold": NATURAL_NUMBER,
  "terminating": BOOLEAN,
  "keyids": [KEY_ID, ...],
  "paths": [PATH, ...]
}

ROLE is a string,

PATH is a string.

§TimestampMetadata

{
  "_type": "timestamp",
  "version": NATURAL_NUMBER,
  "expires": EXPIRES,
  "snapshot": METADATA_DESCRIPTION
}

Trait Implementations§

Source§

impl Clone for Pouf1

Source§

fn clone(&self) -> Pouf1

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Pouf1

Source§

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

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

impl PartialEq for Pouf1

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Pouf for Pouf1

Source§

fn extension() -> &'static str

assert_eq!(Pouf1::extension(), "json");
Source§

fn canonicalize(raw_data: &Self::RawData) -> Result<Vec<u8>>

let jsn: &[u8] = br#"{"foo": "bar", "baz": "quux"}"#;
let raw = Pouf1::from_slice(jsn).unwrap();
let out = Pouf1::canonicalize(&raw).unwrap();
assert_eq!(out, br#"{"baz":"quux","foo":"bar"}"#);
Source§

fn deserialize<T>(raw_data: &Self::RawData) -> Result<T>

#[derive(Deserialize, Debug, PartialEq)]
struct Thing {
   foo: String,
   bar: String,
}

let jsn = json!({"foo": "wat", "bar": "lol"});
let thing = Thing { foo: "wat".into(), bar: "lol".into() };
let de: Thing = Pouf1::deserialize(&jsn).unwrap();
assert_eq!(de, thing);
Source§

fn serialize<T>(data: &T) -> Result<Self::RawData>
where T: Serialize,

#[derive(Serialize)]
struct Thing {
   foo: String,
   bar: String,
}

let jsn = json!({"foo": "wat", "bar": "lol"});
let thing = Thing { foo: "wat".into(), bar: "lol".into() };
let se: serde_json::Value = Pouf1::serialize(&thing).unwrap();
assert_eq!(se, jsn);
Source§

fn from_slice<T>(slice: &[u8]) -> Result<T>

let jsn: &[u8] = br#"{"foo": "bar", "baz": "quux"}"#;
let _: HashMap<String, String> = Pouf1::from_slice(&jsn).unwrap();
Source§

type RawData = Value

The type of data that is contained in the signed portion of metadata.
Source§

impl Eq for Pouf1

Source§

impl StructuralPartialEq for Pouf1

Auto Trait Implementations§

§

impl Freeze for Pouf1

§

impl RefUnwindSafe for Pouf1

§

impl Send for Pouf1

§

impl Sync for Pouf1

§

impl Unpin for Pouf1

§

impl UnsafeUnpin for Pouf1

§

impl UnwindSafe for Pouf1

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more