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

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

Implementations§

source§

impl SymmetricKeyAlgorithm

source

pub fn block_size(self) -> usize

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

source

pub fn key_size(self) -> usize

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

source

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

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.

source

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

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.

source

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

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.

source

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

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

source

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

Encrypt the data using CFB mode, without padding. Overwrites the input. Uses an IV of all zeroes, as specified in the openpgp cfb mode.

source

pub fn encrypt( self, key: &[u8], plaintext: &[u8] ) -> Result<Vec<u8, Global>, Error>

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

source

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

source

pub fn encrypt_protected( self, key: &[u8], plaintext: &[u8] ) -> Result<Vec<u8, Global>, Error>

source

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

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.

source

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

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

source

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

Generate a new session key.

Trait Implementations§

source§

impl Clone for SymmetricKeyAlgorithm

source§

fn clone(&self) -> SymmetricKeyAlgorithm

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SymmetricKeyAlgorithm

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for SymmetricKeyAlgorithm

source§

fn default() -> SymmetricKeyAlgorithm

Returns the “default value” for a type. Read more
source§

impl FromPrimitive for SymmetricKeyAlgorithm

source§

fn from_i64(n: i64) -> Option<SymmetricKeyAlgorithm>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u64(n: u64) -> Option<SymmetricKeyAlgorithm>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
source§

impl PartialEq<SymmetricKeyAlgorithm> for SymmetricKeyAlgorithm

source§

fn eq(&self, other: &SymmetricKeyAlgorithm) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for SymmetricKeyAlgorithm

source§

impl DefaultIsZeroes for SymmetricKeyAlgorithm

source§

impl Eq for SymmetricKeyAlgorithm

source§

impl StructuralEq for SymmetricKeyAlgorithm

source§

impl StructuralPartialEq for SymmetricKeyAlgorithm

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<Z> Zeroize for Zwhere Z: DefaultIsZeroes,

§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.