Skip to main content

RandomAccessDecryptor

Trait RandomAccessDecryptor 

Source
pub(crate) trait RandomAccessDecryptor<R> {
    type Error;

    // Required method
    async fn decrypt_range(
        &self,
        data_source: R,
        range: Range<usize>,
    ) -> Result<Vec<u8>, Self::Error>;
}
Expand description

A symmetric decryptor that supports random-access reads: given the complete encrypted wire stream and a plaintext byte range, return only the plaintext covering that range.

Random access is only possible for wire formats whose framing lets the decryptor seek into the ciphertext without reading the whole stream and whose chunks are individually authenticated. Chunked-AEAD STREAM qualifies (fixed-size nonce prefix + fixed-size chunks, each with its own AEAD tag); AES-256-CBC + HMAC-SHA256 does not, because its trailing MAC covers the entire ciphertext and the stream must be read in full before any bytes can be trusted.

Required Associated Types§

Source

type Error

Error returned when authentication fails on any read chunk, the wire bytes are shorter than the framing requires, or range exceeds the plaintext length.

Required Methods§

Source

async fn decrypt_range( &self, data_source: R, range: Range<usize>, ) -> Result<Vec<u8>, Self::Error>

Decrypt the plaintext bytes covering range from the encrypted ciphertext byte stream.

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.

Implementors§