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

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

Available symmetric key algorithms.

Variants

Plaintext

Plaintext or unencrypted data

IDEA
TripleDES

TripleDES (DES-EDE, 168 bit key derived from 192)

CAST5

CAST5 (128 bit key, as per [RFC2144])

Blowfish

Blowfish (128 bit key, 16 rounds)

AES128
AES192
AES256
Twofish

Twofish with 256-bit key [TWOFISH]

Camellia128
Camellia192
Camellia256
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(self, 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_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 Default for SymmetricKeyAlgorithm[src]

impl Eq for SymmetricKeyAlgorithm[src]

impl PartialEq<SymmetricKeyAlgorithm> for SymmetricKeyAlgorithm[src]

impl Debug for SymmetricKeyAlgorithm[src]

impl FromPrimitive for SymmetricKeyAlgorithm[src]

impl DefaultIsZeroes for SymmetricKeyAlgorithm[src]

Auto Trait Implementations

Blanket Implementations

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

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

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> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

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

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

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

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