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)] 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); 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 { diff --git a/libs/bao1x-hal/src/sigcheck.rs b/libs/bao1x-hal/src/sigcheck.rs index 410236c13..f140ed57a 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))) @@ -347,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) { 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