block_padding

Trait Padding

Source
pub trait Padding<BlockSize: ArrayLength<u8>> {
    const TYPE: PadType;

    // Required methods
    fn pad(block: &mut Block<BlockSize>, pos: usize);
    fn unpad(block: &Block<BlockSize>) -> Result<&[u8], UnpadError>;

    // Provided method
    fn unpad_blocks(blocks: &[Block<BlockSize>]) -> Result<&[u8], UnpadError> { ... }
}
Expand description

Trait for padding messages divided into blocks

Required Associated Constants§

Source

const TYPE: PadType

Padding type

Required Methods§

Source

fn pad(block: &mut Block<BlockSize>, pos: usize)

Pads block filled with data up to pos (i.e length of a message stored in the block is equal to pos).

§Panics

If pos is bigger than BlockSize. Most padding algorithms also panic if they are equal.

Source

fn unpad(block: &Block<BlockSize>) -> Result<&[u8], UnpadError>

Unpad data in the block.

Returns Err(UnpadError) if the block contains malformed padding.

Provided Methods§

Source

fn unpad_blocks(blocks: &[Block<BlockSize>]) -> Result<&[u8], UnpadError>

Unpad data in the blocks.

Returns Err(UnpadError) if the block contains malformed padding.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, B: ArrayLength<u8>> Padding<B> for T
where T: RawPadding,

Source§

const TYPE: PadType = T::TYPE