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.
This commit is contained in:
bunnie 2021-07-13 00:47:05 +08:00
parent a4f8346c34
commit 8045e0aac8

View file

@ -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<Option<String::<1024>>, 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))
}
}