|
esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
|
Classes | |
| class | CipherState |
| Wraps a symmetric key plus a monotonically increasing nonce, per the Noise CipherState object. More... | |
| class | NoiseHandshake |
| Drives the two-message NNpsk0 handshake. More... | |
| class | SymmetricState |
Implements the Noise SymmetricState object: it accumulates the handshake transcript hash h, derives keys through the chaining key ck, and owns the handshake CipherState. More... | |
Typedefs | |
| using | Hash = std::array< std::uint8_t, hash_len > |
| using | SymmetricKey = std::array< std::uint8_t, key_len > |
| using | PublicKey = std::array< std::uint8_t, key_len > |
| using | PrivateKey = std::array< std::uint8_t, key_len > |
Functions | |
| Hash | sha256 (ByteView data) |
SHA-256 of data. | |
| Hash | hmac_sha256 (ByteView key, ByteView data) |
HMAC-SHA-256 with key over data. | |
| void | hkdf (const Hash &chaining_key, ByteView input_key_material, int num_outputs, Hash &o1, Hash &o2, Hash &o3) |
Noise HKDF: derive num_outputs (1..3) 32-byte values from chaining_key and input_key_material. | |
| PublicKey | x25519_base (const PrivateKey &private_key) |
| X25519 public key for a private scalar. | |
| SymmetricKey | x25519 (const PrivateKey &private_key, const PublicKey &peer_public) |
| X25519 shared secret. Throws EncryptionError on an all-zero (degenerate) result. | |
| void | generate_keypair (PrivateKey &private_key, PublicKey &public_key) |
| Generate a fresh X25519 keypair from the system CSPRNG. | |
| ByteBuffer | aead_encrypt (const SymmetricKey &key, std::uint64_t nonce, ByteView ad, ByteView plaintext) |
| AEAD ChaCha20-Poly1305 (IETF) encryption. | |
| bool | aead_decrypt (const SymmetricKey &key, std::uint64_t nonce, ByteView ad, ByteView ciphertext, ByteBuffer &out_plaintext) |
| AEAD ChaCha20-Poly1305 (IETF) decryption. Returns false on auth failure. | |
| bool | base64_decode (const std::string &text, ByteBuffer &out) |
| Decode standard base64. Returns false on malformed input. | |
Variables | |
| constexpr auto | protocol_name = "Noise_NNpsk0_25519_ChaChaPoly_SHA256" |
| Noise protocol name for the ESPHome native API. | |
| constexpr std::size_t | hash_len = 32 |
| SHA-256 digest / key size. | |
| constexpr std::size_t | key_len = 32 |
| Symmetric / DH key size. | |
| using esphome::api::noise::Hash = typedef std::array<std::uint8_t, hash_len> |
| using esphome::api::noise::PrivateKey = typedef std::array<std::uint8_t, key_len> |
| using esphome::api::noise::PublicKey = typedef std::array<std::uint8_t, key_len> |
| using esphome::api::noise::SymmetricKey = typedef std::array<std::uint8_t, key_len> |
| bool esphome::api::noise::aead_decrypt | ( | const SymmetricKey & | key, |
| std::uint64_t | nonce, | ||
| ByteView | ad, | ||
| ByteView | ciphertext, | ||
| ByteBuffer & | out_plaintext | ||
| ) |
AEAD ChaCha20-Poly1305 (IETF) decryption. Returns false on auth failure.
| ByteBuffer esphome::api::noise::aead_encrypt | ( | const SymmetricKey & | key, |
| std::uint64_t | nonce, | ||
| ByteView | ad, | ||
| ByteView | plaintext | ||
| ) |
AEAD ChaCha20-Poly1305 (IETF) encryption.
nonce is the Noise message counter (encoded as 4 zero bytes + 8-byte little-endian). Returns ciphertext||tag.
| bool esphome::api::noise::base64_decode | ( | const std::string & | text, |
| ByteBuffer & | out | ||
| ) |
Decode standard base64. Returns false on malformed input.
| void esphome::api::noise::generate_keypair | ( | PrivateKey & | private_key, |
| PublicKey & | public_key | ||
| ) |
Generate a fresh X25519 keypair from the system CSPRNG.
| void esphome::api::noise::hkdf | ( | const Hash & | chaining_key, |
| ByteView | input_key_material, | ||
| int | num_outputs, | ||
| Hash & | o1, | ||
| Hash & | o2, | ||
| Hash & | o3 | ||
| ) |
Noise HKDF: derive num_outputs (1..3) 32-byte values from chaining_key and input_key_material.
Only the first num_outputs of o1/o2/o3 are valid.
HMAC-SHA-256 with key over data.
| SymmetricKey esphome::api::noise::x25519 | ( | const PrivateKey & | private_key, |
| const PublicKey & | peer_public | ||
| ) |
X25519 shared secret. Throws EncryptionError on an all-zero (degenerate) result.
| PublicKey esphome::api::noise::x25519_base | ( | const PrivateKey & | private_key | ) |
X25519 public key for a private scalar.
|
inlineconstexpr |
SHA-256 digest / key size.
|
inlineconstexpr |
Symmetric / DH key size.
|
inlineconstexpr |
Noise protocol name for the ESPHome native API.