|
esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
|
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 Hash & | handshake_hash () const noexcept |
| void | set_ephemeral_for_testing (const PrivateKey &private_key) |
| Test hook: force a fixed ephemeral private key (for known-answer vectors). | |
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.
|
strong |
|
inlinenoexcept |
| 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.
|
inlinenoexcept |
| 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.
| 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).
| 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).
| ByteBuffer esphome::api::noise::NoiseHandshake::write_message | ( | ByteView | payload = ByteView{} | ) |
Write the next handshake message (Initiator: message 1; Responder: 2).