pub trait EncryptionAlgorithm {
type Meta: Serialize + DeserializeOwned;
type Secrets: Serialize + DeserializeOwned;
type Context: EncryptionContext;
// Required methods
fn alg() -> &'static str;
fn generate(
&self,
rng: impl RngCore + CryptoRng,
) -> Result<(Key, Self::Secrets), AlgorithmError>;
fn open_inner(
&self,
meta: &Self::Meta,
secrets: &Self::Secrets,
) -> Result<Self::Context, AlgorithmError>;
fn encrypt_inner(
&self,
rng: impl RngCore + CryptoRng,
recipient: &PubRecord,
payload: &[u8],
aad: &[u8],
) -> Result<(Self::Meta, Vec<u8>), AlgorithmError>;
// Provided methods
fn info() -> Vec<u8> ⓘ { ... }
fn open(
&self,
info: &EncryptionInfo,
secrets: &[u8],
) -> Result<Self::Context, AlgorithmError> { ... }
fn encrypt<T>(
&self,
rng: impl RngCore + CryptoRng,
recipient: &PubRecord,
payload: &[u8],
aad: &[u8],
) -> Result<Payload<T>, AlgorithmError> { ... }
}Required Associated Types§
type Meta: Serialize + DeserializeOwned
type Secrets: Serialize + DeserializeOwned
type Context: EncryptionContext
Required Methods§
fn alg() -> &'static str
fn generate( &self, rng: impl RngCore + CryptoRng, ) -> Result<(Key, Self::Secrets), AlgorithmError>
fn open_inner( &self, meta: &Self::Meta, secrets: &Self::Secrets, ) -> Result<Self::Context, AlgorithmError>
fn encrypt_inner( &self, rng: impl RngCore + CryptoRng, recipient: &PubRecord, payload: &[u8], aad: &[u8], ) -> Result<(Self::Meta, Vec<u8>), AlgorithmError>
Provided Methods§
fn info() -> Vec<u8> ⓘ
fn open( &self, info: &EncryptionInfo, secrets: &[u8], ) -> Result<Self::Context, AlgorithmError>
fn encrypt<T>( &self, rng: impl RngCore + CryptoRng, recipient: &PubRecord, payload: &[u8], aad: &[u8], ) -> Result<Payload<T>, AlgorithmError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.