pub struct SymmetricAlgorithm { /* private fields */ }
Expand description

Symmetric algorithm

Implementations§

source§

impl SymmetricAlgorithm

source

pub fn open( id: SymmetricAlgorithmId, chaining_mode: ChainingMode ) -> Result<Self>

Open a symmetric algorithm provider

Examples
let algo = SymmetricAlgorithm::open(SymmetricAlgorithmId::Aes, ChainingMode::Cbc);

assert!(algo.is_ok());
source

pub fn chaining_mode(&self) -> ChainingMode

Returns the chaining mode of the algorithm.

Examples
let algo = SymmetricAlgorithm::open(SymmetricAlgorithmId::Aes, ChainingMode::Cbc).unwrap();
let chaining_mode = algo.chaining_mode();

assert_eq!(ChainingMode::Cbc, chaining_mode);
source

pub fn valid_key_sizes(&self) -> Result<Vec<usize>>

Returns a list of all the valid key sizes for an algorithm.

The key sizes are defined in bits.

Examples
let algo = SymmetricAlgorithm::open(SymmetricAlgorithmId::Aes, ChainingMode::Cbc).unwrap();
let valid_key_sizes = algo.valid_key_sizes().unwrap();

assert_eq!([128, 192, 256], valid_key_sizes.as_slice());
source

pub fn new_key(&self, secret: &[u8]) -> Result<SymmetricAlgorithmKey>

Creates a new key from the algorithm

The secret value is the shared-secret between the two parties. For example, it may be a hash of a password or some other reproducible data. The size of the secret must fit with one of the valid key sizes (see valid_key_sizes).

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.