pub type AnyKey = KeyT<dyn AnyKeyAlg + Send + Sync + RefUnwindSafe + UnwindSafe>;Available on crate feature
any_key only.Expand description
The type-erased representation for a concrete key instance
Aliased Type§
pub struct AnyKey(/* private fields */);Implementations§
Trait Implementations§
Source§impl AnyKeyCreate for Box<AnyKey>
impl AnyKeyCreate for Box<AnyKey>
Source§fn 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.
Source§fn 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.
Source§fn 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
Source§fn 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
Source§fn 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
Source§fn 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
Source§fn 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
Source§fn 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
Source§fn 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
Source§impl KeyAeadInPlace for AnyKey
impl KeyAeadInPlace for AnyKey
Source§fn encrypt_in_place(
&self,
buffer: &mut dyn ResizeBuffer,
nonce: &[u8],
aad: &[u8],
) -> Result<usize, Error>
fn encrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<usize, Error>
Encrypt a secret value in place, appending the verification tag and
returning the length of the ciphertext
Source§fn decrypt_in_place(
&self,
buffer: &mut dyn ResizeBuffer,
nonce: &[u8],
aad: &[u8],
) -> Result<(), Error>
fn decrypt_in_place( &self, buffer: &mut dyn ResizeBuffer, nonce: &[u8], aad: &[u8], ) -> Result<(), Error>
Decrypt an encrypted (verification tag appended) value in place
Source§fn aead_params(&self) -> KeyAeadParams
fn aead_params(&self) -> KeyAeadParams
Get the nonce and tag length for encryption
Source§fn aead_padding(&self, msg_len: usize) -> usize
fn aead_padding(&self, msg_len: usize) -> usize
Get the ciphertext padding required
Source§impl KeyExchange for AnyKey
impl KeyExchange for AnyKey
Source§fn write_key_exchange(
&self,
other: &AnyKey,
out: &mut dyn WriteBuffer,
) -> Result<(), Error>
fn write_key_exchange( &self, other: &AnyKey, out: &mut dyn WriteBuffer, ) -> Result<(), Error>
Perform a key exchange, writing the result to the provided buffer.
Source§fn key_exchange_bytes(&self, other: &Rhs) -> Result<SecretBytes, Error>
fn key_exchange_bytes(&self, other: &Rhs) -> Result<SecretBytes, Error>
Available on crate feature
alloc only.Perform a key exchange and return a new allocated buffer.
Source§impl KeySigVerify for AnyKey
impl KeySigVerify for AnyKey
Source§fn verify_signature(
&self,
message: &[u8],
signature: &[u8],
sig_type: Option<SignatureType>,
) -> Result<bool, Error>
fn verify_signature( &self, message: &[u8], signature: &[u8], sig_type: Option<SignatureType>, ) -> Result<bool, Error>
Check the validity of signature over a message with the
specified signature type.
Source§impl KeySign for AnyKey
impl KeySign for AnyKey
Source§fn write_signature(
&self,
message: &[u8],
sig_type: Option<SignatureType>,
out: &mut dyn WriteBuffer,
) -> Result<(), Error>
fn write_signature( &self, message: &[u8], sig_type: Option<SignatureType>, out: &mut dyn WriteBuffer, ) -> Result<(), Error>
Create a signature of the requested type and write it to the
provided buffer.
Source§fn create_signature(
&self,
message: &[u8],
sig_type: Option<SignatureType>,
) -> Result<SecretBytes, Error>
fn create_signature( &self, message: &[u8], sig_type: Option<SignatureType>, ) -> Result<SecretBytes, Error>
Available on crate feature
alloc only.Create a signature of the requested type and return an allocated
buffer.
Source§impl ToJwk for AnyKey
impl ToJwk for AnyKey
Source§fn encode_jwk(&self, enc: &mut dyn JwkEncoder) -> Result<(), Error>
fn encode_jwk(&self, enc: &mut dyn JwkEncoder) -> Result<(), Error>
Write the JWK representation to an encoder
Source§fn to_jwk_thumbprint(&self, alg: Option<KeyAlg>) -> Result<String, Error>
fn to_jwk_thumbprint(&self, alg: Option<KeyAlg>) -> Result<String, Error>
Available on crate feature
alloc only.Create the JWK thumbprint of the key
Source§fn to_jwk_public(&self, alg: Option<KeyAlg>) -> Result<String, Error>
fn to_jwk_public(&self, alg: Option<KeyAlg>) -> Result<String, Error>
Available on crate feature
alloc only.Create a JWK of the public key
Source§fn to_jwk_secret(&self, alg: Option<KeyAlg>) -> Result<SecretBytes, Error>
fn to_jwk_secret(&self, alg: Option<KeyAlg>) -> Result<SecretBytes, Error>
Available on crate feature
alloc only.Create a JWK of the secret key
Source§impl ToPublicBytes for AnyKey
impl ToPublicBytes for AnyKey
Source§fn write_public_bytes(&self, out: &mut dyn WriteBuffer) -> Result<(), Error>
fn write_public_bytes(&self, out: &mut dyn WriteBuffer) -> Result<(), Error>
Write the key public bytes to a buffer.
Source§fn to_public_bytes(&self) -> Result<SecretBytes, Error>
fn to_public_bytes(&self) -> Result<SecretBytes, Error>
Available on crate feature
alloc only.Write the key public bytes to a new allocated buffer.
Source§impl ToSecretBytes for AnyKey
impl ToSecretBytes for AnyKey
Source§fn write_secret_bytes(&self, out: &mut dyn WriteBuffer) -> Result<(), Error>
fn write_secret_bytes(&self, out: &mut dyn WriteBuffer) -> Result<(), Error>
Write the key secret bytes to a buffer.
Source§fn to_secret_bytes(&self) -> Result<SecretBytes, Error>
fn to_secret_bytes(&self) -> Result<SecretBytes, Error>
Available on crate feature
alloc only.Write the key secret bytes to a new allocated buffer.