Skip to main content

KeyInit

Trait KeyInit 

pub trait KeyInit: Sized + KeySizeUser {
    // Required method
    fn new(key: &Array<u8, Self::KeySize>) -> Self;

    // Provided methods
    fn new_from_slice(key: &[u8]) -> Result<Self, InvalidLength> { ... }
    fn generate_key<R>(rng: &mut R) -> Array<u8, Self::KeySize>
       where R: CryptoRng { ... }
}
Expand description

Types which can be initialized from a key.

Required Methods§

fn new(key: &Array<u8, Self::KeySize>) -> Self

Create new value from fixed size key.

Provided Methods§

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

Create new value from variable size key.

§Errors

Returns [InvalidLength] in the event the length of the provided slice is not equal to <Self as KeySizeUser>::KeySize::USIZE.

fn generate_key<R>(rng: &mut R) -> Array<u8, Self::KeySize>
where R: CryptoRng,

👎Deprecated since 0.2.0:

use the Generate trait impl on Key instead

DEPRECATED: generate random key using the provided [CryptoRng].

Instead, you can now use the [Generate] trait directly with the [Key] type:

let key = Key::generate_from_rng(rng);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, S> KeyInit for XofFixedWrapper<T, S>
where T: ExtendableOutput + KeyInit, S: ArraySize,

Source§

fn new( key: &Array<u8, <XofFixedWrapper<T, S> as KeySizeUser>::KeySize>, ) -> XofFixedWrapper<T, S>

Implementors§

Source§

impl<D: Digest + BlockSizeUser> KeyInit for SimpleHmac<D>

Source§

impl<D: Digest + BlockSizeUser> KeyInit for SimpleHmacReset<D>

Source§

impl<D: EagerHash> KeyInit for Hmac<D>

Source§

impl<D: EagerHash> KeyInit for HmacCore<D>

Source§

impl<D: EagerHash> KeyInit for HmacReset<D>

Source§

impl<D: EagerHash> KeyInit for HmacResetCore<D>

§

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