Trait Encryptable

Source
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§

Source

fn encrypt<F>( &self, key: &Key, csprng: impl CryptoRngCore, ) -> Result<F, CryptError>
where F: From<(XNonce, Vec<u8>)>, Self: ProstEncode + Decryptable<O> + Decryptable<F>,

Encrypt this data structure with automatic nonce generation.

Source

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>,

Encrypt this data structure by taking ownership, with automatic nonce generation.

Source

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,

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.

Implementations on Foreign Types§

Source§

impl Encryptable<Envelope> for MessageVaultPassport

Source§

impl Encryptable<GenericVault> for Key

Source§

impl Encryptable<GenericVault> for SharedSecretKeys

Source§

impl Encryptable<MessageVault> for Message

Implementors§