Struct ockam_vault::SoftwareVault [−][src]
pub struct SoftwareVault { /* fields omitted */ }
Expand description
Vault implementation that stores secrets in memory and uses software crypto.
Examples
use ockam_vault::SoftwareVault;
use ockam_core::Result;
use ockam_vault_core::{SecretAttributes, SecretType, SecretPersistence, CURVE25519_SECRET_LENGTH, SecretVault, Signer, Verifier};
async fn example() -> Result<()> {
let mut vault = SoftwareVault::default();
let mut attributes = SecretAttributes::new(
SecretType::Curve25519,
SecretPersistence::Ephemeral,
CURVE25519_SECRET_LENGTH,
);
let secret = vault.secret_generate(attributes).await?;
let public = vault.secret_public_key_get(&secret).await?;
let data = "Very important stuff".as_bytes();
let signature = vault.sign(&secret, data).await?;
assert!(vault.verify(&signature, &public, data).await?);
Ok(())
}
Implementations
Validate secret key.
Trait Implementations
fn ec_diffie_hellman<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret,
peer_public_key: &'life2 PublicKey
) -> Pin<Box<dyn Future<Output = Result<Secret>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn ec_diffie_hellman<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret,
peer_public_key: &'life2 PublicKey
) -> Pin<Box<dyn Future<Output = Result<Secret>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Compute Elliptic-Curve Diffie-Hellman using this secret key and the specified uncompressed public key Read more
fn hkdf_sha256<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
salt: &'life1 Secret,
info: &'life2 [u8],
ikm: Option<&'life3 Secret>,
output_attributes: Vec<SecretAttributes>
) -> Pin<Box<dyn Future<Output = Result<Vec<Secret>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn hkdf_sha256<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
salt: &'life1 Secret,
info: &'life2 [u8],
ikm: Option<&'life3 Secret>,
output_attributes: Vec<SecretAttributes>
) -> Pin<Box<dyn Future<Output = Result<Vec<Secret>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Compute sha256. Salt and Ikm should be of Buffer type. Output secrets should be only of type Buffer or AES
Return Secret
for given key id
fn secret_generate<'life0, 'async_trait>(
&'life0 mut self,
attributes: SecretAttributes
) -> Pin<Box<dyn Future<Output = Result<Secret>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn secret_generate<'life0, 'async_trait>(
&'life0 mut self,
attributes: SecretAttributes
) -> Pin<Box<dyn Future<Output = Result<Secret>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Generate fresh secret. Only Curve25519 and Buffer types are supported
Extract public key from secret. Only Curve25519 type is supported
Remove secret from memory
Import a secret with given attributes from binary form into the vault
Export a secret key to the binary form represented as SecretKey
fn secret_attributes_get<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret
) -> Pin<Box<dyn Future<Output = Result<SecretAttributes>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn secret_attributes_get<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret
) -> Pin<Box<dyn Future<Output = Result<SecretAttributes>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Get the attributes for a secret
Sign data with xeddsa algorithm. Only curve25519 is supported.
fn aead_aes_gcm_encrypt<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret,
plaintext: &'life2 [u8],
nonce: &'life3 [u8],
aad: &'life4 [u8]
) -> Pin<Box<dyn Future<Output = Result<Buffer<u8>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn aead_aes_gcm_encrypt<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret,
plaintext: &'life2 [u8],
nonce: &'life3 [u8],
aad: &'life4 [u8]
) -> Pin<Box<dyn Future<Output = Result<Buffer<u8>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Encrypt a payload using AES-GCM
fn aead_aes_gcm_decrypt<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret,
cipher_text: &'life2 [u8],
nonce: &'life3 [u8],
aad: &'life4 [u8]
) -> Pin<Box<dyn Future<Output = Result<Buffer<u8>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn aead_aes_gcm_decrypt<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret,
cipher_text: &'life2 [u8],
nonce: &'life3 [u8],
aad: &'life4 [u8]
) -> Pin<Box<dyn Future<Output = Result<Buffer<u8>>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Decrypt a payload using AES-GCM
fn verify<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
signature: &'life1 Signature,
public_key: &'life2 PublicKey,
data: &'life3 [u8]
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn verify<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 mut self,
signature: &'life1 Signature,
public_key: &'life2 PublicKey,
data: &'life3 [u8]
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Verify signature with xeddsa algorithm. Only curve25519 is supported.
Auto Trait Implementations
impl RefUnwindSafe for SoftwareVault
impl Send for SoftwareVault
impl Sync for SoftwareVault
impl Unpin for SoftwareVault
impl UnwindSafe for SoftwareVault
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more