12enum class PinCheck {
Ok, Wrong, LockedOut, NotSet };
15 PinCheck status = PinCheck::NotSet;
16 uint32_t seconds_left = 0;
26 static constexpr uint32_t kMaxFailures = 5;
27 static constexpr uint32_t kBaseLockoutMs = 60000;
28 static constexpr uint32_t kMaxLockoutMs = 3600000;
32 bool set_pin(
const char* pin,
size_t len,
const uint8_t (&salt)[kSaltLen]);
39 uint32_t _failures = 0;
40 uint32_t _lockouts = 0;
42 uint32_t _lock_start_ms = 0;
43 uint32_t _lock_len_ms = 0;
Guards the PIN. The 5th consecutive wrong PIN starts a lockout of min(60 s * 2^k, 3600 s),...
Definition pin_guard.h:24
PinResult check(const char *pin, size_t len, uint32_t now_ms)
Checks a PIN. While locked out nothing is evaluated. Wrap-safe in now_ms.
Definition pin_guard.cpp:57
bool set_pin(const char *pin, size_t len, const uint8_t(&salt)[kSaltLen])
Stores hash = sha256(salt || pin). False (nothing changed) if the PIN is not 4-8 digits.
Definition pin_guard.cpp:39
@ Ok
out holds exactly the stored bytes
Plain value types shared by the WiFi provisioning logic (pure C++20, no heap).
Salted PIN hash as stored in NVS.
Definition prov_types.h:38
Definition pin_guard.h:14