mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
re-introduce "wait for hardware" hashes for "big hashes"
This commit is contained in:
parent
75506afc25
commit
0c7be94c22
3 changed files with 6 additions and 10 deletions
|
|
@ -18,7 +18,7 @@ use backend::bcrypt::*;
|
||||||
use modals::Modals;
|
use modals::Modals;
|
||||||
use root_keys::api::AesRootkeyType;
|
use root_keys::api::AesRootkeyType;
|
||||||
use root_keys::api::KeywrapError;
|
use root_keys::api::KeywrapError;
|
||||||
use sha2::{Digest, Sha512_256, Sha512_256Sw};
|
use sha2::{Digest, Sha512_256Hw, Sha512_256Sw};
|
||||||
use spinor::SPINOR_BULK_ERASE_SIZE;
|
use spinor::SPINOR_BULK_ERASE_SIZE;
|
||||||
use subtle::ConstantTimeEq;
|
use subtle::ConstantTimeEq;
|
||||||
|
|
||||||
|
|
@ -2956,8 +2956,7 @@ impl PddbOs {
|
||||||
region.len() == root_keys::api::CHECKSUM_BLOCKLEN_PAGE as usize * PAGE_SIZE,
|
region.len() == root_keys::api::CHECKSUM_BLOCKLEN_PAGE as usize * PAGE_SIZE,
|
||||||
"CHECKSUM_BLOCKLEN_PAGE is not an even divisor of the PDDB size"
|
"CHECKSUM_BLOCKLEN_PAGE is not an even divisor of the PDDB size"
|
||||||
);
|
);
|
||||||
// FIXME: should be "wait for hardware" strategy but this does not exist in 0.10 API
|
let mut hasher = Sha512_256Hw::new();
|
||||||
let mut hasher = Sha512_256::new();
|
|
||||||
hasher.update(region); // reserve the first 32 bytes of salt for the HKDF
|
hasher.update(region); // reserve the first 32 bytes of salt for the HKDF
|
||||||
let digest = hasher.finalize();
|
let digest = hasher.finalize();
|
||||||
// copy only the first 128 bits of the hash into the checksum array
|
// copy only the first 128 bits of the hash into the checksum array
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub use oracle::FpgaKeySource;
|
||||||
use rand_core::RngCore;
|
use rand_core::RngCore;
|
||||||
use root_keys::key2bits::*;
|
use root_keys::key2bits::*;
|
||||||
use sha2::Digest;
|
use sha2::Digest;
|
||||||
use sha2::{Sha256, Sha512, Sha512_256Sw};
|
use sha2::{Sha256, Sha512Hw, Sha512_256Sw};
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
use xous::KERNEL_BACKUP_OFFSET;
|
use xous::KERNEL_BACKUP_OFFSET;
|
||||||
use xous_semver::SemVer;
|
use xous_semver::SemVer;
|
||||||
|
|
@ -2681,8 +2681,7 @@ impl<'a> RootKeys {
|
||||||
+ 8; // two u32 words are appended to the end, which repeat the "version" and "length" fields encoded in the signature block
|
+ 8; // two u32 words are appended to the end, which repeat the "version" and "length" fields encoded in the signature block
|
||||||
|
|
||||||
// this is a huge hash, so, get a hardware hasher, even if it means waiting for it
|
// this is a huge hash, so, get a hardware hasher, even if it means waiting for it
|
||||||
// FIXME: should be "wait for hardware" strategy but this does not exist in 0.10 API
|
let mut hasher = Sha512Hw::new();
|
||||||
let mut hasher = Sha512::new();
|
|
||||||
|
|
||||||
// extract the secret key so we can prime the hash
|
// extract the secret key so we can prime the hash
|
||||||
let expanded_key = ExpandedSecretKey::from(&signing_key.secret);
|
let expanded_key = ExpandedSecretKey::from(&signing_key.secret);
|
||||||
|
|
@ -2732,8 +2731,7 @@ impl<'a> RootKeys {
|
||||||
let r = Scalar::from_bytes_mod_order_wide(&output);
|
let r = Scalar::from_bytes_mod_order_wide(&output);
|
||||||
let R = (&r * &constants::ED25519_BASEPOINT_TABLE).compress();
|
let R = (&r * &constants::ED25519_BASEPOINT_TABLE).compress();
|
||||||
|
|
||||||
// FIXME: should be "wait for hardware" strategy but this does not exist in 0.10 API
|
let mut hasher = Sha512Hw::new();
|
||||||
let mut hasher = Sha512::new();
|
|
||||||
hasher.update(R.as_bytes());
|
hasher.update(R.as_bytes());
|
||||||
hasher.update(signing_key.public.as_bytes());
|
hasher.update(signing_key.public.as_bytes());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -650,8 +650,7 @@ fn do_update(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_package(pkg: &[u8], pkg_type: PackageType) -> bool {
|
fn validate_package(pkg: &[u8], pkg_type: PackageType) -> bool {
|
||||||
// FIXME: should be "wait for hardware" strategy but this does not exist in 0.10 API
|
let mut hasher = sha2::Sha512_256Hw::new();
|
||||||
let mut hasher = sha2::Sha512_256::new();
|
|
||||||
let mut temp: [u8; 4] = Default::default();
|
let mut temp: [u8; 4] = Default::default();
|
||||||
temp.copy_from_slice(&pkg[0x20..0x24]);
|
temp.copy_from_slice(&pkg[0x20..0x24]);
|
||||||
if pkg_type == PackageType::Ec {
|
if pkg_type == PackageType::Ec {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue