TlsStream

Struct TlsStream 

Source
pub struct TlsStream { /* private fields */ }
Expand description

A TlsStream is generally responsible for handling the framing and decrypting of the TLS Record protocol.

Consider the following scenario

messages ->   |------m1------|--------m2------|--------m3-------|
records  ->   |----r1----|-------r2---|-----r3------|----r4-----|
packets  ->   |--p1--|---p2---|---p3--|---p4--|--p5----|---p6---|

Assume (without loss of generality) that each read call returns an individual, single packet.

§Packet Buffering

We won’t be able to decrypt r1 until we have received both p1 and p2. To handle this we buffer all the reads in byte_buffer until the full record is available.

§Record Buffering

Depending on different key logging implementations, we won’t be able to decrypt the record immediately. We buffer complete records in record_buffer until the decryption keys are available.

Even once we’re able to decrypt records, We won’t be able to parse m1 until we have received both r1 and r2. We buffer the decrypted plaintext in plaintext_content_stream

Note that the content_stream will only ever hold a single content type.

TODO: shenanigans here. We either have to “poll_decrypt” each time we have gotten a full record, or we need to poll_decrypt when we see a new content type (before we add it to the stream). I like the first option because it’s less modality.

THOUGHT: Can obfuscated records have multiple inner content types in them? I think the answer is no. And if the answer is yes then 😭.

Implementations§

Source§

impl TlsStream

Source

pub fn new(sender: Mode) -> Self

Source

pub fn suppress_next_key_state(&mut self)

Set need_next_key_space to false

While the “sender” streams are almost entirely independent, that get’s broken in the event of a hello retry.

Normally, when the Server sends a ServerHello this means that the next message will be the EncryptedExtension (which the TLS Stream will need to decrypt).

But if it was a We need a way for the server stream to tell the client stream that there’s actually another client hello on the way.

Source

pub fn feed_bytes(&mut self, data: &[u8])

Add bytes to a TLS stream.

In the case of a DecryptingPipe, this is the method called by the Read & Write IO methods.

This method will not do any decryption, but will try and assemble existing data into complete records.

Source

pub fn digest_bytes( &mut self, state: &mut ConversationState, key_manger: &KeyManager, ) -> Result<Vec<ContentValue>>

Attempt to decrypt available bytes.

Trait Implementations§

Source§

impl Debug for TlsStream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more