convert secboot to have an argument for returning the hash

also compute the hash and return the value as part of this patch
This commit is contained in:
bunnie 2024-01-08 00:16:20 +08:00
parent 2f47a9d4f2
commit 8f3229c9ea

View file

@ -271,7 +271,7 @@ impl Keyrom {
// returns true if the kernel is valid
// side-effects the "devboot" register in the gfx engine if devkeys were detected
pub fn validate_xous_img(xous_img_offset: *const u32) -> bool {
pub fn validate_xous_img(xous_img_offset: *const u32, fs_prehash: &mut [u8; 64]) -> bool {
// reset the SHA block, in case we're coming out of a warm reset
let mut sha = CSR::new(utra::sha512::HW_SHA512_BASE as *mut u32);
sha.wfo(utra::sha512::POWER_ON, 1);
@ -448,7 +448,11 @@ pub fn validate_xous_img(xous_img_offset: *const u32) -> bool {
gfx.msg("Checking signature...\n\r", &mut cursor);
let mut h: Sha512 = Sha512::new();
h.update(&image);
if pubkey.verify_prehashed(h, None, &ed25519_signature).is_ok() {
// The prehash needs to be finalized before we create a new hasher instance. We
// only have one hardware hasher available.
let prehash = h.finalize();
if pubkey.verify_prehashed(prehash.as_slice(), None, &ed25519_signature).is_ok() {
fs_prehash.copy_from_slice(prehash.as_slice());
gfx.msg("Signature check passed\n\r", &mut cursor);
println!("Signature check passed");
break;