mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
commit
a8012a6e01
7 changed files with 133 additions and 159 deletions
|
|
@ -1,4 +1,53 @@
|
||||||
{
|
{
|
||||||
|
"vault2.fido.pin_uv_auth": {
|
||||||
|
"en": "PIN creation",
|
||||||
|
"en-tts": "PIN creation",
|
||||||
|
"fr": "Création du PIN",
|
||||||
|
"ja": "PIN作成",
|
||||||
|
"zh": "创建 PIN"
|
||||||
|
},
|
||||||
|
"vault2.fido.make_credentials": {
|
||||||
|
"en": "Make credential",
|
||||||
|
"en-tts": "Make credential",
|
||||||
|
"fr": "Créer un identifiant",
|
||||||
|
"ja": "認証情報を作成",
|
||||||
|
"zh": "创建凭据"
|
||||||
|
},
|
||||||
|
"vault2.fido.exclude_list": {
|
||||||
|
"en": "Exclude credentials",
|
||||||
|
"en-tts": "Exclude credentials",
|
||||||
|
"fr": "Exclure les identifiants",
|
||||||
|
"ja": "認証情報を除外",
|
||||||
|
"zh": "排除凭据"
|
||||||
|
},
|
||||||
|
"vault2.fido.get_assertion": {
|
||||||
|
"en": "Allow?",
|
||||||
|
"en-tts": "Allow?",
|
||||||
|
"fr": "Autoriser ?",
|
||||||
|
"ja": "許可しますか?",
|
||||||
|
"zh": "允许?"
|
||||||
|
},
|
||||||
|
"vault2.u2f.factoryreset": {
|
||||||
|
"en": "Factory reset?",
|
||||||
|
"en-tts": "Factory reset?",
|
||||||
|
"fr": "Réinitialisation d'usine ?",
|
||||||
|
"ja": "工場出荷時設定にリセットしますか?",
|
||||||
|
"zh": "恢复出厂设置?"
|
||||||
|
},
|
||||||
|
"vault2.u2f.authenticator_selection": {
|
||||||
|
"en": "Make primary authenticator?",
|
||||||
|
"en-tts": "Make primary authenticator?",
|
||||||
|
"fr": "Définir comme authentificateur principal ?",
|
||||||
|
"ja": "プライマリ認証器に設定しますか?",
|
||||||
|
"zh": "设为主认证器?"
|
||||||
|
},
|
||||||
|
"vault2.u2f.vendor_configure": {
|
||||||
|
"en": "Allow vendor configuration?",
|
||||||
|
"en-tts": "Allow vendor configuration?",
|
||||||
|
"fr": "Autoriser la configuration du fournisseur ?",
|
||||||
|
"ja": "ベンダー設定を許可しますか?",
|
||||||
|
"zh": "允许供应商配置?"
|
||||||
|
},
|
||||||
"vault.add_new": {
|
"vault.add_new": {
|
||||||
"en": "<Add New...>",
|
"en": "<Add New...>",
|
||||||
"en-tts": "<Add New...>",
|
"en-tts": "<Add New...>",
|
||||||
|
|
|
||||||
|
|
@ -711,10 +711,7 @@ impl CtapState {
|
||||||
// This case was added in FIDO 2.1.
|
// This case was added in FIDO 2.1.
|
||||||
if auth_param.is_empty() {
|
if auth_param.is_empty() {
|
||||||
check_user_presence(env, channel, Some(
|
check_user_presence(env, channel, Some(
|
||||||
format!("{}\n{:x?}",
|
t!("vault2.fido.pin_uv_auth", locales::LANG).to_owned(),
|
||||||
t!("vault.fido.pin_uv_auth", locales::LANG),
|
|
||||||
channel
|
|
||||||
)
|
|
||||||
))?;
|
))?;
|
||||||
if storage::pin_hash(env)?.is_none() {
|
if storage::pin_hash(env)?.is_none() {
|
||||||
return Err(Ctap2StatusCode::CTAP2_ERR_PIN_NOT_SET);
|
return Err(Ctap2StatusCode::CTAP2_ERR_PIN_NOT_SET);
|
||||||
|
|
@ -845,12 +842,11 @@ impl CtapState {
|
||||||
// without user interaction.
|
// without user interaction.
|
||||||
#[cfg(feature="xous")]
|
#[cfg(feature="xous")]
|
||||||
{
|
{
|
||||||
let mut desc = String::from(t!("vault.fido.exclude_list", locales::LANG));
|
let rp = if let Some(name) = rp.rp_name {name.to_string()} else {rp_id.to_string()};
|
||||||
desc.push_str(
|
let desc = format!(
|
||||||
&format!("\n\nRelying Party: {}\nUser name: {}",
|
"{}\n{}",
|
||||||
if let Some(name) = rp.rp_name {name.to_string()} else {rp_id.to_string()},
|
rp,
|
||||||
if let Some(name) = user.user_display_name {name} else {user.user_name.unwrap_or("*Unspecified*".to_string())},
|
t!("vault2.fido.exclude_list", locales::LANG)
|
||||||
)
|
|
||||||
);
|
);
|
||||||
let _ = check_user_presence(env, channel, Some(desc));
|
let _ = check_user_presence(env, channel, Some(desc));
|
||||||
}
|
}
|
||||||
|
|
@ -863,15 +859,8 @@ impl CtapState {
|
||||||
|
|
||||||
#[cfg(feature="xous")]
|
#[cfg(feature="xous")]
|
||||||
{
|
{
|
||||||
let mut make_cred_desc = String::from(t!("vault.fido.make_credential", locales::LANG));
|
let rp = if let Some(name) = rp.rp_name {name.to_string()} else {rp_id.to_string()};
|
||||||
let alt_name = user.user_name.as_deref().unwrap_or("*Unspecified*");
|
let make_cred_desc = format!("{}\n{}", rp, t!("vault2.fido.make_credentials", locales::LANG));
|
||||||
make_cred_desc.push_str(
|
|
||||||
&format!("\n\nRelying Party: {}\nUser name: {}",
|
|
||||||
// prefer the "friendly name" over the technical name
|
|
||||||
if let Some(name) = &rp.rp_name {name.to_string()} else {rp_id.to_string()},
|
|
||||||
if let Some(name) = &user.user_display_name {name} else {alt_name}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
check_user_presence(env, channel, Some(make_cred_desc))?;
|
check_user_presence(env, channel, Some(make_cred_desc))?;
|
||||||
}
|
}
|
||||||
#[cfg(not(feature="xous"))]
|
#[cfg(not(feature="xous"))]
|
||||||
|
|
@ -1258,13 +1247,7 @@ impl CtapState {
|
||||||
if options.up {
|
if options.up {
|
||||||
#[cfg(feature="xous")]
|
#[cfg(feature="xous")]
|
||||||
{
|
{
|
||||||
let mut desc = String::from(t!("vault.fido.get_assertion", locales::LANG));
|
let desc: String = format!("{}\n{}", rp_id, t!("vault2.fido.get_assertion", locales::LANG));
|
||||||
desc.push_str(
|
|
||||||
&format!("\n\nRelying Party: {}\nClient data hash: {}",
|
|
||||||
rp_id,
|
|
||||||
hex::encode(&client_data_hash),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
check_user_presence(env, channel, Some(desc))?;
|
check_user_presence(env, channel, Some(desc))?;
|
||||||
}
|
}
|
||||||
#[cfg(not(feature="xous"))]
|
#[cfg(not(feature="xous"))]
|
||||||
|
|
@ -1397,9 +1380,8 @@ impl CtapState {
|
||||||
#[cfg(feature="xous")]
|
#[cfg(feature="xous")]
|
||||||
{
|
{
|
||||||
check_user_presence(env, channel, Some(
|
check_user_presence(env, channel, Some(
|
||||||
format!("{}\n{:x?}",
|
format!("{}",
|
||||||
t!("vault.u2f.factoryreset", locales::LANG),
|
t!("vault2.u2f.factoryreset", locales::LANG),
|
||||||
channel
|
|
||||||
)
|
)
|
||||||
))?;
|
))?;
|
||||||
}
|
}
|
||||||
|
|
@ -1425,9 +1407,8 @@ impl CtapState {
|
||||||
#[cfg(feature="xous")]
|
#[cfg(feature="xous")]
|
||||||
{
|
{
|
||||||
check_user_presence(env, channel, Some(
|
check_user_presence(env, channel, Some(
|
||||||
format!("{}\n{:x?}",
|
format!("{}",
|
||||||
t!("vault.u2f.authenticator_selection", locales::LANG),
|
t!("vault2.u2f.authenticator_selection", locales::LANG),
|
||||||
channel
|
|
||||||
)
|
)
|
||||||
))?;
|
))?;
|
||||||
}
|
}
|
||||||
|
|
@ -1446,9 +1427,8 @@ impl CtapState {
|
||||||
#[cfg(feature="xous")]
|
#[cfg(feature="xous")]
|
||||||
{
|
{
|
||||||
check_user_presence(env, channel, Some(
|
check_user_presence(env, channel, Some(
|
||||||
format!("{}\n{:x?}",
|
format!("{}",
|
||||||
t!("vault.u2f.vendor_configure", locales::LANG),
|
t!("vault2.u2f.vendor_configure", locales::LANG),
|
||||||
channel
|
|
||||||
)
|
)
|
||||||
))?;
|
))?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
76
apps-baosec/vault2/src/env/xous/mod.rs
vendored
76
apps-baosec/vault2/src/env/xous/mod.rs
vendored
|
|
@ -1,7 +1,6 @@
|
||||||
use core::sync::atomic::{AtomicU32, Ordering};
|
use core::sync::atomic::{AtomicU32, Ordering};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::AtomicBool;
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||||
|
|
@ -95,13 +94,12 @@ pub struct XousEnv {
|
||||||
modals: Modals,
|
modals: Modals,
|
||||||
last_user_presence_request: Option<Instant>,
|
last_user_presence_request: Option<Instant>,
|
||||||
ctap1_cid: xous::CID,
|
ctap1_cid: xous::CID,
|
||||||
lefty_mode: Arc<AtomicBool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XousEnv {
|
impl XousEnv {
|
||||||
/// Returns the unique instance of the Xous environment.
|
/// Returns the unique instance of the Xous environment.
|
||||||
/// Blocks until the PDDB is mounted
|
/// Blocks until the PDDB is mounted
|
||||||
pub fn new(conn: xous::CID, lefty_mode: Arc<AtomicBool>) -> Self {
|
pub fn new(conn: xous::CID) -> Self {
|
||||||
// We rely on `take_storage` to ensure that this function is called only once.
|
// We rely on `take_storage` to ensure that this function is called only once.
|
||||||
let storage = XousStorage {};
|
let storage = XousStorage {};
|
||||||
let store = Store::new(storage).ok().unwrap();
|
let store = Store::new(storage).ok().unwrap();
|
||||||
|
|
@ -201,7 +199,6 @@ impl XousEnv {
|
||||||
|
|
||||||
std::thread::spawn({
|
std::thread::spawn({
|
||||||
let main_cid = conn.clone();
|
let main_cid = conn.clone();
|
||||||
let lefty_mode = lefty_mode.clone();
|
|
||||||
move || {
|
move || {
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
let pddb = pddb::Pddb::new();
|
let pddb = pddb::Pddb::new();
|
||||||
|
|
@ -252,10 +249,7 @@ impl XousEnv {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
let key = kbhit.load(Ordering::SeqCst);
|
let key = kbhit.load(Ordering::SeqCst);
|
||||||
if key != 0
|
if key != 0 && key != '↓' as u32 {
|
||||||
&& ((!lefty_mode.load(Ordering::SeqCst) && (key != 0x11))
|
|
||||||
|| (lefty_mode.load(Ordering::SeqCst) && (key != 0x14)))
|
|
||||||
{
|
|
||||||
// approved
|
// approved
|
||||||
log::trace!("approved");
|
log::trace!("approved");
|
||||||
request.approved = true;
|
request.approved = true;
|
||||||
|
|
@ -272,9 +266,7 @@ impl XousEnv {
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
modals.dynamic_notification_close().ok();
|
modals.dynamic_notification_close().ok();
|
||||||
} else if (!lefty_mode.load(Ordering::SeqCst) && (key == 0x11))
|
} else if key == '↓' as u32 {
|
||||||
|| (lefty_mode.load(Ordering::SeqCst) && (key == 0x14))
|
|
||||||
{
|
|
||||||
// denied
|
// denied
|
||||||
log::trace!("denied");
|
log::trace!("denied");
|
||||||
request.approved = false;
|
request.approved = false;
|
||||||
|
|
@ -306,18 +298,10 @@ impl XousEnv {
|
||||||
log::info!("countdown: {}", new_remaining);
|
log::info!("countdown: {}", new_remaining);
|
||||||
last_remaining = new_remaining;
|
last_remaining = new_remaining;
|
||||||
let mut to_request_str = request_str.to_string();
|
let mut to_request_str = request_str.to_string();
|
||||||
to_request_str.push_str(&format!(
|
to_request_str.push_str(&format!("{}s", last_remaining,));
|
||||||
"\n\n⚠ {}{} ⚠\n",
|
|
||||||
last_remaining,
|
|
||||||
t!("vault.fido.countdown", locales::LANG)
|
|
||||||
));
|
|
||||||
modals
|
modals
|
||||||
.dynamic_notification_update(
|
.dynamic_notification_update(
|
||||||
Some(if lefty_mode.load(Ordering::SeqCst) {
|
Some(t!("vault2.fido.get_assertion", locales::LANG)),
|
||||||
t!("vault.u2freq_lefty", locales::LANG)
|
|
||||||
} else {
|
|
||||||
t!("vault.u2freq", locales::LANG)
|
|
||||||
}),
|
|
||||||
Some(&to_request_str),
|
Some(&to_request_str),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -437,11 +421,7 @@ impl XousEnv {
|
||||||
|
|
||||||
modals
|
modals
|
||||||
.dynamic_notification(
|
.dynamic_notification(
|
||||||
Some(if lefty_mode.load(Ordering::SeqCst) {
|
Some(t!("vault2.fido.get_assertion", locales::LANG)),
|
||||||
t!("vault.u2freq_lefty", locales::LANG)
|
|
||||||
} else {
|
|
||||||
t!("vault.u2freq", locales::LANG)
|
|
||||||
}),
|
|
||||||
Some(&to_request_str),
|
Some(&to_request_str),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -619,7 +599,6 @@ impl XousEnv {
|
||||||
modals: modals::Modals::new(&xns).unwrap(),
|
modals: modals::Modals::new(&xns).unwrap(),
|
||||||
last_user_presence_request: None,
|
last_user_presence_request: None,
|
||||||
ctap1_cid,
|
ctap1_cid,
|
||||||
lefty_mode,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -689,16 +668,7 @@ impl UserPresence for XousEnv {
|
||||||
let reason = reason.unwrap_or(String::new());
|
let reason = reason.unwrap_or(String::new());
|
||||||
let kbhit = Arc::new(AtomicU32::new(0));
|
let kbhit = Arc::new(AtomicU32::new(0));
|
||||||
let expiration = Instant::now().checked_add(timeout).expect("duration bug");
|
let expiration = Instant::now().checked_add(timeout).expect("duration bug");
|
||||||
self.modals
|
self.modals.dynamic_notification(None, Some(&reason)).unwrap();
|
||||||
.dynamic_notification(
|
|
||||||
Some(if self.lefty_mode.load(Ordering::SeqCst) {
|
|
||||||
t!("vault.u2freq_lefty", locales::LANG)
|
|
||||||
} else {
|
|
||||||
t!("vault.u2freq", locales::LANG)
|
|
||||||
}),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
// start the keyboard hit listener thread
|
// start the keyboard hit listener thread
|
||||||
let _ = std::thread::spawn({
|
let _ = std::thread::spawn({
|
||||||
let token = self.modals.token().clone();
|
let token = self.modals.token().clone();
|
||||||
|
|
@ -722,25 +692,12 @@ impl UserPresence for XousEnv {
|
||||||
|
|
||||||
let mut last_remaining = u64::MAX;
|
let mut last_remaining = u64::MAX;
|
||||||
loop {
|
loop {
|
||||||
let mut request_str = String::from(&reason);
|
|
||||||
let remaining = expiration.duration_since(Instant::now()).as_secs();
|
let remaining = expiration.duration_since(Instant::now()).as_secs();
|
||||||
if last_remaining != remaining {
|
if last_remaining != remaining {
|
||||||
log::info!("countdown: {}", remaining);
|
log::info!("countdown: {}", remaining);
|
||||||
// only update the UX once per second
|
// only update the UX once per second
|
||||||
request_str.push_str(&format!(
|
|
||||||
"\n\n⚠ {}{} ⚠\n",
|
|
||||||
remaining,
|
|
||||||
t!("vault.fido.countdown", locales::LANG)
|
|
||||||
));
|
|
||||||
self.modals
|
self.modals
|
||||||
.dynamic_notification_update(
|
.dynamic_notification_update(None, Some(&format!("{}\n{}s", reason, remaining)))
|
||||||
Some(if self.lefty_mode.load(Ordering::SeqCst) {
|
|
||||||
t!("vault.u2freq_lefty", locales::LANG)
|
|
||||||
} else {
|
|
||||||
t!("vault.u2freq", locales::LANG)
|
|
||||||
}),
|
|
||||||
Some(&request_str),
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
last_remaining = remaining;
|
last_remaining = remaining;
|
||||||
}
|
}
|
||||||
|
|
@ -751,21 +708,12 @@ impl UserPresence for XousEnv {
|
||||||
return Err(UserPresenceError::Timeout);
|
return Err(UserPresenceError::Timeout);
|
||||||
}
|
}
|
||||||
let key_hit = kbhit.load(Ordering::SeqCst);
|
let key_hit = kbhit.load(Ordering::SeqCst);
|
||||||
if key_hit != 0
|
if key_hit != 0 && key_hit != '↓' as u32 {
|
||||||
&& (
|
// approve
|
||||||
// approve
|
|
||||||
(!self.lefty_mode.load(Ordering::SeqCst) && (key_hit != 0x11)) // 0x11 is the F1 key
|
|
||||||
|| (self.lefty_mode.load(Ordering::SeqCst) && (key_hit != 0x14))
|
|
||||||
// 0x14 is the F4 key
|
|
||||||
)
|
|
||||||
{
|
|
||||||
self.modals.dynamic_notification_close().ok();
|
self.modals.dynamic_notification_close().ok();
|
||||||
return Ok(());
|
return Ok(());
|
||||||
} else if
|
} else if key_hit == '↓' as u32 {
|
||||||
// deny
|
// deny
|
||||||
(!self.lefty_mode.load(Ordering::SeqCst) && (key_hit == 0x11))
|
|
||||||
|| (self.lefty_mode.load(Ordering::SeqCst) && (key_hit == 0x14))
|
|
||||||
{
|
|
||||||
self.modals.dynamic_notification_close().ok();
|
self.modals.dynamic_notification_close().ok();
|
||||||
return Err(UserPresenceError::Declined);
|
return Err(UserPresenceError::Declined);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,6 @@ fn main() -> ! {
|
||||||
// Protects access to the openSK PDDB entries from simultaneous readout on the UX while OpenSK is updating
|
// Protects access to the openSK PDDB entries from simultaneous readout on the UX while OpenSK is updating
|
||||||
let opensk_mutex = Arc::new(Mutex::new(0));
|
let opensk_mutex = Arc::new(Mutex::new(0));
|
||||||
let allow_host = Arc::new(AtomicBool::new(false));
|
let allow_host = Arc::new(AtomicBool::new(false));
|
||||||
// storage for lefty mode
|
|
||||||
let lefty_mode = Arc::new(AtomicBool::new(false));
|
|
||||||
|
|
||||||
let mut vault_ui = VaultUi::new(&xns, conn, item_lists.clone(), mode.clone());
|
let mut vault_ui = VaultUi::new(&xns, conn, item_lists.clone(), mode.clone());
|
||||||
|
|
||||||
|
|
@ -229,14 +227,13 @@ fn main() -> ! {
|
||||||
let allow_host = allow_host.clone();
|
let allow_host = allow_host.clone();
|
||||||
let opensk_mutex = opensk_mutex.clone();
|
let opensk_mutex = opensk_mutex.clone();
|
||||||
let conn = conn.clone();
|
let conn = conn.clone();
|
||||||
let lefty_mode = lefty_mode.clone();
|
|
||||||
move || {
|
move || {
|
||||||
let mut vendor_session = VendorSession::default();
|
let mut vendor_session = VendorSession::default();
|
||||||
// block until the PDDB is mounted
|
// block until the PDDB is mounted
|
||||||
let pddb = pddb::Pddb::new();
|
let pddb = pddb::Pddb::new();
|
||||||
pddb.is_mounted_blocking();
|
pddb.is_mounted_blocking();
|
||||||
|
|
||||||
let env = XousEnv::new(conn, lefty_mode); // lefty_mode is now owned by env
|
let env = XousEnv::new(conn);
|
||||||
let mut ctap = vault2::Ctap::new(env, Instant::now());
|
let mut ctap = vault2::Ctap::new(env, Instant::now());
|
||||||
loop {
|
loop {
|
||||||
match ctap.env().main_hid_connection().u2f_wait_incoming() {
|
match ctap.env().main_hid_connection().u2f_wait_incoming() {
|
||||||
|
|
@ -379,40 +376,9 @@ fn main() -> ! {
|
||||||
allow_totp_rendering.store(true, Ordering::SeqCst);
|
allow_totp_rendering.store(true, Ordering::SeqCst);
|
||||||
vault_ui.redraw();
|
vault_ui.redraw();
|
||||||
}
|
}
|
||||||
Some(VaultOp::MenuTotpMode) => {
|
|
||||||
*mode.lock().unwrap() = VaultMode::Totp;
|
|
||||||
// reload DB on mode switch
|
|
||||||
xous::send_message(
|
|
||||||
actions_conn,
|
|
||||||
xous::Message::new_blocking_scalar(ActionOp::ReloadDb.to_usize().unwrap(), 0, 0, 0, 0),
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
vault_ui.refresh_draw_list();
|
|
||||||
allow_totp_rendering.store(true, Ordering::SeqCst);
|
|
||||||
xous::send_message(
|
|
||||||
pump_conn,
|
|
||||||
xous::Message::new_scalar(PumpOp::Pump.to_usize().unwrap(), 0, 0, 0, 0),
|
|
||||||
)
|
|
||||||
.expect("couldn't start the pumper");
|
|
||||||
vault_ui.redraw();
|
|
||||||
}
|
|
||||||
Some(VaultOp::MenuPwMode) => {
|
|
||||||
{
|
|
||||||
// lock needs to go out of scope so we don't hang the later ops
|
|
||||||
*mode.lock().unwrap() = VaultMode::Password;
|
|
||||||
}
|
|
||||||
allow_totp_rendering.store(false, Ordering::SeqCst);
|
|
||||||
// reload DB on mode switch
|
|
||||||
xous::send_message(
|
|
||||||
actions_conn,
|
|
||||||
xous::Message::new_blocking_scalar(ActionOp::ReloadDb.to_usize().unwrap(), 0, 0, 0, 0),
|
|
||||||
)
|
|
||||||
.ok();
|
|
||||||
vault_ui.redraw();
|
|
||||||
}
|
|
||||||
Some(VaultOp::KeyPress) => xous::msg_scalar_unpack!(msg, k1, _k2, _k3, _k4, {
|
Some(VaultOp::KeyPress) => xous::msg_scalar_unpack!(msg, k1, _k2, _k3, _k4, {
|
||||||
let k = char::from_u32(k1 as u32).unwrap_or('\u{0000}');
|
let k = char::from_u32(k1 as u32).unwrap_or('\u{0000}');
|
||||||
log::debug!("key {}", k);
|
log::info!("key {}", k);
|
||||||
if menu_active {
|
if menu_active {
|
||||||
menu_mgr.key_press(k);
|
menu_mgr.key_press(k);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -435,7 +401,61 @@ fn main() -> ! {
|
||||||
vault_ui.redraw();
|
vault_ui.redraw();
|
||||||
}
|
}
|
||||||
'→' => {
|
'→' => {
|
||||||
vault_ui.nav(NavDir::Reserved);
|
let current_mode = *mode.lock().unwrap();
|
||||||
|
match current_mode {
|
||||||
|
VaultMode::Password => {
|
||||||
|
{
|
||||||
|
*mode.lock().unwrap() = VaultMode::Totp;
|
||||||
|
}
|
||||||
|
// reload DB on mode switch
|
||||||
|
xous::send_message(
|
||||||
|
actions_conn,
|
||||||
|
xous::Message::new_blocking_scalar(
|
||||||
|
ActionOp::ReloadDb.to_usize().unwrap(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
vault_ui.refresh_draw_list();
|
||||||
|
allow_totp_rendering.store(true, Ordering::SeqCst);
|
||||||
|
xous::send_message(
|
||||||
|
pump_conn,
|
||||||
|
xous::Message::new_scalar(
|
||||||
|
PumpOp::Pump.to_usize().unwrap(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.expect("couldn't start the pumper");
|
||||||
|
vault_ui.redraw();
|
||||||
|
}
|
||||||
|
VaultMode::Totp => {
|
||||||
|
{
|
||||||
|
// lock needs to go out of scope so we don't hang the later ops
|
||||||
|
*mode.lock().unwrap() = VaultMode::Password;
|
||||||
|
}
|
||||||
|
allow_totp_rendering.store(false, Ordering::SeqCst);
|
||||||
|
// reload DB on mode switch
|
||||||
|
xous::send_message(
|
||||||
|
actions_conn,
|
||||||
|
xous::Message::new_blocking_scalar(
|
||||||
|
ActionOp::ReloadDb.to_usize().unwrap(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
|
vault_ui.redraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vault_ui.redraw();
|
vault_ui.redraw();
|
||||||
}
|
}
|
||||||
'🔥' => {
|
'🔥' => {
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,6 @@ use crate::VaultOp;
|
||||||
pub fn create_submenu(vault_conn: xous::CID, actions_conn: xous::CID, menu_mgr: xous::SID) -> MenuMatic {
|
pub fn create_submenu(vault_conn: xous::CID, actions_conn: xous::CID, menu_mgr: xous::SID) -> MenuMatic {
|
||||||
let mut menu_items = Vec::<MenuItem>::new();
|
let mut menu_items = Vec::<MenuItem>::new();
|
||||||
|
|
||||||
menu_items.push(MenuItem {
|
|
||||||
name: String::from(t!("vault.menu_totp_mode", locales::LANG)),
|
|
||||||
action_conn: Some(vault_conn),
|
|
||||||
action_opcode: VaultOp::MenuTotpMode.to_u32().unwrap(),
|
|
||||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
|
||||||
close_on_select: true,
|
|
||||||
});
|
|
||||||
menu_items.push(MenuItem {
|
|
||||||
name: String::from(t!("vault.menu_pw_mode", locales::LANG)),
|
|
||||||
action_conn: Some(vault_conn),
|
|
||||||
action_opcode: VaultOp::MenuPwMode.to_u32().unwrap(),
|
|
||||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
|
||||||
close_on_select: true,
|
|
||||||
});
|
|
||||||
menu_items.push(MenuItem {
|
menu_items.push(MenuItem {
|
||||||
name: String::from(t!("vault.menu_edit", locales::LANG)),
|
name: String::from(t!("vault.menu_edit", locales::LANG)),
|
||||||
action_conn: Some(vault_conn),
|
action_conn: Some(vault_conn),
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ pub enum NavDir {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
Autotype,
|
Autotype,
|
||||||
Reserved,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Centralizes tunable UI parameters for TOTP
|
/// Centralizes tunable UI parameters for TOTP
|
||||||
|
|
@ -443,9 +442,6 @@ impl VaultUi {
|
||||||
self.handle_autotype(item.guid, false).unwrap();
|
self.handle_autotype(item.guid, false).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NavDir::Reserved => {
|
|
||||||
// tbd
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VaultMode::Totp => {
|
VaultMode::Totp => {
|
||||||
|
|
@ -462,9 +458,6 @@ impl VaultUi {
|
||||||
self.usb_dev.send_str(&code).ok();
|
self.usb_dev.send_str(&code).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NavDir::Reserved => {
|
|
||||||
// tbd
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.totp_code = None;
|
self.totp_code = None;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@ pub(crate) enum VaultOp {
|
||||||
MenuAutotypeRate,
|
MenuAutotypeRate,
|
||||||
MenuLeftyMode,
|
MenuLeftyMode,
|
||||||
MenuDone,
|
MenuDone,
|
||||||
MenuTotpMode,
|
|
||||||
MenuPwMode,
|
|
||||||
|
|
||||||
BasisChange,
|
BasisChange,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue