esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
cipher_state.hpp
Go to the documentation of this file.
1#pragma once
2
5
8
9#include <cstdint>
10
12
16public:
18 void initialize_key(const SymmetricKey& key);
19
20 [[nodiscard]] bool has_key() const noexcept {
21 return has_key_;
22 }
23 [[nodiscard]] std::uint64_t nonce() const noexcept {
24 return nonce_;
25 }
26
30
34
35private:
36 SymmetricKey key_{};
37 std::uint64_t nonce_ = 0;
38 bool has_key_ = false;
39};
40
41} // namespace esphome::api::noise
Byte buffer / view aliases and protobuf base-128 varint codec.
Non-owning view over a contiguous run of bytes (a C++17 stand-in for std::span<const std::uint8_t>).
Definition bytes.hpp:17
Wraps a symmetric key plus a monotonically increasing nonce, per the Noise CipherState object.
Definition cipher_state.hpp:15
ByteBuffer decrypt_with_ad(ByteView ad, ByteView ciphertext)
AEAD-decrypt ciphertext, advancing the nonce.
void initialize_key(const SymmetricKey &key)
Set the key and reset the nonce to zero.
std::uint64_t nonce() const noexcept
Definition cipher_state.hpp:23
bool has_key() const noexcept
Definition cipher_state.hpp:20
ByteBuffer encrypt_with_ad(ByteView ad, ByteView plaintext)
AEAD-encrypt plaintext with associated data ad, advancing the nonce.
Definition cipher_state.hpp:11
std::array< std::uint8_t, key_len > SymmetricKey
Definition primitives.hpp:21
std::vector< std::uint8_t > ByteBuffer
Owning, growable byte buffer.
Definition bytes.hpp:13
Noise cryptographic primitives (SHA-256, HMAC, HKDF, X25519, ChaCha20- Poly1305, base64).