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.
This commit is contained in:
bunnie 2026-01-22 19:46:07 +08:00
parent 9d972f59d5
commit 23b7bc0142

View file

@ -24,6 +24,9 @@ const COUNTER_STRIDE_U32: usize = ONEWAY_LEN / size_of::<u32>();
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,