simplify erased key reporting on debug

this reduces the amount of prints for a key range being
erased so if the debug flags are on boot isn't delayed
while the debug prints. instead, a total tally of the
erased keys for a key range is printed.
This commit is contained in:
bunnie 2025-12-19 01:12:57 +08:00
parent 36b103ef6c
commit 49e526f60b
No known key found for this signature in database

View file

@ -292,7 +292,7 @@ pub fn erase_secrets(csprng: &mut Option<&mut Csprng>) -> Result<(), String> {
// safety: these words are excluded from the hash check because we need to pass from boot0 through // safety: these words are excluded from the hash check because we need to pass from boot0 through
// to the loader, but the "hard reset" check happens only in boot1 // to the loader, but the "hard reset" check happens only in boot1
unsafe { unsafe {
buram.store_slice_no_hash(&[0u8; 32], crate::buram::ERASURE_PROOF_RANGE_BYTES.start); buram.store_slice_no_hash(&[0u8; 32], ERASURE_PROOF_RANGE_BYTES.start);
} }
let mut zero_key_count = 0; let mut zero_key_count = 0;
@ -305,6 +305,7 @@ pub fn erase_secrets(csprng: &mut Option<&mut Csprng>) -> Result<(), String> {
csprng.as_deref_mut().map(|rng| rng.random_delay()); csprng.as_deref_mut().map(|rng| rng.random_delay());
if slot.get_type() == SlotType::Data { if slot.get_type() == SlotType::Data {
let (_pa, rw_perms) = slot.get_access_spec(); let (_pa, rw_perms) = slot.get_access_spec();
let mut erased_keys = 0;
for data_index in slot.try_into_data_iter().unwrap() { for data_index in slot.try_into_data_iter().unwrap() {
bollard!(die_no_std, 4); bollard!(die_no_std, 4);
csprng.as_deref_mut().map(|rng| rng.random_delay()); csprng.as_deref_mut().map(|rng| rng.random_delay());
@ -345,13 +346,19 @@ pub fn erase_secrets(csprng: &mut Option<&mut Csprng>) -> Result<(), String> {
rcurst.wo(utralib::utra::sysctrl::SFR_RCURST0, 0x55AA); rcurst.wo(utralib::utra::sysctrl::SFR_RCURST0, 0x55AA);
*/ */
} else { } else {
crate::println!("Key range at {} confirmed erased", slot.get_base()); erased_keys += 1;
} }
} }
_ => {} _ => {}
} }
bollard!(die_no_std, 4); bollard!(die_no_std, 4);
} }
crate::println!(
"Key range at {}: {}/{} keys confirmed erased",
slot.get_base(),
erased_keys,
slot.len()
);
bollard!(die_no_std, 4); bollard!(die_no_std, 4);
} }
bollard!(die_no_std, 4); bollard!(die_no_std, 4);