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
43
44
45
46
47
48
49
use alloc::vec::Vec;
use rand_core::CryptoRngCore;
use crate::errors::Result;
use crate::key::{PrivateKey, PublicKey};
pub trait PaddingScheme {
fn decrypt<Rng: CryptoRngCore, Priv: PrivateKey>(
self,
rng: Option<&mut Rng>,
priv_key: &Priv,
ciphertext: &[u8],
) -> Result<Vec<u8>>;
fn encrypt<Rng: CryptoRngCore, Pub: PublicKey>(
self,
rng: &mut Rng,
pub_key: &Pub,
msg: &[u8],
) -> Result<Vec<u8>>;
}
pub trait SignatureScheme {
fn sign<Rng: CryptoRngCore, Priv: PrivateKey>(
self,
rng: Option<&mut Rng>,
priv_key: &Priv,
hashed: &[u8],
) -> Result<Vec<u8>>;
fn verify<Pub: PublicKey>(self, pub_key: &Pub, hashed: &[u8], sig: &[u8]) -> Result<()>;
}