use crate::{
AeadSecretKeyHandle, HashOutput, HkdfOutput, SecretBufferHandle, X25519PublicKey,
X25519SecretKeyHandle,
};
use ockam_core::compat::vec::Vec;
use ockam_core::{async_trait, compat::boxed::Box, Result};
pub enum HKDFNumberOfOutputs {
Two,
Three,
}
#[async_trait]
pub trait VaultForSecureChannels: Send + Sync + 'static {
async fn x25519_ecdh(
&self,
secret_key_handle: &X25519SecretKeyHandle,
peer_public_key: &X25519PublicKey,
) -> Result<SecretBufferHandle>;
async fn hash(&self, data: &[u8]) -> Result<HashOutput>;
async fn hkdf(
&self,
salt: &SecretBufferHandle,
input_key_material: Option<&SecretBufferHandle>,
number_of_outputs: HKDFNumberOfOutputs,
) -> Result<HkdfOutput>;
async fn aead_encrypt(
&self,
secret_key_handle: &AeadSecretKeyHandle,
plain_text: &mut [u8],
nonce: &[u8],
aad: &[u8],
) -> Result<()>;
async fn aead_decrypt<'a>(
&self,
secret_key_handle: &AeadSecretKeyHandle,
cipher_text: &'a mut [u8],
nonce: &[u8],
aad: &[u8],
) -> Result<&'a mut [u8]>;
async fn persist_aead_key(&self, secret_key_handle: &AeadSecretKeyHandle) -> Result<()>;
async fn load_aead_key(&self, secret_key_handle: &AeadSecretKeyHandle) -> Result<()>;
async fn generate_static_x25519_secret_key(&self) -> Result<X25519SecretKeyHandle>;
async fn delete_static_x25519_secret_key(
&self,
secret_key_handle: X25519SecretKeyHandle,
) -> Result<bool>;
async fn generate_ephemeral_x25519_secret_key(&self) -> Result<X25519SecretKeyHandle>;
async fn delete_ephemeral_x25519_secret_key(
&self,
secret_key_handle: X25519SecretKeyHandle,
) -> Result<bool>;
async fn get_x25519_public_key(
&self,
secret_key_handle: &X25519SecretKeyHandle,
) -> Result<X25519PublicKey>;
async fn get_x25519_secret_key_handle(
&self,
public_key: &X25519PublicKey,
) -> Result<X25519SecretKeyHandle>;
async fn import_secret_buffer(&self, buffer: Vec<u8>) -> Result<SecretBufferHandle>;
async fn delete_secret_buffer(&self, secret_buffer_handle: SecretBufferHandle) -> Result<bool>;
async fn convert_secret_buffer_to_aead_key(
&self,
secret_buffer_handle: SecretBufferHandle,
) -> Result<AeadSecretKeyHandle>;
async fn delete_aead_secret_key(&self, secret_key_handle: AeadSecretKeyHandle) -> Result<bool>;
}