|
esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
|
Noise cryptographic primitives (SHA-256, HMAC, HKDF, X25519, ChaCha20- Poly1305, base64). More...


Go to the source code of this file.
Namespaces | |
| namespace | esphome |
| namespace | esphome::api |
| namespace | esphome::api::noise |
Typedefs | |
| using | esphome::api::noise::Hash = std::array< std::uint8_t, hash_len > |
| using | esphome::api::noise::SymmetricKey = std::array< std::uint8_t, key_len > |
| using | esphome::api::noise::PublicKey = std::array< std::uint8_t, key_len > |
| using | esphome::api::noise::PrivateKey = std::array< std::uint8_t, key_len > |
Functions | |
| Hash | esphome::api::noise::sha256 (ByteView data) |
SHA-256 of data. | |
| Hash | esphome::api::noise::hmac_sha256 (ByteView key, ByteView data) |
HMAC-SHA-256 with key over data. | |
| 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. | |
| PublicKey | esphome::api::noise::x25519_base (const PrivateKey &private_key) |
| X25519 public key for a private scalar. | |
| SymmetricKey | esphome::api::noise::x25519 (const PrivateKey &private_key, const PublicKey &peer_public) |
| X25519 shared secret. Throws EncryptionError on an all-zero (degenerate) result. | |
| void | esphome::api::noise::generate_keypair (PrivateKey &private_key, PublicKey &public_key) |
| Generate a fresh X25519 keypair from the system CSPRNG. | |
| ByteBuffer | esphome::api::noise::aead_encrypt (const SymmetricKey &key, std::uint64_t nonce, ByteView ad, ByteView plaintext) |
| AEAD ChaCha20-Poly1305 (IETF) encryption. | |
| 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. | |
| bool | esphome::api::noise::base64_decode (const std::string &text, ByteBuffer &out) |
| Decode standard base64. Returns false on malformed input. | |
Variables | |
| constexpr std::size_t | esphome::api::noise::hash_len = 32 |
| SHA-256 digest / key size. | |
| constexpr std::size_t | esphome::api::noise::key_len = 32 |
| Symmetric / DH key size. | |
Noise cryptographic primitives (SHA-256, HMAC, HKDF, X25519, ChaCha20- Poly1305, base64).
The implementation (src/crypto/primitives.cpp) wraps vendored, public-domain reference code under src/crypto/detail/ plus the OS CSPRNG. Built only when ESPHOME_API_WITH_NOISE is on.