From 1ec93dc4132e13518457f38a2f77965a08691f31 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Sat, 26 Sep 2026 22:05:16 +0200 Subject: [PATCH] Rename signing secret to BMW_NISSAN_FIRMWARE_SIGNING_KEY Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/firmware.yml | 8 ++++---- CLAUDE.md | 2 +- include/config/ota_config.h | 2 +- wiki/log.md | 2 +- wiki/pages/ota-updates.md | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/firmware.yml b/.gitea/workflows/firmware.yml index 9860abb..5dc1a75 100644 --- a/.gitea/workflows/firmware.yml +++ b/.gitea/workflows/firmware.yml @@ -12,7 +12,7 @@ name: Firmware # "patrol-a||"). This is what `ota install` # on the controller pulls. # -# Signing key: repo secret FIRMWARE_SIGNING_KEY (PEM, EC P-256). Its public +# Signing key: repo secret BMW_NISSAN_FIRMWARE_SIGNING_KEY (PEM, EC P-256). Its public # half is compiled into the firmware (include/config/ota_config.h) and kept in # tools/ota/firmware_signing_pub.pem, which this job uses to self-check the # signature before publishing. See wiki/pages/ota-updates.md. @@ -74,15 +74,15 @@ jobs: - name: Sign + manifest (tags only) if: startsWith(github.ref, 'refs/tags/') env: - FIRMWARE_SIGNING_KEY: ${{ secrets.FIRMWARE_SIGNING_KEY }} + BMW_NISSAN_FIRMWARE_SIGNING_KEY: ${{ secrets.BMW_NISSAN_FIRMWARE_SIGNING_KEY }} run: | set -e - [ -n "$FIRMWARE_SIGNING_KEY" ] || { echo "::error::secret FIRMWARE_SIGNING_KEY is not set"; exit 1; } + [ -n "$BMW_NISSAN_FIRMWARE_SIGNING_KEY" ] || { echo "::error::secret BMW_NISSAN_FIRMWARE_SIGNING_KEY is not set"; exit 1; } SHA=$(sha256sum dist/firmware.bin | cut -d' ' -f1) SIZE=$(stat -c%s dist/firmware.bin) printf '%s' "patrol-a|${VERSION}|${SHA}" > stmt.txt umask 077 - printf '%s\n' "$FIRMWARE_SIGNING_KEY" > key.pem + printf '%s\n' "$BMW_NISSAN_FIRMWARE_SIGNING_KEY" > key.pem openssl dgst -sha256 -sign key.pem -out sig.der stmt.txt rm -f key.pem # Self-check against the public key the firmware carries. diff --git a/CLAUDE.md b/CLAUDE.md index 8e02ead..1b46d93 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -231,7 +231,7 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage): ### OTA updates (`ota` console) -`src/modules/ota_update.cpp` pulls signed firmware from this repo's Gitea releases (`include/config/ota_config.h`: server, repo, Let's Encrypt roots, signing public key). Manual only: `ota status | check | install [force] | rollback` - the future password-gated Diagnostics screen will call the same code. Install is refused unless parked (engine off, shaft still, lever not in a drive gear; silent bus = parked), checked before download and again before the slot switch. The manifest's ECDSA P-256 signature over `patrol-a|version|sha256` is checked before download; the streamed image must match that sha256. `verifyRollbackLater()` is overridden so a new image stays pending until `Ota::tick()` confirms it after 30 s - a reset before that rolls back. CI: `.gitea/workflows/firmware.yml` (push `main` -> rolling unsigned pre-release `main-latest`; tag `v*` -> signed release, needs repo secret `FIRMWARE_SIGNING_KEY`). Never put secrets in firmware source - the repo and its release binaries are public. Details: `wiki/pages/ota-updates.md`. +`src/modules/ota_update.cpp` pulls signed firmware from this repo's Gitea releases (`include/config/ota_config.h`: server, repo, Let's Encrypt roots, signing public key). Manual only: `ota status | check | install [force] | rollback` - the future password-gated Diagnostics screen will call the same code. Install is refused unless parked (engine off, shaft still, lever not in a drive gear; silent bus = parked), checked before download and again before the slot switch. The manifest's ECDSA P-256 signature over `patrol-a|version|sha256` is checked before download; the streamed image must match that sha256. `verifyRollbackLater()` is overridden so a new image stays pending until `Ota::tick()` confirms it after 30 s - a reset before that rolls back. CI: `.gitea/workflows/firmware.yml` (push `main` -> rolling unsigned pre-release `main-latest`; tag `v*` -> signed release, needs repo secret `BMW_NISSAN_FIRMWARE_SIGNING_KEY`). Never put secrets in firmware source - the repo and its release binaries are public. Details: `wiki/pages/ota-updates.md`. ### ESP-NOW link diff --git a/include/config/ota_config.h b/include/config/ota_config.h index 5bdd352..cea88d7 100644 --- a/include/config/ota_config.h +++ b/include/config/ota_config.h @@ -8,7 +8,7 @@ * * Nothing in here is secret: the CA roots and the signing PUBLIC key are meant * to be public. The signing private key lives only in the Gitea repo secret - * FIRMWARE_SIGNING_KEY (plus the owner's offline backup). + * BMW_NISSAN_FIRMWARE_SIGNING_KEY (plus the owner's offline backup). */ #ifndef OTA_CONFIG_H diff --git a/wiki/log.md b/wiki/log.md index 00fa094..a285d8d 100644 --- a/wiki/log.md +++ b/wiki/log.md @@ -112,4 +112,4 @@ Tightened the live-data findings after checking the full capture: the Launch use ## [2026-09-26] build | OTA updates for Controller A -Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offsets kept - tunables v150 survived the one-time USB flash on COM10, verified). New src/modules/ota_update.cpp + include/config/ota_config.h: manual `ota status|check|install|rollback` console; HTTPS pull from the (now public) Gitea repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, image hashed while streaming, parked gate before download and before slot switch, rollback via verifyRollbackLater() override + 30 s confirm. TLS trusts ISRG Root X1 + Root YR (both verified against the server chain). CI: .gitea/workflows/firmware.yml (main -> rolling unsigned pre-release main-latest; v* tag -> signed release with manifest.txt). Decisions: manual trigger (future Diagnostics screen), public repos instead of a device token, Controller B to be updated by A over ESP-NOW (wire is one-way). Wrote pages/ota-updates.md. Pending: FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end. +Repartitioned A to dual OTA slots (2 x 7.9 MB, SPIFFS dropped, nvs/otadata offsets kept - tunables v150 survived the one-time USB flash on COM10, verified). New src/modules/ota_update.cpp + include/config/ota_config.h: manual `ota status|check|install|rollback` console; HTTPS pull from the (now public) Gitea repo's latest release, ECDSA P-256 signature over "patrol-a|version|sha256" checked before download, image hashed while streaming, parked gate before download and before slot switch, rollback via verifyRollbackLater() override + 30 s confirm. TLS trusts ISRG Root X1 + Root YR (both verified against the server chain). CI: .gitea/workflows/firmware.yml (main -> rolling unsigned pre-release main-latest; v* tag -> signed release with manifest.txt). Decisions: manual trigger (future Diagnostics screen), public repos instead of a device token, Controller B to be updated by A over ESP-NOW (wire is one-way). Wrote pages/ota-updates.md. Pending: BMW_NISSAN_FIRMWARE_SIGNING_KEY repo secret, enable repo Actions, first v* tag to test end-to-end. diff --git a/wiki/pages/ota-updates.md b/wiki/pages/ota-updates.md index 9118c9a..9d86795 100644 --- a/wiki/pages/ota-updates.md +++ b/wiki/pages/ota-updates.md @@ -13,7 +13,7 @@ How Controller A updates itself from this repo's Gitea releases, why each piece ``` git push tag vX.Y.Z ──► Gitea Actions (.gitea/workflows/firmware.yml, runner ubuntu-latest) pio run (-DFW_VERSION="vX.Y.Z") - sign "patrol-a|vX.Y.Z|" with secret FIRMWARE_SIGNING_KEY + sign "patrol-a|vX.Y.Z|" with secret BMW_NISSAN_FIRMWARE_SIGNING_KEY release vX.Y.Z: firmware.bin + firmware.elf + manifest.txt │ public repo, HTTPS, no token Controller A `ota install` ◄──────┘ (parked, Wi-Fi joined) @@ -60,7 +60,7 @@ Wi-Fi must be joined via the Settings screen first. Joining an AP moves the radi ## Secrets and keys -- `FIRMWARE_SIGNING_KEY` — Gitea **repo secret** (Settings → Actions → Secrets), the EC P-256 private key PEM. Generated 2026-09-26; keep an offline backup. Losing it means devices only accept updates after one USB flash with a new public key. +- `BMW_NISSAN_FIRMWARE_SIGNING_KEY` — Gitea **repo secret** (Settings → Actions → Secrets), the EC P-256 private key PEM. Generated 2026-09-26; keep an offline backup. Losing it means devices only accept updates after one USB flash with a new public key. - Public key: compiled in (`OTA_SIGNING_PUBKEY_PEM`) and in `tools/ota/firmware_signing_pub.pem` (CI self-checks each signature against it before publishing). - Rotating the key: new keypair → update both public-key copies → USB-flash once (a device only trusts the key it was built with).