[−][src]Trait block_modes::BlockMode
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>]
)
&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>]
)
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
Decrypt blocks of data
Provided methods
fn new_fix(
key: &GenericArray<u8, <C as BlockCipher>::KeySize>,
iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>
) -> Self
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.
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.
Implementors
impl<C: BlockCipher, P: Padding> BlockMode<C, P> for Cbc<C, P>
[src]
fn new(cipher: C, iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>) -> Self
[src]
fn encrypt_blocks(
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
fn decrypt_blocks(
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]
&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
[src]
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>
[src]
fn encrypt(self, buffer: &mut [u8], pos: usize) -> Result<&[u8], BlockModeError>
[src]
fn decrypt(self, buffer: &mut [u8]) -> Result<&[u8], BlockModeError>
[src]
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(cipher: C, _iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>) -> Self
[src]
fn new_var(key: &[u8], _iv: &[u8]) -> Result<Self, InvalidKeyIvLength>
[src]
fn encrypt_blocks(
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
fn decrypt_blocks(
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]
&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
[src]
key: &GenericArray<u8, <C as BlockCipher>::KeySize>,
iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>
) -> Self
fn encrypt(self, buffer: &mut [u8], pos: usize) -> Result<&[u8], BlockModeError>
[src]
fn decrypt(self, buffer: &mut [u8]) -> Result<&[u8], BlockModeError>
[src]
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(cipher: C, iv: &GenericArray<u8, C::BlockSize>) -> Self
[src]
fn encrypt_blocks(
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
fn decrypt_blocks(
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
[src]
&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
[src]
key: &GenericArray<u8, <C as BlockCipher>::KeySize>,
iv: &GenericArray<u8, <C as BlockCipher>::BlockSize>
) -> Self