Trait cipher::block::BlockModeEncrypt
source · pub trait BlockModeEncrypt: BlockSizeUser + Sized {
// Required method
fn encrypt_with_backend(
&mut self,
f: impl BlockModeEncClosure<BlockSize = Self::BlockSize>,
);
// Provided methods
fn encrypt_block_inout(&mut self, block: InOut<'_, '_, Block<Self>>) { ... }
fn encrypt_blocks_inout(&mut self, blocks: InOutBuf<'_, '_, Block<Self>>) { ... }
fn encrypt_block(&mut self, block: &mut Block<Self>) { ... }
fn encrypt_block_b2b(
&mut self,
in_block: &Block<Self>,
out_block: &mut Block<Self>,
) { ... }
fn encrypt_blocks(&mut self, blocks: &mut [Block<Self>]) { ... }
fn encrypt_blocks_b2b(
&mut self,
in_blocks: &[Block<Self>],
out_blocks: &mut [Block<Self>],
) -> Result<(), NotEqualError> { ... }
fn encrypt_padded_inout<'out, P: Padding<Self::BlockSize>>(
self,
data: InOutBufReserved<'_, 'out, u8>,
) -> Result<&'out [u8], PadError> { ... }
fn encrypt_padded<P: Padding<Self::BlockSize>>(
self,
buf: &mut [u8],
msg_len: usize,
) -> Result<&[u8], PadError> { ... }
fn encrypt_padded_b2b<'a, P: Padding<Self::BlockSize>>(
self,
msg: &[u8],
out_buf: &'a mut [u8],
) -> Result<&'a [u8], PadError> { ... }
fn encrypt_padded_vec<P: Padding<Self::BlockSize>>(
self,
msg: &[u8],
) -> Vec<u8> { ... }
}
Expand description
Encrypt-only functionality for block ciphers and modes with mutable access to self
.
The main use case for this trait is blocks modes, but it also can be used
for hardware cryptographic engines which require &mut self
access to an
underlying hardware peripheral.
Required Methods§
sourcefn encrypt_with_backend(
&mut self,
f: impl BlockModeEncClosure<BlockSize = Self::BlockSize>,
)
fn encrypt_with_backend( &mut self, f: impl BlockModeEncClosure<BlockSize = Self::BlockSize>, )
Encrypt data using backend provided to the rank-2 closure.
Provided Methods§
sourcefn encrypt_block_inout(&mut self, block: InOut<'_, '_, Block<Self>>)
fn encrypt_block_inout(&mut self, block: InOut<'_, '_, Block<Self>>)
Encrypt single inout
block.
sourcefn encrypt_blocks_inout(&mut self, blocks: InOutBuf<'_, '_, Block<Self>>)
fn encrypt_blocks_inout(&mut self, blocks: InOutBuf<'_, '_, Block<Self>>)
Encrypt inout
blocks.
sourcefn encrypt_block(&mut self, block: &mut Block<Self>)
fn encrypt_block(&mut self, block: &mut Block<Self>)
Encrypt single block in-place.
sourcefn encrypt_block_b2b(
&mut self,
in_block: &Block<Self>,
out_block: &mut Block<Self>,
)
fn encrypt_block_b2b( &mut self, in_block: &Block<Self>, out_block: &mut Block<Self>, )
Encrypt in_block
and write result to out_block
.
sourcefn encrypt_blocks(&mut self, blocks: &mut [Block<Self>])
fn encrypt_blocks(&mut self, blocks: &mut [Block<Self>])
Encrypt blocks in-place.
sourcefn encrypt_blocks_b2b(
&mut self,
in_blocks: &[Block<Self>],
out_blocks: &mut [Block<Self>],
) -> Result<(), NotEqualError>
fn encrypt_blocks_b2b( &mut self, in_blocks: &[Block<Self>], out_blocks: &mut [Block<Self>], ) -> Result<(), NotEqualError>
Encrypt blocks buffer-to-buffer.
Returns NotEqualError
if provided in_blocks
and out_blocks
have different lengths.
sourcefn encrypt_padded_inout<'out, P: Padding<Self::BlockSize>>(
self,
data: InOutBufReserved<'_, 'out, u8>,
) -> Result<&'out [u8], PadError>
Available on crate feature block-padding
only.
fn encrypt_padded_inout<'out, P: Padding<Self::BlockSize>>( self, data: InOutBufReserved<'_, 'out, u8>, ) -> Result<&'out [u8], PadError>
block-padding
only.Pad input and encrypt. Returns resulting ciphertext slice.
Returns PadError
if length of output buffer is not sufficient.
sourcefn encrypt_padded<P: Padding<Self::BlockSize>>(
self,
buf: &mut [u8],
msg_len: usize,
) -> Result<&[u8], PadError>
Available on crate feature block-padding
only.
fn encrypt_padded<P: Padding<Self::BlockSize>>( self, buf: &mut [u8], msg_len: usize, ) -> Result<&[u8], PadError>
block-padding
only.Pad input and encrypt in-place. Returns resulting ciphertext slice.
Returns PadError
if length of output buffer is not sufficient.
sourcefn encrypt_padded_b2b<'a, P: Padding<Self::BlockSize>>(
self,
msg: &[u8],
out_buf: &'a mut [u8],
) -> Result<&'a [u8], PadError>
Available on crate feature block-padding
only.
fn encrypt_padded_b2b<'a, P: Padding<Self::BlockSize>>( self, msg: &[u8], out_buf: &'a mut [u8], ) -> Result<&'a [u8], PadError>
block-padding
only.Pad input and encrypt buffer-to-buffer. Returns resulting ciphertext slice.
Returns PadError
if length of output buffer is not sufficient.