Struct ockam::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
pub fn check_secret(
&mut self,
secret: &[u8],
attributes: &SecretAttributes
) -> Result<(), Error>
pub fn check_secret(
&mut self,
secret: &[u8],
attributes: &SecretAttributes
) -> Result<(), Error>
Validate secret key.
Create a new SoftwareVault
Trait Implementations
pub 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, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
SoftwareVault: 'async_trait,
pub 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, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
SoftwareVault: 'async_trait,
Compute Elliptic-Curve Diffie-Hellman using this secret key and the specified uncompressed public key Read more
Returns the “default value” for a type. Read more
pub 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, Global>
) -> Pin<Box<dyn Future<Output = Result<Vec<Secret, Global>, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
SoftwareVault: 'async_trait,
pub 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, Global>
) -> Pin<Box<dyn Future<Output = Result<Vec<Secret, Global>, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
SoftwareVault: '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
Return KeyId for given public key
pub fn secret_generate<'life0, 'async_trait>(
&'life0 mut self,
attributes: SecretAttributes
) -> Pin<Box<dyn Future<Output = Result<Secret, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
SoftwareVault: 'async_trait,
pub fn secret_generate<'life0, 'async_trait>(
&'life0 mut self,
attributes: SecretAttributes
) -> Pin<Box<dyn Future<Output = Result<Secret, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
SoftwareVault: '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
pub fn secret_import<'life0, 'life1, 'async_trait>(
&'life0 mut self,
secret: &'life1 [u8],
attributes: SecretAttributes
) -> Pin<Box<dyn Future<Output = Result<Secret, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
SoftwareVault: 'async_trait,
pub fn secret_import<'life0, 'life1, 'async_trait>(
&'life0 mut self,
secret: &'life1 [u8],
attributes: SecretAttributes
) -> Pin<Box<dyn Future<Output = Result<Secret, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
SoftwareVault: 'async_trait,
Import a secret with given attributes from binary form into the vault
Export a secret key to the binary form represented as SecretKey
pub fn secret_attributes_get<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret
) -> Pin<Box<dyn Future<Output = Result<SecretAttributes, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
SoftwareVault: 'async_trait,
pub fn secret_attributes_get<'life0, 'life1, 'async_trait>(
&'life0 mut self,
context: &'life1 Secret
) -> Pin<Box<dyn Future<Output = Result<SecretAttributes, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
SoftwareVault: 'async_trait,
Get the attributes for a secret
pub fn sign<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
secret_key: &'life1 Secret,
data: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<Signature, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
SoftwareVault: 'async_trait,
pub fn sign<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
secret_key: &'life1 Secret,
data: &'life2 [u8]
) -> Pin<Box<dyn Future<Output = Result<Signature, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
SoftwareVault: 'async_trait,
Sign data with xeddsa algorithm. Only curve25519 is supported.
pub 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<Vec<u8, Global>, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
SoftwareVault: 'async_trait,
pub 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<Vec<u8, Global>, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
SoftwareVault: 'async_trait,
Encrypt a payload using AES-GCM
pub 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<Vec<u8, Global>, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
SoftwareVault: 'async_trait,
pub 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<Vec<u8, Global>, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
SoftwareVault: 'async_trait,
Decrypt a payload using AES-GCM
pub 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, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
SoftwareVault: 'async_trait,
pub 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, Error>> + Send + 'async_trait, Global>>ⓘ where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
SoftwareVault: '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
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;pub fn vzip(self) -> V
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more