From 94524227513f8f242e016c4885039ca7f67480be Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 3 Apr 2026 23:43:46 +0800 Subject: [PATCH] add some apis for owc frobbing --- libs/bao1x-hal/src/acram.rs | 7 ++++++- libs/keystore-api/src/gen2_api.rs | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/bao1x-hal/src/acram.rs b/libs/bao1x-hal/src/acram.rs index 95410008f..8244a6fc9 100644 --- a/libs/bao1x-hal/src/acram.rs +++ b/libs/bao1x-hal/src/acram.rs @@ -30,12 +30,17 @@ pub const ONEWAY_MAX_VALUE: u32 = 10_0000; /// a single boot attempt. pub const ONEWAY_MAX_DELTA: u32 = 512; -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, num_derive::FromPrimitive, num_derive::ToPrimitive)] pub enum OneWayErr { OutOfBounds, IncFail, InvalidCoding, + // used to report messaging errors in xous environments + InternalError, + // used to indicate things are OK in xous environments + None, } + pub struct OneWayCounter { #[cfg(feature = "std")] mapping: MemoryRange, diff --git a/libs/keystore-api/src/gen2_api.rs b/libs/keystore-api/src/gen2_api.rs index 24aebf613..10a125cba 100644 --- a/libs/keystore-api/src/gen2_api.rs +++ b/libs/keystore-api/src/gen2_api.rs @@ -24,6 +24,9 @@ pub enum Opcode { /// Flag operations GetFlags = 512, SetFlags = 513, + /// One way counter operations + GetOneWayCounter = 768, + IncOneWayCounter = 769, // ----- below are non-cryptographic opcodes but used to manipulate sensitive state ----- /// Set bootwait parameters @@ -41,3 +44,8 @@ pub enum EphemeralOp { GetMsb, SetMsb, } + +/// Series of magic numbers not meant for cryptographic authentication, +/// but for detecting fat-fingered API implementations. +pub const OWC_MAGIC_GET: [usize; 3] = [0x2b46_2ab3, 0xf7e3_1b59, 0x7bba_d222]; +pub const OWC_MAGIC_INC: [usize; 3] = [0xeb5d_fc81, 0x8b6d_6a90, 0xf720_491a];