ockam_vault_sync_core/vault_mutex/
hasher.rs1use crate::VaultMutex;
2use ockam_core::vault::{Hasher, Secret, SecretAttributes, SmallBuffer};
3use ockam_core::Result;
4use ockam_core::{async_trait, compat::boxed::Box};
5
6#[async_trait]
7impl<V: Hasher + Send> Hasher for VaultMutex<V> {
8 async fn sha256(&mut self, data: &[u8]) -> Result<[u8; 32]> {
9 self.0.lock().await.sha256(data).await
10 }
11
12 async fn hkdf_sha256(
13 &mut self,
14 salt: &Secret,
15 info: &[u8],
16 ikm: Option<&Secret>,
17 output_attributes: SmallBuffer<SecretAttributes>,
18 ) -> Result<SmallBuffer<Secret>> {
19 self.0
20 .lock()
21 .await
22 .hkdf_sha256(salt, info, ikm, output_attributes)
23 .await
24 }
25}
26
27#[cfg(test)]
28mod tests {
29 use ockam_vault::SoftwareVault;
30
31 fn new_vault() -> SoftwareVault {
32 SoftwareVault::default()
33 }
34
35 #[ockam_macros::vault_test]
36 fn sha256() {}
37
38 #[ockam_macros::vault_test]
39 fn hkdf() {}
40}