Trait block_padding::Padding[][src]

pub trait Padding {
    fn pad_block(block: &mut [u8], pos: usize) -> Result<(), PadError>;
fn unpad(data: &[u8]) -> Result<&[u8], UnpadError>; fn pad(
        buf: &mut [u8],
        pos: usize,
        block_size: usize
    ) -> Result<&mut [u8], PadError> { ... } }

Trait for padding messages divided into blocks

Required Methods

Pads block filled with data up to pos.

pos should be inside of the block and block must not be full, i.e. pos < block.len() must be true. Otherwise method will return PadError. Some potentially irreversible padding schemes can allow padding of the full block, in this case aforementioned condition is relaxed to pos <= block.len().

Unpad given data by truncating it according to the used padding. In case of the malformed padding will return UnpadError

Provided Methods

Pads message with length pos in the provided buffer.

&buf[..pos] is percieved as the message, buffer must contain at least one block of leftover space, i.e. buf.len() - pos >= block_size must be true. Otherwise method will return PadError.

Implementors