Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
oneway_sequence_store.h File Reference

Persistent rolling-sequence counters for one-way (1W) transmit. More...

#include "proto_sizes.h"
#include "esphome/core/preferences.h"
#include <cstdint>
#include <vector>
Include dependency graph for oneway_sequence_store.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  esphome::home_io_control::OneWaySequenceStore
 Per-controller-identity rolling sequence counters, persisted across reboots. More...

Namespaces

namespace  esphome
namespace  esphome::home_io_control

Variables

static constexpr uint16_t esphome::home_io_control::ONEWAY_SEQUENCE_ACCEPTANCE_WINDOW = 1000
 How far ahead of its stored high-water mark a device will still accept a jump.
static constexpr uint16_t esphome::home_io_control::ONEWAY_SEQUENCE_STRIDE = 8
 How many sequences one flash write reserves.
static constexpr uint16_t esphome::home_io_control::ONEWAY_SEQUENCE_REBOOT_HEADROOM = 8
 How many consecutive unclean reboots the stride must survive while staying inside a device's acceptance window.

Detailed Description

Persistent rolling-sequence counters for one-way (1W) transmit.

1W has no reply, no challenge and no acknowledgement. Its entire replay defence is a rolling 16-bit sequence carried in every frame and mixed into the authenticator's IV: a device remembers the highest sequence it has accepted from each transmitter and rejects anything at or below it. That makes this counter the one piece of state the hub cannot afford to lose, and the reason it is the only thing the component writes to persistent storage — see ADR 0025, which records that exception to ADR 0018 and draws its boundary.

The failure is asymmetric, and every rule below follows from it:

  • Skipping sequences is safe. A device accepts a forward jump within its acceptance window, so a counter that runs ahead costs nothing.
  • Reusing one is not. The device rejects it as a replay.
  • Falling behind is unrecoverable without intervention. Every later command is rejected too, permanently, and silently — 1W emits no error, so a hub with a stale counter keeps transmitting well-formed, correctly-signed frames that nothing acts on.

This class is the only place in the component that increments or persists a sequence.

Definition in file oneway_sequence_store.h.