KeyInit

Trait KeyInit 

Source
pub trait KeyInit: KeySizeUser + Sized {
    // Required method
    fn new(key: &Key<Self>) -> Self;

    // Provided methods
    fn weak_key_test(_key: &Key<Self>) -> Result<(), WeakKeyError> { ... }
    fn new_checked(key: &Key<Self>) -> Result<Self, WeakKeyError> { ... }
    fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength> { ... }
    fn generate_key() -> Result<Key<Self>, OsError> { ... }
    fn generate_key_with_rng<R: CryptoRng + ?Sized>(rng: &mut R) -> Key<Self> { ... }
    fn try_generate_key_with_rng<R: TryCryptoRng + ?Sized>(
        rng: &mut R,
    ) -> Result<Key<Self>, R::Error> { ... }
}
Expand description

Types which can be initialized from key.

Required Methods§

Source

fn new(key: &Key<Self>) -> Self

Create new value from fixed size key.

Provided Methods§

Source

fn weak_key_test(_key: &Key<Self>) -> Result<(), WeakKeyError>

Check if the key might be considered weak.

Source

fn new_checked(key: &Key<Self>) -> Result<Self, WeakKeyError>

Create new value from fixed size key after checking it for weakness.

Source

fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength>

Create new value from variable size key.

Source

fn generate_key() -> Result<Key<Self>, OsError>

Available on crate feature os_rng only.

Generate random key using the operating system’s secure RNG.

Source

fn generate_key_with_rng<R: CryptoRng + ?Sized>(rng: &mut R) -> Key<Self>

Available on crate feature rand_core only.

Generate random key using the provided CryptoRng.

Source

fn try_generate_key_with_rng<R: TryCryptoRng + ?Sized>( rng: &mut R, ) -> Result<Key<Self>, R::Error>

Available on crate feature rand_core only.

Generate random key using the provided TryCryptoRng.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> KeyInit for T
where T: InnerInit, T::Inner: KeyInit,