mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
Merge branch 'main' into bunnie-dev
This commit is contained in:
commit
6bd4eeb9c5
4 changed files with 41 additions and 26 deletions
5
Cargo.lock
generated
5
Cargo.lock
generated
|
|
@ -1527,6 +1527,7 @@ dependencies = [
|
||||||
"root-keys",
|
"root-keys",
|
||||||
"sha2",
|
"sha2",
|
||||||
"spinor",
|
"spinor",
|
||||||
|
"subtle",
|
||||||
"susres",
|
"susres",
|
||||||
"ticktimer-server",
|
"ticktimer-server",
|
||||||
"trng",
|
"trng",
|
||||||
|
|
@ -2278,9 +2279,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "subtle"
|
name = "subtle"
|
||||||
version = "2.4.0"
|
version = "2.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
|
checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "susres"
|
name = "susres"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ cipher = "0.3.0"
|
||||||
bitfield = "0.13.2"
|
bitfield = "0.13.2"
|
||||||
aes-gcm-siv = "0.10.3"
|
aes-gcm-siv = "0.10.3"
|
||||||
llio = {path="../llio"}
|
llio = {path="../llio"}
|
||||||
|
subtle = {version = "2.4.1", default-features = false}
|
||||||
|
|
||||||
# passwords
|
# passwords
|
||||||
sha2 = {path = "../engine-sha512"}
|
sha2 = {path = "../engine-sha512"}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use aes::{Aes256, Block, BLOCK_SIZE};
|
||||||
use aes::cipher::{BlockDecrypt, BlockEncrypt, NewBlockCipher, generic_array::GenericArray};
|
use aes::cipher::{BlockDecrypt, BlockEncrypt, NewBlockCipher, generic_array::GenericArray};
|
||||||
use root_keys::api::AesRootkeyType;
|
use root_keys::api::AesRootkeyType;
|
||||||
use spinor::SPINOR_BULK_ERASE_SIZE;
|
use spinor::SPINOR_BULK_ERASE_SIZE;
|
||||||
|
use subtle::ConstantTimeEq;
|
||||||
use core::ops::{Deref, DerefMut};
|
use core::ops::{Deref, DerefMut};
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
|
||||||
|
|
@ -1171,33 +1172,21 @@ impl PddbOs {
|
||||||
|
|
||||||
let (kenc, kcom) = self.kcom_func(key.try_into().unwrap(), &nonce_comm);
|
let (kenc, kcom) = self.kcom_func(key.try_into().unwrap(), &nonce_comm);
|
||||||
let cipher = Aes256GcmSiv::new(Key::from_slice(&kenc));
|
let cipher = Aes256GcmSiv::new(Key::from_slice(&kenc));
|
||||||
match cipher.decrypt(
|
|
||||||
|
// Attempt decryption. This is None on failure
|
||||||
|
let plaintext = cipher.decrypt(
|
||||||
Nonce::from_slice(nonce),
|
Nonce::from_slice(nonce),
|
||||||
Payload {
|
Payload {
|
||||||
aad,
|
aad,
|
||||||
msg: &ct_plus_mac,
|
msg: &ct_plus_mac,
|
||||||
}
|
}
|
||||||
) {
|
).ok();
|
||||||
Ok(data) => {
|
|
||||||
assert!(data.len() == KCOM_CT_LEN, "authentication successful, but wrong amount of data was recovered");
|
// Only return the plaintext if the stored key commitment agrees with the computed one
|
||||||
if kcom == key_comm_stored {
|
if kcom.ct_eq(&key_comm_stored).into() {
|
||||||
Some(data)
|
plaintext
|
||||||
} else {
|
} else {
|
||||||
log::debug!("Key commitment failed to match on a reputed basis root block");
|
None
|
||||||
None
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
// do the commit check again at the same point, even if there is an error, for some semblance of constant time
|
|
||||||
// (of course the error messages leak information, if they are forced on)
|
|
||||||
if kcom == key_comm_stored {
|
|
||||||
log::trace!("Error decrypting page: {:?}", e); // sometimes this is totally "normal", like when we're testing for valid data.
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
log::trace!("Error decrypting page + commitment error: {:?}", e);
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,11 +166,35 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let kkey = args.nth(4);
|
let kkey = args.nth(4);
|
||||||
match task.as_deref() {
|
match task.as_deref() {
|
||||||
Some("renode-image") => {
|
Some("renode-image") => {
|
||||||
generate_app_menus(&vec!["ball".to_string()]);
|
let mut args = env::args();
|
||||||
|
args.nth(1);
|
||||||
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
|
let mut apps: Vec<String> = args.collect();
|
||||||
|
if apps.len() == 0 { // add the standard demo apps if none are specified
|
||||||
|
println!("No apps specified, adding default apps...");
|
||||||
|
apps.push("ball".to_string());
|
||||||
|
apps.push("repl".to_string());
|
||||||
|
}
|
||||||
|
for app in &apps {
|
||||||
|
pkgs.push(app);
|
||||||
|
}
|
||||||
|
generate_app_menus(&apps);
|
||||||
renode_image(false, &hw_pkgs, &[])?
|
renode_image(false, &hw_pkgs, &[])?
|
||||||
},
|
},
|
||||||
Some("renode-test") => {
|
Some("renode-test") => {
|
||||||
generate_app_menus(&vec!["ball".to_string()]);
|
let mut args = env::args();
|
||||||
|
args.nth(1);
|
||||||
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
|
let mut apps: Vec<String> = args.collect();
|
||||||
|
if apps.len() == 0 { // add the standard demo apps if none are specified
|
||||||
|
println!("No apps specified, adding default apps...");
|
||||||
|
apps.push("ball".to_string());
|
||||||
|
apps.push("repl".to_string());
|
||||||
|
}
|
||||||
|
for app in &apps {
|
||||||
|
pkgs.push(app);
|
||||||
|
}
|
||||||
|
generate_app_menus(&apps);
|
||||||
renode_image(false, &cbtest_pkgs, &[])?
|
renode_image(false, &cbtest_pkgs, &[])?
|
||||||
},
|
},
|
||||||
Some("libstd-test") => {
|
Some("libstd-test") => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue