pub struct Database<D: Pouf> { /* private fields */ }Expand description
Contains trusted TUF metadata and can be used to verify other metadata and targets.
Implementations§
Source§impl<D: Pouf> Database<D>
impl<D: Pouf> Database<D>
Sourcepub fn from_root_with_trusted_keys<'a, I>(
raw_root: &RawSignedMetadata<D, RootMetadata>,
root_threshold: u32,
root_keys: I,
) -> Result<Self>where
I: IntoIterator<Item = &'a PublicKey>,
pub fn from_root_with_trusted_keys<'a, I>(
raw_root: &RawSignedMetadata<D, RootMetadata>,
root_threshold: u32,
root_keys: I,
) -> Result<Self>where
I: IntoIterator<Item = &'a PublicKey>,
Create a new Database struct from a set of trusted root keys that are used to verify
the signed metadata. The signed root metadata must be signed with at least a
root_threshold of the provided root_keys. It is not necessary for the root metadata to
contain these keys.
Sourcepub fn from_trusted_root(
raw_root: &RawSignedMetadata<D, RootMetadata>,
) -> Result<Self>
pub fn from_trusted_root( raw_root: &RawSignedMetadata<D, RootMetadata>, ) -> Result<Self>
Create a new Database struct from a piece of metadata that is assumed to be trusted.
WARNING: This is trust-on-first-use (TOFU) and offers weaker security guarantees than
the related method Database::from_root_with_trusted_keys because this method needs to
deserialize raw_root before we have verified it has been signed properly. This exposes us
to potential parser exploits. This method should only be used if the metadata is loaded from
a trusted source.
Sourcepub fn from_metadata_with_trusted_keys<'a, I>(
metadata_set: &RawSignedMetadataSet<D>,
root_threshold: u32,
root_keys: I,
) -> Result<Self>where
I: IntoIterator<Item = &'a PublicKey>,
pub fn from_metadata_with_trusted_keys<'a, I>(
metadata_set: &RawSignedMetadataSet<D>,
root_threshold: u32,
root_keys: I,
) -> Result<Self>where
I: IntoIterator<Item = &'a PublicKey>,
Create a new Database struct from a set of metadata that is assumed to be trusted. The
signed root metadata in the metadata_set must be signed with at least a root_threshold
of the provided root_keys. It is not necessary for the root metadata to contain these keys.
Sourcepub fn from_metadata_with_trusted_keys_and_start_time<'a, I>(
start_time: &DateTime<Utc>,
metadata_set: &RawSignedMetadataSet<D>,
root_threshold: u32,
root_keys: I,
) -> Result<Self>where
I: IntoIterator<Item = &'a PublicKey>,
pub fn from_metadata_with_trusted_keys_and_start_time<'a, I>(
start_time: &DateTime<Utc>,
metadata_set: &RawSignedMetadataSet<D>,
root_threshold: u32,
root_keys: I,
) -> Result<Self>where
I: IntoIterator<Item = &'a PublicKey>,
Create a new Database struct from a set of metadata that is assumed to be trusted. The
signed root metadata in the metadata_set must be signed with at least a root_threshold
of the provided root_keys. It is not necessary for the root metadata to contain these keys.
Sourcepub fn from_trusted_metadata(
metadata_set: &RawSignedMetadataSet<D>,
) -> Result<Self>
pub fn from_trusted_metadata( metadata_set: &RawSignedMetadataSet<D>, ) -> Result<Self>
Create a new Database struct from a set of metadata that is assumed to be trusted.
WARNING: This is trust-on-first-use (TOFU) and offers weaker security guarantees than
the related method Database::from_metadata_with_trusted_keys because this method needs
to deserialize the root metadata from metadata_set before we have verified it has been
signed properly. This exposes us to potential parser exploits. This method should only be
used if the metadata is loaded from a trusted source.
Sourcepub fn from_trusted_metadata_with_start_time(
metadata_set: &RawSignedMetadataSet<D>,
start_time: &DateTime<Utc>,
) -> Result<Self>
pub fn from_trusted_metadata_with_start_time( metadata_set: &RawSignedMetadataSet<D>, start_time: &DateTime<Utc>, ) -> Result<Self>
Create a new Database struct from a set of metadata that is assumed to be trusted.
WARNING: This is trust-on-first-use (TOFU) and offers weaker security guarantees than
the related method Database::from_metadata_with_trusted_keys because this method needs
to deserialize the root metadata from metadata_set before we have verified it has been
signed properly. This exposes us to potential parser exploits. This method should only be
used if the metadata is loaded from a trusted source.
Sourcepub fn trusted_root(&self) -> &Verified<RootMetadata>
pub fn trusted_root(&self) -> &Verified<RootMetadata>
An immutable reference to the root metadata.
Sourcepub fn trusted_targets(&self) -> Option<&Verified<TargetsMetadata>>
pub fn trusted_targets(&self) -> Option<&Verified<TargetsMetadata>>
An immutable reference to the optional targets metadata.
Sourcepub fn trusted_snapshot(&self) -> Option<&Verified<SnapshotMetadata>>
pub fn trusted_snapshot(&self) -> Option<&Verified<SnapshotMetadata>>
An immutable reference to the optional snapshot metadata.
Sourcepub fn trusted_timestamp(&self) -> Option<&Verified<TimestampMetadata>>
pub fn trusted_timestamp(&self) -> Option<&Verified<TimestampMetadata>>
An immutable reference to the optional timestamp metadata.
Sourcepub fn trusted_delegations(
&self,
) -> &HashMap<MetadataPath, Verified<TargetsMetadata>>
pub fn trusted_delegations( &self, ) -> &HashMap<MetadataPath, Verified<TargetsMetadata>>
An immutable reference to the delegated metadata.
Sourcepub fn update_metadata(
&mut self,
metadata: &RawSignedMetadataSet<D>,
) -> Result<bool>
pub fn update_metadata( &mut self, metadata: &RawSignedMetadataSet<D>, ) -> Result<bool>
Verify and update metadata. Returns true if any of the metadata was updated.
Sourcepub fn update_metadata_with_start_time(
&mut self,
metadata: &RawSignedMetadataSet<D>,
start_time: &DateTime<Utc>,
) -> Result<bool>
pub fn update_metadata_with_start_time( &mut self, metadata: &RawSignedMetadataSet<D>, start_time: &DateTime<Utc>, ) -> Result<bool>
Verify and update metadata. Returns true if any of the metadata was updated.
Sourcepub fn update_root(
&mut self,
raw_root: &RawSignedMetadata<D, RootMetadata>,
) -> Result<()>
pub fn update_root( &mut self, raw_root: &RawSignedMetadata<D, RootMetadata>, ) -> Result<()>
Verify and update the root metadata.
Sourcepub fn update_timestamp(
&mut self,
start_time: &DateTime<Utc>,
raw_timestamp: &RawSignedMetadata<D, TimestampMetadata>,
) -> Result<Option<&Verified<TimestampMetadata>>>
pub fn update_timestamp( &mut self, start_time: &DateTime<Utc>, raw_timestamp: &RawSignedMetadata<D, TimestampMetadata>, ) -> Result<Option<&Verified<TimestampMetadata>>>
Verify and update the timestamp metadata.
Returns a reference to the parsed metadata if the metadata was newer.
Sourcepub fn update_snapshot(
&mut self,
start_time: &DateTime<Utc>,
raw_snapshot: &RawSignedMetadata<D, SnapshotMetadata>,
) -> Result<bool>
pub fn update_snapshot( &mut self, start_time: &DateTime<Utc>, raw_snapshot: &RawSignedMetadata<D, SnapshotMetadata>, ) -> Result<bool>
Verify and update the snapshot metadata.
Sourcepub fn update_targets(
&mut self,
start_time: &DateTime<Utc>,
raw_targets: &RawSignedMetadata<D, TargetsMetadata>,
) -> Result<bool>
pub fn update_targets( &mut self, start_time: &DateTime<Utc>, raw_targets: &RawSignedMetadata<D, TargetsMetadata>, ) -> Result<bool>
Verify and update the targets metadata.
Sourcepub fn update_delegated_targets(
&mut self,
start_time: &DateTime<Utc>,
parent_role: &MetadataPath,
role: &MetadataPath,
raw_delegated_targets: &RawSignedMetadata<D, TargetsMetadata>,
) -> Result<bool>
pub fn update_delegated_targets( &mut self, start_time: &DateTime<Utc>, parent_role: &MetadataPath, role: &MetadataPath, raw_delegated_targets: &RawSignedMetadata<D, TargetsMetadata>, ) -> Result<bool>
Verify and update a delegation metadata.
Sourcepub fn target_description(
&self,
target_path: &TargetPath,
) -> Result<TargetDescription>
pub fn target_description( &self, target_path: &TargetPath, ) -> Result<TargetDescription>
Get a reference to the description needed to verify the target defined by the given
TargetPath. Returns an Error if the target is not defined in the trusted
metadata. This may mean the target exists somewhere in the metadata, but the chain of trust
to that target may be invalid or incomplete.
Sourcepub fn target_description_with_start_time(
&self,
start_time: &DateTime<Utc>,
target_path: &TargetPath,
) -> Result<TargetDescription>
pub fn target_description_with_start_time( &self, start_time: &DateTime<Utc>, target_path: &TargetPath, ) -> Result<TargetDescription>
Get a reference to the description needed to verify the target defined by the given
TargetPath. Returns an Error if the target is not defined in the trusted
metadata. This may mean the target exists somewhere in the metadata, but the chain of trust
to that target may be invalid or incomplete.