1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::vault::{KeyId, PublicKey, SecretAttributes, SecretKey};
use crate::Result;
use crate::{async_trait, compat::boxed::Box};

/// Defines the `Secret` management interface for Ockam Vaults.
///
/// # Examples
///
/// See `ockam_vault::SoftwareVault` for a usage example.
///
#[async_trait]
pub trait SecretVault {
    /// Generate a fresh secret with the given attributes.
    async fn secret_generate(&self, attributes: SecretAttributes) -> Result<KeyId>;
    /// Import a secret with the given attributes from binary form into the vault.
    async fn secret_import(&self, secret: &[u8], attributes: SecretAttributes) -> Result<KeyId>;
    /// Export a secret key to the binary form represented as [`SecretKey`].
    async fn secret_export(&self, key_id: &KeyId) -> Result<SecretKey>;
    /// Return the attributes for a secret.
    async fn secret_attributes_get(&self, key_id: &KeyId) -> Result<SecretAttributes>;
    /// Return the associated public key given the secret key.
    async fn secret_public_key_get(&self, key_id: &KeyId) -> Result<PublicKey>;
    /// Remove a secret from the vault.
    async fn secret_destroy(&self, key_id: KeyId) -> Result<()>;
}