From 4d86e8a82b66199f936c92107504c3292ea40e27 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 15 Feb 2026 03:27:20 +0800 Subject: [PATCH] use die_no_std in hardening; remove excess prints also fix some math regarding birthday paradoxes and the random number checking. --- libs/bao1x-hal/src/clocks.rs | 4 ++-- libs/bao1x-hal/src/hardening.rs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/bao1x-hal/src/clocks.rs b/libs/bao1x-hal/src/clocks.rs index 47c9a6017..ad5a52529 100644 --- a/libs/bao1x-hal/src/clocks.rs +++ b/libs/bao1x-hal/src/clocks.rs @@ -157,7 +157,7 @@ where cgu.wo(sysctrl::SFR_IPCARIPFLOW, 0x32); for _ in 0..4096 { - bao1x_api::bollard!(4); + bao1x_api::bollard!(crate::sigcheck::die_no_std, 4); } cgu.wo( @@ -189,7 +189,7 @@ where cgu.wo(sysctrl::SFR_IPCARIPFLOW, 0x32); for _ in 0..4096 { - bao1x_api::bollard!(4); + bao1x_api::bollard!(crate::sigcheck::die_no_std, 4); } bao1x_api::bollard!(6); diff --git a/libs/bao1x-hal/src/hardening.rs b/libs/bao1x-hal/src/hardening.rs index f567b8c2d..ee7497d1c 100644 --- a/libs/bao1x-hal/src/hardening.rs +++ b/libs/bao1x-hal/src/hardening.rs @@ -46,7 +46,6 @@ pub fn check_pll() { pub fn die() -> ! { let owc = OneWayCounter::new(); // safety: this is safe because the offset is from a checked, pre-defined value - crate::println_d!("die!die!die!die!"); unsafe { owc.inc(POSSIBLE_ATTACKS).unwrap(); } @@ -95,7 +94,7 @@ impl Csprng { // do a quick health check on the TRNG before using it. Looks for repeated values over 8 samples. // this will rule out e.g. TRNG output tied to 0 or 1, or an external feed just feeding it repetitive - // data. About 1 in 500 million chance of triggering falsely if the TRNG is truly random. + // data. About 1 in 33 million chance of triggering falsely if the TRNG is truly random. let mut values = [0u32; 8]; for value in values.iter_mut() { *value = ro_trng.get_raw(); @@ -236,7 +235,7 @@ pub fn reset_sensors() { } // wait for reset to propagate for _ in 0..100 { - bao1x_api::bollard!(4); + bao1x_api::bollard!(die, 4); } // re-arm bao1x_api::bollard!(die, 4);