Trait encrypt_stuff::encryption::Encryption

source ·
pub trait Encryption {
    type Cipher: Aead + AeadCore + KeyInit + KeySizeUser;

    // Provided methods
    fn encrypt<Data: Serialize>(
        data: &Data,
        key: &GenericArray<u8, <Self::Cipher as KeySizeUser>::KeySize>,
    ) -> Result<Encrypted<Data>, EncryptionError> { ... }
    fn decrypt<Data>(
        encrypted: &Encrypted<Data>,
        key: &GenericArray<u8, <Self::Cipher as KeySizeUser>::KeySize>,
    ) -> Result<Decrypted<Data>, EncryptionError> { ... }
    fn decrypt_exposed<Data>(
        encrypted: &Encrypted<Data>,
        key: &GenericArray<u8, <Self::Cipher as KeySizeUser>::KeySize>,
    ) -> Result<DecryptedExposed<Data>, EncryptionError> { ... }
}
Expand description

general trait for encrypting serializable data

Required Associated Types§

Provided Methods§

source

fn encrypt<Data: Serialize>( data: &Data, key: &GenericArray<u8, <Self::Cipher as KeySizeUser>::KeySize>, ) -> Result<Encrypted<Data>, EncryptionError>

convert the data to it’s serialized form and then encypt it using [Cipher]

source

fn decrypt<Data>( encrypted: &Encrypted<Data>, key: &GenericArray<u8, <Self::Cipher as KeySizeUser>::KeySize>, ) -> Result<Decrypted<Data>, EncryptionError>

decrypt the data to it’s serialized form, pre-emptively wraps data in a Secret

source

fn decrypt_exposed<Data>( encrypted: &Encrypted<Data>, key: &GenericArray<u8, <Self::Cipher as KeySizeUser>::KeySize>, ) -> Result<DecryptedExposed<Data>, EncryptionError>

decrypt the data to it’s serialized form

Object Safety§

This trait is not object safe.

Implementors§