Skip to content

Commit

Permalink
Revert changes to strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1968 committed Jan 29, 2025
1 parent c7975aa commit 388646b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 24 deletions.
31 changes: 16 additions & 15 deletions fmc/src/flow/rt_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ File Name:
Abstract:
Alias RT DICE Layer & PCR extension
aliasrt DICE Layer & PCR extension
--*/
use caliptra_cfi_derive::cfi_impl_fn;
Expand Down Expand Up @@ -49,20 +49,21 @@ impl RtAliasLayer {
return Err(CaliptraError::FMC_ALIAS_KV_COLLISION);
}

cprintln!("[alias rt] Derive CDI");
cprintln!("[alias rt] Store in in slot 0x{:x}", KEY_ID_RT_CDI as u8);
cprintln!("[aliasrt] Derive CDI");
cprintln!("[aliasrt] Store in in slot 0x{:x}", KEY_ID_RT_CDI as u8);

// Derive CDI
Self::derive_cdi(env, input.cdi, KEY_ID_RT_CDI)?;
report_boot_status(FmcBootStatus::RtAliasDeriveCdiComplete as u32);
cprintln!("[aliasrt] Derive Key Pair");
cprintln!(
"[alias rt] Store priv key in slot 0x{:x}",
"[aliasrt] Store priv key in slot 0x{:x}",
KEY_ID_RT_PRIV_KEY as u8
);

// Derive DICE Key Pair from CDI
let key_pair = Self::derive_key_pair(env, KEY_ID_RT_CDI, KEY_ID_RT_PRIV_KEY)?;
cprintln!("[alias rt] Derive Key Pair - Done");
cprintln!("[aliasrt] Derive Key Pair - Done");
report_boot_status(FmcBootStatus::RtAliasKeyPairDerivationComplete as u32);

// Generate the Subject Serial Number and Subject Key Identifier.
Expand Down Expand Up @@ -100,16 +101,16 @@ impl RtAliasLayer {
#[inline(never)]
pub fn run(env: &mut FmcEnv) -> CaliptraResult<()> {
Self::extend_pcrs(env)?;
cprintln!("[alias rt] Extend RT PCRs Done");
cprintln!("[aliasrt] Extend RT PCRs Done");

env.pcr_bank
.set_pcr_lock(caliptra_common::RT_FW_CURRENT_PCR);
env.pcr_bank
.set_pcr_lock(caliptra_common::RT_FW_JOURNEY_PCR);
cprintln!("[alias rt] Lock RT PCRs Done");
cprintln!("[aliasrt] Lock RT PCRs Done");

Self::populate_dv(env)?;
cprintln!("[alias rt] Populate DV Done");
cprintln!("[aliasrt] Populate DV Done");
report_boot_status(crate::FmcBootStatus::RtMeasurementComplete as u32);

// Retrieve Dice Input Layer from Hand Off and Derive Key
Expand Down Expand Up @@ -169,7 +170,7 @@ impl RtAliasLayer {
}
ResetReason::WarmReset => {
cfi_assert_eq(reset_reason, ResetReason::WarmReset);
cprintln!("[alias rt : skip pcr extension");
cprintln!("[aliasrt :skip pcr extension");
Ok(())
}
ResetReason::Unknown => {
Expand Down Expand Up @@ -325,7 +326,7 @@ impl RtAliasLayer {

// Sign the `To Be Signed` portion
cprintln!(
"[alias rt] Signing Cert with AUTHO
"[aliasrt] Signing Cert with AUTHO
RITY.KEYID = {}",
auth_priv_key as u8
);
Expand All @@ -337,7 +338,7 @@ impl RtAliasLayer {
let sig = okref(&sig)?;
// Clear the authority private key
cprintln!(
"[alias rt] Erasing AUTHORITY.KEYID = {}",
"[aliasrt] Erasing AUTHORITY.KEYID = {}",
auth_priv_key as u8
);
// FMC ensures that CDIFMC and PrivateKeyFMC are locked to block further usage until the next boot.
Expand All @@ -346,13 +347,13 @@ impl RtAliasLayer {

let _pub_x: [u8; 48] = (&pub_key.x).into();
let _pub_y: [u8; 48] = (&pub_key.y).into();
cprintln!("[alias rt] PUB.X = {}", HexBytes(&_pub_x));
cprintln!("[alias rt] PUB.Y = {}", HexBytes(&_pub_y));
cprintln!("[aliasrt] PUB.X = {}", HexBytes(&_pub_x));
cprintln!("[aliasrt] PUB.Y = {}", HexBytes(&_pub_y));

let _sig_r: [u8; 48] = (&sig.r).into();
let _sig_s: [u8; 48] = (&sig.s).into();
cprintln!("[alias rt] SIG.R = {}", HexBytes(&_sig_r));
cprintln!("[alias rt] SIG.S = {}", HexBytes(&_sig_s));
cprintln!("[aliasrt] SIG.R = {}", HexBytes(&_sig_r));
cprintln!("[aliasrt] SIG.S = {}", HexBytes(&_sig_s));

// Verify the signature of the `To Be Signed` portion
if Crypto::ecdsa384_verify(env, auth_pub_key, tbs.tbs(), sig)? != Ecc384Result::Success {
Expand Down
15 changes: 11 additions & 4 deletions runtime/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ use core::hint::black_box;
#[cfg(feature = "std")]
pub fn main() {}

const BANNER: &str = r#"Caliptra RT"#;
const BANNER: &str = r#"
____ _ _ _ ____ _____
/ ___|__ _| (_)_ __ | |_ _ __ __ _ | _ \_ _|
| | / _` | | | '_ \| __| '__/ _` | | |_) || |
| |__| (_| | | | |_) | |_| | | (_| | | _ < | |
\____\__,_|_|_| .__/ \__|_| \__,_| |_| \_\|_|
|_|
"#;

#[no_mangle]
#[allow(clippy::empty_loop)]
Expand Down Expand Up @@ -72,15 +79,15 @@ pub extern "C" fn entry_point() -> ! {
}

drivers.run_reset_flow().unwrap_or_else(|e| {
cprintln!("[rt] failed reset flow");
cprintln!("[rt] Runtime failed reset flow");
handle_fatal_error(e.into());
});

if !drivers.persistent_data.get().fht.is_valid() {
cprintln!("[rt] can't load FHT");
cprintln!("[rt] Runtime can't load FHT");
handle_fatal_error(caliptra_drivers::CaliptraError::RUNTIME_HANDOFF_FHT_NOT_LOADED.into());
}
cprintln!("[rt] listening for commands...");
cprintln!("[rt] Runtime listening for mailbox commands...");
if let Err(e) = caliptra_runtime::handle_mailbox_commands(&mut drivers) {
handle_fatal_error(e.into());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ fn fake_boot_test() {
assert_output_contains(&output, "Running Caliptra ROM");
assert_output_contains(&output, "[fake-rom-cold-reset]");
assert_output_contains(&output, "Running Caliptra FMC");
assert_output_contains(&output, r#"Caliptra RT"#);
assert_output_contains(
&output,
r#"
/ ___|__ _| (_)_ __ | |_ _ __ __ _ | _ \_ _|
| | / _` | | | '_ \| __| '__/ _` | | |_) || |
| |__| (_| | | | |_) | |_| | | (_| | | _ < | |
\____\__,_|_|_| .__/ \__|_| \__,_| |_| \_\|_|"#,
);

let payload = MailboxReqHeader {
chksum: caliptra_common::checksum::calc_checksum(u32::from(CommandId::GET_LDEV_CERT), &[]),
Expand Down
2 changes: 1 addition & 1 deletion test/tests/caliptra_integration_tests/jtag_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn gdb_test() {
.unwrap();

hw.step();
hw.step_until_output_contains("[rt] listening for commands...\n")
hw.step_until_output_contains("[rt] Runtime listening for mailbox commands...\n")
.unwrap();

#[cfg(feature = "fpga_realtime")]
Expand Down
14 changes: 11 additions & 3 deletions test/tests/caliptra_integration_tests/smoke_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ fn smoke_test() {
.unwrap();

if firmware::rom_from_env() == &firmware::ROM_WITH_UART {
hw.step_until_output_contains("[rt] listening for commands...\n")
hw.step_until_output_contains("[rt] Runtime listening for mailbox commands...\n")
.unwrap();

let output = hw.output().take(usize::MAX);
assert_output_contains(&output, "Running Caliptra ROM");
assert_output_contains(&output, "[cold-reset]");
Expand All @@ -250,7 +251,14 @@ fn smoke_test() {
assert_output_contains(&output, "[kat] LMS");
assert_output_contains(&output, "[kat] --");
assert_output_contains(&output, "Running Caliptra FMC");
assert_output_contains(&output, r#"Caliptra RT"#);
assert_output_contains(
&output,
r#"
/ ___|__ _| (_)_ __ | |_ _ __ __ _ | _ \_ _|
| | / _` | | | '_ \| __| '__/ _` | | |_) || |
| |__| (_| | | | |_) | |_| | | (_| | | _ < | |
\____\__,_|_|_| .__/ \__|_| \__,_| |_| \_\|_|"#,
);
}

let ldev_cert_resp = hw.mailbox_execute_req(GetLdevCertReq::default()).unwrap();
Expand Down Expand Up @@ -781,7 +789,7 @@ fn test_rt_wdt_timeout() {
hw.step_until_boot_status(RUNTIME_BOOT_STATUS_READY, true);
let fmc_target = hw.output().sink().now();

let rt_wdt_timeout_cycles = fmc_target - wdt_start - 2_000;
let rt_wdt_timeout_cycles = fmc_target - wdt_start - 5_000;
drop(hw);

let security_state = *caliptra_hw_model::SecurityState::default().set_debug_locked(true);
Expand Down

0 comments on commit 388646b

Please sign in to comment.