pub struct FsVerityHasher<H: FsVerityHashValue, const LG_BLKSZ: u8 = 12> {
layers: Vec<FsVerityLayer<H, LG_BLKSZ>>,
value: Option<H>,
n_bytes: u64,
}Expand description
Incremental fs-verity digest computation.
This hasher allows computing fs-verity digests incrementally by feeding data in chunks. The data must be provided in block-aligned chunks (4KB by default) except for the final chunk which may be smaller.
§Example
ⓘ
use composefs::fsverity::{FsVerityHasher, Sha256HashValue};
let mut hasher = FsVerityHasher::<Sha256HashValue>::new();
hasher.write_all(b"hello world");
let digest = hasher.digest();Fields§
§layers: Vec<FsVerityLayer<H, LG_BLKSZ>>§value: Option<H>§n_bytes: u64Implementations§
Source§impl<H: FsVerityHashValue, const LG_BLKSZ: u8> FsVerityHasher<H, LG_BLKSZ>
impl<H: FsVerityHashValue, const LG_BLKSZ: u8> FsVerityHasher<H, LG_BLKSZ>
Sourcepub const BLOCK_SIZE: usize
pub const BLOCK_SIZE: usize
The block size in bytes used for fs-verity Merkle tree computation.
Sourcepub fn add_block(&mut self, data: &[u8])
pub fn add_block(&mut self, data: &[u8])
Add a block of data to the hasher.
For correct results, data should be provided in block-sized chunks (4KB) except for the final chunk which may be smaller.
fn root_hash(&mut self) -> H
Trait Implementations§
Source§impl<H: Debug + FsVerityHashValue, const LG_BLKSZ: u8> Debug for FsVerityHasher<H, LG_BLKSZ>
impl<H: Debug + FsVerityHashValue, const LG_BLKSZ: u8> Debug for FsVerityHasher<H, LG_BLKSZ>
Source§impl<H: FsVerityHashValue, const LG_BLKSZ: u8> Default for FsVerityHasher<H, LG_BLKSZ>
impl<H: FsVerityHashValue, const LG_BLKSZ: u8> Default for FsVerityHasher<H, LG_BLKSZ>
Auto Trait Implementations§
impl<H, const LG_BLKSZ: u8> Freeze for FsVerityHasher<H, LG_BLKSZ>where
H: Freeze,
impl<H, const LG_BLKSZ: u8> RefUnwindSafe for FsVerityHasher<H, LG_BLKSZ>
impl<H, const LG_BLKSZ: u8> Send for FsVerityHasher<H, LG_BLKSZ>
impl<H, const LG_BLKSZ: u8> Sync for FsVerityHasher<H, LG_BLKSZ>
impl<H, const LG_BLKSZ: u8> Unpin for FsVerityHasher<H, LG_BLKSZ>
impl<H, const LG_BLKSZ: u8> UnwindSafe for FsVerityHasher<H, LG_BLKSZ>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more