From f9ef3217f0800cac2e26cdf8549b4cea98bca676 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 4 Feb 2026 15:58:20 +0800 Subject: [PATCH] add test command to overwrite keys --- services/bao-console/Cargo.toml | 3 +++ services/bao-console/src/cmds/test.rs | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/services/bao-console/Cargo.toml b/services/bao-console/Cargo.toml index 32072a3b6..f935a0e75 100644 --- a/services/bao-console/Cargo.toml +++ b/services/bao-console/Cargo.toml @@ -26,6 +26,7 @@ xous-swapper = { path = "../xous-swapper", optional = true } bytemuck = "1.24.0" susres = { path = "../../api/xous-api-susres", package = "xous-api-susres" } keystore = { path = "../keystore" } +keystore-api = { path = "../../libs/keystore-api" } bio-lib = { path = "../../libs/bio-lib", optional = true } arbitrary-int = "1.2" @@ -89,6 +90,8 @@ test-flash = [] ctap-bringup = ["xous-usb-hid"] # this is mutually exclusive with the keystore, as keystore owns rram rramtests = [] +# for testing key erasure in CI +key-testing = ["keystore-api/key-testing", "keystore-api/gen2"] # Activating this makes this crate *try* to grab the DUART. To improve its odds # of winning the race, shift its position to first in the list in the PIDs to be diff --git a/services/bao-console/src/cmds/test.rs b/services/bao-console/src/cmds/test.rs index 06f9bb20b..e49b93a89 100644 --- a/services/bao-console/src/cmds/test.rs +++ b/services/bao-console/src/cmds/test.rs @@ -326,6 +326,29 @@ impl<'a> ShellCmdApi<'a> for Test { }*/ } } + #[cfg(feature = "key-testing")] + "overwrite_keys" => { + // used primary to refresh the key store with a new set of random keys between CI tests + // that are iterating through various configurations to ensure that the key store is erased. + use num_traits::*; + let keystore = _env.xns.request_connection_blocking(keystore_api::SERVER_NAME_KEYS).unwrap(); + xous::send_message( + keystore, + xous::Message::new_scalar( + keystore_api::Opcode::OverwriteKeys.to_usize().unwrap(), + 0, + 0, + 0, + 0, + ), + ) + .unwrap(); + log::info!( + "{}KEYSTORE.OVERWRITE,{}", + bao1x_hal::board::BOOKEND_START, + bao1x_hal::board::BOOKEND_END + ); + } /* // leave this around in case we have more swap bugs to debug // needs to have `swaptest1`` & `swaptest2` added to the image for this to work. "swap" => {