Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
pin_guard.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "prov_types.h"
9
10namespace prov
11{
12enum class PinCheck { Ok, Wrong, LockedOut, NotSet };
13
14struct PinResult {
15 PinCheck status = PinCheck::NotSet;
16 uint32_t seconds_left = 0; // LockedOut only, rounded up
17};
18
24{
25public:
26 static constexpr uint32_t kMaxFailures = 5;
27 static constexpr uint32_t kBaseLockoutMs = 60000;
28 static constexpr uint32_t kMaxLockoutMs = 3600000;
29
30 explicit PinGuard(const PinRecord& rec = PinRecord{});
32 bool set_pin(const char* pin, size_t len, const uint8_t (&salt)[kSaltLen]);
34 PinResult check(const char* pin, size_t len, uint32_t now_ms);
35 const PinRecord& record() const;
36
37private:
38 PinRecord _rec;
39 uint32_t _failures = 0;
40 uint32_t _lockouts = 0;
41 bool _locked = false;
42 uint32_t _lock_start_ms = 0;
43 uint32_t _lock_len_ms = 0;
44};
45} // namespace prov
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