Struct block_buffer::BlockBuffer
source · pub struct BlockBuffer<BS: BlockSizes, K: BufferKind> { /* private fields */ }
Expand description
Buffer for block processing of data.
Implementations§
source§impl<BS: BlockSizes, K: BufferKind> BlockBuffer<BS, K>
impl<BS: BlockSizes, K: BufferKind> BlockBuffer<BS, K>
sourcepub fn try_new(buf: &[u8]) -> Result<Self, Error>
pub fn try_new(buf: &[u8]) -> Result<Self, Error>
Create new buffer from slice.
Returns an error if slice length is not valid for used buffer kind.
sourcepub fn digest_blocks(
&mut self,
input: &[u8],
compress: impl FnMut(&[Block<Self>])
)
pub fn digest_blocks( &mut self, input: &[u8], compress: impl FnMut(&[Block<Self>]) )
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) -> Block<Self>
pub fn pad_with_zeros(&mut self) -> Block<Self>
Pad remaining data with zeros and return resulting block.
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(&Block<Self>)
)
pub fn digest_pad( &mut self, delim: u8, suffix: &[u8], compress: impl FnMut(&Block<Self>) )
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(&Block<Self>)
)
pub fn len64_padding_be( &mut self, data_len: u64, compress: impl FnMut(&Block<Self>) )
Pad message with 0x80, zeros and 64-bit message length using big-endian byte order.
sourcepub fn len64_padding_le(
&mut self,
data_len: u64,
compress: impl FnMut(&Block<Self>)
)
pub fn len64_padding_le( &mut self, data_len: u64, compress: impl FnMut(&Block<Self>) )
Pad message with 0x80, zeros and 64-bit message length using little-endian byte order.
sourcepub fn len128_padding_be(
&mut self,
data_len: u128,
compress: impl FnMut(&Block<Self>)
)
pub fn len128_padding_be( &mut self, data_len: u128, compress: impl FnMut(&Block<Self>) )
Pad message with 0x80, zeros and 128-bit message length using big-endian byte order.
sourcepub fn deserialize(buffer: &Block<Self>) -> Result<Self, Error>
pub fn deserialize(buffer: &Block<Self>) -> Result<Self, Error>
Deserialize buffer from a byte array.