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
impl Responder
Sourcepub fn new(a: Keypair, cert_validity: u32) -> Box<Self>
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.
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.
Sourcepub fn step_1(
&mut self,
elligatorswift_theirs_ephemeral_serialized: [u8; 64],
) -> Result<([u8; 234], NoiseCodec), Error>
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.