mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +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": {
|
||||
"en": "<Add New...>",
|
||||
"en-tts": "<Add New...>",
|
||||
|
|
|
|||
|
|
@ -711,10 +711,7 @@ impl CtapState {
|
|||
// This case was added in FIDO 2.1.
|
||||
if auth_param.is_empty() {
|
||||
check_user_presence(env, channel, Some(
|
||||
format!("{}\n{:x?}",
|
||||
t!("vault.fido.pin_uv_auth", locales::LANG),
|
||||
channel
|
||||
)
|
||||
t!("vault2.fido.pin_uv_auth", locales::LANG).to_owned(),
|
||||
))?;
|
||||
if storage::pin_hash(env)?.is_none() {
|
||||
return Err(Ctap2StatusCode::CTAP2_ERR_PIN_NOT_SET);
|
||||
|
|
@ -845,12 +842,11 @@ impl CtapState {
|
|||
// without user interaction.
|
||||
#[cfg(feature="xous")]
|
||||
{
|
||||
let mut desc = String::from(t!("vault.fido.exclude_list", locales::LANG));
|
||||
desc.push_str(
|
||||
&format!("\n\nRelying Party: {}\nUser 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 {user.user_name.unwrap_or("*Unspecified*".to_string())},
|
||||
)
|
||||
let rp = if let Some(name) = rp.rp_name {name.to_string()} else {rp_id.to_string()};
|
||||
let desc = format!(
|
||||
"{}\n{}",
|
||||
rp,
|
||||
t!("vault2.fido.exclude_list", locales::LANG)
|
||||
);
|
||||
let _ = check_user_presence(env, channel, Some(desc));
|
||||
}
|
||||
|
|
@ -863,15 +859,8 @@ impl CtapState {
|
|||
|
||||
#[cfg(feature="xous")]
|
||||
{
|
||||
let mut make_cred_desc = String::from(t!("vault.fido.make_credential", locales::LANG));
|
||||
let alt_name = user.user_name.as_deref().unwrap_or("*Unspecified*");
|
||||
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}
|
||||
)
|
||||
);
|
||||
let rp = if let Some(name) = rp.rp_name {name.to_string()} else {rp_id.to_string()};
|
||||
let make_cred_desc = format!("{}\n{}", rp, t!("vault2.fido.make_credentials", locales::LANG));
|
||||
check_user_presence(env, channel, Some(make_cred_desc))?;
|
||||
}
|
||||
#[cfg(not(feature="xous"))]
|
||||
|
|
@ -1258,13 +1247,7 @@ impl CtapState {
|
|||
if options.up {
|
||||
#[cfg(feature="xous")]
|
||||
{
|
||||
let mut desc = String::from(t!("vault.fido.get_assertion", locales::LANG));
|
||||
desc.push_str(
|
||||
&format!("\n\nRelying Party: {}\nClient data hash: {}",
|
||||
rp_id,
|
||||
hex::encode(&client_data_hash),
|
||||
)
|
||||
);
|
||||
let desc: String = format!("{}\n{}", rp_id, t!("vault2.fido.get_assertion", locales::LANG));
|
||||
check_user_presence(env, channel, Some(desc))?;
|
||||
}
|
||||
#[cfg(not(feature="xous"))]
|
||||
|
|
@ -1397,9 +1380,8 @@ impl CtapState {
|
|||
#[cfg(feature="xous")]
|
||||
{
|
||||
check_user_presence(env, channel, Some(
|
||||
format!("{}\n{:x?}",
|
||||
t!("vault.u2f.factoryreset", locales::LANG),
|
||||
channel
|
||||
format!("{}",
|
||||
t!("vault2.u2f.factoryreset", locales::LANG),
|
||||
)
|
||||
))?;
|
||||
}
|
||||
|
|
@ -1425,9 +1407,8 @@ impl CtapState {
|
|||
#[cfg(feature="xous")]
|
||||
{
|
||||
check_user_presence(env, channel, Some(
|
||||
format!("{}\n{:x?}",
|
||||
t!("vault.u2f.authenticator_selection", locales::LANG),
|
||||
channel
|
||||
format!("{}",
|
||||
t!("vault2.u2f.authenticator_selection", locales::LANG),
|
||||
)
|
||||
))?;
|
||||
}
|
||||
|
|
@ -1446,9 +1427,8 @@ impl CtapState {
|
|||
#[cfg(feature="xous")]
|
||||
{
|
||||
check_user_presence(env, channel, Some(
|
||||
format!("{}\n{:x?}",
|
||||
t!("vault.u2f.vendor_configure", locales::LANG),
|
||||
channel
|
||||
format!("{}",
|
||||
t!("vault2.u2f.vendor_configure", locales::LANG),
|
||||
)
|
||||
))?;
|
||||
}
|
||||
|
|
|
|||
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 std::io::{Read, Write};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||
|
|
@ -95,13 +94,12 @@ pub struct XousEnv {
|
|||
modals: Modals,
|
||||
last_user_presence_request: Option<Instant>,
|
||||
ctap1_cid: xous::CID,
|
||||
lefty_mode: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl XousEnv {
|
||||
/// Returns the unique instance of the Xous environment.
|
||||
/// 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.
|
||||
let storage = XousStorage {};
|
||||
let store = Store::new(storage).ok().unwrap();
|
||||
|
|
@ -201,7 +199,6 @@ impl XousEnv {
|
|||
|
||||
std::thread::spawn({
|
||||
let main_cid = conn.clone();
|
||||
let lefty_mode = lefty_mode.clone();
|
||||
move || {
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let pddb = pddb::Pddb::new();
|
||||
|
|
@ -252,10 +249,7 @@ impl XousEnv {
|
|||
continue;
|
||||
} else {
|
||||
let key = kbhit.load(Ordering::SeqCst);
|
||||
if key != 0
|
||||
&& ((!lefty_mode.load(Ordering::SeqCst) && (key != 0x11))
|
||||
|| (lefty_mode.load(Ordering::SeqCst) && (key != 0x14)))
|
||||
{
|
||||
if key != 0 && key != '↓' as u32 {
|
||||
// approved
|
||||
log::trace!("approved");
|
||||
request.approved = true;
|
||||
|
|
@ -272,9 +266,7 @@ impl XousEnv {
|
|||
)
|
||||
.ok();
|
||||
modals.dynamic_notification_close().ok();
|
||||
} else if (!lefty_mode.load(Ordering::SeqCst) && (key == 0x11))
|
||||
|| (lefty_mode.load(Ordering::SeqCst) && (key == 0x14))
|
||||
{
|
||||
} else if key == '↓' as u32 {
|
||||
// denied
|
||||
log::trace!("denied");
|
||||
request.approved = false;
|
||||
|
|
@ -306,18 +298,10 @@ impl XousEnv {
|
|||
log::info!("countdown: {}", new_remaining);
|
||||
last_remaining = new_remaining;
|
||||
let mut to_request_str = request_str.to_string();
|
||||
to_request_str.push_str(&format!(
|
||||
"\n\n⚠ {}{} ⚠\n",
|
||||
last_remaining,
|
||||
t!("vault.fido.countdown", locales::LANG)
|
||||
));
|
||||
to_request_str.push_str(&format!("{}s", last_remaining,));
|
||||
modals
|
||||
.dynamic_notification_update(
|
||||
Some(if lefty_mode.load(Ordering::SeqCst) {
|
||||
t!("vault.u2freq_lefty", locales::LANG)
|
||||
} else {
|
||||
t!("vault.u2freq", locales::LANG)
|
||||
}),
|
||||
Some(t!("vault2.fido.get_assertion", locales::LANG)),
|
||||
Some(&to_request_str),
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -437,11 +421,7 @@ impl XousEnv {
|
|||
|
||||
modals
|
||||
.dynamic_notification(
|
||||
Some(if lefty_mode.load(Ordering::SeqCst) {
|
||||
t!("vault.u2freq_lefty", locales::LANG)
|
||||
} else {
|
||||
t!("vault.u2freq", locales::LANG)
|
||||
}),
|
||||
Some(t!("vault2.fido.get_assertion", locales::LANG)),
|
||||
Some(&to_request_str),
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -619,7 +599,6 @@ impl XousEnv {
|
|||
modals: modals::Modals::new(&xns).unwrap(),
|
||||
last_user_presence_request: None,
|
||||
ctap1_cid,
|
||||
lefty_mode,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -689,16 +668,7 @@ impl UserPresence for XousEnv {
|
|||
let reason = reason.unwrap_or(String::new());
|
||||
let kbhit = Arc::new(AtomicU32::new(0));
|
||||
let expiration = Instant::now().checked_add(timeout).expect("duration bug");
|
||||
self.modals
|
||||
.dynamic_notification(
|
||||
Some(if self.lefty_mode.load(Ordering::SeqCst) {
|
||||
t!("vault.u2freq_lefty", locales::LANG)
|
||||
} else {
|
||||
t!("vault.u2freq", locales::LANG)
|
||||
}),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
self.modals.dynamic_notification(None, Some(&reason)).unwrap();
|
||||
// start the keyboard hit listener thread
|
||||
let _ = std::thread::spawn({
|
||||
let token = self.modals.token().clone();
|
||||
|
|
@ -722,25 +692,12 @@ impl UserPresence for XousEnv {
|
|||
|
||||
let mut last_remaining = u64::MAX;
|
||||
loop {
|
||||
let mut request_str = String::from(&reason);
|
||||
let remaining = expiration.duration_since(Instant::now()).as_secs();
|
||||
if last_remaining != remaining {
|
||||
log::info!("countdown: {}", remaining);
|
||||
// only update the UX once per second
|
||||
request_str.push_str(&format!(
|
||||
"\n\n⚠ {}{} ⚠\n",
|
||||
remaining,
|
||||
t!("vault.fido.countdown", locales::LANG)
|
||||
));
|
||||
self.modals
|
||||
.dynamic_notification_update(
|
||||
Some(if self.lefty_mode.load(Ordering::SeqCst) {
|
||||
t!("vault.u2freq_lefty", locales::LANG)
|
||||
} else {
|
||||
t!("vault.u2freq", locales::LANG)
|
||||
}),
|
||||
Some(&request_str),
|
||||
)
|
||||
.dynamic_notification_update(None, Some(&format!("{}\n{}s", reason, remaining)))
|
||||
.unwrap();
|
||||
last_remaining = remaining;
|
||||
}
|
||||
|
|
@ -751,21 +708,12 @@ impl UserPresence for XousEnv {
|
|||
return Err(UserPresenceError::Timeout);
|
||||
}
|
||||
let key_hit = kbhit.load(Ordering::SeqCst);
|
||||
if key_hit != 0
|
||||
&& (
|
||||
// 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
|
||||
)
|
||||
{
|
||||
if key_hit != 0 && key_hit != '↓' as u32 {
|
||||
// approve
|
||||
self.modals.dynamic_notification_close().ok();
|
||||
return Ok(());
|
||||
} else if
|
||||
// deny
|
||||
(!self.lefty_mode.load(Ordering::SeqCst) && (key_hit == 0x11))
|
||||
|| (self.lefty_mode.load(Ordering::SeqCst) && (key_hit == 0x14))
|
||||
{
|
||||
} else if key_hit == '↓' as u32 {
|
||||
// deny
|
||||
self.modals.dynamic_notification_close().ok();
|
||||
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
|
||||
let opensk_mutex = Arc::new(Mutex::new(0));
|
||||
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());
|
||||
|
||||
|
|
@ -229,14 +227,13 @@ fn main() -> ! {
|
|||
let allow_host = allow_host.clone();
|
||||
let opensk_mutex = opensk_mutex.clone();
|
||||
let conn = conn.clone();
|
||||
let lefty_mode = lefty_mode.clone();
|
||||
move || {
|
||||
let mut vendor_session = VendorSession::default();
|
||||
// block until the PDDB is mounted
|
||||
let pddb = pddb::Pddb::new();
|
||||
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());
|
||||
loop {
|
||||
match ctap.env().main_hid_connection().u2f_wait_incoming() {
|
||||
|
|
@ -379,40 +376,9 @@ fn main() -> ! {
|
|||
allow_totp_rendering.store(true, Ordering::SeqCst);
|
||||
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, {
|
||||
let k = char::from_u32(k1 as u32).unwrap_or('\u{0000}');
|
||||
log::debug!("key {}", k);
|
||||
log::info!("key {}", k);
|
||||
if menu_active {
|
||||
menu_mgr.key_press(k);
|
||||
} else {
|
||||
|
|
@ -435,7 +401,61 @@ fn main() -> ! {
|
|||
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();
|
||||
}
|
||||
'🔥' => {
|
||||
|
|
|
|||
|
|
@ -9,20 +9,6 @@ use crate::VaultOp;
|
|||
pub fn create_submenu(vault_conn: xous::CID, actions_conn: xous::CID, menu_mgr: xous::SID) -> MenuMatic {
|
||||
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 {
|
||||
name: String::from(t!("vault.menu_edit", locales::LANG)),
|
||||
action_conn: Some(vault_conn),
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ pub enum NavDir {
|
|||
Up,
|
||||
Down,
|
||||
Autotype,
|
||||
Reserved,
|
||||
}
|
||||
|
||||
/// Centralizes tunable UI parameters for TOTP
|
||||
|
|
@ -443,9 +442,6 @@ impl VaultUi {
|
|||
self.handle_autotype(item.guid, false).unwrap();
|
||||
}
|
||||
}
|
||||
NavDir::Reserved => {
|
||||
// tbd
|
||||
}
|
||||
}
|
||||
}
|
||||
VaultMode::Totp => {
|
||||
|
|
@ -462,9 +458,6 @@ impl VaultUi {
|
|||
self.usb_dev.send_str(&code).ok();
|
||||
}
|
||||
}
|
||||
NavDir::Reserved => {
|
||||
// tbd
|
||||
}
|
||||
}
|
||||
self.totp_code = None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,6 @@ pub(crate) enum VaultOp {
|
|||
MenuAutotypeRate,
|
||||
MenuLeftyMode,
|
||||
MenuDone,
|
||||
MenuTotpMode,
|
||||
MenuPwMode,
|
||||
|
||||
BasisChange,
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue