pub trait Encryptable<O> {
// Provided methods
fn encrypt<F>(
&self,
key: &Key,
csprng: impl CryptoRngCore,
) -> Result<F, CryptError>
where F: From<(XNonce, Vec<u8>)>,
Self: ProstEncode + Decryptable<O> + Decryptable<F> { ... }
fn encrypt_owned<F>(
self,
key: &Key,
csprng: impl CryptoRngCore,
) -> Result<F, CryptError>
where F: From<(XNonce, Vec<u8>)>,
Self: ProstEncodeOwned + Decryptable<O> + Decryptable<F> { ... }
fn encrypt_owned_with_nonce<F>(
self,
key: &Key,
nonce: &XNonce,
) -> Result<F, CryptError>
where F: From<Vec<u8>>,
Self: ProstEncodeOwned + DecryptableWithNonce<O> + Decryptable<F> + Sized { ... }
}Expand description
Encryptable using symmetric encryption.
Provides multiple encryption methods for data structures, supporting both
automatic nonce generation and explicit nonce usage. The O parameter
represents the output type after encryption.
Provided Methods§
Sourcefn encrypt<F>(
&self,
key: &Key,
csprng: impl CryptoRngCore,
) -> Result<F, CryptError>
fn encrypt<F>( &self, key: &Key, csprng: impl CryptoRngCore, ) -> Result<F, CryptError>
Encrypt this data structure with automatic nonce generation.
Sourcefn encrypt_owned<F>(
self,
key: &Key,
csprng: impl CryptoRngCore,
) -> Result<F, CryptError>
fn encrypt_owned<F>( self, key: &Key, csprng: impl CryptoRngCore, ) -> Result<F, CryptError>
Encrypt this data structure by taking ownership, with automatic nonce generation.
Sourcefn encrypt_owned_with_nonce<F>(
self,
key: &Key,
nonce: &XNonce,
) -> Result<F, CryptError>
fn encrypt_owned_with_nonce<F>( self, key: &Key, nonce: &XNonce, ) -> Result<F, CryptError>
Encrypt this data structure using a provided nonce.
For instances where nonces are managed externally.
§Security
Never reuse the same nonce with the same key, as this breaks semantic security.
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.