Skip to content

zephyr: imgtool: sim: support multiple keys#1

Open
JPHutchins wants to merge 1 commit intomainfrom
feature-zephyr-multiple-signing-keys
Open

zephyr: imgtool: sim: support multiple keys#1
JPHutchins wants to merge 1 commit intomainfrom
feature-zephyr-multiple-signing-keys

Conversation

@JPHutchins
Copy link
Copy Markdown
Collaborator

@JPHutchins JPHutchins commented Apr 17, 2026

zephyr: support 2 signing keys

Add optional kconfig BOOT_SIGNATURE_KEY_FILE_2. Update keys.c to support multiple keys of the same type.

imgtool: add --name-suffix to getpub

Update documentation and test coverage.

sim: tests for multiple ed25519 keys

Update sim test cases to cover multiple keys.

Upstream PR is in draft here: mcu-tools#2701

Copilot AI review requested due to automatic review settings April 17, 2026 23:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends MCUboot’s signing-key support to allow two embedded verification keys (same signature type) in Zephyr builds and the simulator, and updates imgtool to emit distinct symbol names so multiple keys of the same type can be linked together.

Changes:

  • Zephyr: add CONFIG_BOOT_SIGNATURE_KEY_FILE_2 and generate/embed a second public key (with distinct symbol names) when configured.
  • imgtool: add --name-suffix to getpub/getpubhash for lang-c / lang-rust outputs, plus tests and docs.
  • Simulator: embed multiple ED25519 verification keys behind a new sig-second-key feature and add multi-key sim test coverage.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sim/tests/core.rs Adds simulator integration tests covering primary/secondary/unknown signing keys.
sim/src/tlv.rs Introduces SigningKey selection and uses different key material for ED25519 signatures.
sim/src/lib.rs Exposes tlv module publicly so integration tests can access SigningKey.
sim/src/image.rs Adds helpers to build images signed with a selected key and new secondary-slot test images.
sim/src/ed25519_pub_key_2-rs.txt Adds autogenerated ED25519 secondary public key bytes for sim.
sim/src/ed25519_pub_key_unknown-rs.txt Adds autogenerated “unknown” ED25519 public key bytes for sim negative tests.
sim/mcuboot-sys/csupport/keys.c Adds optional second embedded verification key and computes key count from array size.
sim/mcuboot-sys/build.rs Adds sig-second-key feature wiring and enforces it only with ED25519 in sim.
sim/mcuboot-sys/Cargo.toml Declares sig-second-key feature for simulator bootloader build.
sim/Cargo.toml Wires sig-second-key feature through to mcuboot-sys.
scripts/tests/test_keys.py Adds tests verifying --name-suffix affects emitted symbol names and is rejected for raw/pem.
scripts/imgtool/main.py Implements --name-suffix options for getpub/getpubhash and validates encoding constraints.
scripts/imgtool/keys/general.py Adds name_suffix support to C/Rust public key and hash emitters.
root-ed25519-2.pem Adds secondary ED25519 private key material for simulator/Zephyr test usage.
root-ed25519-unknown.pem Adds “unknown” ED25519 private key material for simulator negative tests.
docs/signed_images.md Documents Zephyr’s primary/secondary signing key configuration knobs.
docs/readme-zephyr.md Updates Zephyr docs to describe two-key support and constraints.
docs/imgtool.md Documents imgtool --name-suffix behavior and encoding restrictions.
boot/zephyr/sample.yaml Adds a Zephyr sample test configuration exercising the second signing key option.
boot/zephyr/keys.c Adds optional second key entry and computes bootutil_key_cnt from array size.
boot/zephyr/Kconfig Introduces BOOT_SIGNATURE_KEY_FILE_2 with appropriate dependencies.
boot/zephyr/CMakeLists.txt Generates and compiles a second public key source file with --name-suffix _2.
.github/workflows/sim.yaml Adds CI coverage for sig-ed25519 sig-second-key simulator feature set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sim/src/image.rs
&ram,
&dep,
ImageManipulation::None,
Some(0),
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs further investigation.

Comment on lines +189 to +190
"""Map from keygen key_type names to the shortname() each key class emits,
which is the prefix used in the autogenerated C/Rust symbol names."""
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing that you cost $$

Comment thread scripts/imgtool/main.py
Comment on lines +148 to +149
'signing keys in the same image. Ignored for PEM/raw '
'encodings (those emit no identifiers).')
Comment thread scripts/imgtool/main.py
valid_hash_encodings[0]))
@click.option('--name-suffix', 'name_suffix', metavar='SUFFIX', default='',
help='Append SUFFIX to the emitted C symbol names (lang-c '
'encoding only). Ignored for raw encoding.')
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

zephyr: support 2 signing keys

Add optional kconfig BOOT_SIGNATURE_KEY_FILE_2. Update
keys.c to support multiple keys of the same type.

imgtool: add --name-suffix to getpub

Update documentation and test coverage.

sim: tests for multiple ed25519 keys

Update sim test cases to cover multiple keys.

Signed-off-by: JP Hutchins <jp@intercreate.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants