pub trait KeyManager:
Send
+ Sync
+ Debug
+ 'static {
Show 19 methods
// Required methods
fn secrets(&self) -> Arc<RwLock<HashMap<String, Secret>>>;
fn generate_key(
&self,
options: DIDGenerationOptions,
) -> Result<GeneratedKey>;
fn generate_web_did(
&self,
domain: &str,
options: DIDGenerationOptions,
) -> Result<GeneratedKey>;
fn add_key(&self, key: &GeneratedKey) -> Result<()>;
fn remove_key(&self, did: &str) -> Result<()>;
fn has_key(&self, did: &str) -> Result<bool>;
fn list_keys(&self) -> Result<Vec<String>>;
fn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>;
fn add_signing_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn SigningKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_encryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn EncryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_decryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn DecryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_signing_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SigningKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_encryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn EncryptionKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_decryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DecryptionKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn resolve_verification_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VerificationKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn sign_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kid: &'life1 str,
payload: &'life2 [u8],
protected_header: Option<JwsProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn verify_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jws: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn encrypt_jwe<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
sender_kid: &'life1 str,
recipient_kid: &'life2 str,
plaintext: &'life3 [u8],
protected_header: Option<JweProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn decrypt_jwe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jwe: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Trait defining the interface for a key manager component
Required Methods§
Sourcefn secrets(&self) -> Arc<RwLock<HashMap<String, Secret>>>
fn secrets(&self) -> Arc<RwLock<HashMap<String, Secret>>>
Get access to the secrets storage for this key manager
Sourcefn generate_key(&self, options: DIDGenerationOptions) -> Result<GeneratedKey>
fn generate_key(&self, options: DIDGenerationOptions) -> Result<GeneratedKey>
Generate a new key with the specified options
Sourcefn generate_web_did(
&self,
domain: &str,
options: DIDGenerationOptions,
) -> Result<GeneratedKey>
fn generate_web_did( &self, domain: &str, options: DIDGenerationOptions, ) -> Result<GeneratedKey>
Generate a new web DID with the specified domain and options
Sourcefn add_key(&self, key: &GeneratedKey) -> Result<()>
fn add_key(&self, key: &GeneratedKey) -> Result<()>
Add an existing key to the key manager
Sourcefn remove_key(&self, did: &str) -> Result<()>
fn remove_key(&self, did: &str) -> Result<()>
Remove a key from the key manager
Sourcefn has_key(&self, did: &str) -> Result<bool>
fn has_key(&self, did: &str) -> Result<bool>
Check if the key manager has a key for the given DID
Sourcefn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>
fn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>
Get the raw private key bytes and key type for a DID
Sourcefn add_signing_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn SigningKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_signing_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn SigningKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a signing key to the key manager
Sourcefn add_encryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn EncryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_encryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn EncryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add an encryption key to the key manager
Sourcefn add_decryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn DecryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_decryption_key<'life0, 'async_trait>(
&'life0 self,
key: Arc<dyn DecryptionKey + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Add a decryption key to the key manager
Sourcefn get_signing_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SigningKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_signing_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SigningKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a signing key by ID
Sourcefn get_encryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn EncryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_encryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn EncryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get an encryption key by ID
Sourcefn get_decryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DecryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_decryption_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DecryptionKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a decryption key by ID
Sourcefn resolve_verification_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VerificationKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resolve_verification_key<'life0, 'life1, 'async_trait>(
&'life0 self,
kid: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VerificationKey + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resolve a verification key by ID
Sourcefn sign_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kid: &'life1 str,
payload: &'life2 [u8],
protected_header: Option<JwsProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn sign_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
kid: &'life1 str,
payload: &'life2 [u8],
protected_header: Option<JwsProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sign data with a key
Sourcefn verify_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jws: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn verify_jws<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jws: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Verify a JWS
Sourcefn encrypt_jwe<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
sender_kid: &'life1 str,
recipient_kid: &'life2 str,
plaintext: &'life3 [u8],
protected_header: Option<JweProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn encrypt_jwe<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
sender_kid: &'life1 str,
recipient_kid: &'life2 str,
plaintext: &'life3 [u8],
protected_header: Option<JweProtected>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Encrypt data for a recipient
Sourcefn decrypt_jwe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jwe: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn decrypt_jwe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
jwe: &'life1 str,
expected_kid: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Decrypt a JWE