mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add collateral erasure check to keystore
in no case should any baochip firmware be holding secret collateral used by third party firmwares, thus a non-erased state is a panic
This commit is contained in:
parent
6b7ff11b4e
commit
cc00201774
2 changed files with 17 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||||
use bao1x_hal::rram::Reram;
|
use bao1x_hal::rram::Reram;
|
||||||
use keystore_api::*;
|
use keystore_api::*;
|
||||||
use xous::SID;
|
use xous::SID;
|
||||||
|
|
@ -15,6 +16,12 @@ pub fn keystore(sid: SID) -> ! {
|
||||||
// derive the master key
|
// derive the master key
|
||||||
store.derive_master_key();
|
store.derive_master_key();
|
||||||
|
|
||||||
|
if store.is_collateral_erased() {
|
||||||
|
log::info!("{}COLLATERAL.ERASED,{}", BOOKEND_START, BOOKEND_END);
|
||||||
|
} else {
|
||||||
|
panic!("Collateral is not erased - protocol error for Baochip firmwares!");
|
||||||
|
}
|
||||||
|
|
||||||
let mut msg_opt = None;
|
let mut msg_opt = None;
|
||||||
|
|
||||||
// allow preemption once the keystore has claimed locks on all its critical resources
|
// allow preemption once the keystore has claimed locks on all its critical resources
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use bao1x_api::{
|
||||||
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||||
use bao1x_hal::{
|
use bao1x_hal::{
|
||||||
acram::{OneWayCounter, SlotManager},
|
acram::{OneWayCounter, SlotManager},
|
||||||
board::{CHAFF_KEYS, NUISANCE_KEYS_0, NUISANCE_KEYS_1, ROOT_SEED, THE_FLAG_1},
|
board::{CHAFF_KEYS, COLLATERAL, NUISANCE_KEYS_0, NUISANCE_KEYS_1, ROOT_SEED, THE_FLAG_1},
|
||||||
rram::Reram,
|
rram::Reram,
|
||||||
};
|
};
|
||||||
use hkdf::Hkdf;
|
use hkdf::Hkdf;
|
||||||
|
|
@ -89,6 +89,15 @@ impl KeyStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// returns `true` if collateral is erased
|
||||||
|
pub fn is_collateral_erased(&mut self) -> bool {
|
||||||
|
let collateral = self.slot_mgr.read(&COLLATERAL).unwrap();
|
||||||
|
let check_val = vec![bao1x_hal::sigcheck::ERASE_VALUE; COLLATERAL.len() * SLOT_ELEMENT_LEN_BYTES];
|
||||||
|
// log::info!("collateral: {:x?}", &collateral);
|
||||||
|
// log::info!("check_val: {:x?}", &check_val);
|
||||||
|
collateral == &check_val
|
||||||
|
}
|
||||||
|
|
||||||
pub fn derive_master_key(&mut self) {
|
pub fn derive_master_key(&mut self) {
|
||||||
let mut ikm = Vec::<u8>::new();
|
let mut ikm = Vec::<u8>::new();
|
||||||
let mut salt = Vec::<u8>::new();
|
let mut salt = Vec::<u8>::new();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue