Struct aries_askar::kms::LocalKey

source ·
pub struct LocalKey { /* private fields */ }
Expand description

A stored key entry

Implementations§

source§

impl LocalKey

source

pub fn generate(alg: KeyAlg, ephemeral: bool) -> Result<Self, Error>

Create a new random key or keypair

source

pub fn from_seed( alg: KeyAlg, seed: &[u8], method: Option<&str> ) -> Result<Self, Error>

Create a new deterministic key or keypair

source

pub fn from_jwk_slice(jwk: &[u8]) -> Result<Self, Error>

Import a key or keypair from a JWK in binary format

source

pub fn from_jwk(jwk: &str) -> Result<Self, Error>

Import a key or keypair from a JWK

source

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

Import a public key from its compact representation

source

pub fn to_public_bytes(&self) -> Result<SecretBytes, Error>

Export the raw bytes of the public key

source

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

Import a symmetric key or public-private keypair from its compact representation

source

pub fn to_secret_bytes(&self) -> Result<SecretBytes, Error>

Export the raw bytes of the private key

source

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

source

pub fn algorithm(&self) -> KeyAlg

Accessor for the key algorithm

source

pub fn to_jwk_public(&self, alg: Option<KeyAlg>) -> Result<String, Error>

Get the public JWK representation for this key or keypair

source

pub fn to_jwk_secret(&self) -> Result<SecretBytes, Error>

Get the JWK representation for this private key or keypair

source

pub fn to_jwk_thumbprint(&self, alg: Option<KeyAlg>) -> Result<String, Error>

Get the JWK thumbprint for this key or keypair

source

pub fn to_jwk_thumbprints(&self) -> Result<Vec<String>, Error>

Get the set of indexed JWK thumbprints for this key or keypair

source

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

Map this key or keypair to its equivalent for another key algorithm

source

pub fn aead_params(&self) -> Result<KeyAeadParams, Error>

Fetch the AEAD parameter lengths

source

pub fn aead_padding(&self, msg_len: usize) -> usize

Calculate the padding required for a message

source

pub fn aead_random_nonce(&self) -> Result<Vec<u8>, Error>

Create a new random nonce for AEAD message encryption

source

pub fn aead_encrypt( &self, message: &[u8], nonce: &[u8], aad: &[u8] ) -> Result<Encrypted, Error>

Perform AEAD message encryption with this encryption key

source

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

source

pub fn sign_message( &self, message: &[u8], sig_type: Option<&str> ) -> Result<Vec<u8>, Error>

Sign a message with this private signing key

source

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

source

pub fn wrap_key(&self, key: &LocalKey, nonce: &[u8]) -> Result<Encrypted, Error>

Wrap another key using this key

source

pub fn unwrap_key<'d>( &'d self, alg: KeyAlg, ciphertext: impl Into<ToDecrypt<'d>>, nonce: &[u8] ) -> Result<LocalKey, Error>

Unwrap a key using this key

Trait Implementations§

source§

impl Debug for LocalKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl KeyExchange for LocalKey

source§

fn write_key_exchange( &self, other: &LocalKey, out: &mut dyn WriteBuffer ) -> Result<(), CryptoError>

Perform a key exchange, writing the result to the provided buffer.
source§

fn key_exchange_bytes(&self, other: &Rhs) -> Result<SecretBytes, Error>

Perform a key exchange and return a new allocated buffer.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more