From 8cefe7c16b21ce39ec271d9c8c9447fcacf9f127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 17 Mar 2024 14:35:26 +0100 Subject: [PATCH] Move the scheme return fn type definitions to the scheme module --- src/cipher_box.rs | 4 ---- src/scheme.rs | 10 +++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cipher_box.rs b/src/cipher_box.rs index 7e4b29f..34a3e02 100644 --- a/src/cipher_box.rs +++ b/src/cipher_box.rs @@ -5,10 +5,6 @@ use crate::kdf::derive_key; use crate::{storage, IkmId, InputKeyMaterialList}; use std::time::{SystemTime, UNIX_EPOCH}; -pub(crate) type DecryptionFunction = dyn Fn(&[u8], &EncryptedData, &str) -> Result>; -pub(crate) type EncryptionFunction = dyn Fn(&[u8], &[u8], &[u8], &str) -> Result; -pub(crate) type GenNonceFunction = dyn Fn() -> Result>; - #[derive(Debug)] pub(crate) struct EncryptedData { pub(crate) nonce: Vec, diff --git a/src/scheme.rs b/src/scheme.rs index 853bc6a..a089481 100644 --- a/src/scheme.rs +++ b/src/scheme.rs @@ -1,5 +1,7 @@ #[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")] use crate::kdf::KdfFunction; use crate::Error; @@ -9,6 +11,12 @@ mod blake3; #[cfg(feature = "encryption")] mod xchacha20poly1305; +#[cfg(feature = "encryption")] +pub(crate) type DecryptionFunction = dyn Fn(&[u8], &EncryptedData, &str) -> Result>; +#[cfg(feature = "encryption")] +pub(crate) type EncryptionFunction = dyn Fn(&[u8], &[u8], &[u8], &str) -> Result; +#[cfg(feature = "encryption")] +pub(crate) type GenNonceFunction = dyn Fn() -> Result>; pub(crate) type SchemeSerializeType = u32; #[derive(Copy, Clone, Debug, PartialEq)]