mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
fix issue where pubkey was being erased before access
verification happens after the private key material is erased, which incidentally nukes public key material, causing verification to fail. This caches a copy of the pubkey material before the erase happens.
This commit is contained in:
parent
13e13fdfd6
commit
c05e66b32c
1 changed files with 8 additions and 9 deletions
|
|
@ -1465,6 +1465,14 @@ impl<'a> RootKeys {
|
||||||
pb.set_percentage(95);
|
pb.set_percentage(95);
|
||||||
src_oracle.clear();
|
src_oracle.clear();
|
||||||
dst_oracle.clear();
|
dst_oracle.clear();
|
||||||
|
// make a backup copy of the public key before we purge it. Pubkey is...public, so that's fine!
|
||||||
|
let pubkey = match update_type {
|
||||||
|
UpdateType::Restore => {
|
||||||
|
log::info!("Restore process is verifying using staged public key");
|
||||||
|
PublicKey::from_bytes(&self.read_staged_key_256(KeyRomLocs::SELFSIGN_PUBKEY)).expect("public key was not valid")
|
||||||
|
}
|
||||||
|
_ => PublicKey::from_bytes(&self.read_key_256(KeyRomLocs::SELFSIGN_PUBKEY)).expect("public key was not valid")
|
||||||
|
};
|
||||||
self.purge_sensitive_data();
|
self.purge_sensitive_data();
|
||||||
self.spinor.set_staging_write_protect(false).expect("couldn't un-protect the staging area");
|
self.spinor.set_staging_write_protect(false).expect("couldn't un-protect the staging area");
|
||||||
for b in keypair_bytes.iter_mut() {
|
for b in keypair_bytes.iter_mut() {
|
||||||
|
|
@ -1478,13 +1486,6 @@ impl<'a> RootKeys {
|
||||||
// check signatures
|
// check signatures
|
||||||
if keypair.is_some() {
|
if keypair.is_some() {
|
||||||
pb.set_percentage(96);
|
pb.set_percentage(96);
|
||||||
let pubkey = match update_type {
|
|
||||||
UpdateType::Restore => {
|
|
||||||
log::info!("Restore process is verifying using staged public key");
|
|
||||||
PublicKey::from_bytes(&self.read_staged_key_256(KeyRomLocs::SELFSIGN_PUBKEY)).expect("public key was not valid")
|
|
||||||
}
|
|
||||||
_ => PublicKey::from_bytes(&self.read_key_256(KeyRomLocs::SELFSIGN_PUBKEY)).expect("public key was not valid")
|
|
||||||
};
|
|
||||||
if !self.verify_gateware_self_signature(Some(&pubkey)) {
|
if !self.verify_gateware_self_signature(Some(&pubkey)) {
|
||||||
return Err(RootkeyResult::IntegrityError);
|
return Err(RootkeyResult::IntegrityError);
|
||||||
}
|
}
|
||||||
|
|
@ -2273,14 +2274,12 @@ impl<'a> RootKeys {
|
||||||
|
|
||||||
/// This is a fast check on the gateware meant to be called on boot just to confirm that we're using a self-signed gateware
|
/// This is a fast check on the gateware meant to be called on boot just to confirm that we're using a self-signed gateware
|
||||||
pub fn verify_gateware_self_signature(&mut self, maybe_pubkey: Option<&PublicKey>) -> bool {
|
pub fn verify_gateware_self_signature(&mut self, maybe_pubkey: Option<&PublicKey>) -> bool {
|
||||||
log::info!("Verifying gateware called with pubkey {:?}", maybe_pubkey);
|
|
||||||
let local_pk = PublicKey::from_bytes(&self.read_key_256(KeyRomLocs::SELFSIGN_PUBKEY)).expect("public key was not valid");
|
let local_pk = PublicKey::from_bytes(&self.read_key_256(KeyRomLocs::SELFSIGN_PUBKEY)).expect("public key was not valid");
|
||||||
let pubkey = if let Some(pk) = maybe_pubkey {
|
let pubkey = if let Some(pk) = maybe_pubkey {
|
||||||
pk
|
pk
|
||||||
} else {
|
} else {
|
||||||
&local_pk
|
&local_pk
|
||||||
};
|
};
|
||||||
log::info!("Finally decided to use public key {:?}", pubkey);
|
|
||||||
// read the signature directly out of the keyrom
|
// read the signature directly out of the keyrom
|
||||||
let gateware_region = self.gateware();
|
let gateware_region = self.gateware();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue