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:
RootMetadataSnapshotMetadataTargetsMetadataTimestampMetadata
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§
impl Eq for Pouf1
Source§impl Pouf for Pouf1
impl Pouf for Pouf1
Source§fn canonicalize(raw_data: &Self::RawData) -> Result<Vec<u8>>
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>where
T: DeserializeOwned,
fn deserialize<T>(raw_data: &Self::RawData) -> Result<T>where
T: DeserializeOwned,
#[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,
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>where
T: DeserializeOwned,
fn from_slice<T>(slice: &[u8]) -> Result<T>where
T: DeserializeOwned,
let jsn: &[u8] = br#"{"foo": "bar", "baz": "quux"}"#;
let _: HashMap<String, String> = Pouf1::from_slice(&jsn).unwrap();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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.