From 8045e0aac8ffe9ee98600e52babfe3f0074e1d7a Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 13 Jul 2021 00:47:05 +0800 Subject: [PATCH] add the keys command this is the beginning of where key management goes. for now, all you can do is just turn USB debug on and off. --- services/shellchat/src/cmds/keys.rs | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 services/shellchat/src/cmds/keys.rs diff --git a/services/shellchat/src/cmds/keys.rs b/services/shellchat/src/cmds/keys.rs new file mode 100644 index 000000000..15dfd0f1f --- /dev/null +++ b/services/shellchat/src/cmds/keys.rs @@ -0,0 +1,43 @@ +use crate::{ShellCmdApi, CommonEnv}; +use xous_ipc::String; + +#[derive(Debug)] +pub struct Keys { +} +impl Keys { + pub fn new() -> Keys { + Keys {} + } +} + +impl<'a> ShellCmdApi<'a> for Keys { + cmd_api!(keys); // inserts boilerplate for command API + + fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result>, xous::Error> { + use core::fmt::Write; + let mut ret = String::<1024>::new(); + let helpstring = "keys options: usblock usbunlock"; + + let mut tokens = args.as_str().unwrap().split(' '); + + if let Some(sub_cmd) = tokens.next() { + match sub_cmd { + "usblock" => { + env.llio.debug_usb(Some(true)).unwrap(); + write!(ret, "USB debug port locked out; one word at 0x80000000 is disclosable via USB.").unwrap(); + } + "usbunlock" => { + env.llio.debug_usb(Some(false)).unwrap(); + write!(ret, "USB debug port unlocked: all secrets are readable via USB!").unwrap(); + } + _ => { + write!(ret, "{}", helpstring).unwrap(); + } + } + + } else { + write!(ret, "{}", helpstring).unwrap(); + } + Ok(Some(ret)) + } +}