Skip to main content

TlsSession

Trait TlsSession 

Source
pub trait TlsSession: Send + 'static {
    // Required methods
    fn step<'i>(
        &mut self,
        input: &'i mut [u8],
        output: &mut [u8],
    ) -> Result<TlsProgress<'i>, TlsError>;
    fn encrypt(
        &mut self,
        plaintext: &[u8],
        output: &mut [u8],
    ) -> Result<usize, TlsError>;
    fn close(&mut self, output: &mut [u8]) -> Result<usize, TlsError>;
    fn on_transport_closed(&mut self) -> TlsCloseKind;
    fn info(&self) -> Option<TlsInfo>;
    fn input_capacity_required(&self) -> usize;
}
Expand description

One connection’s TLS state machine. Never blocks, never does IO.

See docs/API.md (TLS seam) for how the server drives it.

Required Methods§

Source

fn step<'i>( &mut self, input: &'i mut [u8], output: &mut [u8], ) -> Result<TlsProgress<'i>, TlsError>

Ciphertext is in input; free space for records to send is output.

§Errors

A TlsError; TlsFailure::HelloRefused closes the connection with CloseReason::HelloRefused, anything else with TlsFailed.

Source

fn encrypt( &mut self, plaintext: &[u8], output: &mut [u8], ) -> Result<usize, TlsError>

Encrypts plaintext into output: all records or none.

§Errors

TlsFailure::OutputFull when output cannot hold every record.

Source

fn close(&mut self, output: &mut [u8]) -> Result<usize, TlsError>

Writes close_notify into output.

§Errors

TlsFailure::OutputFull or TlsFailure::State.

Source

fn on_transport_closed(&mut self) -> TlsCloseKind

The peer’s transport closed: was the TLS stream ended cleanly?

Source

fn info(&self) -> Option<TlsInfo>

SNI, ALPN, version, and cipher suite; Some after the handshake.

Source

fn input_capacity_required(&self) -> usize

The smallest input buffer the session needs now.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§