win_crypto_ng::symmetric

Struct SymmetricAlgorithm

Source
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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.