pub trait AnyKeyCreate: Sized {
// Required methods
fn generate_with_rng(
alg: KeyAlg,
rng: impl KeyMaterial,
) -> Result<Self, Error>;
fn generate_for_hardware(alg: KeyAlg) -> Result<Self, Error>;
fn get_with_id(alg: KeyAlg, id: &str) -> Result<Self, Error>;
fn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>;
fn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>;
fn from_key<K: HasKeyAlg + HasKeyBackend + Send + Sync + RefUnwindSafe + UnwindSafe + 'static>(
key: K,
) -> Self;
fn from_key_exchange<Sk, Pk>(
alg: KeyAlg,
secret: &Sk,
public: &Pk,
) -> Result<Self, Error>
where Sk: KeyExchange<Pk> + ?Sized,
Pk: ?Sized;
fn from_key_derivation(
alg: KeyAlg,
derive: impl KeyDerivation,
) -> Result<Self, Error>;
fn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>;
// Provided methods
fn random(alg: KeyAlg) -> Result<Self, Error> { ... }
fn random_det(alg: KeyAlg, seed: &[u8]) -> Result<Self, Error> { ... }
}Available on crate feature
any_key only.Expand description
Create AnyKey instances from various sources
Required Methods§
Sourcefn generate_with_rng(alg: KeyAlg, rng: impl KeyMaterial) -> Result<Self, Error>
fn generate_with_rng(alg: KeyAlg, rng: impl KeyMaterial) -> Result<Self, Error>
Generate a new key from a key material generator for the given key algorithm.
Sourcefn generate_for_hardware(alg: KeyAlg) -> Result<Self, Error>
fn generate_for_hardware(alg: KeyAlg) -> Result<Self, Error>
Generate a new key with an id for the given key algorithm.
Sourcefn get_with_id(alg: KeyAlg, id: &str) -> Result<Self, Error>
fn get_with_id(alg: KeyAlg, id: &str) -> Result<Self, Error>
Get a key by id for hardware-based key
Sourcefn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>
fn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>
Load a public key from its byte representation
Sourcefn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>
fn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>
Load a secret key or keypair from its byte representation
Sourcefn from_key<K: HasKeyAlg + HasKeyBackend + Send + Sync + RefUnwindSafe + UnwindSafe + 'static>(
key: K,
) -> Self
fn from_key<K: HasKeyAlg + HasKeyBackend + Send + Sync + RefUnwindSafe + UnwindSafe + 'static>( key: K, ) -> Self
Convert from a concrete key instance
Sourcefn from_key_exchange<Sk, Pk>(
alg: KeyAlg,
secret: &Sk,
public: &Pk,
) -> Result<Self, Error>
fn from_key_exchange<Sk, Pk>( alg: KeyAlg, secret: &Sk, public: &Pk, ) -> Result<Self, Error>
Create a new key instance from a key exchange
Sourcefn from_key_derivation(
alg: KeyAlg,
derive: impl KeyDerivation,
) -> Result<Self, Error>
fn from_key_derivation( alg: KeyAlg, derive: impl KeyDerivation, ) -> Result<Self, Error>
Create a new key instance from a key derivation
Sourcefn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>
fn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>
Derive the corresponding key for the provided key algorithm
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".