Trait block_modes::BlockMode [−][src]
pub trait BlockMode<C: BlockCipher, P: Padding>: Sized { type IvSize: ArrayLength<u8>; fn new(cipher: C, iv: &GenericArray<u8, Self::IvSize>) -> 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 NewBlockCipher>::KeySize>,
iv: &GenericArray<u8, Self::IvSize>
) -> Self
where
C: NewBlockCipher, { ... } fn new_from_slices(
key: &[u8],
iv: &[u8]
) -> Result<Self, InvalidKeyIvLength>
where
C: NewBlockCipher, { ... } 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.
Associated Types
Loading content...Required methods
fn new(cipher: C, iv: &GenericArray<u8, Self::IvSize>) -> Self
[src]
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>]
)
[src]
&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>]
)
[src]
&mut self,
blocks: &mut [GenericArray<u8, <C as BlockCipher>::BlockSize>]
)
Decrypt blocks of data
Provided methods
fn new_fix(
key: &GenericArray<u8, <C as NewBlockCipher>::KeySize>,
iv: &GenericArray<u8, Self::IvSize>
) -> Self where
C: NewBlockCipher,
[src]
key: &GenericArray<u8, <C as NewBlockCipher>::KeySize>,
iv: &GenericArray<u8, Self::IvSize>
) -> Self where
C: NewBlockCipher,
Create a new block mode instance from fixed sized key and IV.
fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidKeyIvLength> where
C: NewBlockCipher,
[src]
C: NewBlockCipher,
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>
[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)
.
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.
fn encrypt_vec(self, plaintext: &[u8]) -> Vec<u8>ⓘ
[src]
Encrypt message and store result in vector.
fn decrypt_vec(self, ciphertext: &[u8]) -> Result<Vec<u8>, BlockModeError>
[src]
Encrypt message and store result in vector.
Implementors
impl<C, P> BlockMode<C, P> for Cbc<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
[src]
impl<C, P> BlockMode<C, P> for Cbc<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
[src]type IvSize = C::BlockSize
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>]
)
impl<C, P> BlockMode<C, P> for Cfb8<C, P> where
C: BlockCipher + BlockEncrypt,
P: Padding,
[src]
impl<C, P> BlockMode<C, P> for Cfb8<C, P> where
C: BlockCipher + BlockEncrypt,
P: Padding,
[src]type IvSize = C::BlockSize
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>]
)
impl<C, P> BlockMode<C, P> for Cfb<C, P> where
C: BlockCipher + BlockEncrypt,
P: Padding,
[src]
impl<C, P> BlockMode<C, P> for Cfb<C, P> where
C: BlockCipher + BlockEncrypt,
P: Padding,
[src]type IvSize = C::BlockSize
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>]
)
impl<C, P> BlockMode<C, P> for Ecb<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
[src]
impl<C, P> BlockMode<C, P> for Ecb<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
[src]type IvSize = U0
fn new(cipher: C, _iv: &GenericArray<u8, U0>) -> Self
[src]
fn new_from_slices(key: &[u8], _iv: &[u8]) -> Result<Self, InvalidKeyIvLength> where
C: NewBlockCipher,
[src]
C: NewBlockCipher,
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>]
)
impl<C, P> BlockMode<C, P> for Ige<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
C::BlockSize: Add,
Sum<<C as BlockCipher>::BlockSize, <C as BlockCipher>::BlockSize>: ArrayLength<u8>,
[src]
impl<C, P> BlockMode<C, P> for Ige<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
C::BlockSize: Add,
Sum<<C as BlockCipher>::BlockSize, <C as BlockCipher>::BlockSize>: ArrayLength<u8>,
[src]type IvSize = Sum<<C as BlockCipher>::BlockSize, <C as BlockCipher>::BlockSize>
fn new(cipher: C, iv: &GenericArray<u8, Self::IvSize>) -> 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>]
)
impl<C, P> BlockMode<C, P> for Ofb<C, P> where
C: BlockCipher + BlockEncrypt,
P: Padding,
[src]
impl<C, P> BlockMode<C, P> for Ofb<C, P> where
C: BlockCipher + BlockEncrypt,
P: Padding,
[src]type IvSize = C::BlockSize
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>]
)
impl<C, P> BlockMode<C, P> for Pcbc<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
[src]
impl<C, P> BlockMode<C, P> for Pcbc<C, P> where
C: BlockCipher + BlockEncrypt + BlockDecrypt,
P: Padding,
[src]type IvSize = C::BlockSize
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>]
)