pub enum FsVerityHasher {
Sha256(FsVerityHasherOptions),
Sha512(FsVerityHasherOptions),
}
Expand description
FsVerityHasher
is used by fsverity to construct merkle trees for verity-enabled files.
FsVerityHasher
is parameterized by a salt and a block size.
Variants§
Sha256(FsVerityHasherOptions)
Sha512(FsVerityHasherOptions)
Implementations§
Source§impl FsVerityHasher
impl FsVerityHasher
pub fn block_size(&self) -> usize
pub fn hash_size(&self) -> usize
pub fn fsverity(&self) -> bool
Sourcepub fn hash_block(&self, block: &[u8]) -> Vec<u8> ⓘ
pub fn hash_block(&self, block: &[u8]) -> Vec<u8> ⓘ
Computes the MerkleTree digest from a block
of data.
A MerkleTree digest is a hash of a block of data. The block will be zero filled if its
len is less than the block_size, except for when the first data block is completely empty.
If salt.len() > 0
, we prepend the block with the salt which itself is zero filled up
to the padding.
§Panics
Panics if block.len()
exceeds self.block_size()
.
Sourcepub fn hash_hashes(&self, hashes: &[Vec<u8>]) -> Vec<u8> ⓘ
pub fn hash_hashes(&self, hashes: &[Vec<u8>]) -> Vec<u8> ⓘ
Computes a MerkleTree digest from a block of hashes
.
Like hash_block
, hash_hashes
zero fills incomplete buffers and prepends the digests
with a salt, which is zero filled up to the padding.
§Panics
Panics if any of the following conditions are met:
hashes.len()
is 0hashes.len() > self.block_size() / digest length
Trait Implementations§
Source§impl Clone for FsVerityHasher
impl Clone for FsVerityHasher
Source§fn clone(&self) -> FsVerityHasher
fn clone(&self) -> FsVerityHasher
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more