[][src]Trait block_modes::BlockMode

pub trait BlockMode<C: BlockCipher, P: Padding>: Sized {
    fn new(
        cipher: C,
        iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>
    ) -> Self;
fn encrypt_blocks(
        &mut self,
        blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
    );
fn decrypt_blocks(
        &mut self,
        blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
    ); fn new_fix(
        key: &GenericArray<u8, <C as BlockCipher>::KeySize>,
        iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>
    ) -> Self { ... }
fn new_var(key: &[u8], iv: &[u8]) -> Result<Self, InvalidKeyIvLength> { ... }
fn encrypt(
        self,
        buffer: &mut [u8],
        pos: usize
    ) -> Result<&[u8], BlockModeError> { ... }
fn decrypt(self, buffer: &mut [u8]) -> Result<&[u8], BlockModeError> { ... }
fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8> { ... }
fn decrypt_vec(self, ciphertext: &[u8]) -> Result<Vec<u8>, 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.

Required methods

fn new(cipher: C, iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>) -> Self

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

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

Encrypt blocks of data

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

Decrypt blocks of data

Loading content...

Provided methods

fn new_fix(
    key: &GenericArray<u8, <C as BlockCipher>::KeySize>,
    iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>
) -> Self

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

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

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

Returns an error if key or IV have unsupported length.

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

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).

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

Decrypt message in-place.

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

Important traits for Vec<u8>
fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8>

Encrypt message and store result in vector.

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

Encrypt message and store result in vector.

Loading content...

Implementors

impl<C: BlockCipher, P: Padding> BlockMode<C, P> for Cbc<C, P>[src]

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

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

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

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

Important traits for Vec<u8>
fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8>[src]

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

impl<C: BlockCipher, P: Padding> BlockMode<C, P> for Ecb<C, P>[src]

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

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

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

Important traits for Vec<u8>
fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8>[src]

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

impl<C: BlockCipher, P: Padding> BlockMode<C, P> for Pcbc<C, P>[src]

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

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

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

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

Important traits for Vec<u8>
fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8>[src]

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

Loading content...