Trait gost_modes::BlockMode[][src]

pub trait BlockMode<C, P> where
    C: BlockCipher + NewBlockCipher,
    P: Padding, 
{ type IvSize: ArrayLength<u8>; pub fn new(cipher: C, iv: &GenericArray<u8, Self::IvSize>) -> Self;
pub fn encrypt_blocks(
        &mut self,
        blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
    );
pub fn decrypt_blocks(
        &mut self,
        blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
    ); pub fn new_fix(
        key: &GenericArray<u8, <C as NewBlockCipher>::KeySize>,
        iv: &GenericArray<u8, Self::IvSize>
    ) -> Self { ... }
pub fn new_from_slices(
        key: &[u8],
        iv: &[u8]
    ) -> Result<Self, InvalidKeyIvLength> { ... }
pub fn encrypt(
        self,
        buffer: &mut [u8],
        pos: usize
    ) -> Result<&[u8], BlockModeError> { ... }
pub fn decrypt(self, buffer: &mut [u8]) -> Result<&[u8], BlockModeError> { ... }
pub fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8, Global> { ... }
pub fn decrypt_vec(
        self,
        ciphertext: &[u8]
    ) -> Result<Vec<u8, Global>, BlockModeError> { ... } }

Trait for a block cipher mode of operation that is used to apply a block cipher operation to input data to transform it into a variable-length output message.

Associated Types

type IvSize: ArrayLength<u8>[src]

Initialization Vector size.

Loading content...

Required methods

pub fn new(cipher: C, iv: &GenericArray<u8, Self::IvSize>) -> Self[src]

Create a new block mode instance from initialized block cipher and IV.

pub fn encrypt_blocks(
    &mut self,
    blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]

Encrypt blocks of data

pub fn decrypt_blocks(
    &mut self,
    blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]

Decrypt blocks of data

Loading content...

Provided methods

pub fn new_fix(
    key: &GenericArray<u8, <C as NewBlockCipher>::KeySize>,
    iv: &GenericArray<u8, Self::IvSize>
) -> Self
[src]

Create a new block mode instance from fixed sized key and IV.

pub fn new_from_slices(
    key: &[u8],
    iv: &[u8]
) -> Result<Self, InvalidKeyIvLength>
[src]

Create a new block mode instance from variable size key and IV.

Returns an error if key or IV have unsupported length.

pub fn encrypt(
    self,
    buffer: &mut [u8],
    pos: usize
) -> Result<&[u8], BlockModeError>
[src]

Encrypt message in-place.

&buffer[..pos] is used as a message and &buffer[pos..] as a reserved space for padding. The padding space should be big enough for padding, otherwise method will return Err(BlockModeError).

pub fn decrypt(self, buffer: &mut [u8]) -> Result<&[u8], BlockModeError>[src]

Decrypt message in-place.

Returns an error if buffer length is not multiple of block size and if after decoding message has malformed padding.

pub fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8, Global>[src]

Encrypt message and store result in vector.

pub fn decrypt_vec(
    self,
    ciphertext: &[u8]
) -> Result<Vec<u8, Global>, BlockModeError>
[src]

Encrypt message and store result in vector.

Loading content...

Implementations on Foreign Types

impl<C, P> BlockMode<C, P> for Ige<C, P> where
    C: BlockCipher + NewBlockCipher + BlockEncrypt + BlockDecrypt,
    P: Padding,
    <C as BlockCipher>::BlockSize: Add<<C as BlockCipher>::BlockSize>,
    <<C as BlockCipher>::BlockSize as Add<<C as BlockCipher>::BlockSize>>::Output: ArrayLength<u8>, 
[src]

type IvSize = <<C as BlockCipher>::BlockSize as Add<<C as BlockCipher>::BlockSize>>::Output

impl<C, P> BlockMode<C, P> for Pcbc<C, P> where
    C: BlockCipher + BlockEncrypt + BlockDecrypt + NewBlockCipher,
    P: Padding, 
[src]

type IvSize = <C as BlockCipher>::BlockSize

impl<C, P> BlockMode<C, P> for Ofb<C, P> where
    C: BlockCipher + BlockEncrypt + NewBlockCipher,
    P: Padding, 
[src]

type IvSize = <C as BlockCipher>::BlockSize

impl<C, P> BlockMode<C, P> for Cfb8<C, P> where
    C: BlockCipher + BlockEncrypt + NewBlockCipher,
    P: Padding, 
[src]

type IvSize = <C as BlockCipher>::BlockSize

impl<C, P> BlockMode<C, P> for Cfb<C, P> where
    C: BlockCipher + BlockEncrypt + NewBlockCipher,
    P: Padding, 
[src]

type IvSize = <C as BlockCipher>::BlockSize

impl<C, P> BlockMode<C, P> for Cbc<C, P> where
    C: BlockCipher + BlockEncrypt + BlockDecrypt + NewBlockCipher,
    P: Padding, 
[src]

type IvSize = <C as BlockCipher>::BlockSize

Loading content...

Implementors

impl<C, P> BlockMode<C, P> for Ecb<C, P> where
    C: BlockCipher + BlockEncrypt + BlockDecrypt + NewBlockCipher,
    P: Padding, 
[src]

type IvSize = UTerm

impl<C, P, Z> BlockMode<C, P> for GostCbc<C, P, Z> where
    C: BlockCipher + BlockEncrypt + BlockDecrypt + NewBlockCipher,
    C::BlockSize: IsLessOrEqual<U255>,
    Z: ArrayLength<Block<C>> + Unsigned + Mul<C::BlockSize> + IsGreater<U0> + IsLessOrEqual<U255>,
    Prod<Z, C::BlockSize>: ArrayLength<u8>,
    P: Padding, 
[src]

type IvSize = Prod<Z, C::BlockSize>

Loading content...