From 10ef6bda029fa547944eb2975240d3dda74d59d1 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 18 Jan 2026 20:52:51 +0800 Subject: [PATCH] add information about root key seed to regular sign_image Three pieces of inforation are leaked about the root seed: - whether or not the first 64 bits are all 0 - whether or not the first 64 bits are all 3's - whether if none of the above are true It's fairly indirect leakage, and I think it is a relatively minor price to pay for the confidence it gives that some underlying library behavior didn't accidentally lead to faulty keygen. Note that these 64 bits are 64 bits out of tens of thousands of bits that go into the keygen, because the nuisance keys and the chaff key are all blended together to create the final derived root key. Thus the security margin on the key is quite large and even a full disclosure of these 64-bits is a minor impact on overall security. --- .../keystore/src/platform/baosec/store.rs | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/services/keystore/src/platform/baosec/store.rs b/services/keystore/src/platform/baosec/store.rs index 1f397b0d6..08c47377e 100644 --- a/services/keystore/src/platform/baosec/store.rs +++ b/services/keystore/src/platform/baosec/store.rs @@ -109,22 +109,20 @@ impl KeyStore { // read key material ikm.extend_from_slice(self.slot_mgr.read(&ROOT_SEED).unwrap()); - #[cfg(feature = "hazardous-debug")] - { - // analyze part of the key and print some informative statements during hazardous-debug - // we want to make sure that keys are actually being initialized, erased, or denied - // look at only 64 bits out of the 256 bit key - it's enough that it's highly unlikely that - // these 64 bits would match any of the zero/erased values, but not so much that if a - // dev image is accidentally signed & released that it'd be a serious threat to security - // as you'd still have 192 bits of secret material - let root_seed = self.slot_mgr.read(&ROOT_SEED).unwrap(); - if root_seed[..8] == [0u8; 8] { - log::info!("{}KEYSTORE.ZERO,{}", BOOKEND_START, BOOKEND_END); - } else if root_seed[..8] == [bao1x_hal::sigcheck::ERASE_VALUE; 8] { - log::info!("{}KEYSTORE.ERASED,{}", BOOKEND_START, BOOKEND_END); - } else { - log::info!("{}KEYSTORE.KEYPASS,{}", BOOKEND_START, BOOKEND_END); - } + + // Analyze part of the key and print some informative statements. + // We want to make sure that keys are actually being initialized, erased, or denied + // look at only 64 bits out of the 256 bit key - it's enough that it's highly unlikely that + // these 64 bits would match any of the zero/erased values, but not so much that if these + // values are leaked, that it'd be a serious threat to security as you'd still have 192 bits of + // secret material, not to mention all the additional nuisance keys and chaff keys yet to come. + let root_seed = self.slot_mgr.read(&ROOT_SEED).unwrap(); + if root_seed[..8] == [0u8; 8] { + log::info!("{}KEYSTORE.ZERO,{}", BOOKEND_START, BOOKEND_END); + } else if root_seed[..8] == [bao1x_hal::sigcheck::ERASE_VALUE; 8] { + log::info!("{}KEYSTORE.ERASED,{}", BOOKEND_START, BOOKEND_END); + } else { + log::info!("{}KEYSTORE.KEYPASS,{}", BOOKEND_START, BOOKEND_END); } // build nuisance key offsets - this is direct readout hardening