Struct aries_askar::kms::LocalKey
source · pub struct LocalKey { /* private fields */ }
Expand description
A stored key entry
Implementations§
source§impl LocalKey
impl LocalKey
sourcepub fn generate(alg: KeyAlg, ephemeral: bool) -> Result<Self, Error>
pub fn generate(alg: KeyAlg, ephemeral: bool) -> Result<Self, Error>
Create a new random key or keypair
sourcepub fn from_seed(
alg: KeyAlg,
seed: &[u8],
method: Option<&str>
) -> Result<Self, Error>
pub fn from_seed( alg: KeyAlg, seed: &[u8], method: Option<&str> ) -> Result<Self, Error>
Create a new deterministic key or keypair
sourcepub fn from_jwk_slice(jwk: &[u8]) -> Result<Self, Error>
pub fn from_jwk_slice(jwk: &[u8]) -> Result<Self, Error>
Import a key or keypair from a JWK in binary format
sourcepub fn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>
pub fn from_public_bytes(alg: KeyAlg, public: &[u8]) -> Result<Self, Error>
Import a public key from its compact representation
sourcepub fn to_public_bytes(&self) -> Result<SecretBytes, Error>
pub fn to_public_bytes(&self) -> Result<SecretBytes, Error>
Export the raw bytes of the public key
sourcepub fn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>
pub fn from_secret_bytes(alg: KeyAlg, secret: &[u8]) -> Result<Self, Error>
Import a symmetric key or public-private keypair from its compact representation
sourcepub fn to_secret_bytes(&self) -> Result<SecretBytes, Error>
pub fn to_secret_bytes(&self) -> Result<SecretBytes, Error>
Export the raw bytes of the private key
sourcepub fn to_key_exchange(&self, alg: KeyAlg, pk: &LocalKey) -> Result<Self, Error>
pub fn to_key_exchange(&self, alg: KeyAlg, pk: &LocalKey) -> Result<Self, Error>
Derive a new key from a Diffie-Hellman exchange between this keypair and a public key
sourcepub fn to_jwk_public(&self, alg: Option<KeyAlg>) -> Result<String, Error>
pub fn to_jwk_public(&self, alg: Option<KeyAlg>) -> Result<String, Error>
Get the public JWK representation for this key or keypair
sourcepub fn to_jwk_secret(&self) -> Result<SecretBytes, Error>
pub fn to_jwk_secret(&self) -> Result<SecretBytes, Error>
Get the JWK representation for this private key or keypair
sourcepub fn to_jwk_thumbprint(&self, alg: Option<KeyAlg>) -> Result<String, Error>
pub fn to_jwk_thumbprint(&self, alg: Option<KeyAlg>) -> Result<String, Error>
Get the JWK thumbprint for this key or keypair
sourcepub fn to_jwk_thumbprints(&self) -> Result<Vec<String>, Error>
pub fn to_jwk_thumbprints(&self) -> Result<Vec<String>, Error>
Get the set of indexed JWK thumbprints for this key or keypair
sourcepub fn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>
pub fn convert_key(&self, alg: KeyAlg) -> Result<Self, Error>
Map this key or keypair to its equivalent for another key algorithm
sourcepub fn aead_params(&self) -> Result<KeyAeadParams, Error>
pub fn aead_params(&self) -> Result<KeyAeadParams, Error>
Fetch the AEAD parameter lengths
sourcepub fn aead_padding(&self, msg_len: usize) -> usize
pub fn aead_padding(&self, msg_len: usize) -> usize
Calculate the padding required for a message
sourcepub fn aead_random_nonce(&self) -> Result<Vec<u8>, Error>
pub fn aead_random_nonce(&self) -> Result<Vec<u8>, Error>
Create a new random nonce for AEAD message encryption
sourcepub fn aead_encrypt(
&self,
message: &[u8],
nonce: &[u8],
aad: &[u8]
) -> Result<Encrypted, Error>
pub fn aead_encrypt( &self, message: &[u8], nonce: &[u8], aad: &[u8] ) -> Result<Encrypted, Error>
Perform AEAD message encryption with this encryption key
sourcepub fn aead_decrypt<'d>(
&'d self,
ciphertext: impl Into<ToDecrypt<'d>>,
nonce: &[u8],
aad: &[u8]
) -> Result<SecretBytes, Error>
pub fn aead_decrypt<'d>( &'d self, ciphertext: impl Into<ToDecrypt<'d>>, nonce: &[u8], aad: &[u8] ) -> Result<SecretBytes, Error>
Perform AEAD message decryption with this encryption key
sourcepub fn sign_message(
&self,
message: &[u8],
sig_type: Option<&str>
) -> Result<Vec<u8>, Error>
pub fn sign_message( &self, message: &[u8], sig_type: Option<&str> ) -> Result<Vec<u8>, Error>
Sign a message with this private signing key
sourcepub fn verify_signature(
&self,
message: &[u8],
signature: &[u8],
sig_type: Option<&str>
) -> Result<bool, Error>
pub fn verify_signature( &self, message: &[u8], signature: &[u8], sig_type: Option<&str> ) -> Result<bool, Error>
Verify a message signature with this private signing key or public verification key