pub fn verify_signatures<'a, D, M, I>(
role: &MetadataPath,
raw_metadata: &RawSignedMetadata<D, M>,
threshold: u32,
authorized_keys: I,
) -> Result<Verified<M>, Error>Expand description
Verify this metadata.
let key_1: &[u8] = include_bytes!("../tests/ed25519/ed25519-1.pk8.der");
let key_1 = Ed25519PrivateKey::from_pkcs8(&key_1).unwrap();
let key_2: &[u8] = include_bytes!("../tests/ed25519/ed25519-2.pk8.der");
let key_2 = Ed25519PrivateKey::from_pkcs8(&key_2).unwrap();
let raw_snapshot = SnapshotMetadataBuilder::new()
.signed::<Pouf1>(&key_1)
.unwrap()
.to_raw()
.unwrap();
assert!(verify_signatures(
&MetadataPath::snapshot(),
&raw_snapshot,
1,
vec![key_1.public()],
).is_ok());
// fail with increased threshold
assert!(verify_signatures(
&MetadataPath::snapshot(),
&raw_snapshot,
2,
vec![key_1.public()],
).is_err());
// fail when the keys aren't authorized
assert!(verify_signatures(
&MetadataPath::snapshot(),
&raw_snapshot,
1,
vec![key_2.public()],
).is_err());
// fail when the keys don't exist
assert!(verify_signatures(
&MetadataPath::snapshot(),
&raw_snapshot,
1,
&[],
).is_err());