noise_sv2

Struct Responder

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

Represents the state and operations of the responder in the Noise NX protocol handshake. It handles cryptographic key exchanges, manages handshake state, and securely establishes a connection with the initiator. The responder manages key generation, Diffie-Hellman exchanges, message decryption, and state transitions, ensuring secure communication. Sensitive cryptographic material is securely erased when no longer needed.

Implementations§

Source§

impl Responder

Source

pub fn new(a: Keypair, cert_validity: u32) -> Box<Self>

Creates a new Responder instance with the provided authority keypair and certificate validity.

Constructs a new Responder with the necessary cryptographic state for the Noise NX protocol handshake. It generates ephemeral and static key pairs for the responder and prepares the handshake state. The authority keypair and certificate validity period are also configured.

Source

pub fn from_authority_kp( public: &[u8; 32], private: &[u8; 32], cert_validity: Duration, ) -> Result<Box<Self>, Error>

Creates a new Responder instance with the provided 32-byte authority key pair.

Constructs a new Responder with a given public and private key pair, which represents the responder’s authority credentials. It verifies that the provided public key matches the corresponding private key, ensuring the authenticity of the authority key pair. The certificate validity duration is also set here. Fails if the key pair is mismatched.

Source

pub fn step_1( &mut self, elligatorswift_theirs_ephemeral_serialized: [u8; 64], ) -> Result<([u8; 234], NoiseCodec), Error>

Processes the first step of the Noise NX protocol handshake for the responder.

This function manages the responder’s side of the handshake after receiving the initiator’s initial message. It processes the ephemeral public key provided by the initiator, derives the necessary shared secrets, and constructs the response message. The response includes the responder’s ephemeral public key (in its ElligatorSwift-encoded form), the encrypted static public key, and a signature noise message. Additionally, it establishes the session ciphers for encrypting and decrypting further communication.

On success, it returns a tuple containing the response message to be sent back to the initiator and a NoiseCodec instance, which is configured with the session ciphers for secure transmission of subsequent messages.

On failure, the method returns an error if there is an issue during encryption, decryption, or any other step of the handshake process.

Trait Implementations§

Source§

impl Debug for Responder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Responder

Source§

fn drop(&mut self)

Ensures that sensitive data is securely erased when the Responder instance is dropped, preventing any potential leakage of cryptographic material.

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