Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate LDevID CDI in the fake ROM boot flow. #1822

Open
wants to merge 5 commits into
base: main-2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions rom/dev/src/flow/fake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::print::HexBytes;
use crate::rom_env::RomEnv;
use caliptra_common::RomBootStatus::*;
use caliptra_common::{
keyids::KEY_ID_ROM_FMC_CDI,
memory_layout::{FMCALIAS_TBS_ORG, FMCALIAS_TBS_SIZE, LDEVID_TBS_ORG, LDEVID_TBS_SIZE},
FirmwareHandoffTable,
};
Expand Down Expand Up @@ -154,6 +155,8 @@ impl FakeRomFlow {
// SKIP Execute IDEVID layer
// LDEVID cert
copy_canned_ldev_cert(env)?;
// LDEVID cdi
initialize_fake_ldevid_cdi(env)?;

// Unlock the SHA Acc by creating a SHA Acc operation and dropping it.
// In real ROM, this is done as part of executing the SHA-ACC KAT.
Expand Down Expand Up @@ -187,6 +190,17 @@ impl FakeRomFlow {
}
}

// Used to derive the firmware's hash chain.
fn initialize_fake_ldevid_cdi(env: &mut RomEnv) -> CaliptraResult<()> {
env.hmac.hmac(
&HmacKey::Array4x12(&Array4x12::default()),
&HmacData::Slice(b""),
&mut env.trng,
KeyWriteArgs::new(KEY_ID_ROM_FMC_CDI, KeyUsage::default().set_hmac_key_en()).into(),
HmacMode::Hmac384,
)
}

pub fn copy_canned_ldev_cert(env: &mut RomEnv) -> CaliptraResult<()> {
// Store signature
env.data_vault.set_ldev_dice_signature(&FAKE_LDEV_SIG);
Expand Down