1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pub mod encryptor;
pub mod signer;
pub use crate::Error;
#[cfg(feature = "raw-crypto")]
pub use encryptor::CryptoAlgorithm;
#[cfg(feature = "raw-crypto")]
pub use signer::SignatureAlgorithm;
pub type SymmetricCypherMethod = Box<dyn Fn(&[u8], &[u8], &[u8]) -> Result<Vec<u8>, Error>>;
pub type AssymetricCyptherMethod = Box<dyn Fn(&[u8], &[u8], &[u8], &[u8]) -> Result<Vec<u8>, Error>>;
pub type SigningMethod = Box<dyn Fn(&[u8], &[u8]) -> Result<Vec<u8>, Error>>;
pub type ValidationMethod = Box<dyn Fn(&[u8], &[u8], &[u8]) -> Result<bool, Error>>;
pub trait Cypher {
fn encryptor(&self) -> SymmetricCypherMethod;
fn decryptor(&self) -> SymmetricCypherMethod;
fn assymetric_encryptor(&self) -> AssymetricCyptherMethod;
}
pub trait Signer {
fn signer(&self) -> SigningMethod;
fn validator(&self) -> ValidationMethod;
}