#[non_exhaustive]pub enum Cipher {
None,
Aes128Cbc,
Aes192Cbc,
Aes256Cbc,
Aes128Ctr,
Aes192Ctr,
Aes256Ctr,
Aes128Gcm,
Aes256Gcm,
ChaCha20Poly1305,
TDesCbc,
}
Expand description
Cipher algorithms.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
None
No cipher.
Aes128Cbc
AES-128 in cipher block chaining (CBC) mode.
Aes192Cbc
AES-192 in cipher block chaining (CBC) mode.
Aes256Cbc
AES-256 in cipher block chaining (CBC) mode.
Aes128Ctr
AES-128 in counter (CTR) mode.
Aes192Ctr
AES-192 in counter (CTR) mode.
Aes256Ctr
AES-256 in counter (CTR) mode.
Aes128Gcm
AES-128 in Galois/Counter Mode (GCM).
Aes256Gcm
AES-256 in Galois/Counter Mode (GCM).
ChaCha20Poly1305
ChaCha20-Poly1305
TDesCbc
TripleDES in block chaining (CBC) mode
Implementations§
Source§impl Cipher
impl Cipher
Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
Get the string identifier which corresponds to this algorithm.
Sourcepub fn key_and_iv_size(self) -> Option<(usize, usize)>
pub fn key_and_iv_size(self) -> Option<(usize, usize)>
Get the key and IV size for this cipher in bytes.
Sourcepub fn block_size(self) -> usize
pub fn block_size(self) -> usize
Get the block size for this cipher in bytes.
Sourcepub fn padding_len(self, input_size: usize) -> usize
pub fn padding_len(self, input_size: usize) -> usize
Compute the length of padding necessary to pad the given input to the block size.
Sourcepub fn has_tag(self) -> bool
pub fn has_tag(self) -> bool
Does this cipher have an authentication tag? (i.e. is it an AEAD mode?)
Sourcepub fn decrypt(
self,
key: &[u8],
iv: &[u8],
buffer: &mut [u8],
tag: Option<Array<u8, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>>,
) -> Result<(), Error>
pub fn decrypt( self, key: &[u8], iv: &[u8], buffer: &mut [u8], tag: Option<Array<u8, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>>, ) -> Result<(), Error>
Decrypt the ciphertext in the buffer
in-place using this cipher.
Returns Error::Length
in the event that buffer
is not a multiple of the cipher’s
block size.
Sourcepub fn encrypt(
self,
key: &[u8],
iv: &[u8],
buffer: &mut [u8],
) -> Result<Option<Array<u8, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>>, Error>
pub fn encrypt( self, key: &[u8], iv: &[u8], buffer: &mut [u8], ) -> Result<Option<Array<u8, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>>>, Error>
Encrypt the ciphertext in the buffer
in-place using this cipher.
Returns Error::Length
in the event that buffer
is not a multiple of the cipher’s
block size.
Trait Implementations§
Source§impl Ord for Cipher
impl Ord for Cipher
Source§impl PartialOrd for Cipher
impl PartialOrd for Cipher
impl Copy for Cipher
impl Eq for Cipher
impl Label for Cipher
impl StructuralPartialEq for Cipher
Auto Trait Implementations§
impl Freeze for Cipher
impl RefUnwindSafe for Cipher
impl Send for Cipher
impl Sync for Cipher
impl Unpin for Cipher
impl UnwindSafe for Cipher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Encode for Twhere
T: Label,
impl<T> Encode for Twhere
T: Label,
Source§fn encoded_len(&self) -> Result<usize, Error>
fn encoded_len(&self) -> Result<usize, Error>
Source§fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>
Writer
.Source§fn encoded_len_prefixed(&self) -> Result<usize, Error>
fn encoded_len_prefixed(&self) -> Result<usize, Error>
uint32
length prefix.Source§fn encode_prefixed(&self, writer: &mut impl Writer) -> Result<(), Error>
fn encode_prefixed(&self, writer: &mut impl Writer) -> Result<(), Error>
uint32
length prefix
set to Encode::encoded_len
.