use die_no_std in hardening; remove excess prints

also fix some math regarding birthday paradoxes and the
random number checking.
This commit is contained in:
bunnie 2026-02-15 03:27:20 +08:00
parent 70f219ba0a
commit 4d86e8a82b
No known key found for this signature in database
2 changed files with 4 additions and 5 deletions

View file

@ -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);

View file

@ -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);