Skip to main content

ContentCipher

Trait ContentCipher 

Source
pub trait ContentCipher:
    Send
    + Sync
    + 'static {
    // Required methods
    fn seal<'a>(
        &'a self,
        plaintext: Vec<u8>,
        context: &'a [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, A2aError>> + Send + 'a>>;
    fn open<'a>(
        &'a self,
        sealed: Vec<u8>,
        context: &'a [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, A2aError>> + Send + 'a>>;
}
Available on crate feature encryption only.
Expand description

Seals and opens part content for EncryptedTaskStore.

The same shape as PushConfigCipher (with the sqlite or postgres feature), so one implementation can serve both; Aes256GcmCipher does. context names where the value is stored and must be authenticated with it, as an AEAD’s associated data: opening under any other context must fail. An implementation must use an authenticated cipher, never reuse a nonce under one key, and fail rather than return unauthenticated plaintext.

Required Methods§

Source

fn seal<'a>( &'a self, plaintext: Vec<u8>, context: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, A2aError>> + Send + 'a>>

Encrypts plaintext, authenticating context with it.

§Errors

An error fails the store’s write, and nothing is stored.

Source

fn open<'a>( &'a self, sealed: Vec<u8>, context: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, A2aError>> + Send + 'a>>

Decrypts what seal returned for the same context.

§Errors

Must fail when sealed was altered or sealed under another context, or its key is unknown. The store’s read then fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§