---
title: "Secure Boot and Code Signing"
description: "Establish a chain of trust on E1M-AEN with MCUboot and ECDSA-P256 — sign firmware with the shared dev key or your own, verify rejection of untrusted images, and manage production keys on an air-gapped signing workstation."
source: https://docs.alplab.ai/app-notes/an-010-secure-boot
subtitle: "AN-010 · E1M and E1M-X SoMs"
document: "AN-010"
revision: "0.8"
date: "October 2026"
status: "Preliminary"
pdf: https://docs.alplab.ai/docs-pdf/an-010-secure-boot-v0.8.pdf
---

# Secure Boot and Code Signing

## 1 Scope {#scope}

Establish a chain of trust from the SoM's immutable boot ROM to the application image: on E1M-AEN the Alif Secure Enclave ROM hands off to MCUboot, which verifies the application's ECDSA-P256 signature against a public key compiled into the bootloader before chaining in. This AN walks the dev-key bench flow and the production-key lifecycle. On E1M-AEN, MCUboot is built single-slot (`SB_CONFIG_MCUBOOT_MODE_SINGLE_APP=y`): there is no secondary or scratch slot, so there is no A/B swap and no rollback. An image that fails verification is refused, and the module stays in MCUboot until a correctly signed image is written to slot0.

The production lock-down is **destructive** — blowing the SoM's debug-disable fuse is permanent and cannot be undone, and once a production public key is baked into a fielded bootloader only images signed by the matching private key will boot. Read the **Production Key Management** section fully before locking down any module that will leave your bench.

:::warning[Warning:]
**Do not architect key management around the OPTIGA Trust M secure element.** No E1M-AEN module fits a secure element: the OPTIGA Trust M is fitted only on E1M-X V2N and E1M-X V2N-M1. On those two modules the Alp SDK™ v0.17.0 driver is partial: probe, Coprocessor UID and a raw APDU session only, with no typed key generation, key export or signing call and no PSA driver. The production signing key today lives on an **air-gapped signing workstation**. See **Production Key Management**.
:::

**Table 1:** Scope summary

| Audience | Security engineers shipping fielded firmware that must not be replaced by attackers. |
|---|---|
| Prerequisites | An AEN EVK or E1M-AEN module, the SDK checked out, OpenSSL 3.0+, and the MCUboot `imgtool` that ships with the Zephyr build. For fielded units, an <strong>air-gapped signing workstation</strong> holding the production key; this AN uses the SDK's dev key only for the bench walk-through. |
| Outcome | Module's MCUboot bootloader accepts only firmware signed by the trusted key; unsigned or wrong-key firmware is refused at boot. |
| Time | 60 minutes (key generation is fast; understanding the implications is the long pole). |
| Source | `docs/secure-boot.md` and `docs/tutorials/10-secure-boot-signing.md` in [alp-sdk](https://github.com/alplabai/alp-sdk). |

## 2 Step 1 — Generate Signing Keys {#step-1-generate-signing-keys}

AEN secure boot uses ECDSA-P256 throughout. For the bench, nothing needs generating: `zephyr/sysbuild/aen/sysbuild.conf` signs with the committed **shared** development key `keys/mcuboot_shared_dev_ecdsa_p256.pem`, which the factory MCUboot on Alp Lab pre-provisioned E1M-AEN modules trusts.

:::warning[Warning:]
The shared development key is public and gives **no** security: anyone can sign images for a module still running the factory MCUboot.
:::

To use your own dev key instead, generate it once with the SDK helper (idempotent — it preserves an existing key):

```bash
cd alp-sdk
bash keys/generate_dev_key.sh
```

Expected output starts with:

```
Generating ECDSA-P256 dev signing key at <abs>/keys/mcuboot_dev_ecdsa_p256.pem...
```

The key is written to the `.gitignored` file `keys/mcuboot_dev_ecdsa_p256.pem`; never commit it. Then build with `-DSB_CONFIG_BOOT_SIGNATURE_KEY_FILE=<abs>/keys/mcuboot_dev_ecdsa_p256.pem` and re-provision the module with the MCUboot from that build. The factory MCUboot refuses images signed with this key.

For production, generate the key the same way but **on an air-gapped workstation**, and keep the private half there. Only the public half travels to the build host, as `keys/mcuboot_prod_ecdsa_p256.pub.pem`. See **Production Key Management** below.

:::warning[Warning:]
Treat the production signing key like the master key it is. Losing it means **no future firmware can be installed** on any device whose bootloader trusts it; leaking it means anyone can install firmware on every such device. Back it up offline, in a safe, before you sign the first production image. The dev key under `keys/` is for the bench only.
:::

## 3 Step 2 — Build and Sign a Firmware Image {#step-2-build-and-sign-a-firmware-image}

Sysbuild builds the MCUboot bootloader and the application together, and signs the application as part of the build:

```bash
west build -b alp_e1m_aen801_m55_he/ae822fa0e5597ls0/rtss_he examples/peripheral-io/hello-world \
    --sysbuild \
    -- -DSB_CONF_FILE=/abs/path/to/alp-sdk/zephyr/sysbuild/aen/sysbuild.conf
```

The sysbuild config is a CMake define passed after `--`, not a `west build` flag. The path must be **absolute**: sysbuild resolves a relative `SB_CONF_FILE` against `APP_DIR`, not the directory you ran the command from.

(If your `board.yaml` carries a `boot:` block, the loader emits the matching overlay at `build/alp_sysbuild.conf`, which becomes the canonical `SB_CONF_FILE` path.)

The build produces the bootloader at `build/mcuboot/zephyr/zephyr.bin` and the signed application at `build/zephyr/zephyr.signed.bin` (the raw `build/zephyr/zephyr.bin` is unsigned — don't flash it). The signed image is structurally:

```
+----------------------------+
| MCUboot image header       |
|   (0x200 B: version, size) |
+----------------------------+
| firmware (application)     |
+----------------------------+
| TLV trailer                |
|   ECDSA-P256 signature +   |
|   SHA-256 image hash       |
+----------------------------+
```

On E1M-AEN, `west flash` refuses MCUboot (sysbuild) builds on every module (alp-sdk2274), and a plain `west flash` also refuses on pre-provisioned modules (2262).

:::warning[Warning:]
Do **not** override the refusal with `--replace-atoc`: it deletes the factory MCUboot ATOC entry and leaves the module unable to boot.
:::

On a module whose MCUboot is already provisioned, write only the signed application to slot0 (`0x80010000`) over J-Link, following alp-sdk `docs/aen-provisioning.md` §0.5 Option B. Prefer the scripted path `scripts/bench/aen/flash-jlink-mramxip.sh`: it pads the image to 16 KiB sector boundaries and proves the write with a fresh read-back. The raw JLinkExe session (`device AE822FA0E5597LS0_M55_HE`, `loadbin build/zephyr/zephyr.signed.bin 0x80010000`) has two hazards (alp-sdk2233). It erases the rest of any partially-covered 16 KiB sector to `0xFF`. Its `verifybin` checks J-Link's cache, not MRAM, so confirm the write with a fresh-session read instead. Option B writes the application only: a module without a resident MCUboot will not boot until MCUboot is provisioned with the SETOOLS flow in `zephyr/sysbuild/aen/README.md`.

MCUboot verifies the ECDSA-P256 signature in the TLV trailer **before** chaining into the application. On an invalid signature it refuses the image. On E1M-AEN (single-slot MCUboot) there is no previous image to fall back to: the module stays in MCUboot until a correctly signed image is written to slot0.

## 4 Step 3 — Compile the Production Key into the Bootloader {#step-3-compile-the-production-key-into-the-bootloader}

There is no public-key-hash fuse to burn on AEN. The trust anchor is the public key compiled into the MCUboot bootloader. The production lifecycle:

1. **Generate the production key pair on an air-gapped workstation.** The private half stays on that machine and is never copied to a networked host.
2. **Carry the public half out** (USB, or read it off the screen) and commit it as `keys/mcuboot_prod_ecdsa_p256.pub.pem`. Only the public half leaves the air gap.
3. **Compile the bootloader against the production public key** by overriding `SB_CONFIG_BOOT_SIGNATURE_KEY_FILE` to point at that file when building MCUboot for production firmware.
4. **Sign release images on the air-gapped workstation.** Copy the unsigned image in, run `imgtool sign` against the private key, copy the signed image out.
5. **Lock the module down** by blowing the debug-disable fuse (see the per-SoM bring-up doc / **QS-** guide) so JTAG/SWD can no longer overwrite the bootloader region.

The recommended way to wire this is a top-level `boot:` block in your project's `board.yaml`; the loader emits the matching `SB_CONFIG_*` overlay automatically:

```yaml
# board.yaml
boot:
  method: mcuboot
  signing:
    algorithm: ecdsa_p256
    key_file: keys/mcuboot_prod_ecdsa_p256.pub.pem
```

Slot and scratch **sizes** are not `board.yaml` fields. MCUboot takes its slot geometry from the board device-tree partitions; use the `storage:` block to declare the project's own partition table. (Alp SDK™ v0.11.0 removed the `slots:`, `scratch_size_kib:` and `anti_rollback:` keys from the `boot:` block, which rejects unknown keys — a `board.yaml` still carrying them fails validation.)

:::warning[Warning:]
Once the production key is compiled in and the debug-disable fuse is blown, the module accepts **only** firmware signed by the corresponding private key, and the lock-down cannot be undone. Test the full signing flow with the dev key on an EVK **before** committing a production key to any unit that will leave your bench.
:::

## 5 Step 4 — Verify {#step-4-verify}

Power-cycle the module. On the UART you should see the MCUboot banner accept the image and hand off to the application:

```
*** Booting MCUboot v1.x ...
[INF] Starting bootloader
[INF] Image index: 0, Swap type: none
...
[hello] ALP SDK hello-world starting
```

Then sign with the wrong key and re-flash to confirm rejection:

```bash
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 \
    -out /tmp/fake_key.pem

imgtool sign --key /tmp/fake_key.pem --version 0.1.0 \
    --header-size 0x200 --align 16 --slot-size 0x2A0000 --pad-header \
    build/zephyr/zephyr.bin /tmp/zephyr.fakesigned.bin
```

Write `/tmp/zephyr.fakesigned.bin` to slot0 with the same J-Link slot0 write described in Step 2 (not `west flash`, which refuses on E1M-AEN).

MCUboot output:

```
*** Booting MCUboot v1.x ...
[INF] Starting bootloader
[INF] Image index: 0, Swap type: none
[ERR] Image in the primary slot is not valid!
[ERR] Unable to find bootable image
```

MCUboot refuses to chain into the wrongly-signed image and halts. Restore a properly-signed image to recover.

## 6 Production Key Management {#production-key-management}

For production, the bench dev key is **not acceptable**. Recommended set-up:

**Table 2:** Production key store

| Store | Notes |
|---|---|
| <strong>Air-gapped signing workstation</strong> — <strong>use this today</strong> | The practical production key store on every current SoM. The private key is generated on and never leaves a permanently disconnected machine; unsigned images are copied in and signed images copied out over removable media. Compromise of the dev key or the build host does not yield production signing power — only physical access to the workstation does. Its weakness is that the key exists as a file, so physical security, disk encryption, and an offline backup carry the whole guarantee. |
| <strong>Per-generation key rotation</strong> | Generate the next-generation key pair on the same air-gapped workstation, compile the bootloader with both public keys so either is accepted, roll the new key out via OTA signed by the current key, then retire the old key after one update window (typically 90 days). |
| <strong>OPTIGA Trust M secure element</strong> — <strong>future work</strong> | <strong>Not usable as a key store today.</strong> The part is not fitted on any E1M-AEN module; on E1M-X V2N and E1M-X V2N-M1, which fit it, the v0.17.0 driver is partial (probe, Coprocessor UID and a raw APDU session over Infineon's host library). There are no typed key generation, key export or signing calls and no PSA driver behind `<alp/security.h>`. Design the product so the key store can migrate later; do not depend on it now. |

:::note[Note:]
The SDK ships `examples/v2n/v2n-secure-element-sign` and `examples/aen/aen-secure-element-sign` to **verify the probe contract** — they confirm the chip ACKs and that the signing entry points cleanly refuse, rather than fabricating a signature. Despite the names, they do not sign anything. `docs/tutorials/06-secure-element-sign.md` walks the same contract.
:::

## 7 Troubleshooting {#troubleshooting}

**Table 3:** Common failures

| Symptom | Likely cause / fix |
|---|---|
| Build complains about the signing-key algorithm | AEN secure boot uses ECDSA-P256. Set `signing.algorithm: ecdsa_p256` in the `board.yaml` `boot:` block (or use the stock sysbuild profile) and a matching `key_file`. |
| MCUboot logs `Image in the primary slot is not valid!` | The image was signed with a key the bootloader doesn't trust. Rebuild with the `key_file` that matches `SB_CONFIG_BOOT_SIGNATURE_KEY_FILE`, then reflash a properly-signed image. |
| Module won't boot after compiling a production key | The bootloader was built against a <strong>different</strong> public key than the one signing the image. Recovery is reflashing a correctly-signed image — unless the debug-disable fuse is already blown, in which case the unit is unrecoverable. |
| MCUboot reports the image is too large for the slot | The signed image exceeds the slot size. Trim the firmware — a smaller image is the only in-project remedy. Slot geometry is <strong>not</strong> settable from `board.yaml`: MCUboot takes it from the board device-tree partitions, so growing a slot is a change to the board definition in the SDK, not a per-project field. Check `build_type: MinSizeRel` and drop unused libraries first. |
| Updated image boots once then reverts | Not applicable to E1M-AEN (single-slot MCUboot): there is no swap, no test image and no revert. |
| OPTIGA calls fail on E1M-AEN | Expected: no E1M-AEN module fits the OPTIGA Trust M, so `optiga_trust_m_init()` returns `ALP_ERR_NOT_READY` (no ACK at `0x30`). On E1M-X V2N and E1M-X V2N-M1, which fit it, the v0.17.0 driver is partial (probe, Coprocessor UID, raw APDU session); there are no typed keygen/sign calls, so keep using the air-gapped signing workstation. |

## 8 References {#references}

- **Canonical doc**: `docs/secure-boot.md`, `docs/tutorials/10-secure-boot-signing.md`, and `docs/adr/0006-secure-boot-secure-ota.md` in alp-sdk.
- **SDK tooling**: `keys/generate_dev_key.sh`, `west build --sysbuild`, MCUboot `imgtool`, `west flash`.
- **Examples**: `examples/aen/aen-mcuboot-smoke` (MCUboot smoke test), `examples/peripheral-io/hello-world`.
- **Secure element (probe contract only)**: `docs/tutorials/06-secure-element-sign.md`, `examples/v2n/v2n-secure-element-sign`, `examples/aen/aen-secure-element-sign`, header `<alp/chips/optiga_trust_m.h>` (see its `@par Driver scope: [PARTIAL]`).
- **Companion AN**: **AN-006** (OTA updates with signed images), **AN-007** (mproc mailbox — the M33 firmware must be signed too).
- **Vendor reference**: Alif Secure Enclave / Ensemble documentation (AEN); Infineon OPTIGA Trust M Solution Reference Manual; for V2N M33 secure boot see `docs/rzv2n-m33-secure-boot.md` (Renesas RZ/V2N TF-A BL2 chain).

## 9 Revision History {#revision-history}

**Table 4:** Revision History

<table>
<thead>
<tr><th>Revision</th><th>Changes</th><th>Date</th></tr>
</thead>
<tbody>
<tr>
<td>0.1</td>
<td>
<ul>
<li>Initial draft.</li>
</ul>
</td>
<td>May 2026</td>
</tr>
<tr>
<td>0.2</td>
<td>
<ul>
<li>Aligned with current alp-sdk: AEN secure boot is MCUboot + ECDSA-P256 (not RSA-PSS/boot-ROM OTP).</li>
<li>Replaced the invented `west sign`/`alp-fuse` pubkey-hash flow with the real `keys/generate_dev_key.sh` dev key, sysbuild build, `imgtool` signing, OPTIGA Trust M production-key lifecycle, and `SB_CONFIG_BOOT_SIGNATURE_KEY_FILE`.</li>
<li>Fixed example path (`examples/peripheral-io/hello-world`), board target (`alp_e1m_evk_aen`), MCUboot console output, troubleshooting, references, and canonical-source header.</li>
</ul>
</td>
<td>June 2026</td>
</tr>
<tr>
<td>0.3</td>
<td>
<ul>
<li>Corrected the key-store story: the OPTIGA Trust M driver is probe-only — it confirms the part ACKs and returns `ALP_ERR_NOSUPPORT` for product-info, raw APDUs, `CalcSign`, `GenKeyPair` and ECDH, so on-chip key generation, export and signing are unavailable today.</li>
<li>The air-gapped signing workstation is now presented as the practical key store and the secure-element path as future work, with a warning against architecting product key management around it.</li>
<li>Removed a troubleshooting row citing a Kconfig symbol that does not exist.</li>
<li>Fixed the Alp SDK repository links (`alpDevs` → `alplabai`).</li>
</ul>
</td>
<td>July 2026</td>
</tr>
<tr>
<td>0.4</td>
<td>
<ul>
<li>Retensed to Alp SDK<sup>TM</sup> v0.11.0.</li>
<li>Replaced `--sysbuild-config`, a flag that has never existed in any Zephyr — west forwarded it to CMake and the configure died with `Unknown argument --sysbuild-config` — with `-- -DSB_CONF_FILE=<absolute path>`, noting that sysbuild resolves a relative path against `APP_DIR` rather than the cwd.</li>
<li>Removed the `slots:` key from the production `board.yaml` snippet and rewrote the "image too large for the slot" troubleshooting row, which sent readers to `slots.primary.size_kib`: v0.11.0 removed `slots:`, `scratch_size_kib:` and `anti_rollback:` from the `boot:` block, so both the snippet and the suggested remedy now fail schema validation.</li>
<li>Slot geometry comes from the board device-tree partitions.</li>
</ul>
</td>
<td>July 2026</td>
</tr>
<tr>
<td>0.5</td>
<td>
<ul>
<li>Replaced the phantom board target `alp_e1m_evk_aen` in the Step 2 build command with the real fully-qualified target `alp_e1m_aen801_m55_he/ae822fa0e5597ls0/rtss_he` (E1M-AEN801 HE, Alif Ensemble E8): the old identifier resolves nowhere in the alp-sdk board tree, so the documented `west build` failed at board resolution.</li>
</ul>
</td>
<td>July 2026</td>
</tr>
<tr>
<td>0.6</td>
<td>
<ul>
<li>Re-verified against Alp SDK<sup>TM</sup> v0.17.0.</li>
<li>Scoped the OPTIGA Trust M "not fitted" statements to E1M-AEN801 and E1M-AEN803 (the SDK marks the part `assembled: false` on those two modules only) instead of every E1M-AEN module.</li>
<li>Described the v0.17.0 OPTIGA driver scope (probe, Coprocessor UID, raw APDU session; no typed key generation or signing).</li>
</ul>
</td>
<td>October 2026</td>
</tr>
<tr>
<td>0.7</td>
<td>
<ul>
<li>Corrected the OPTIGA Trust M fitment: no E1M-AEN module fits a secure element (DS-AEN-001 0.13, secure element removed); the part is fitted only on E1M-X V2N and E1M-X V2N-M1.</li>
<li>The warning, the key-store table and the troubleshooting row no longer imply that E1M-AEN modules other than E1M-AEN801 / E1M-AEN803 fit it.</li>
</ul>
</td>
<td>October 2026</td>
</tr>
<tr>
<td>0.8</td>
<td>
<ul>
<li>Release history: every entry formatted as a bullet list.</li>
</ul>
</td>
<td>October 2026</td>
</tr>
</tbody>
</table>
