Skip to main content

TlsClientHelloReader

Struct TlsClientHelloReader 

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

TLS ClientHello reader with incremental parsing support

This struct manages reading and parsing TLS ClientHello messages incrementally, handling cases where the ClientHello arrives in multiple TCP packets.

§Example

use huginn_net_tls::TlsClientHelloReader;

let mut reader = TlsClientHelloReader::new();

// Add bytes incrementally
reader.add_bytes(&[0x16, 0x03, 0x01, 0x00, 0x4a]);
reader.add_bytes(&[/* more bytes */]);

if let Some(signature) = reader.get_signature() {
    println!("Got TLS signature");
}

Implementations§

Source§

impl TlsClientHelloReader

Source

pub fn new() -> Self

Create a new TLS ClientHello reader

§Returns

A new TlsClientHelloReader instance ready to process TLS ClientHello data

Source

pub fn add_bytes( &mut self, data: &[u8], ) -> Result<Option<Signature>, HuginnNetTlsError>

Add bytes to the buffer and attempt to parse ClientHello

This method handles incremental data arrival, parsing the ClientHello as soon as enough data is available.

§Parameters
  • data: New bytes to add to the buffer
§Returns
  • Ok(Some(Signature)) if ClientHello was successfully parsed
  • Ok(None) if more data is needed or signature already parsed
  • Err(HuginnNetTlsError) if parsing fails
Source

pub fn get_signature(&self) -> Option<&Signature>

Get the parsed signature if available

§Returns
  • Some(Signature) if signature has been parsed
  • None if signature not yet available
Source

pub fn signature_parsed(&self) -> bool

Check if signature has been parsed

§Returns

true if signature is available, false otherwise

Source

pub fn reset(&mut self)

Reset the reader to process a new ClientHello

Clears the buffer and resets parsing state, allowing the reader to be reused.

Source

pub fn buffer_len(&self) -> usize

Get the current buffer size

Returns the number of bytes currently accumulated in the buffer.

Trait Implementations§

Source§

impl Default for TlsClientHelloReader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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