Struct fs_verity::FsVerityDigest
source · pub struct FsVerityDigest<D = Sha256, S = [u8; 0]>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,{ /* private fields */ }
Expand description
Calculates an fs-verity measurement over the input data.
Implementations§
source§impl<D> FsVerityDigest<D>where
D: InnerHash,
impl<D> FsVerityDigest<D>where D: InnerHash,
source§impl<D, S> FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
sourcepub fn new_with_salt(salt: S) -> Self
pub fn new_with_salt(salt: S) -> Self
Creates a new instance of FsVerityDigest
with the given salt. The salt will be mixed
into every internal hash calculation.
Note that the current Linux kernel does not allow you to read back the salt used for a particular verity-protected file, which may be a problem depending on your use case.
This will panic if the salt is longer than MAX_SALT_SIZE
bytes.
sourcepub fn new_with_salt_and_block_size(salt: S, block_size: usize) -> Self
pub fn new_with_salt_and_block_size(salt: S, block_size: usize) -> Self
Creates a new instance of FsVerityDigest
with the given salt and a custom block size.
This will panic if the salt is longer than MAX_SALT_SIZE
bytes.
If you want to be compatible with the Linux kernel implementation it is not a good idea
to change the block_size
, as the kernel currently requires it to be equal to the system
page size, which is 4096 on most architectures. Some modern 64 bit ARM systems have a
64kB page size though.
The block size must be a power of two, and it must be at least twice the size of the digests produced by the inner hash algorithm. This code will panic otherwise.
sourcepub fn inner_hash_algorithm(&self) -> InnerHashAlgorithm
pub fn inner_hash_algorithm(&self) -> InnerHashAlgorithm
Returns the InnerHashAlgorithm
value corresponding to the used inner hash algorithm.
Trait Implementations§
source§impl<D, S> BlockSizeUser for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> BlockSizeUser for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
NOTE: This reports the base hash function’s input block size, not the Merkle tree block size you
specify when creating the FsVerityDigest
!
While this may be confusing, it is probably more faithful to the purpose of the BlockInput
trait.
We don’t need to buffer an entire Merkle tree block in memory; data can be efficiently processed
in chunks of the base hash’s input block size.
§fn block_size() -> usize
fn block_size() -> usize
source§impl<D, S> Clone for FsVerityDigest<D, S>where
D: InnerHash + Clone,
S: AsRef<[u8]> + Clone + Default + Clone,
impl<D, S> Clone for FsVerityDigest<D, S>where D: InnerHash + Clone, S: AsRef<[u8]> + Clone + Default + Clone,
source§impl<D, S> Default for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> Default for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
source§impl<D: InnerHash + 'static, S: AsRef<[u8]> + Clone + Default + 'static> DynFsVerityDigest for FsVerityDigest<D, S>
impl<D: InnerHash + 'static, S: AsRef<[u8]> + Clone + Default + 'static> DynFsVerityDigest for FsVerityDigest<D, S>
fn inner_hash_algorithm(&self) -> InnerHashAlgorithm
source§impl<D, S> FixedOutput for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> FixedOutput for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
source§fn finalize_into(self, out: &mut Output<Self>)
fn finalize_into(self, out: &mut Output<Self>)
§fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>
fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>
source§impl<D, S> FixedOutputReset for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> FixedOutputReset for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
source§fn finalize_into_reset(&mut self, out: &mut Output<Self>)
fn finalize_into_reset(&mut self, out: &mut Output<Self>)
§fn finalize_fixed_reset(&mut self) -> GenericArray<u8, Self::OutputSize>
fn finalize_fixed_reset(&mut self) -> GenericArray<u8, Self::OutputSize>
source§impl<D, S> OutputSizeUser for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> OutputSizeUser for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
§type OutputSize = <D as OutputSizeUser>::OutputSize
type OutputSize = <D as OutputSizeUser>::OutputSize
§fn output_size() -> usize
fn output_size() -> usize
source§impl<D, S> Reset for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> Reset for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
Resets to a blank state, but with the same Merkle tree block size and salt
source§impl<D, S> Update for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> Update for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
source§impl<D, S> Write for FsVerityDigest<D, S>where
D: InnerHash,
S: AsRef<[u8]> + Clone + Default,
impl<D, S> Write for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)