esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
esphome::api::noise::NoiseHandshake Class Reference

Drives the two-message NNpsk0 handshake. More...

#include <noise_handshake.hpp>

Public Types

enum class  Role { Initiator , Responder }
 

Public Member Functions

void initialize (Role role, const SymmetricKey &psk, ByteView prologue)
 Set up with the role, the 32-byte PSK and the prologue.
 
ByteBuffer write_message (ByteView payload=ByteView{})
 Write the next handshake message (Initiator: message 1; Responder: 2).
 
bool read_message (ByteView message, ByteBuffer &out_payload)
 Read the next handshake message into out_payload.
 
bool is_complete () const noexcept
 
void split (CipherState &send, CipherState &recv)
 After completion, derive the transport cipher states for this role (send is what this side encrypts with, recv what it decrypts with).
 
const Hashhandshake_hash () const noexcept
 
void set_ephemeral_for_testing (const PrivateKey &private_key)
 Test hook: force a fixed ephemeral private key (for known-answer vectors).
 

Detailed Description

Drives the two-message NNpsk0 handshake.

The client is the Initiator; the Responder role exists for tests and the loopback emulator.

Token sequence: -> psk, e then <- e, ee. Under PSK, the e token mixes the ephemeral public key into BOTH the hash and the key.

Member Enumeration Documentation

◆ Role

Enumerator
Initiator 
Responder 

Member Function Documentation

◆ handshake_hash()

const Hash & esphome::api::noise::NoiseHandshake::handshake_hash ( ) const
inlinenoexcept

◆ initialize()

void esphome::api::noise::NoiseHandshake::initialize ( Role  role,
const SymmetricKey psk,
ByteView  prologue 
)

Set up with the role, the 32-byte PSK and the prologue.

◆ is_complete()

bool esphome::api::noise::NoiseHandshake::is_complete ( ) const
inlinenoexcept

◆ read_message()

bool esphome::api::noise::NoiseHandshake::read_message ( ByteView  message,
ByteBuffer out_payload 
)

Read the next handshake message into out_payload.

Returns false on an authentication failure (e.g. wrong PSK) or a too-short message.

◆ set_ephemeral_for_testing()

void esphome::api::noise::NoiseHandshake::set_ephemeral_for_testing ( const PrivateKey private_key)

Test hook: force a fixed ephemeral private key (for known-answer vectors).

◆ split()

void esphome::api::noise::NoiseHandshake::split ( CipherState send,
CipherState recv 
)

After completion, derive the transport cipher states for this role (send is what this side encrypts with, recv what it decrypts with).

◆ write_message()

ByteBuffer esphome::api::noise::NoiseHandshake::write_message ( ByteView  payload = ByteView{})

Write the next handshake message (Initiator: message 1; Responder: 2).


The documentation for this class was generated from the following file: