Struct TransportState

Source
pub struct TransportState<H: Hash> { /* private fields */ }
Expand description

Noise transport session between 2 participant. Communication is Asymmetric. So it is possible to send messages independently from the messages to receive. This allows to continue sending our current messages without having to make sure we are in sync with the remote messages.

All messages are authenticated and because we are rekeying after each messages we have strong forward secrecy.

Implementations§

Source§

impl<H: Hash> TransportState<H>

Source

pub fn split(self) -> (TransportSendHalf<H>, TransportReceiveHalf<H>)

split the transport state into a sending half and receiving half

this is to make it easier to handle bidirectional connections asynchronously.

Source

pub fn noise_session(&self) -> &H::HASH

unique identifier of the noise session

Source

pub fn remote_public_identity(&self) -> &PublicKey

get the remote’s public identity

Source

pub fn count_received(&self) -> u64

get the number of message received from the remote peer

this function will be a little tainted by the handshake state it also account for the number of times either encrypt or decrypt has been used during the handshake. This is because during the handshake the exchange is symmetrical while in the transport era the exchanges are asymmetrical.

Source

pub fn count_sent(&self) -> u64

get the number of message sent to the remote peer

this function will be a little tainted by the handshake state it also account for the number of times either encrypt or decrypt has been used during the handshake. This is because during the handshake the exchange is symmetrical while in the transport era the exchanges are asymmetrical.

Source

pub fn send( &mut self, input: impl AsRef<[u8]>, output: &mut [u8], ) -> Result<(), CipherStateError>

send message to the remote peer

The output must be at least 16 bytes longer than the input this is in order to add the MAC, this will be use to authenticate the message has not been tempered with.

Source

pub fn receive( &mut self, input: impl AsRef<[u8]>, output: &mut [u8], ) -> Result<(), CipherStateError>

receive message from the remote peer

The output can have 16 bytes less than the input. This is because the MAC is appended in the input message so we can verify the message has not been tempered with.

Auto Trait Implementations§

§

impl<H> Freeze for TransportState<H>
where <H as Hash>::HASH: Freeze,

§

impl<H> RefUnwindSafe for TransportState<H>
where <H as Hash>::HASH: RefUnwindSafe,

§

impl<H> Send for TransportState<H>
where <H as Hash>::HASH: Send,

§

impl<H> Sync for TransportState<H>
where <H as Hash>::HASH: Sync,

§

impl<H> Unpin for TransportState<H>
where <H as Hash>::HASH: Unpin,

§

impl<H> UnwindSafe for TransportState<H>
where <H as Hash>::HASH: UnwindSafe,

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

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V