deny boot to any developer-key signed kernel/detached-app/swap images

Secret keys can't be erased after boot1 exits because the protection
bits are hardened from modification after that point.

thus it is not possible for the loader to switch the device
into developer mode.

Thus the only way to enter developer mode is through a dev-mode
signed loader. A system that has never been put into developer
mode will refuse to run any developer-mode xous kernel, app, swap
images.

Once a system has been exposed to a dev-mode signed loader,
the boot1 will flip the developer mode bit and erase the secret
keys.

Later on, if a production loader is replaced, it doesn't matter
that a production loader is loading dev-mode signed successors
because the secret keys are already erased.

Note that in all cases, the key revocations take precedence
so if the developer key is revoked, these cases should never
even be encountered.
This commit is contained in:
bunnie 2025-11-18 23:33:33 +08:00
parent 22f44f82b9
commit a208d59690
No known key found for this signature in database
2 changed files with 38 additions and 6 deletions

View file

@ -281,8 +281,17 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32)
if tag == *bao1x_api::pubkeys::KEYSLOT_INITIAL_TAGS[bao1x_api::pubkeys::DEVELOPER_KEY_SLOT]
|| k == bao1x_api::pubkeys::DEVELOPER_KEY_SLOT
{
crate::println!("Developer key detected, ensuring secrets are erased");
bao1x_hal::sigcheck::erase_secrets();
// we can't erase keys in the loader, because the keys have already been locked
// out at this point. Thus, ensure that the system is already in developer mode.
let owc = bao1x_hal::acram::OneWayCounter::new();
if owc.get(bao1x_api::DEVELOPER_MODE).unwrap() == 0 {
crate::println!(
"Kernel is devkey signed, but system is not in developer mode. Dying!"
);
bao1x_hal::sigcheck::die_no_std();
} else {
crate::println!("Developer key detected on kernel. Proceeding in developer mode!");
}
}
}
Err(e) => {
@ -315,8 +324,19 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32)
== *bao1x_api::pubkeys::KEYSLOT_INITIAL_TAGS[bao1x_api::pubkeys::DEVELOPER_KEY_SLOT]
|| k == bao1x_api::pubkeys::DEVELOPER_KEY_SLOT
{
crate::println!("Developer key detected, ensuring secrets are erased");
bao1x_hal::sigcheck::erase_secrets();
// we can't erase keys in the loader, because the keys have already been locked
// out at this point. Thus, ensure that the system is already in developer mode.
let owc = bao1x_hal::acram::OneWayCounter::new();
if owc.get(bao1x_api::DEVELOPER_MODE).unwrap() == 0 {
crate::println!(
"Detached app is devkey signed, but system is not in developer mode. Dying!"
);
bao1x_hal::sigcheck::die_no_std();
} else {
crate::println!(
"Developer key detected on detached app. Proceeding in developer mode!"
);
}
}
true
}

View file

@ -256,8 +256,20 @@ impl SwapHal {
[bao1x_api::pubkeys::DEVELOPER_KEY_SLOT]
|| k == bao1x_api::pubkeys::DEVELOPER_KEY_SLOT
{
crate::println!("Developer key detected, ensuring secrets are erased");
bao1x_hal::sigcheck::erase_secrets();
// we can't erase keys in the loader, because the keys have already been
// locked out at this point. Thus,
// ensure that the system is already in developer mode.
let owc = bao1x_hal::acram::OneWayCounter::new();
if owc.get(bao1x_api::DEVELOPER_MODE).unwrap() == 0 {
crate::println!(
"Swap is devkey signed, but system is not in developer mode. Dying!"
);
bao1x_hal::sigcheck::die_no_std();
} else {
crate::println!(
"Developer key detected on swap. Proceeding in developer mode!"
);
}
}
}
Err(e) => {