ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
xxtea_encryption.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_PACKET_INTERFACE_XXTEA
5#include <array>
6#include <initializer_list>
7
9#include "packet_interface.h"
10
12
28 public:
29 XxteaEncryption(PacketInterface *lower, bool rolling_code);
30
31 void setup() override;
32 void dump_config() override;
33 bool send_to_interface(const PacketBuffer &data, const PacketMetaData &meta_data) override;
34
35 void set_key(std::initializer_list<uint32_t> key);
36
37 protected:
38 void receive_(const PacketBuffer &data, const PacketMetaData &meta_data);
39 bool accept_counter_(uint32_t boot, uint32_t counter);
40 void next_boot_();
41
43 const size_t trailer_size_;
44 std::array<uint32_t, 8> key_{};
45 // Separate buffers, as a layer above may send a reply while a received packet is being passed up; both are in one
46 // block allocated in setup(), and tx_buffer_ stays null if that fails
54 uint32_t echo_boot_{0}; // highest boot number heard from the peer
55 bool peer_seen_{false};
56 bool old_boot_warned_{false};
57 const bool rolling_code_;
58};
59
60} // namespace esphome::packet_interface
61#endif
A buffer class that efficiently represents a composite buffer with three sections:
A class that will transport data to and from an abstract channel.
A struct to hold metadata about a packet.
An encryption layer that encrypts and authenticates each packet with XXTEA and a 256-bit shared key.
XxteaEncryption(PacketInterface *lower, bool rolling_code)
bool accept_counter_(uint32_t boot, uint32_t counter)
bool send_to_interface(const PacketBuffer &data, const PacketMetaData &meta_data) override
void receive_(const PacketBuffer &data, const PacketMetaData &meta_data)
void set_key(std::initializer_list< uint32_t > key)
const char * key
static void uint32_t