From 10ef6bda029fa547944eb2975240d3dda74d59d1 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 18 Jan 2026 20:52:51 +0800 Subject: [PATCH 1/6] add information about root key seed to regular sign_image Three pieces of inforation are leaked about the root seed: - whether or not the first 64 bits are all 0 - whether or not the first 64 bits are all 3's - whether if none of the above are true It's fairly indirect leakage, and I think it is a relatively minor price to pay for the confidence it gives that some underlying library behavior didn't accidentally lead to faulty keygen. Note that these 64 bits are 64 bits out of tens of thousands of bits that go into the keygen, because the nuisance keys and the chaff key are all blended together to create the final derived root key. Thus the security margin on the key is quite large and even a full disclosure of these 64-bits is a minor impact on overall security. --- .../keystore/src/platform/baosec/store.rs | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/services/keystore/src/platform/baosec/store.rs b/services/keystore/src/platform/baosec/store.rs index 1f397b0d6..08c47377e 100644 --- a/services/keystore/src/platform/baosec/store.rs +++ b/services/keystore/src/platform/baosec/store.rs @@ -109,22 +109,20 @@ impl KeyStore { // read key material ikm.extend_from_slice(self.slot_mgr.read(&ROOT_SEED).unwrap()); - #[cfg(feature = "hazardous-debug")] - { - // analyze part of the key and print some informative statements during hazardous-debug - // we want to make sure that keys are actually being initialized, erased, or denied - // look at only 64 bits out of the 256 bit key - it's enough that it's highly unlikely that - // these 64 bits would match any of the zero/erased values, but not so much that if a - // dev image is accidentally signed & released that it'd be a serious threat to security - // as you'd still have 192 bits of secret material - let root_seed = self.slot_mgr.read(&ROOT_SEED).unwrap(); - if root_seed[..8] == [0u8; 8] { - log::info!("{}KEYSTORE.ZERO,{}", BOOKEND_START, BOOKEND_END); - } else if root_seed[..8] == [bao1x_hal::sigcheck::ERASE_VALUE; 8] { - log::info!("{}KEYSTORE.ERASED,{}", BOOKEND_START, BOOKEND_END); - } else { - log::info!("{}KEYSTORE.KEYPASS,{}", BOOKEND_START, BOOKEND_END); - } + + // Analyze part of the key and print some informative statements. + // We want to make sure that keys are actually being initialized, erased, or denied + // look at only 64 bits out of the 256 bit key - it's enough that it's highly unlikely that + // these 64 bits would match any of the zero/erased values, but not so much that if these + // values are leaked, that it'd be a serious threat to security as you'd still have 192 bits of + // secret material, not to mention all the additional nuisance keys and chaff keys yet to come. + let root_seed = self.slot_mgr.read(&ROOT_SEED).unwrap(); + if root_seed[..8] == [0u8; 8] { + log::info!("{}KEYSTORE.ZERO,{}", BOOKEND_START, BOOKEND_END); + } else if root_seed[..8] == [bao1x_hal::sigcheck::ERASE_VALUE; 8] { + log::info!("{}KEYSTORE.ERASED,{}", BOOKEND_START, BOOKEND_END); + } else { + log::info!("{}KEYSTORE.KEYPASS,{}", BOOKEND_START, BOOKEND_END); } // build nuisance key offsets - this is direct readout hardening From 32397a8d9f5025a5495f10657511c29f59241a25 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 18 Jan 2026 21:41:40 +0800 Subject: [PATCH 2/6] upgrade tag message to beta-0 --- bao1x-boot/boot1/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bao1x-boot/boot1/src/main.rs b/bao1x-boot/boot1/src/main.rs index 9ec98e90e..fac28b3da 100644 --- a/bao1x-boot/boot1/src/main.rs +++ b/bao1x-boot/boot1/src/main.rs @@ -33,7 +33,7 @@ use crate::secboot::try_boot; // Notes: // - "Towards" - not a release yet, but working towards the stated milestone // - Eliminating "Towards" is done at the tag-out point. -const RELEASE_DESCRIPTION: &'static str = "Towards Beta-0"; +const RELEASE_DESCRIPTION: &'static str = "Beta-0"; static UART_RX: Mutex>> = Mutex::new(RefCell::new(VecDeque::new())); #[allow(dead_code)] From 763a2c290d90f66ed73cc6b962e33b03dd6b1b43 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 18 Jan 2026 22:37:08 +0800 Subject: [PATCH 3/6] make boot more forgiving of inconsistent initial values --- libs/bao1x-hal/src/sigcheck.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/bao1x-hal/src/sigcheck.rs b/libs/bao1x-hal/src/sigcheck.rs index 410236c13..c975799a9 100644 --- a/libs/bao1x-hal/src/sigcheck.rs +++ b/libs/bao1x-hal/src/sigcheck.rs @@ -286,7 +286,12 @@ pub fn erase_collateral(csprng: &mut Option<&mut Csprng>) -> Result<(), String> bollard!(die_no_std, 4); csprng.as_deref_mut().map(|rng| rng.random_delay()); // only clear ACL if it isn't already cleared - if slot_mgr.get_acl(slot).unwrap().raw_u32() != 0 { + if slot_mgr + .get_acl(slot) + .unwrap_or(AccessSettings::Data(DataSlotAccess::new_with_raw_value(0xFFFF_FFFF))) + .raw_u32() + != 0 + { // clear the ACL so we can operate on the data slot_mgr .set_acl(&mut rram, slot, &AccessSettings::Data(DataSlotAccess::new_with_raw_value(0))) From 18a58c7d183f4f4bb93b585c1d16bcf03f3ffec3 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 19 Jan 2026 00:18:13 +0800 Subject: [PATCH 4/6] add more graceful handling of erase inconsistencies --- libs/bao1x-hal/src/sigcheck.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libs/bao1x-hal/src/sigcheck.rs b/libs/bao1x-hal/src/sigcheck.rs index c975799a9..f140ed57a 100644 --- a/libs/bao1x-hal/src/sigcheck.rs +++ b/libs/bao1x-hal/src/sigcheck.rs @@ -352,15 +352,23 @@ pub fn erase_secrets(csprng: &mut Option<&mut Csprng>) -> Result<(), String> { match rw_perms { RwPerms::ReadWrite | RwPerms::WriteOnly => { // only clear ACL if it isn't already cleared - if slot_mgr.get_acl(slot).unwrap().raw_u32() != 0 { + if slot_mgr + .get_acl(slot) + .unwrap_or(AccessSettings::Data(DataSlotAccess::new_with_raw_value(0xFFFF_FFFF))) + .raw_u32() + != 0 + { // clear the ACL so we can operate on the data - slot_mgr - .set_acl( - &mut rram, - slot, - &AccessSettings::Data(DataSlotAccess::new_with_raw_value(0)), - ) - .expect("couldn't reset ACL"); + match slot_mgr.set_acl( + &mut rram, + slot, + &AccessSettings::Data(DataSlotAccess::new_with_raw_value(0)), + ) { + Ok(_) => (), + Err(e) => { + crate::println!("Couldn't erase ACL: {:?}", e); + } + } } let bytes = unsafe { slot_mgr.read_data_slot(data_index) }; if bytes.iter().all(|&b| b == 0) { From 6bb94a148ed637bb44058b276626b437e5407036 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 19 Jan 2026 02:41:47 +0800 Subject: [PATCH 5/6] when usb is disconnected, toggle the correct flag was turning off console altogether we actually just want to turn off printing to USB. --- bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs b/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs index 0f70943e5..0c2cfc092 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/usb/glue.rs @@ -145,7 +145,7 @@ pub fn setup() -> (UsbDeviceState, u32) { } pub fn shutdown() { - crate::debug::USE_CONSOLE.store(false, core::sync::atomic::Ordering::SeqCst); + crate::USB_CONNECTED.store(false, core::sync::atomic::Ordering::SeqCst); unsafe { if let Some(ref mut usb_ref) = crate::platform::bao1x::usb::USB { let usb = &mut *core::ptr::addr_of_mut!(*usb_ref); From 97df81de448d8dc85ecaa96636cb0fea26bfa9b2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 19 Jan 2026 03:34:55 +0800 Subject: [PATCH 6/6] fix permissible function code on altboot this allows recovery from revoked keys and trying to load a dev-boot signed image from alt-boot loader --- libs/bao1x-api/src/pubkeys/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/bao1x-api/src/pubkeys/mod.rs b/libs/bao1x-api/src/pubkeys/mod.rs index a89dd1651..8a12bdd8d 100644 --- a/libs/bao1x-api/src/pubkeys/mod.rs +++ b/libs/bao1x-api/src/pubkeys/mod.rs @@ -72,12 +72,16 @@ pub const BOOT0_TO_BOOT1: SecurityConfiguration = SecurityConfiguration { }; /// This is different from a jump directly to loader/baremetal because the -/// function codes *must* be for Boot1. +/// function codes *must* be for Boot1 or Baremetal. Loader is not a valid option. pub const BOOT0_TO_ALTBOOT1: SecurityConfiguration = SecurityConfiguration { image_ptr: crate::LOADER_START as *const u32, pubkey_ptr: crate::BOOT0_START as *const u32, revocation_owc: crate::BOOT0_REVOCATION_OFFSET, - function_codes: &[FunctionCode::Boot1 as u32, FunctionCode::UpdatedBoot1 as u32], + function_codes: &[ + FunctionCode::Boot1 as u32, + FunctionCode::UpdatedBoot1 as u32, + FunctionCode::Baremetal as u32, + ], }; pub const BOOT1_TO_LOADER_OR_BAREMETAL: SecurityConfiguration = SecurityConfiguration {