#[repr(u8)]pub enum SymmetricKeyAlgorithm {
Show 17 variants
Plaintext = 0,
IDEA = 1,
TripleDES = 2,
CAST5 = 3,
Blowfish = 4,
AES128 = 7,
AES192 = 8,
AES256 = 9,
Twofish = 10,
Camellia128 = 11,
Camellia192 = 12,
Camellia256 = 13,
MKV128128 = 14,
MKV128192 = 15,
MKV128256 = 16,
Private10 = 110,
Other(u8),
}
Expand description
Available symmetric key algorithms. Ref: https://www.rfc-editor.org/rfc/rfc9580.html#name-symmetric-key-algorithms
Variants§
Plaintext = 0
Plaintext or unencrypted data
IDEA = 1
IDEA
TripleDES = 2
Triple-DES
CAST5 = 3
CAST5
Blowfish = 4
Blowfish
AES128 = 7
AES with 128-bit key
AES192 = 8
AES with 192-bit key
AES256 = 9
AES with 256-bit key
Twofish = 10
Twofish with 256-bit key
Camellia128 = 11
Camellia with 128-bit key
Camellia192 = 12
Camellia with 192-bit key
Camellia256 = 13
Camellia with 256-bit key
MKV128128 = 14
MKV128 with 128-bit key
MKV128192 = 15
AES with 192-bit key
MKV128256 = 16
AES with 256-bit key
Private10 = 110
Other(u8)
Implementations§
Source§impl SymmetricKeyAlgorithm
impl SymmetricKeyAlgorithm
Sourcepub fn block_size(self) -> usize
pub fn block_size(self) -> usize
The size of a single block in bytes. Based on https://github.com/gpg/libgcrypt/blob/master/cipher
Sourcepub const fn key_size(self) -> usize
pub const fn key_size(self) -> usize
The size of a single block in bytes. Based on https://github.com/gpg/libgcrypt/blob/master/cipher
Sourcepub fn decrypt<'a>(
self,
key: &[u8],
ciphertext: &'a mut [u8],
) -> Result<&'a [u8]>
pub fn decrypt<'a>( self, key: &[u8], ciphertext: &'a mut [u8], ) -> Result<&'a [u8]>
Decrypt the data using CFB mode, without padding. Overwrites the input. Uses an IV of all zeroes, as specified in the openpgp cfb mode. Does resynchronization.
Sourcepub fn decrypt_protected<'a>(
self,
key: &[u8],
ciphertext: &'a mut [u8],
) -> Result<&'a [u8]>
pub fn decrypt_protected<'a>( self, key: &[u8], ciphertext: &'a mut [u8], ) -> Result<&'a [u8]>
Decrypt the data using CFB mode, without padding. Overwrites the input. Uses an IV of all zeroes, as specified in the openpgp cfb mode. Does not do resynchronization.
Sourcepub fn decrypt_with_iv<'a>(
self,
key: &[u8],
iv_vec: &[u8],
ciphertext: &'a mut [u8],
resync: bool,
) -> Result<(&'a [u8], &'a [u8])>
pub fn decrypt_with_iv<'a>( self, key: &[u8], iv_vec: &[u8], ciphertext: &'a mut [u8], resync: bool, ) -> Result<(&'a [u8], &'a [u8])>
Decrypt the data using CFB mode, without padding. Overwrites the input.
OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and prefixes the plaintext with BS+2 octets of random data, such that octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB resynchronization after encrypting those BS+2 octets.
Thus, for an algorithm that has a block size of 8 octets (64 bits), the IV is 10 octets long and octets 7 and 8 of the IV are the same as octets 9 and 10. For an algorithm with a block size of 16 octets (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate octets 15 and 16. Those extra two octets are an easy check for a correct key.
Sourcepub fn decrypt_with_iv_regular(
self,
key: &[u8],
iv_vec: &[u8],
ciphertext: &mut [u8],
) -> Result<()>
pub fn decrypt_with_iv_regular( self, key: &[u8], iv_vec: &[u8], ciphertext: &mut [u8], ) -> Result<()>
Decrypt the data using CFB mode, without padding. Overwrites the input. This is regular CFB, not OpenPgP CFB.
Sourcepub fn encrypt<R: CryptoRng + Rng>(
self,
rng: R,
key: &[u8],
plaintext: &[u8],
) -> Result<Vec<u8>>
pub fn encrypt<R: CryptoRng + Rng>( self, rng: R, key: &[u8], plaintext: &[u8], ) -> Result<Vec<u8>>
Encrypt the data using CFB mode, without padding. Overwrites the input. Uses an IV of all zeroes, as specified in the openpgp cfb mode.
pub fn encrypt_protected<R: CryptoRng + Rng>( self, rng: R, key: &[u8], plaintext: &[u8], ) -> Result<Vec<u8>>
Sourcepub fn encrypt_with_iv(
self,
key: &[u8],
iv_vec: &[u8],
ciphertext: &mut [u8],
resync: bool,
) -> Result<()>
pub fn encrypt_with_iv( self, key: &[u8], iv_vec: &[u8], ciphertext: &mut [u8], resync: bool, ) -> Result<()>
Encrypt the data using CFB mode, without padding. Overwrites the input.
OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and prefixes the plaintext with BS+2 octets of random data, such that octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB resynchronization after encrypting those BS+2 octets.
Trait Implementations§
Source§impl Clone for SymmetricKeyAlgorithm
impl Clone for SymmetricKeyAlgorithm
Source§fn clone(&self) -> SymmetricKeyAlgorithm
fn clone(&self) -> SymmetricKeyAlgorithm
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SymmetricKeyAlgorithm
impl Debug for SymmetricKeyAlgorithm
Source§impl Default for SymmetricKeyAlgorithm
impl Default for SymmetricKeyAlgorithm {
fn default() -> Self {
Self::AES128
}
}
VGISC.COM
impl Default for SymmetricKeyAlgorithm
impl Default for SymmetricKeyAlgorithm { fn default() -> Self { Self::AES128 } } VGISC.COM