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,

source

pub fn new() -> Self

Creates a new instance of FsVerityDigest with an empty salt.

This is probably what you want.

source§

impl<D, S> FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,

source

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.

source

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.

source

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,

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.

§

type BlockSize = <D as BlockSizeUser>::BlockSize

Equal to the inner hash algorithm’s block size.

§

fn block_size() -> usize

Return block size in bytes.
source§

impl<D, S> Clone for FsVerityDigest<D, S>where D: InnerHash + Clone, S: AsRef<[u8]> + Clone + Default + Clone,

source§

fn clone(&self) -> FsVerityDigest<D, S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<D, S> Default for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<D: InnerHash + 'static, S: AsRef<[u8]> + Clone + Default + 'static> DynFsVerityDigest for FsVerityDigest<D, S>

source§

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>)

Consume value and write result into provided array.
§

fn finalize_fixed(self) -> GenericArray<u8, Self::OutputSize>

Retrieve result and consume the hasher instance.
source§

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>)

Write result into provided array and reset the hasher state.
§

fn finalize_fixed_reset(&mut self) -> GenericArray<u8, Self::OutputSize>

Retrieve result and reset the hasher state.
source§

impl<D, S> OutputSizeUser for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,

§

type OutputSize = <D as OutputSizeUser>::OutputSize

Size of the output in bytes.
§

fn output_size() -> usize

Return output size in bytes.
source§

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§

fn reset(&mut self)

Reset state to its initial value.
source§

impl<D, S> Update for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,

source§

fn update(&mut self, data: &[u8])

Update state using the provided data.
§

fn chain(self, data: impl AsRef<[u8]>) -> Selfwhere Self: Sized,

Digest input data in a chained manner.
source§

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>

Write a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
source§

impl<D, S> HashMarker for FsVerityDigest<D, S>where D: InnerHash, S: AsRef<[u8]> + Clone + Default,

Auto Trait Implementations§

§

impl<D, S> RefUnwindSafe for FsVerityDigest<D, S>where D: RefUnwindSafe, S: RefUnwindSafe,

§

impl<D, S> Send for FsVerityDigest<D, S>where D: Send, S: Send,

§

impl<D, S> Sync for FsVerityDigest<D, S>where D: Sync, S: Sync,

§

impl<D, S> Unpin for FsVerityDigest<D, S>where D: Unpin, S: Unpin,

§

impl<D, S> UnwindSafe for FsVerityDigest<D, S>where D: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<D> Digest for Dwhere D: FixedOutput + Default + Update + HashMarker,

§

fn new() -> D

Create new hasher instance.
§

fn new_with_prefix(data: impl AsRef<[u8]>) -> Dwhere D: Default,

Create new hasher instance which has processed the provided data.
§

fn update(&mut self, data: impl AsRef<[u8]>)

Process data, updating the internal state.
§

fn chain_update(self, data: impl AsRef<[u8]>) -> D

Process input data in a chained manner.
§

fn finalize(self) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize>

Retrieve result and consume hasher instance.
§

fn finalize_into( self, out: &mut GenericArray<u8, <D as OutputSizeUser>::OutputSize> )

Write result into provided array and consume the hasher instance.
§

fn finalize_reset( &mut self ) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize>where D: FixedOutputReset,

Retrieve result and reset hasher instance.
§

fn finalize_into_reset( &mut self, out: &mut GenericArray<u8, <D as OutputSizeUser>::OutputSize> )where D: FixedOutputReset,

Write result into provided array and reset the hasher instance.
§

fn reset(&mut self)where D: Reset,

Reset hasher instance to its initial state.
§

fn output_size() -> usize

Get output size of the hasher
§

fn digest( data: impl AsRef<[u8]> ) -> GenericArray<u8, <D as OutputSizeUser>::OutputSize>

Compute hash of data.
§

impl<D> DynDigest for Dwhere D: Update + FixedOutputReset + Reset + Clone + 'static,

§

fn update(&mut self, data: &[u8])

Digest input data. Read more
§

fn finalize_reset(&mut self) -> Box<[u8], Global>

Retrieve result and reset hasher instance
§

fn finalize(self: Box<D, Global>) -> Box<[u8], Global>

Retrieve result and consume boxed hasher instance
§

fn finalize_into(self, buf: &mut [u8]) -> Result<(), InvalidBufferSize>

Write result into provided array and consume the hasher instance. Read more
§

fn finalize_into_reset( &mut self, buf: &mut [u8] ) -> Result<(), InvalidBufferSize>

Write result into provided array and reset the hasher instance. Read more
§

fn reset(&mut self)

Reset hasher instance to its initial state.
§

fn output_size(&self) -> usize

Get output size of the hasher
§

fn box_clone(&self) -> Box<dyn DynDigest + 'static, Global>

Clone hasher state into a boxed trait object
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoResult<T> for T

§

type Err = Infallible

source§

fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.