From 23b7bc0142d63ecf0664821e3a7c51dca813c38a Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 22 Jan 2026 19:46:07 +0800 Subject: [PATCH] add an upper limit for counter increments this is a sanity check number that can be used by firmware to vet a counter value before incrementing to it. it's particularly useful to thwart wear-out attacks agaisnt anti-rollback firmware versions, i.e. by specifying an extremely high anti-rollback number one might be able to cause a reset-to-0 failure and this prevents that from happening by limiting the maximum value of the the counter that can be requested. --- libs/bao1x-hal/src/acram.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/bao1x-hal/src/acram.rs b/libs/bao1x-hal/src/acram.rs index acf6dd43d..68106a8a0 100644 --- a/libs/bao1x-hal/src/acram.rs +++ b/libs/bao1x-hal/src/acram.rs @@ -24,6 +24,9 @@ const COUNTER_STRIDE_U32: usize = ONEWAY_LEN / size_of::(); pub const MAX_ONEWAY_COUNTERS: usize = 8192 / ONEWAY_LEN; pub const CODESEL_END: usize = 0x603D_A000; +/// This is set by the wear-out limit of the underlying RRAM. +pub const ONEWAY_MAX_VALUE: u32 = 10_0000; + #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum OneWayErr { OutOfBounds,