diff --git a/services/pddb/src/api.rs b/services/pddb/src/api.rs index 4df3e2cd1..b5107fe45 100644 --- a/services/pddb/src/api.rs +++ b/services/pddb/src/api.rs @@ -201,6 +201,9 @@ pub(crate) enum Opcode { /// Rekey the PDDB RekeyPddb = 42, + /// Reset "don't ask to init root keys" flag - pass-through to root keys object - for end of OQC test + ResetDontAskInit = 43, + /// This key type could not be decoded InvalidOpcode = u32::MAX as _, } diff --git a/services/pddb/src/backend/hw.rs b/services/pddb/src/backend/hw.rs index b5cde8abc..3fdfcdfe3 100644 --- a/services/pddb/src/backend/hw.rs +++ b/services/pddb/src/backend/hw.rs @@ -2302,6 +2302,9 @@ impl PddbOs { } } + pub(crate) fn reset_dont_ask_init(&self) { + self.rootkeys.do_reset_dont_ask_init(); + } //-------------------------------- TESTING ----------------------------------------- // always gated behind a feature flag. Includes routines that are nonsensicle in normal operation at best, // and very dangerous from a security perspective at worst. diff --git a/services/pddb/src/lib.rs b/services/pddb/src/lib.rs index 9f64b281d..58710270c 100644 --- a/services/pddb/src/lib.rs +++ b/services/pddb/src/lib.rs @@ -628,6 +628,13 @@ impl Pddb { panic!("Internal error: wrong return code for is_efuse_secured()"); } } + /// Reset the "don't ask to init root keys" flag. Used primarily by the OQC test routine to reset this in case + /// a worker accidentally set it during testing. + pub fn reset_dont_ask_init(&self) { + send_message(self.conn, + Message::new_blocking_scalar(Opcode::ResetDontAskInit.to_usize().unwrap(), 0, 0, 0, 0) + ).expect("couldn't send ResetDontAskInit"); + } /// Rekey the PDDB. This can be a very long-running blocking operation that will definitely. /// interrupt normal user flow. pub fn rekey_pddb(&self, op: PddbRekeyOp) -> Result<()> { diff --git a/services/pddb/src/main.rs b/services/pddb/src/main.rs index 5610a42cc..4b8d18439 100644 --- a/services/pddb/src/main.rs +++ b/services/pddb/src/main.rs @@ -1396,6 +1396,10 @@ fn wrapped_main() -> ! { let result = basis_cache.rekey(&mut pddb_os, rekey_op); buffer.replace(result).unwrap(); } + Opcode::ResetDontAskInit => { + pddb_os.reset_dont_ask_init(); + xous::return_scalar(msg.sender, 1).ok(); + } #[cfg(not(any(target_os = "none", target_os = "xous")))] Opcode::DangerousDebug => { let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) }; diff --git a/services/root-keys/locales/i18n.json b/services/root-keys/locales/i18n.json index 41350a033..04ef68352 100644 --- a/services/root-keys/locales/i18n.json +++ b/services/root-keys/locales/i18n.json @@ -126,10 +126,10 @@ "en-tts": "Device keys already initialized." }, "rootkeys.confirm": { - "en": "🔐 Create passwords for Precursor 🔐\n\nYou will be prompted for two passwords:\n\t1. Device unlock PIN code\n\t2. Root passphrase.\n\nAre you ready?", + "en": "🔐 Setup passwords for Precursor 🔐\n\nYou will be prompted for two passwords:\n\t1. Device unlock PIN code\n\t2. Root passphrase.\n\nAre you ready?", "ja": "これにより、Precursorデバイスのルートキーが初期化されます。\n\n2つのパスワードの入力を求められます。\n\t1.デバイスのロック解除PINコード\n\t2.システムアップデートパスフレーズ。\n\n準備はいいですか?", "zh": "仅当您准备好信 任此设备时才 应继续", - "en-tts": "Create passwords for Precursor. You will create two passwords, a PIN code, and a root password." + "en-tts": "Setup passwords for Precursor. You will create two passwords, a PIN code, and a root password." }, "rootkeys.confirm.yes": { "en": "I'm ready!", diff --git a/services/root-keys/src/api.rs b/services/root-keys/src/api.rs index 441edf72b..2b21176b0 100644 --- a/services/root-keys/src/api.rs +++ b/services/root-keys/src/api.rs @@ -99,6 +99,8 @@ pub(crate) enum Opcode { EraseBackupBlock = 45, /// Checks to see if "don't ask me about updates" is set IsDontAskSet = 46, + /// Resets the dont ask bit. Mainly for use by the OQC testing routine + ResetDontAsk = 47, } #[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive, PartialEq, Eq)] diff --git a/services/root-keys/src/implementation.rs b/services/root-keys/src/implementation.rs index 965167ea3..ea94018df 100644 --- a/services/root-keys/src/implementation.rs +++ b/services/root-keys/src/implementation.rs @@ -2552,6 +2552,14 @@ impl<'a> RootKeys { self.gateware().len() as u32 - 4, ).expect("couldn't erase backup region"); } + pub fn reset_dont_ask_init(&mut self) { + self.spinor.patch( + self.gateware(), + self.gateware_base(), + &[0xffu8; 4], + self.gateware().len() as u32 - 4, + ).expect("couldn't erase backup region"); + } pub fn read_backup_header(&mut self) -> Option { let kernel = self.kernel(); let backup = &kernel[KERNEL_BACKUP_OFFSET as usize..KERNEL_BACKUP_OFFSET as usize + size_of::()]; diff --git a/services/root-keys/src/lib.rs b/services/root-keys/src/lib.rs index 10093267d..3e32d1d80 100644 --- a/services/root-keys/src/lib.rs +++ b/services/root-keys/src/lib.rs @@ -153,6 +153,12 @@ impl RootKeys { 0, 0, 0, 0) ).expect("couldn't send message to root keys"); } + pub fn do_reset_dont_ask_init(&self) { + send_message(self.conn, + Message::new_blocking_scalar(Opcode::ResetDontAsk.to_usize().unwrap(), + 0, 0, 0, 0) + ).expect("couldn't send message to root keys"); + } /// Returns the raw, unchecked restore header. Further checking may be done at the restore point, /// but the purpose of this is to just decide if we should even try to initiate a restore. pub fn get_restore_header(&self) -> Result, xous::Error> { diff --git a/services/root-keys/src/main.rs b/services/root-keys/src/main.rs index 10519c7ac..c83a3e288 100644 --- a/services/root-keys/src/main.rs +++ b/services/root-keys/src/main.rs @@ -371,6 +371,7 @@ mod implementation { } pub fn is_dont_ask_init_set(&self) -> bool {false} pub fn set_dont_ask_init(&self) {} + pub fn reset_dont_ask_init(&mut self) {} } } @@ -1664,6 +1665,10 @@ fn main() -> ! { xous::return_scalar(msg.sender, 0).ok(); } }), + Some(Opcode::ResetDontAsk) => msg_blocking_scalar_unpack!(msg, _, _, _, _, { + keys.reset_dont_ask_init(); + xous::return_scalar(msg.sender, 1).ok(); + }), Some(Opcode::TestUx) => msg_blocking_scalar_unpack!(msg, _arg, _, _, _, { // dummy test for now xous::return_scalar(msg.sender, 1234).unwrap(); diff --git a/services/shellchat/src/cmds/test.rs b/services/shellchat/src/cmds/test.rs index f809fa427..ec82a05d2 100644 --- a/services/shellchat/src/cmds/test.rs +++ b/services/shellchat/src/cmds/test.rs @@ -581,6 +581,10 @@ impl<'a> ShellCmdApi<'a> for Test { wifi_tries += 1; } + log::info!("Resetting the don't ask flag for initializing root keys"); + let pddb = pddb::Pddb::new(); + pddb.reset_dont_ask_init(); + AUDIO_OQC.store(true, Ordering::Relaxed); self.freq = 659.25; self.left_play = true;