From d9d146352fb004dfe6b8af489b5ee0b3aa11a719 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 5 Dec 2025 22:43:49 +0800 Subject: [PATCH] ensure that hardened_get2 is used correctly with an assert --- libs/bao1x-hal/src/acram.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/bao1x-hal/src/acram.rs b/libs/bao1x-hal/src/acram.rs index eb7e961f5..ae3ec184e 100644 --- a/libs/bao1x-hal/src/acram.rs +++ b/libs/bao1x-hal/src/acram.rs @@ -128,6 +128,10 @@ impl OneWayCounter { /// if they are not, then something bad happened. #[inline(always)] pub fn hardened_get2(&self, offset: usize, dupe: usize) -> Result<(u32, u32), OneWayErr> { + assert!( + offset != dupe, + "hardened_get2 requires different offsets; use hardened_get for same offset gets" + ); bollard!(4); const HARDENING_FACTOR: usize = 4; #[cfg(not(feature = "std"))]