Struct win_crypto_ng::symmetric::SymmetricAlgorithm
source · pub struct SymmetricAlgorithm { /* private fields */ }
Expand description
Symmetric algorithm
Implementations§
source§impl SymmetricAlgorithm
impl SymmetricAlgorithm
sourcepub fn open(
id: SymmetricAlgorithmId,
chaining_mode: ChainingMode
) -> Result<Self>
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());
sourcepub fn chaining_mode(&self) -> ChainingMode
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);
sourcepub fn valid_key_sizes(&self) -> Result<Vec<usize>>
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());
sourcepub fn new_key(&self, secret: &[u8]) -> Result<SymmetricAlgorithmKey>
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§
impl RefUnwindSafe for SymmetricAlgorithm
impl Send for SymmetricAlgorithm
impl !Sync for SymmetricAlgorithm
impl Unpin for SymmetricAlgorithm
impl UnwindSafe for SymmetricAlgorithm
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more