-
Notifications
You must be signed in to change notification settings - Fork 2
Cryptographic Security and Provisioning
GiZano edited this page Aug 31, 2026
·
2 revisions
QuakeGuard implements a Zero-Trust security model for its IoT edge nodes.
Upon its first boot, the ESP32-C3 uses mbedtls to generate a unique ECDSA key pair using the NIST P-256 curve (secp256r1).
- Private Key: Stored permanently in Non-Volatile Storage (NVS) to sign outgoing telemetry — never leaves the device.
- Public Key: Extracted in DER format, hex-encoded, acting as the unforgeable sensor identity in the backend.
- The device sends a
POSTto/devices/registerwith itspublic_key_hex, MAC address, coordinates, andENROLLMENT_TOKEN. - The backend validates the factory token and, via a geohash-based Redis fast-path (
zoneindex:<geohash>prec 3 → set of zone ids) with authoritative PostGIS fallback (ST_Containsordered byST_Area ASC), assigns the sensor to the smallest containing polygon. When a GNSS fix exists it is the live or last-known NVS fix; otherwise coordinates may be omitted and the backend keepsNULLgeometry →Unknown Region. - A unique
sensor_idis returned and saved to NVS (quake-config).
Automatic first-boot provisioning is the only path since v1.2.2 — the compile-time SENSOR_ID shortcut was removed.
Telemetry payloads are value:timestamp hashed via SHA-256 and signed with the private key. Payloads are identical on MQTT and serial planes ([QG:FB] frames carry the same JSON behind the marker). When the serial fallback drains, the payload is re-signed with the current software wall clock (epochAtSync+millis()) so the backend replay window accepts it.
The validate_iot_payload pipeline enforces four gates:
-
API Key Verification: Constant-time
hmac.compare_digestcheck onX-API-Key. -
Sensor Status: Verifies the sensor ID exists and is
active. -
Anti-Replay Protection: Rejects payloads older than a 300-second threshold (
403 Forbidden). -
Signature Verification: Python
cryptographyverifies ECDSA against the stored public key (DER and rawr||stolerant).
- Previous: Hardware & Edge Computing (ESP32-C3)
- Next: Data Plane & Message Broker (MQTT)
- Back to: Home