Move the scheme return fn type definitions to the scheme module

This commit is contained in:
Rodolphe Bréard 2024-03-17 14:35:26 +01:00
parent b8539602f0
commit 8cefe7c16b
2 changed files with 9 additions and 5 deletions

View file

@ -5,10 +5,6 @@ use crate::kdf::derive_key;
use crate::{storage, IkmId, InputKeyMaterialList}; use crate::{storage, IkmId, InputKeyMaterialList};
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
pub(crate) type DecryptionFunction = dyn Fn(&[u8], &EncryptedData, &str) -> Result<Vec<u8>>;
pub(crate) type EncryptionFunction = dyn Fn(&[u8], &[u8], &[u8], &str) -> Result<EncryptedData>;
pub(crate) type GenNonceFunction = dyn Fn() -> Result<Vec<u8>>;
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct EncryptedData { pub(crate) struct EncryptedData {
pub(crate) nonce: Vec<u8>, pub(crate) nonce: Vec<u8>,

View file

@ -1,5 +1,7 @@
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use crate::cipher_box::{DecryptionFunction, EncryptionFunction, GenNonceFunction}; use crate::cipher_box::EncryptedData;
#[cfg(feature = "encryption")]
use crate::error::Result;
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use crate::kdf::KdfFunction; use crate::kdf::KdfFunction;
use crate::Error; use crate::Error;
@ -9,6 +11,12 @@ mod blake3;
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
mod xchacha20poly1305; mod xchacha20poly1305;
#[cfg(feature = "encryption")]
pub(crate) type DecryptionFunction = dyn Fn(&[u8], &EncryptedData, &str) -> Result<Vec<u8>>;
#[cfg(feature = "encryption")]
pub(crate) type EncryptionFunction = dyn Fn(&[u8], &[u8], &[u8], &str) -> Result<EncryptedData>;
#[cfg(feature = "encryption")]
pub(crate) type GenNonceFunction = dyn Fn() -> Result<Vec<u8>>;
pub(crate) type SchemeSerializeType = u32; pub(crate) type SchemeSerializeType = u32;
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]