[][src]Enum pgp::crypto::sym::SymmetricKeyAlgorithm

#[repr(u8)]pub enum SymmetricKeyAlgorithm {
    Plaintext,
    IDEA,
    TripleDES,
    CAST5,
    Blowfish,
    AES128,
    AES192,
    AES256,
    Twofish,
    Camellia128,
    Camellia192,
    Camellia256,
    Private10,
}

Variants

Plaintext

Plaintext or unencrypted data

IDEA

IDEA

TripleDES

Triple-DES

CAST5

CAST5

Blowfish

Blowfish

AES128

AES with 128-bit key

AES192

AES with 192-bit key

AES256

AES with 256-bit key

Twofish

Twofish with 256-bit key

Camellia128

Camellia with 128-bit key

Camellia192

Camellia with 192-bit key

Camellia256

Camellia with 256-bit key

Private10

Methods

impl SymmetricKeyAlgorithm[src]

pub fn block_size(self) -> usize[src]

The size of a single block in bytes. Based on https://github.com/gpg/libgcrypt/blob/master/cipher

pub fn key_size(self) -> usize[src]

The size of a single block in bytes. Based on https://github.com/gpg/libgcrypt/blob/master/cipher

pub fn decrypt<'a>(
    self,
    key: &[u8],
    ciphertext: &'a mut [u8]
) -> Result<&'a [u8]>
[src]

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.

pub fn decrypt_protected<'a>(
    self,
    key: &[u8],
    ciphertext: &'a mut [u8]
) -> Result<&'a [u8]>
[src]

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.

pub fn decrypt_with_iv<'a>(
    self,
    key: &[u8],
    iv_vec: &[u8],
    ciphertext: &'a mut [u8],
    resync: bool
) -> Result<(&'a [u8], &'a [u8])>
[src]

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.

pub fn decrypt_with_iv_regular<'a>(
    self,
    key: &[u8],
    iv_vec: &[u8],
    ciphertext: &'a mut [u8]
) -> Result<()>
[src]

Decrypt the data using CFB mode, without padding. Overwrites the input. This is regular CFB, not OpenPgP CFB.

pub fn encrypt_with_rng<R: CryptoRng + Rng>(
    self,
    rng: &mut R,
    key: &[u8],
    plaintext: &[u8]
) -> Result<Vec<u8>>
[src]

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(self, key: &[u8], plaintext: &[u8]) -> Result<Vec<u8>>[src]

Same as encrypt_with_rng, but uses rand::thread_rng for RNG.

pub fn encrypt_protected_with_rng<'a, R: CryptoRng + Rng>(
    self,
    rng: &mut R,
    key: &[u8],
    plaintext: &'a [u8]
) -> Result<Vec<u8>>
[src]

pub fn encrypt_protected<'a>(
    self,
    key: &[u8],
    plaintext: &'a [u8]
) -> Result<Vec<u8>>
[src]

pub fn encrypt_with_iv<'a>(
    self,
    key: &[u8],
    iv_vec: &[u8],
    ciphertext: &'a mut [u8],
    resync: bool
) -> Result<()>
[src]

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.

pub fn encrypt_with_iv_regular(
    self,
    key: &[u8],
    iv_vec: &[u8],
    plaintext: &mut [u8]
) -> Result<()>
[src]

Encrypt the data using CFB mode, without padding. Overwrites the input.

pub fn new_session_key<R: Rng + CryptoRng>(self, rng: &mut R) -> Vec<u8>[src]

Generate a new session key.

Trait Implementations

impl Clone for SymmetricKeyAlgorithm[src]

impl Copy for SymmetricKeyAlgorithm[src]

impl Debug for SymmetricKeyAlgorithm[src]

impl Default for SymmetricKeyAlgorithm[src]

impl DefaultIsZeroes for SymmetricKeyAlgorithm[src]

impl Eq for SymmetricKeyAlgorithm[src]

impl FromPrimitive for SymmetricKeyAlgorithm[src]

impl PartialEq<SymmetricKeyAlgorithm> for SymmetricKeyAlgorithm[src]

impl StructuralEq for SymmetricKeyAlgorithm[src]

impl StructuralPartialEq for SymmetricKeyAlgorithm[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> InitializableFromZeroed for T where
    T: Default
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Err = <U as TryFrom<T>>::Err

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<Z> Zeroize for Z where
    Z: DefaultIsZeroes
[src]