AnyKeyCreate

Trait AnyKeyCreate 

Source
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§

Source

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.

Source

fn generate_for_hardware(alg: KeyAlg) -> Result<Self, Error>

Generate a new key with an id for the given key algorithm.

Source

fn get_with_id(alg: KeyAlg, id: &str) -> Result<Self, Error>

Get a key by id for hardware-based key

Source

fn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>

Load a public key from its byte representation

Source

fn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>

Load a secret key or keypair from its byte representation

Source

fn from_key<K: HasKeyAlg + HasKeyBackend + Send + Sync + RefUnwindSafe + UnwindSafe + 'static>( key: K, ) -> Self

Convert from a concrete key instance

Source

fn from_key_exchange<Sk, Pk>( alg: KeyAlg, secret: &Sk, public: &Pk, ) -> Result<Self, Error>
where Sk: KeyExchange<Pk> + ?Sized, Pk: ?Sized,

Create a new key instance from a key exchange

Source

fn from_key_derivation( alg: KeyAlg, derive: impl KeyDerivation, ) -> Result<Self, Error>

Create a new key instance from a key derivation

Source

fn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>

Derive the corresponding key for the provided key algorithm

Provided Methods§

Source

fn random(alg: KeyAlg) -> Result<Self, Error>

Available on crate feature getrandom only.

Generate a new random key for the given key algorithm.

Source

fn random_det(alg: KeyAlg, seed: &[u8]) -> Result<Self, Error>

Generate a new random key for the given key algorithm.

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.

Implementations on Foreign Types§

Source§

impl AnyKeyCreate for Box<AnyKey>

Source§

fn generate_with_rng(alg: KeyAlg, rng: impl KeyMaterial) -> Result<Self, Error>

Source§

fn generate_for_hardware(alg: KeyAlg) -> Result<Self, Error>

Source§

fn get_with_id(alg: KeyAlg, id: &str) -> Result<Self, Error>

Source§

fn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>

Source§

fn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>

Source§

fn from_key<K: HasKeyAlg + HasKeyBackend + Send + Sync + RefUnwindSafe + UnwindSafe + 'static>( key: K, ) -> Self

Source§

fn from_key_exchange<Sk, Pk>( alg: KeyAlg, secret: &Sk, public: &Pk, ) -> Result<Self, Error>
where Sk: KeyExchange<Pk> + ?Sized, Pk: ?Sized,

Source§

fn from_key_derivation( alg: KeyAlg, derive: impl KeyDerivation, ) -> Result<Self, Error>

Source§

fn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>

Source§

impl AnyKeyCreate for Arc<AnyKey>

Source§

fn generate_with_rng(alg: KeyAlg, rng: impl KeyMaterial) -> Result<Self, Error>

Source§

fn generate_for_hardware(alg: KeyAlg) -> Result<Self, Error>

Source§

fn get_with_id(alg: KeyAlg, id: &str) -> Result<Self, Error>

Source§

fn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>

Source§

fn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>

Source§

fn from_key<K: HasKeyAlg + HasKeyBackend + Send + Sync + RefUnwindSafe + UnwindSafe + 'static>( key: K, ) -> Self

Source§

fn from_key_exchange<Sk, Pk>( alg: KeyAlg, secret: &Sk, public: &Pk, ) -> Result<Self, Error>
where Sk: KeyExchange<Pk> + ?Sized, Pk: ?Sized,

Source§

fn from_key_derivation( alg: KeyAlg, derive: impl KeyDerivation, ) -> Result<Self, Error>

Source§

fn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>

Implementors§