mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
upgrade audit routines to use the new signature checking API
This commit is contained in:
parent
8be0f1004b
commit
50d32ecb42
1 changed files with 33 additions and 74 deletions
|
|
@ -4,7 +4,7 @@ use alloc::string::{String, ToString};
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::convert::TryInto;
|
use core::convert::TryInto;
|
||||||
|
|
||||||
use bao1x_api::signatures::FunctionCode;
|
use bao1x_api::pubkeys::{BOOT0_SELF_CHECK, BOOT0_TO_BOOT1, BOOT1_TO_LOADER_OR_BAREMETAL};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use bao1x_api::*;
|
use bao1x_api::*;
|
||||||
use bao1x_hal::acram::OneWayCounter;
|
use bao1x_hal::acram::OneWayCounter;
|
||||||
|
|
@ -357,58 +357,33 @@ impl Repl {
|
||||||
crate::println!("");
|
crate::println!("");
|
||||||
}
|
}
|
||||||
|
|
||||||
match bao1x_hal::sigcheck::validate_image(
|
match bao1x_hal::sigcheck::validate_image(BOOT0_SELF_CHECK, None, None) {
|
||||||
bao1x_api::BOOT0_START as *const u32,
|
Ok((k, k2, tag, target)) => crate::println!(
|
||||||
bao1x_api::BOOT0_START as *const u32,
|
"Boot0: key {}/{} ({}) -> {:x}",
|
||||||
bao1x_api::BOOT0_REVOCATION_OFFSET,
|
|
||||||
&[FunctionCode::Boot0 as u32],
|
|
||||||
false,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
) {
|
|
||||||
Ok((k, k2, tag)) => crate::println!(
|
|
||||||
"Boot0: key {}/{} ({})",
|
|
||||||
k,
|
k,
|
||||||
k2,
|
!k2,
|
||||||
core::str::from_utf8(&tag).unwrap_or("invalid tag")
|
core::str::from_utf8(&tag).unwrap_or("invalid tag"),
|
||||||
|
target ^ u32::from_le_bytes(tag)
|
||||||
),
|
),
|
||||||
Err(e) => crate::println!("Boot0 did not validate: {:?}", e),
|
Err(e) => crate::println!("Boot0 did not validate: {:?}", e),
|
||||||
}
|
}
|
||||||
match bao1x_hal::sigcheck::validate_image(
|
match bao1x_hal::sigcheck::validate_image(BOOT0_TO_BOOT1, None, None) {
|
||||||
bao1x_api::BOOT1_START as *const u32,
|
Ok((k, k2, tag, target)) => crate::println!(
|
||||||
bao1x_api::BOOT0_START as *const u32,
|
"Boot1: key {}/{} ({}) -> {:x}",
|
||||||
bao1x_api::BOOT0_REVOCATION_OFFSET,
|
|
||||||
&[
|
|
||||||
FunctionCode::Boot1 as u32,
|
|
||||||
FunctionCode::UpdatedBoot1 as u32,
|
|
||||||
FunctionCode::Developer as u32,
|
|
||||||
],
|
|
||||||
false,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
) {
|
|
||||||
Ok((k, k2, tag)) => crate::println!(
|
|
||||||
"Boot1: key {}/{} ({})",
|
|
||||||
k,
|
k,
|
||||||
k2,
|
!k2,
|
||||||
core::str::from_utf8(&tag).unwrap_or("invalid tag")
|
core::str::from_utf8(&tag).unwrap_or("invalid tag"),
|
||||||
|
target ^ u32::from_le_bytes(tag)
|
||||||
),
|
),
|
||||||
Err(e) => crate::println!("Boot1 did not validate: {:?}", e),
|
Err(e) => crate::println!("Boot1 did not validate: {:?}", e),
|
||||||
}
|
}
|
||||||
match bao1x_hal::sigcheck::validate_image(
|
match bao1x_hal::sigcheck::validate_image(BOOT1_TO_LOADER_OR_BAREMETAL, None, None) {
|
||||||
bao1x_api::LOADER_START as *const u32,
|
Ok((k, k2, tag, target)) => crate::println!(
|
||||||
bao1x_api::BOOT1_START as *const u32,
|
"Next stage: key {}/{} ({}) -> {:x}",
|
||||||
bao1x_api::BOOT1_REVOCATION_OFFSET,
|
|
||||||
&crate::secboot::ALLOWED_FUNCTIONS,
|
|
||||||
false,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
) {
|
|
||||||
Ok((k, k2, tag)) => crate::println!(
|
|
||||||
"Next stage: key {}/{} ({})",
|
|
||||||
k,
|
k,
|
||||||
k2,
|
!k2,
|
||||||
core::str::from_utf8(&tag).unwrap_or("invalid tag")
|
core::str::from_utf8(&tag).unwrap_or("invalid tag"),
|
||||||
|
target ^ u32::from_le_bytes(tag)
|
||||||
),
|
),
|
||||||
Err(e) => crate::println!("Next stage did not validate: {:?}", e),
|
Err(e) => crate::println!("Next stage did not validate: {:?}", e),
|
||||||
}
|
}
|
||||||
|
|
@ -475,38 +450,22 @@ impl Repl {
|
||||||
crate::println!("** System did not meet minimum requirements for security **");
|
crate::println!("** System did not meet minimum requirements for security **");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"lockdown" => {
|
"lockdown" => match bao1x_hal::sigcheck::validate_image(BOOT0_TO_BOOT1, None, None) {
|
||||||
match bao1x_hal::sigcheck::validate_image(
|
Ok((k, _k2, _tag, _target)) => {
|
||||||
bao1x_api::BOOT1_START as *const u32,
|
if k != bao1x_api::pubkeys::DEVELOPER_KEY_SLOT {
|
||||||
bao1x_api::BOOT0_START as *const u32,
|
crate::println!("This will permanently disable developer mode. It cannot be undone!");
|
||||||
bao1x_api::BOOT0_REVOCATION_OFFSET,
|
crate::println!("Proceed? (type 'YES' in all caps to proceed)");
|
||||||
&[
|
self.lockdown_armed = true;
|
||||||
FunctionCode::Boot1 as u32,
|
} else {
|
||||||
FunctionCode::UpdatedBoot1 as u32,
|
crate::println!(
|
||||||
FunctionCode::Developer as u32,
|
"Boot1 is signed with the developer key. Refusing to lockdown, as that would brick the chip."
|
||||||
],
|
)
|
||||||
false,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
) {
|
|
||||||
Ok((k, _k2, _tag)) => {
|
|
||||||
if k != bao1x_api::pubkeys::DEVELOPER_KEY_SLOT {
|
|
||||||
crate::println!(
|
|
||||||
"This will permanently disable developer mode. It cannot be undone!"
|
|
||||||
);
|
|
||||||
crate::println!("Proceed? (type 'YES' in all caps to proceed)");
|
|
||||||
self.lockdown_armed = true;
|
|
||||||
} else {
|
|
||||||
crate::println!(
|
|
||||||
"Boot1 is signed with the developer key. Refusing to lockdown, as that would brick the chip."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(_e) => {
|
|
||||||
crate::println!("Boot1 has no valid signature, lockdown would brick the chip.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Err(_e) => {
|
||||||
|
crate::println!("Boot1 has no valid signature, lockdown would brick the chip.")
|
||||||
|
}
|
||||||
|
},
|
||||||
"baosec-init" => {
|
"baosec-init" => {
|
||||||
// this routine is used to initialize baosec products - sets the board type and
|
// this routine is used to initialize baosec products - sets the board type and
|
||||||
// erases the off-chip FLASH
|
// erases the off-chip FLASH
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue