🔐 Device-level security (defence in depth)
Beyond the cloud, the cameras themselves would be hardened in three complementary layers. Each layer defends against a different threat, and the hardware layer protects the secrets used by the other two — so an attacker would have to defeat all three at once.
- Layer 1 — Unique per-camera token (application level): instead of one shared secret, each camera derives its own token from its MAC address combined with a server-side secret (HMAC-SHA256). The server recomputes and verifies it on every request. A stolen token only works for a single camera, and any camera can be revoked individually. Cost is negligible (~2 KB RAM, SHA-256 is built into the ESP32) and it is fully reversible, making it the safe first step.
- Layer 2 — Mutual TLS with signed client certificates (connection level): each camera would carry a unique X.509 certificate signed by a private certificate authority (PKI). The server would reject any connection that does not present a certificate signed by that authority, so a foreign or counterfeit ESP32 simply cannot establish a session. This is the classic « signed certificate » solution; its main cost is RAM during the TLS handshake (~40–50 KB), which the WROVER absorbs thanks to its 8 MB PSRAM. The real effort is operational: running a PKI, issuing one certificate per camera, and handling revocation.
- Layer 3 — Secure Boot + Flash Encryption (hardware level): the ESP32's hardware eFuses (one-time-programmable bits, physically irreversible) would store keys that (a) make the chip run only firmware signed with the manufacturer's private key, refusing any tampered or infected build at boot, and (b) encrypt the flash so the firmware — and the secrets from layers 1 and 2 — cannot be read even by desoldering the chip. This is what truly answers « don't let an infected device in », because it guarantees only the genuine firmware ever executes and its secrets stay inside the silicon.
- Why all three together: layer 3 protects layers 1 and 2 — without it the per-camera token and the certificate's private key could be extracted from the firmware; with it they become inextractable. An intruder would need a firmware signed by us, a certificate signed by our authority, and a valid token, all at once. They are deployed in order (token first, mTLS next, hardware sealing last) because Secure Boot is irreversible and is applied only once the firmware is final — like pouring concrete for the foundations once the plans are frozen.