expose is_efuse_secured() API via the PDDB

is_efuse_secured() comes from rootkeys, but we don't want
to expose the full rootkeys API to the world.

PDDB already has an approved capability for accessing rootkeys,
so this single API is passed through via the PDDB object here,
allowing other procesess to query it.
This commit is contained in:
bunnie 2022-05-28 18:18:37 +08:00
parent 811bd88111
commit f4a18401e5
4 changed files with 28 additions and 0 deletions

View file

@ -120,6 +120,9 @@ pub(crate) enum Opcode {
/// Menu opcodes
MenuListBasis,
/// Security state checks
IsEfuseSecured,
/// Suspend/resume callback
SuspendResume,
/// quit the server

View file

@ -243,6 +243,9 @@ impl PddbOs {
self.fspace_log_next_addr = None;
self.pddb_mr.reset();
}
pub(crate) fn is_efuse_secured(&self) -> bool {
self.rootkeys.is_efuse_secured().expect("couldn't query efuse security state") == Some(true)
}
pub(crate) fn nonce_gen(&self) -> Nonce {
let nonce_array = self.entropy.borrow_mut().get_nonce();

View file

@ -599,6 +599,21 @@ impl Pddb {
}
Ok(dict_list)
}
/// Public function to query efuse security state. Replicated here to avoid exposing RootKeys full API to the world.
pub fn is_efuse_secured(&self) -> bool {
let response = send_message(self.conn,
Message::new_blocking_scalar(Opcode::IsEfuseSecured.to_usize().unwrap(), 0, 0, 0, 0)
).expect("couldn't make call to query efuse security state");
if let xous::Result::Scalar1(result) = response {
if result == 1 {
true
} else {
false
}
} else {
panic!("Internal error: wrong return code for is_efuse_secured()");
}
}
/// Triggers a dump of the PDDB to host disk
#[cfg(not(any(target_os = "none", target_os = "xous")))]
pub fn dbg_dump(&self, name: &str) -> Result<()> {

View file

@ -532,6 +532,13 @@ fn xmain() -> ! {
basis_cache.suspend(&mut pddb_os);
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
}),
Some(Opcode::IsEfuseSecured) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
if pddb_os.is_efuse_secured() {
xous::return_scalar(msg.sender, 1).unwrap();
} else {
xous::return_scalar(msg.sender, 0).unwrap();
}
}),
Some(Opcode::IsMounted) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
if basis_cache.basis_count() > 0 { // if there's anything in the cache, we're mounted.
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");