Repository navigation
status: the device's public key and its fingerprint - #46
Conversation
`cerberus status` prints the public key and its fingerprint: SHA-256 of the 32 raw key bytes, the first 16 in lowercase hex, eight groups of four. The cloud's panel shows the same line on the device page, so the two can be compared by eye; `echo <key> | base64 -d | sha256sum` checks it by hand. The suite pins the vector the coordinator's tests pin too. status must not need randomness and deriving the public key does (X25519 blinding), so the agent keeps the public half in the store as cerberus_device_pubkey: written the first time it is derived, never again unless the key changes. A key from an older agent shows "known after the next start" until then. clean and the installer remove it. Version 0.3.2.
PR Summary by QodoShow device public key and fingerprint in status
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
1.
|
Two review findings on the fingerprint (#46). A full U-Boot environment stopped an enrolled camera: the public-key cache went through store_set, which dies when fw_setenv fails, and device_key runs before the interface is up. store_put now takes a soft mode that warns and returns instead; the cache is written softly, and a camera with no room for it starts as before, with status saying the fingerprint is not known yet. status could show another key's fingerprint: the cache was trusted on its own, so a private key replaced or removed by hand left the old public key on display. The cache is now "<public>:<binding>", the binding being the first 8 bytes of SHA-256 of the raw private key (nothing secret: it sits next to the key itself). status shows the fingerprint only when the stored private key matches the binding, and still derives nothing.
|
Both findings fixed. 1 (a full store stops enrolled cameras): fixed in 10cd9b9. store_put has a soft mode that warns and returns instead of dying; the public-key cache is written softly, so a U-Boot env with no room for it costs a warning, not the camera's start. Test: a fake fw_setenv that refuses that key; 2 (status can show the wrong key): fixed in 10cd9b9. The cache is now ":", binding = first 8 bytes of SHA-256 of the raw private key; status shows the fingerprint only when the stored private key matches it, and still derives nothing. Tests: a key replaced by hand and a missing key both show no fingerprint. /review |
cerberus statusnow prints two more lines:The fingerprint is SHA-256 of the 32 raw key bytes, the first 16 in lowercase hex, eight groups of four. The cloud's panel shows the same line on the device page ("Details"), so the owner can compare the two by eye and see that the cloud knows the camera by its own key rather than a substituted one. No prefix or salt on purpose:
echo <key> | base64 -d | sha256sumchecks it by hand. The suite pins the same vector as the coordinator's tests.Why the public key is stored.
statusmust not need randomness (there is a test for it), and deriving the public key does: mbedTLS 3 wants an RNG for X25519 blinding. So the agent keeps the public half in the store ascerberus_device_pubkey, written the first time it is derived and never again unless the key changes — one flash write per camera. Until a camera on an older agent restarts,statussays- (known after the next start).cleanand the installer remove the key.Version 0.3.2, CHANGELOG and the three READMEs updated.
Tests:
tests/run.sh184 passed on Alpine (musl, mbedTLS 3); 182 passed, 1 skipped on Debian bookworm (glibc, mbedTLS 2.28).