diff --git a/loader/src/main.rs b/loader/src/main.rs index 8931ee4af..b0f2d33aa 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -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 } diff --git a/loader/src/platform/bao1x/swap.rs b/loader/src/platform/bao1x/swap.rs index 6c5d261c3..4b0785b00 100644 --- a/loader/src/platform/bao1x/swap.rs +++ b/loader/src/platform/bao1x/swap.rs @@ -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) => {