Skip to main content

KeyManager

Trait KeyManager 

Source
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§

Source

fn secrets(&self) -> Arc<RwLock<HashMap<String, Secret>>>

Get access to the secrets storage for this key manager

Source

fn generate_key(&self, options: DIDGenerationOptions) -> Result<GeneratedKey>

Generate a new key with the specified options

Source

fn generate_web_did( &self, domain: &str, options: DIDGenerationOptions, ) -> Result<GeneratedKey>

Generate a new web DID with the specified domain and options

Source

fn add_key(&self, key: &GeneratedKey) -> Result<()>

Add an existing key to the key manager

Source

fn remove_key(&self, did: &str) -> Result<()>

Remove a key from the key manager

Source

fn has_key(&self, did: &str) -> Result<bool>

Check if the key manager has a key for the given DID

Source

fn list_keys(&self) -> Result<Vec<String>>

Get a list of all DIDs in the key manager

Source

fn get_private_key(&self, did: &str) -> Result<(Vec<u8>, KeyType)>

Get the raw private key bytes and key type for a DID

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Implementors§