pub trait JwkStorage: StorageSendSyncMaybe {
// Required methods
fn generate<'life0, 'async_trait>(
&'life0 self,
key_type: KeyType,
alg: JwsAlgorithm,
) -> Pin<Box<dyn Future<Output = Result<JwkGenOutput, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn insert<'life0, 'async_trait>(
&'life0 self,
jwk: Jwk,
) -> Pin<Box<dyn Future<Output = Result<KeyId, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn sign<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
data: &'life2 [u8],
public_key: &'life3 Jwk,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
) -> Pin<Box<dyn Future<Output = Result<(), SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
) -> Pin<Box<dyn Future<Output = Result<bool, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
}
Expand description
Secure storage for cryptographic keys represented as JWKs.
Required Methods§
Sourcefn generate<'life0, 'async_trait>(
&'life0 self,
key_type: KeyType,
alg: JwsAlgorithm,
) -> Pin<Box<dyn Future<Output = Result<JwkGenOutput, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn generate<'life0, 'async_trait>(
&'life0 self,
key_type: KeyType,
alg: JwsAlgorithm,
) -> Pin<Box<dyn Future<Output = Result<JwkGenOutput, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Generate a new key represented as a JSON Web Key.
It is recommended that the implementer exposes constants for the supported KeyType
.
Sourcefn insert<'life0, 'async_trait>(
&'life0 self,
jwk: Jwk,
) -> Pin<Box<dyn Future<Output = Result<KeyId, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn insert<'life0, 'async_trait>(
&'life0 self,
jwk: Jwk,
) -> Pin<Box<dyn Future<Output = Result<KeyId, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Insert an existing JSON Web Key into the storage.
All private key components of the jwk
must be set.
Sourcefn sign<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
data: &'life2 [u8],
public_key: &'life3 Jwk,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn sign<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
data: &'life2 [u8],
public_key: &'life3 Jwk,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Sign the provided data
using the private key identified by key_id
according to the requirements of
the corresponding public_key
(see Jwk::alg
etc.).
§Note
High level methods from this library calling this method are designed to always pass a public_key
that
corresponds to key_id
and additional checks for this in the sign
implementation are normally not required.
This is however based on the expectation that the key material associated with a given KeyId
is immutable.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
) -> Pin<Box<dyn Future<Output = Result<(), SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
) -> Pin<Box<dyn Future<Output = Result<(), SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Deletes the key identified by key_id
.
If the corresponding key does not exist in storage, a KeyStorageError
with kind
KeyNotFound
must be returned.
§Warning
This operation cannot be undone. The keys are purged permanently.
Sourcefn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
) -> Pin<Box<dyn Future<Output = Result<bool, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key_id: &'life1 KeyId,
) -> Pin<Box<dyn Future<Output = Result<bool, SingleStructError<KeyStorageErrorKind>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Returns true
if the key with the given key_id
exists in storage, false
otherwise.