Trait crypto_common::KeyIvInit
source · pub trait KeyIvInit:
KeySizeUser
+ IvSizeUser
+ Sized {
// Required method
fn new(key: &Key<Self>, iv: &Iv<Self>) -> Self;
// Provided methods
fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength> { ... }
fn generate_key() -> Result<Key<Self>, Error> { ... }
fn generate_key_with_rng(
rng: &mut impl CryptoRngCore,
) -> Result<Key<Self>, Error> { ... }
fn generate_iv() -> Result<Iv<Self>, Error> { ... }
fn generate_iv_with_rng(
rng: &mut impl CryptoRngCore,
) -> Result<Iv<Self>, Error> { ... }
fn generate_key_iv() -> Result<(Key<Self>, Iv<Self>), Error> { ... }
fn generate_key_iv_with_rng(
rng: &mut impl CryptoRngCore,
) -> Result<(Key<Self>, Iv<Self>), Error> { ... }
}
Expand description
Types which can be initialized from key and initialization vector (nonce).
Required Methods§
Provided Methods§
sourcefn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength>
fn new_from_slices(key: &[u8], iv: &[u8]) -> Result<Self, InvalidLength>
Create new value from variable length key and nonce.
sourcefn generate_key() -> Result<Key<Self>, Error>
Available on crate feature getrandom
only.
fn generate_key() -> Result<Key<Self>, Error>
getrandom
only.Generate random key using the operating system’s secure RNG.
sourcefn generate_key_with_rng(
rng: &mut impl CryptoRngCore,
) -> Result<Key<Self>, Error>
Available on crate feature rand_core
only.
fn generate_key_with_rng( rng: &mut impl CryptoRngCore, ) -> Result<Key<Self>, Error>
rand_core
only.Generate random key using the provided CryptoRngCore
.
sourcefn generate_iv() -> Result<Iv<Self>, Error>
Available on crate feature getrandom
only.
fn generate_iv() -> Result<Iv<Self>, Error>
getrandom
only.Generate random IV using the operating system’s secure RNG.
sourcefn generate_iv_with_rng(rng: &mut impl CryptoRngCore) -> Result<Iv<Self>, Error>
Available on crate feature rand_core
only.
fn generate_iv_with_rng(rng: &mut impl CryptoRngCore) -> Result<Iv<Self>, Error>
rand_core
only.Generate random IV using the provided CryptoRngCore
.
sourcefn generate_key_iv() -> Result<(Key<Self>, Iv<Self>), Error>
Available on crate feature getrandom
only.
fn generate_key_iv() -> Result<(Key<Self>, Iv<Self>), Error>
getrandom
only.Generate random key and IV using the operating system’s secure RNG.
sourcefn generate_key_iv_with_rng(
rng: &mut impl CryptoRngCore,
) -> Result<(Key<Self>, Iv<Self>), Error>
Available on crate feature rand_core
only.
fn generate_key_iv_with_rng( rng: &mut impl CryptoRngCore, ) -> Result<(Key<Self>, Iv<Self>), Error>
rand_core
only.Generate random key and IV using the provided CryptoRngCore
.
Object Safety§
This trait is not object safe.