pub struct BlockBuffer<BS: BlockSizes, K: BufferKind> {
pub(crate) buffer: MaybeUninit<Array<u8, BS>>,
pub(crate) pos: K::Pos,
}Expand description
Buffer for block processing of data.
Fields§
§buffer: MaybeUninit<Array<u8, BS>>§pos: K::PosImplementations§
Source§impl<BS: BlockSizes, K: BufferKind> BlockBuffer<BS, K>
impl<BS: BlockSizes, K: BufferKind> BlockBuffer<BS, K>
Sourcepub fn digest_blocks(
&mut self,
input: &[u8],
compress: impl FnMut(&[Array<u8, BS>]),
)
pub fn digest_blocks( &mut self, input: &[u8], compress: impl FnMut(&[Array<u8, BS>]), )
Digest data in input in blocks of size BlockSize using
the compress function, which accepts slice of blocks.
Sourcepub fn pad_with_zeros(&mut self) -> Array<u8, BS>
pub fn pad_with_zeros(&mut self) -> Array<u8, BS>
Pad remaining data with zeros and return resulting block.
Sourcepub(crate) unsafe fn set_pos_unchecked(&mut self, pos: usize)
pub(crate) unsafe fn set_pos_unchecked(&mut self, pos: usize)
Set buffer position.
§Safety
Bytes in the range of 0..pos in the buffer field must be properly initialized.
pos must satisfy invariant of buffer kind, i.e. for eager hashes it must be
strictly smaller than block size and for lazy hashes it must be smaller or equal
to block size.
Sourcepub(crate) unsafe fn set_data_unchecked(&mut self, buf: &[u8])
pub(crate) unsafe fn set_data_unchecked(&mut self, buf: &[u8])
Set buffer data.
§Safety
Length of buf must satisfy invariant of buffer kind, i.e. for eager hashes it must be
strictly smaller than block size and for lazy hashes it must be smaller or equal
to block size.
Source§impl<BS, K: BufferKind> BlockBuffer<BS, K>
impl<BS, K: BufferKind> BlockBuffer<BS, K>
Sourcepub fn serialize(&self) -> SerializedBuffer<BS, K>
pub fn serialize(&self) -> SerializedBuffer<BS, K>
Serialize buffer into a byte array.
Sourcepub fn deserialize(buf: &SerializedBuffer<BS, K>) -> Result<Self, Error>
pub fn deserialize(buf: &SerializedBuffer<BS, K>) -> Result<Self, Error>
Deserialize buffer from a byte array.
§Errors
If buf does not represent a valid serialization of BlockBuffer.
Source§impl<BS: BlockSizes> BlockBuffer<BS, Eager>
impl<BS: BlockSizes> BlockBuffer<BS, Eager>
Sourcepub fn digest_pad(
&mut self,
delim: u8,
suffix: &[u8],
compress: impl FnMut(&Array<u8, BS>),
)
pub fn digest_pad( &mut self, delim: u8, suffix: &[u8], compress: impl FnMut(&Array<u8, BS>), )
Compress remaining data after padding it with delim, zeros and
the suffix bytes. If there is not enough unused space, compress
will be called twice.
§Panics
If suffix length is bigger than block size.
Sourcepub fn len64_padding_be(
&mut self,
data_len: u64,
compress: impl FnMut(&Array<u8, BS>),
)
pub fn len64_padding_be( &mut self, data_len: u64, compress: impl FnMut(&Array<u8, BS>), )
Pad message with 0x80, zeros and 64-bit message length using big-endian byte order.