/// 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.
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.
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 .
pub fn from_trusted_root(raw_root: &RawSignedMetadata<D, RootMetadata>) -> Result<Self> {
        let verified_root = {
            // **WARNING**: By deserializing the metadata before verification, we are exposing us
            // to parser exploits.
            let unverified_root = raw_root.parse_untrusted()?.assume_valid()?;
            // Make sure the root signed itself.
            let verified_root = verify::verify_signatures(
                raw_root,
                unverified_root.root().threshold(),
                unverified_root.root_keys(),
            )?;
            verified_root
        };
        Ok(Database {
            trusted_root: verified_root,
            trusted_snapshot: None,
            trusted_targets: None,
            trusted_timestamp: None,
            trusted_delegations: HashMap::new(),
            interchange: PhantomData,
        })
    }
pub fn from_trusted_root ( raw_root : & RawSignedMetadata < D , RootMetadata > ) -> Result < Self > { let verified_root = { // **WARNING**: By deserializing the metadata before verification, we are exposing us // to parser exploits. let unverified_root = raw_root . parse_untrusted ( ) ? . assume_valid ( ) ? ; // Make sure the root signed itself. let verified_root = verify :: verify_signatures ( raw_root , unverified_root . root ( ) . threshold ( ) , unverified_root . root_keys ( ) , ) ? ; verified_root } ; Ok ( Database { trusted_root : verified_root , trusted_snapshot : None , trusted_targets : None , trusted_timestamp : None , trusted_delegations : HashMap :: new ( ) , interchange : PhantomData , } ) }
Create a new [`Database`] struct from a piece of metadata that is assumed to be trusted.
Create a new [ ` Database ` ] struct from a piece of metadata that is assumed to be trusted .
raw_root
&RawSignedMetadata<D, RootMetadata>