Skip to main content

Encryptor

Trait Encryptor 

Source
pub trait Encryptor: Sync + Send {
    // Required methods
    fn encrypt(
        &self,
        plaintext: &[u8],
    ) -> Result<EncryptionResult, OperationOutcomeError>;
    fn decrypt(
        &self,
        ciphertext: &EncryptionResult,
    ) -> Result<Vec<u8>, OperationOutcomeError>;
}
Expand description

Provides symmetric authenticated encryption and decryption of arbitrary byte payloads.

Implementations are expected to encrypt data in a way that ensures both confidentiality and integrity. A value returned by Self::encrypt should be decryptable only by the same implementation initialized with the same keying material.

Required Methods§

Source

fn encrypt( &self, plaintext: &[u8], ) -> Result<EncryptionResult, OperationOutcomeError>

Encrypts the given plaintext.

§Errors

Returns an [OperationOutcomeError] if the plaintext cannot be encrypted.

Source

fn decrypt( &self, ciphertext: &EncryptionResult, ) -> Result<Vec<u8>, OperationOutcomeError>

Decrypts a previously encrypted payload.

§Errors

Returns an [OperationOutcomeError] if the ciphertext is invalid, has been tampered with, or cannot be decrypted.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§