Skip to main content

RecordEncrypter

Trait RecordEncrypter 

Source
pub trait RecordEncrypter: Send + Sync {
    // Required methods
    fn encrypt(
        &mut self,
        record: Record<OutboundPlain<'_>>,
        seq: u64,
        out: &mut Vec<u8>,
    ) -> Result<(), Error>;
    fn encrypted_payload_len(&self, payload_len: usize) -> usize;
}
Expand description

Objects with this trait can encrypt TLS records.

Required Methods§

Source

fn encrypt( &mut self, record: Record<OutboundPlain<'_>>, seq: u64, out: &mut Vec<u8>, ) -> Result<(), Error>

Encrypt the given TLS record, appending it to out.

seq is the sequence number of this record, which can be used to derive a unique Nonce.

A full wire-format TLS record, including all framing the ciphersuite requires, such as any explicit nonce, padding and/or authentication tag, must be appended to out. Any existing data on the front of out must be left alone.

Source

fn encrypted_payload_len(&self, payload_len: usize) -> usize

Return the length of the ciphertext that results from encrypting plaintext of length payload_len.

For a zero payload_len this should return the minimum overhead for any payload. Then, to fragment a long payload into chunks of length F, Rustls will first set A := encrypted_payload_len(0) and then supply the payload to Self::encrypt() in chunks of length F - A. Each encrypt() is then free to pad or otherwise transform the length at its option.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§