Struct rustls::record_layer::RecordLayer

source ·
pub struct RecordLayer {
    message_encrypter: Box<dyn MessageEncrypter>,
    message_decrypter: Box<dyn MessageDecrypter>,
    write_seq: u64,
    read_seq: u64,
    encrypt_state: DirectionState,
    decrypt_state: DirectionState,
    trial_decryption_len: Option<usize>,
}
Expand description

Record layer that tracks decryption and encryption keys.

Fields§

§message_encrypter: Box<dyn MessageEncrypter>§message_decrypter: Box<dyn MessageDecrypter>§write_seq: u64§read_seq: u64§encrypt_state: DirectionState§decrypt_state: DirectionState§trial_decryption_len: Option<usize>

Implementations§

source§

impl RecordLayer

source

pub fn new() -> Self

Create new record layer with no keys.

source

pub(crate) fn is_encrypting(&self) -> bool

source

fn doing_trial_decryption(&mut self, requested: usize) -> bool

source

pub(crate) fn prepare_message_encrypter( &mut self, cipher: Box<dyn MessageEncrypter>, )

Prepare to use the given MessageEncrypter for future message encryption. It is not used until you call start_encrypting.

source

pub(crate) fn prepare_message_decrypter( &mut self, cipher: Box<dyn MessageDecrypter>, )

Prepare to use the given MessageDecrypter for future message decryption. It is not used until you call start_decrypting.

source

pub(crate) fn start_encrypting(&mut self)

Start using the MessageEncrypter previously provided to the previous call to prepare_message_encrypter.

source

pub(crate) fn start_decrypting(&mut self)

Start using the MessageDecrypter previously provided to the previous call to prepare_message_decrypter.

source

pub(crate) fn set_message_encrypter( &mut self, cipher: Box<dyn MessageEncrypter>, )

Set and start using the given MessageEncrypter for future outgoing message encryption.

source

pub(crate) fn set_message_decrypter( &mut self, cipher: Box<dyn MessageDecrypter>, )

Set and start using the given MessageDecrypter for future incoming message decryption.

source

pub(crate) fn set_message_decrypter_with_trial_decryption( &mut self, cipher: Box<dyn MessageDecrypter>, max_length: usize, )

Set and start using the given MessageDecrypter for future incoming message decryption, and enable “trial decryption” mode for when TLS1.3 0-RTT is attempted but rejected by the server.

source

pub(crate) fn finish_trial_decryption(&mut self)

source

pub(crate) fn wants_close_before_encrypt(&self) -> bool

Return true if we are getting close to encrypting too many messages with our encryption key.

source

pub(crate) fn encrypt_exhausted(&self) -> bool

Return true if we outright refuse to do anything with the encryption key.

source

pub(crate) fn decrypt_incoming( &mut self, encr: OpaqueMessage, ) -> Result<Option<Decrypted>, Error>

Decrypt a TLS message.

encr is a decoded message allegedly received from the peer. If it can be decrypted, its decryption is returned. Otherwise, an error is returned.

source

pub(crate) fn encrypt_outgoing( &mut self, plain: BorrowedPlainMessage<'_>, ) -> OpaqueMessage

Encrypt a TLS message.

plain is a TLS message we’d like to send. This function panics if the requisite keying material hasn’t been established yet.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.