Skip to main content

TransportState

Struct TransportState 

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

A Noise transport session: one ciphertext per message.

The nonce advances with every message in each direction; a repeated or reordered ciphertext fails authentication. Payloads are not fragmented at this layer, so a caller that needs to send more than a single Noise message can carry has to split the data itself.

Implementations§

Source§

impl TransportState

Source

pub fn suite(&self) -> Suite

Returns the cipher suite these keys were derived under.

A re-handshake must use it again, and so must anything the specification seals with the suite’s AEAD, such as a pairing payload.

Source

pub fn handshake_hash(&self) -> &[u8; 32]

Returns the handshake hash h of the handshake these keys came from.

Noise finalises h when the second handshake message is processed, and nothing after that changes it. Sendspin uses it once: a re-handshake mixes the previous handshake’s h in as its prologue, so a second handshake that reuses these keys must be built with this value. It is a transcript hash, not key material, but it must still never be logged.

Source

pub fn encrypt(&mut self, plaintext: &[u8]) -> Result<Vec<u8>>

Encrypts one plaintext into a Noise transport message.

Fails if the plaintext does not fit into a single Noise message, that is if it is larger than MAX_MESSAGE_LEN minus the 16-byte authentication tag.

Source

pub fn decrypt(&mut self, ciphertext: &[u8]) -> Result<Vec<u8>>

Decrypts one Noise transport message.

Fails if the ciphertext is longer than a Noise message, shorter than the authentication tag, or does not authenticate under the current key and nonce.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.