Struct BlockBuffer
pub struct BlockBuffer<BS: BlockSizes, K: BufferKind> { /* private fields */ }
Buffer for block processing of data.
Implementations
impl<BS, K: BufferKind> BlockBuffer<BS, K>
where
BS: Add<K::Overhead> + BlockSizes,
Sum<BS, K::Overhead>: ArraySize,
fn serialize(&self) -> SerializedBuffer<BS, K>Serialize buffer into a byte array.
fn deserialize(buf: &SerializedBuffer<BS, K>) -> Result<Self, Error>Deserialize buffer from a byte array.
Errors
If
bufdoes not represent a valid serialization ofBlockBuffer.
impl<BS: BlockSizes> BlockBuffer<BS, Eager>
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 thesuffixbytes. If there is not enough unused space,compresswill be called twice.Panics
If suffix length is bigger than block size.
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.
fn len64_padding_le(&mut self, data_len: u64, compress: impl FnMut(&Array<u8, BS>))Pad message with 0x80, zeros and 64-bit message length using little-endian byte order.
fn len128_padding_be(&mut self, data_len: u128, compress: impl FnMut(&Array<u8, BS>))Pad message with 0x80, zeros and 128-bit message length using big-endian byte order.
impl<BS: BlockSizes, K: BufferKind> BlockBuffer<BS, K>
fn new(buf: &[u8]) -> SelfCreate new buffer from slice.
Panics
If slice length is not valid for used buffer kind.
fn try_new(buf: &[u8]) -> Result<Self, Error>Create new buffer from slice.
Errors
If slice length is not valid for used buffer kind.
fn digest_blocks(&mut self, input: &[u8], compress: impl FnMut(&[Array<u8, BS>]))Digest data in
inputin blocks of sizeBlockSizeusing thecompressfunction, which accepts slice of blocks.fn reset(&mut self)Reset buffer by setting cursor position to zero.
fn pad_with_zeros(&mut self) -> Array<u8, BS>Pad remaining data with zeros and return resulting block.
fn get_pos(&self) -> usizeReturn current cursor position.
fn get_data(&self) -> &[u8]Return slice of data stored inside the buffer.
fn set(&mut self, buf: Array<u8, BS>, pos: usize)Set buffer content and cursor position.
Panics
If
posis bigger or equal to block size.fn size(&self) -> usizeReturn size of the internal buffer in bytes.
fn remaining(&self) -> usizeReturn number of remaining bytes in the internal buffer.
Trait Implementations
impl<BS: BlockSizes, K: BufferKind> Clone for BlockBuffer<BS, K>
fn clone(&self) -> Self
impl<BS: BlockSizes, K: BufferKind> Debug for BlockBuffer<BS, K>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
impl<BS: BlockSizes, K: BufferKind> Default for BlockBuffer<BS, K>
fn default() -> Self
impl<BS: BlockSizes, K: BufferKind> Drop for BlockBuffer<BS, K>
fn drop(&mut self)
impl<BS: BlockSizes, K: BufferKind> Zeroize for BlockBuffer<BS, K>
fn zeroize(&mut self)