Struct cipher::BlockModeDecryptWrapper [−][src]
pub struct BlockModeDecryptWrapper<M: BlockModeDecrypt, P: Padding<M::BlockSize>> { /* fields omitted */ }
Convinience wrapper around the BlockModeDecrypt
trait, which handles
data buffering and provides slice-based methods.
Implementations
impl<M, P> BlockModeDecryptWrapper<M, P> where
M: BlockModeDecrypt,
P: Padding<M::BlockSize>,
[src]
impl<M, P> BlockModeDecryptWrapper<M, P> where
M: BlockModeDecrypt,
P: Padding<M::BlockSize>,
[src]pub fn decrypt_part<'a>(
&mut self,
ciphertext: &[u8],
out_buf: &'a mut [u8]
) -> Result<&'a [u8], BlockModeError>
[src]
&mut self,
ciphertext: &[u8],
out_buf: &'a mut [u8]
) -> Result<&'a [u8], BlockModeError>
Decrypt part of a ciphertext.
This mehthod MUST be used in conjuction with the decrypt_final
method,
otherwise plaintext will not be properly padded and may be truncated.
The method decrypts ciphertext
, writes the resulting plaintext
into out_buf
, and returns it in the Ok
variant. If a whole message
can not be processed, it caches ciphertext leftovers into inner buffer
for future use.
It’s recommended for out_buf
to be at least one block longer than
data
, otherwise the method can return Err(BlockModeError)
if there is
not enough space for encrypted blocks.
pub fn decrypt_final<'a>(
self,
ciphertext: &[u8],
out_buf: &'a mut [u8]
) -> Result<&'a [u8], BlockModeError>
[src]
self,
ciphertext: &[u8],
out_buf: &'a mut [u8]
) -> Result<&'a [u8], BlockModeError>
Pad and decrypt plaintext.
The method decrypts ciphertext, writes the resulting plaintext into
into out_buf
, and unpads it.
It’s recommended for out_buf
to be at least one block longer than
data
, otherwise the method can return Err(BlockModeError)
if there is
not enough space for encrypted blocks.
Trait Implementations
impl<M, P> FromBlockCipherNonce for BlockModeDecryptWrapper<M, P> where
M: BlockModeDecrypt + FromBlockCipherNonce,
P: Padding<M::BlockSize>,
[src]
impl<M, P> FromBlockCipherNonce for BlockModeDecryptWrapper<M, P> where
M: BlockModeDecrypt + FromBlockCipherNonce,
P: Padding<M::BlockSize>,
[src]type BlockCipher = M::BlockCipher
Block cipher used for initialization.
type NonceSize = M::NonceSize
Nonce size in bytes.
fn from_block_cipher_nonce(
cipher: Self::BlockCipher,
nonce: &GenericArray<u8, Self::NonceSize>
) -> Self
[src]
cipher: Self::BlockCipher,
nonce: &GenericArray<u8, Self::NonceSize>
) -> Self
Auto Trait Implementations
impl<M, P> RefUnwindSafe for BlockModeDecryptWrapper<M, P> where
M: RefUnwindSafe,
P: RefUnwindSafe,
<<M as BlockMode>::BlockSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<M, P> RefUnwindSafe for BlockModeDecryptWrapper<M, P> where
M: RefUnwindSafe,
P: RefUnwindSafe,
<<M as BlockMode>::BlockSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<M, P> Send for BlockModeDecryptWrapper<M, P> where
M: Send,
P: Send,
impl<M, P> Send for BlockModeDecryptWrapper<M, P> where
M: Send,
P: Send,
impl<M, P> Sync for BlockModeDecryptWrapper<M, P> where
M: Sync,
P: Sync,
impl<M, P> Sync for BlockModeDecryptWrapper<M, P> where
M: Sync,
P: Sync,
impl<M, P> Unpin for BlockModeDecryptWrapper<M, P> where
M: Unpin,
P: Unpin,
<<M as BlockMode>::BlockSize as ArrayLength<u8>>::ArrayType: Unpin,
impl<M, P> Unpin for BlockModeDecryptWrapper<M, P> where
M: Unpin,
P: Unpin,
<<M as BlockMode>::BlockSize as ArrayLength<u8>>::ArrayType: Unpin,
impl<M, P> UnwindSafe for BlockModeDecryptWrapper<M, P> where
M: UnwindSafe,
P: UnwindSafe,
<<M as BlockMode>::BlockSize as ArrayLength<u8>>::ArrayType: UnwindSafe,
impl<M, P> UnwindSafe for BlockModeDecryptWrapper<M, P> where
M: UnwindSafe,
P: UnwindSafe,
<<M as BlockMode>::BlockSize as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
impl<T> FromKeyNonce for T where
T: FromBlockCipherNonce,
<T as FromBlockCipherNonce>::BlockCipher: FromKey,
[src]
impl<T> FromKeyNonce for T where
T: FromBlockCipherNonce,
<T as FromBlockCipherNonce>::BlockCipher: FromKey,
[src]type KeySize = <<T as FromBlockCipherNonce>::BlockCipher as FromKey>::KeySize
Key size in bytes.
type NonceSize = <T as FromBlockCipherNonce>::NonceSize
Nonce size in bytes.
pub fn new(
&GenericArray<u8, <T as FromKeyNonce>::KeySize>,
&GenericArray<u8, <T as FromKeyNonce>::NonceSize>
) -> T
[src]
&GenericArray<u8, <T as FromKeyNonce>::KeySize>,
&GenericArray<u8, <T as FromKeyNonce>::NonceSize>
) -> T
fn new_from_slices(key: &[u8], nonce: &[u8]) -> Result<Self, InvalidLength>
[src]
fn generate_key(
rng: impl CryptoRng + RngCore
) -> GenericArray<u8, Self::KeySize>
[src]
rng: impl CryptoRng + RngCore
) -> GenericArray<u8, Self::KeySize>
fn generate_nonce(
rng: impl CryptoRng + RngCore
) -> GenericArray<u8, Self::NonceSize>
[src]
rng: impl CryptoRng + RngCore
) -> GenericArray<u8, Self::NonceSize>
fn generate_key_nonce(
rng: impl CryptoRng + RngCore
) -> (GenericArray<u8, Self::KeySize>, GenericArray<u8, Self::NonceSize>)
[src]
rng: impl CryptoRng + RngCore
) -> (GenericArray<u8, Self::KeySize>, GenericArray<u8, Self::NonceSize>)
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self