Skip to content

[keymgr_dpe] Replace keymgr in EG - PR9 top level integration - #30697

Open
rroth-lowrisc wants to merge 64 commits into
lowRISC:masterfrom
rroth-lowrisc:keymgr_dpe_PR9_top_integration
Open

[keymgr_dpe] Replace keymgr in EG - PR9 top level integration#30697
rroth-lowrisc wants to merge 64 commits into
lowRISC:masterfrom
rroth-lowrisc:keymgr_dpe_PR9_top_integration

Conversation

@rroth-lowrisc

@rroth-lowrisc rroth-lowrisc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

PR9 - Top level integration

This PR is the ninth in a series which will replace the keymgr with the kemgr_dpe in earlgrey. The replacement was approved by this RFC.

Merge-Dependencies

Description

Replaces keymgr with keymgr_dpe in top_earlgrey and migrates the software stack to match.
A new top-level parameter keymgr_dpe_seed_selector chooses whether the creator/owner seed comes from flash_ctrl (used by Earl Grey) or otp_ctrl.

The CreatorRootKey derivation moves from the immutable ROM_EXT into the ROM per this RFC, and sealing/attestation keys now live in two parallel DPE slots instead of a single key chain, so sc_keymgr_key_type_t is dropped.

On the software side this ports rom, imm_section, dice_chain, ownership_key, otbn_boot_services, tpm and shutdown, and adds a keymgr_dpe_slot_idx field to otcrypto_key_config_t to select the parent DPE context for sideloaded keys.

Affected SW tests, DV sequences and testplans are updated here rather than in a follow-up, because the top-level swap breaks them as soon as it lands.

The keymgr_dpe requires to have a locked secret2 OTP partition to derive any DPE context and because rom already uses the keymgr_dpe a lot of tests would fail. This PR locks the secret2 partition in the default OTP image in the following lifecycle states: dev, prod, prod_end, rma. With an otp_partition in bazel its possible to get an unlocked secret2 partition:

otp_partition(
    name = "SECRET2",
    lock = False,
),

Open points

This list encompass open points which either needs to be fixed before this PR is merged or a Issue is created.

  • Currently the ft_personalize.c is not yet updated and breaks when building
  • Currently the cmac.c is not yet updated and breaks when building
  • Fix all pentests (otbn_fi.c, otbn_sca.c, ibex_fi.c)
  • rename sel_src_slot in the silicon driver (and all dependent files) to slot_src_sel for consistency with the register description.
  • Find a suitable way to propagate the (fixed) slot number for the attestation and the sealing DPE context throughout the OT repo, replacing the current hardcoded solution (related issue [keymgr_dpe, dice] Remove duplicate definition for the keymgr_dpe slot number #30777)

Follow-ups issues: #30777, #30759, #30811, #30830, #30878, #30690, #30907.

Sidenote

The first commit encompasses all changes on the top-layer to replace the keymgr with keymgr_dpe. I split all autogenerated code into a separate commit to allow for a faster review process.

@andreaskurth andreaskurth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Many thanks @rroth-lowrisc for this work!

I agree with the RTL changes:

  • keymgr_dpe is instantiated in place of keymgr in top_earlgrey with every port correctly wired.
  • The seed source selector for keymgr_dpe is set so that it's behaviorally equivalent to the prior keymgr instance.

The DV changes seem consistent as well (sequences and testplan renamed/added correctly).

I've added a couple small comments on RTL/generation and DV/testplan.

The main unresolved area in this PR I see in SW (I appreciate this PR depends on other PRs where SW changes are work in progress, but I don't expect those PRs to resolve top-level SW issues). Shall we take some time today to discuss this?

Comment thread util/topgen/validate.py
Comment thread hw/top_earlgrey/data/top_earlgrey.hjson
Comment thread hw/top_earlgrey/data/ip/chip_keymgr_dpe_testplan.hjson Outdated
Comment thread hw/ip/keymgr_dpe/data/keymgr_dpe.hjson Outdated
@rroth-lowrisc
rroth-lowrisc requested a review from engdoreis July 28, 2026 14:04
@rroth-lowrisc
rroth-lowrisc force-pushed the keymgr_dpe_PR9_top_integration branch 2 times, most recently from 8151133 to 504036c Compare July 30, 2026 15:35
@rroth-lowrisc
rroth-lowrisc force-pushed the keymgr_dpe_PR9_top_integration branch from 504036c to 513b9b0 Compare August 3, 2026 20:48
@rroth-lowrisc
rroth-lowrisc marked this pull request as ready for review August 3, 2026 20:49
@rroth-lowrisc
rroth-lowrisc requested review from a team and cfrantz as code owners August 3, 2026 20:49
@rroth-lowrisc
rroth-lowrisc requested review from martin-velay and removed request for a team August 3, 2026 20:49
@rroth-lowrisc
rroth-lowrisc force-pushed the keymgr_dpe_PR9_top_integration branch from 513b9b0 to 23068f6 Compare August 3, 2026 20:50
Replace all occurrences of `keymgr` with their respective counterpart
from `keymgr_dpe`. Due to timeout errors the verilator timeout was
set to "long".

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Replace all occurrences of `keymgr` with their respective counterpart
from `keymgr_dpe`.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Replace all occurrences of `keymgr` with their respective counterpart
from `keymgr_dpe`.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Signed-off-by: Raphael Roth <rroth@lowrisc.org>
…ents`

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Replace all occurrences of `keymgr` with their respective counterpart
from `keymgr_dpe`. The sealing key is now derived from DPE slot 0, which
has to stay in sync with the slot used in `dice_chain.c`.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
…value`

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Replace all occurrences of the `keymgr` with the newly introduced
`keymgr_dpe`. Because the `keymgr_dpe` derives the CreatorRootKey in the
ROM rather than in the immutable ROM_EXT, the DICE chain construction had
to be restructured: the ROM now advances the DPE slots and the ROM_EXT
consumes them.

This split was approved by the DPE RFC:
https://docs.google.com/document/d/1iF0EWyJkSEtRL9d057imLo4s6DWNrZ6Mpt0QKD8OMMc

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Compared to the original `keymgr`, the `keymgr_dpe` derives the
_CreatorRootKey_ already in the ROM. Therefore it is impossible to
reconstruct the binding values used for the key derivations. This test
only generates two SW readable keys and compares them, expecting a
mismatch / match depending on the OTP configuration.

The OTP SECRET2 images must be locked, otherwise `keymgr_dpe` will
transition into the invalid state when deriving the CREATOR_ROOT_KEY.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Signed-off-by: Raphael Roth <rroth@lowrisc.org>
The new _rom_ supporting the `keymgr_dpe` introduces several
new `sec_mmio_check_values`. The overall expected number in
the `rom_e2e_static_critical_test.c` must be updated too.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Replace `keymgr` with `keymgr_dpe` in the shutdown path: `HAS_KEYMGR`
becomes `HAS_KEYMGR_DPE`.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Switch the TPM key descriptors and the EK diversifier to their
`keymgr_dpe` types and drop the `.type` field.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
…etup

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Drop the `sc_keymgr_key_type_t` argument from
`otbn_boot_attestation_keygen` and `otbn_boot_attestation_key_save`.
The `keymgr_dpe` encodes the sealing / attestation key in the
DPE slot selected by the diversifier instead of a separate key type.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Replace the `keymgr` testutils with their `keymgr_dpe`
equivalents across the SCA penetration-test firmware

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Replace the `keymgr` testutils with their `keymgr_dpe`
equivalents across the FI penetration-test firmware

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Signed-off-by: Raphael Roth <rroth@lowrisc.org>
…ls functions

Disable `entropy_src_edn_reqs_test` / `kmac_error_conditions_test` /
`kmac_kmac_key_sideload_test` for `darjeeling`. Tracked in lowRISC#30919.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
`keymgr_dpe` now consumes the `creator_root_key` (UDS) directly in the
ROM during boot. Any test that boots through the ROM will fail with
`kErrorKeymgrInternal` if `secret2` isn't locked, since OTP reports the
root key shares as invalid and `keymgr_dpe` flags the load as invalid.

Locking `secret2` computes its digest, which asserts `secrets_valid` and
marks the device as personalized, something the life cycle controller
rejects in RAW and all TEST_* states.

`EARLGREY_STD_OTP_OVERLAYS` uses the new `otp_json_secret2_lock_by_lc_state`
overlay, which provisions the SECRET2 items only, while
`otp_json_{dev,prod,prod_end,rma}` declare the lock.

The default is a locked `secret2` in the `{dev,prod,prod_end,rma}` lc state.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Both `kmac_entropy_test` and `kmac_error_conditions_test` need KMAC to
fetch its entropy from EDN, which is no longer possible once the ROM has
configured KMAC in software entropy mode for the `keymgr_dpe`
operations. Mark them as broken on the sival execution environment
until lowRISC#30949 is resolved.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
See issue lowRISC#30957.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
Due to the `keymgr_dpe` integration into `earlgrey` `secret2` is
locked in the default OTP images for {dev, prod, prod_end, rma}.
The test relies on having an unlocked `secret2` therefore it is
explicitly not locked.

Signed-off-by: Raphael Roth <rroth@lowrisc.org>
@rroth-lowrisc
rroth-lowrisc force-pushed the keymgr_dpe_PR9_top_integration branch from 01f25f2 to ca46fec Compare August 13, 2026 15:02
@rroth-lowrisc

Copy link
Copy Markdown
Contributor Author

@gautschimi @engdoreis Thanks for your reviews, I implemented your suggestion or lakes a question in return.

@gautschimi I directly changed the references from u_keymgr to u_keymgr_dpe and remove the waivers in hw/top_earlgrey/cdc/cdc_waivers.w_recon.tcl (If necessary they can be reintroduced later on). The test error you have seen is unrelated to the keymgr_dpe integration and will be fixed in a separate PR.

@gautschimi

Copy link
Copy Markdown
Contributor

@gautschimi I directly changed the references from u_keymgr to u_keymgr_dpe and remove the waivers in hw/top_earlgrey/cdc/cdc_waivers.w_recon.tcl (If necessary they can be reintroduced later on). The test error you have seen is unrelated to the keymgr_dpe integration and will be fixed in a separate PR.

Thanks. Please reference an issue that is explaining the problem with this test. It might already exist

@rroth-lowrisc

Copy link
Copy Markdown
Contributor Author

@gautschimi I directly changed the references from u_keymgr to u_keymgr_dpe and remove the waivers in hw/top_earlgrey/cdc/cdc_waivers.w_recon.tcl (If necessary they can be reintroduced later on). The test error you have seen is unrelated to the keymgr_dpe integration and will be fixed in a separate PR.

Thanks. Please reference an issue that is explaining the problem with this test. It might already exist

I didn't find a issue, I opened #31000. I don't want to add the issue number somewhere in the code because its clearly related to the logger and not the keymgr_dpe integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants