diff --git a/libs/bao1x-hal/src/board/baosec.rs b/libs/bao1x-hal/src/board/baosec.rs index 47061cfea..51c1ddc03 100644 --- a/libs/bao1x-hal/src/board/baosec.rs +++ b/libs/bao1x-hal/src/board/baosec.rs @@ -18,7 +18,10 @@ pub const SPINOR_ERASE_SIZE: u32 = bao1x_api::offsets::baosec::SPINOR_ERASE_SIZE pub const SPINOR_BULK_ERASE_SIZE: u32 = bao1x_api::offsets::baosec::SPINOR_BULK_ERASE_SIZE; pub const SPINOR_LEN: u32 = bao1x_api::offsets::baosec::SPI_FLASH_LEN as _; pub const PDDB_LOC: u32 = bao1x_api::offsets::baosec::PDDB_ORIGIN as _; +#[cfg(not(feature = "oem-baosec-lite"))] pub const PDDB_LEN: u32 = bao1x_api::offsets::baosec::PDDB_LEN as _; +#[cfg(feature = "oem-baosec-lite")] +pub const PDDB_LEN: u32 = 2560 * 1024; // 2.5MiB length // Define the virtual region that memory-mapped FLASH should go to // top 8 megs are reserved for staging updates, backups, etc. diff --git a/services/pddb/Cargo.toml b/services/pddb/Cargo.toml index 5557196fd..7d84687c6 100644 --- a/services/pddb/Cargo.toml +++ b/services/pddb/Cargo.toml @@ -108,6 +108,7 @@ board-baosec = [ "keystore/board-baosec", "aes/bao1x", ] # USB form factor token +oem-baosec-lite = [] hosted-baosec = [ "gen2", "bao1x-emu", diff --git a/services/pddb/src/backend/fastspace.rs b/services/pddb/src/backend/fastspace.rs index 8cd055d1d..4c53a9f17 100644 --- a/services/pddb/src/backend/fastspace.rs +++ b/services/pddb/src/backend/fastspace.rs @@ -96,8 +96,8 @@ pub(crate) struct SpaceUpdate { // this checksum is "weak" but we are protecting against two scenarios: // 1. partially written SpaceUpdate record (so the last bytes or so are FF) // 2. a malicious attacker - // In the case of (1), the occurence should be diminishingly small (expected to never happen, maybe - // a very unstable system that's "blinking" power constantly would have it occure a few times) + // In the case of (1), the occurrence should be diminishingly small (expected to never happen, maybe + // a very unstable system that's "blinking" power constantly would have it occur a few times) // In the case of (2), an attacker has a chance of generating a collision, but the result is // also unlikely to generate a valid PhysAddr, and if it does, the consequence is some valid data // being treated as free space and getting erased (data loss, not disclosure). diff --git a/services/pddb/src/main.rs b/services/pddb/src/main.rs index a3b556ee8..b3cf98c93 100644 --- a/services/pddb/src/main.rs +++ b/services/pddb/src/main.rs @@ -814,6 +814,7 @@ fn wrapped_main() -> ! { } } let modals = modals::Modals::new(&xns).expect("can't connect to Modals server"); + let fast_format = if cfg!(feature = "oem-baosec-lite") { true } else { false }; match pddb_os.ensure_password() { PasswordState::Correct => { // The behavior in gen2 is mount-or-format: no user approval @@ -821,7 +822,9 @@ fn wrapped_main() -> ! { // of data corruption but I think this is the "right" user experience if !try_mount(&mut pddb_os, &mut basis_cache, &mut basis_monitor_notifications) { log::warn!("PDDB not formatted - formatting the PDDB!"); - pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB"); + pddb_os + .pddb_format(fast_format, Some(&modals)) + .expect("couldn't format PDDB"); if !try_mount( &mut pddb_os, &mut basis_cache, @@ -833,7 +836,7 @@ fn wrapped_main() -> ! { } PasswordState::Uninit => { log::warn!("PDDB not formatted - formatting the PDDB!"); - pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB"); + pddb_os.pddb_format(fast_format, Some(&modals)).expect("couldn't format PDDB"); if !try_mount(&mut pddb_os, &mut basis_cache, &mut basis_monitor_notifications) { panic!("Couldn't format & mount PDDB"); } @@ -843,7 +846,7 @@ fn wrapped_main() -> ! { } PasswordState::Incorrect(_failcount) => { log::warn!("PDDB formatted, but keys rotated. Formatting PDDB!"); - pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB"); + pddb_os.pddb_format(fast_format, Some(&modals)).expect("couldn't format PDDB"); if !try_mount(&mut pddb_os, &mut basis_cache, &mut basis_monitor_notifications) { panic!("Couldn't format & mount PDDB"); }