1#[cfg(feature = "alloc")]
4use alloc::vec::Vec;
5
6use rand_core::TryCryptoRng;
7
8use crate::errors::Result;
9#[cfg(feature = "private-key")]
10use crate::key::RsaPrivateKey;
11use crate::traits::{PublicKeyParts, UnsignedModularInt};
12
13pub trait PaddingScheme {
15 #[cfg(feature = "private-key")]
20 fn decrypt<Rng: TryCryptoRng + ?Sized>(
21 self,
22 rng: Option<&mut Rng>,
23 priv_key: &RsaPrivateKey,
24 ciphertext: &[u8],
25 ) -> Result<Vec<u8>>;
26
27 #[cfg(feature = "alloc")]
29 fn encrypt<Rng, K, T>(self, rng: &mut Rng, pub_key: &K, msg: &[u8]) -> Result<Vec<u8>>
30 where
31 Rng: TryCryptoRng + ?Sized,
32 T: UnsignedModularInt,
33 K: PublicKeyParts<T>;
34}
35
36pub trait SignatureScheme {
38 #[cfg(feature = "private-key")]
40 fn sign<Rng: TryCryptoRng + ?Sized>(
41 self,
42 rng: Option<&mut Rng>,
43 priv_key: &RsaPrivateKey,
44 hashed: &[u8],
45 ) -> Result<Vec<u8>>;
46
47 fn verify<K, T>(self, pub_key: &K, hashed: &[u8], sig: &[u8]) -> Result<()>
54 where
55 T: UnsignedModularInt,
56 K: PublicKeyParts<T>;
57}