mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
migrate u2f to the "vault" app
The vault app is the beginning of a multi-purpose authentication vault. It will feature: 1. FIDO2 authentication 2. TOTP authenticators 3. Password storage to PDDB with auto-typing via keyboard HID This is the first step on a very very long journey.
This commit is contained in:
parent
6745206303
commit
81f823ff34
70 changed files with 21 additions and 193 deletions
67
Cargo.lock
generated
67
Cargo.lock
generated
|
|
@ -89,12 +89,6 @@ version = "1.0.43"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
|
||||
|
||||
[[package]]
|
||||
name = "atomic-polyfill"
|
||||
version = "0.1.8"
|
||||
|
|
@ -384,10 +378,6 @@ dependencies = [
|
|||
"xous-names",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cbor"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.66"
|
||||
|
|
@ -679,15 +669,6 @@ dependencies = [
|
|||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"cbor",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.11.1"
|
||||
|
|
@ -2219,10 +2200,6 @@ version = "2.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
|
||||
[[package]]
|
||||
name = "persistent_store"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.8"
|
||||
|
|
@ -3426,31 +3403,6 @@ version = "1.15.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
|
||||
|
||||
[[package]]
|
||||
name = "u2f"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"byteorder",
|
||||
"cbor",
|
||||
"crypto",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"persistent_store",
|
||||
"rkyv",
|
||||
"subtle",
|
||||
"susres",
|
||||
"ticktimer-server",
|
||||
"usb-device-xous",
|
||||
"usbd-human-interface-device 0.1.1 (git+https://github.com/betrusted-io/usbd-human-interface-device.git?branch=main)",
|
||||
"utralib",
|
||||
"xous",
|
||||
"xous-ipc 0.9.7",
|
||||
"xous-names",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.7"
|
||||
|
|
@ -3636,6 +3588,25 @@ dependencies = [
|
|||
"svd2utra",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vault"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gam",
|
||||
"graphics-server",
|
||||
"locales",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"tts-frontend",
|
||||
"usb-device-xous",
|
||||
"usbd-human-interface-device 0.1.1 (git+https://github.com/betrusted-io/usbd-human-interface-device.git?branch=main)",
|
||||
"xous",
|
||||
"xous-ipc 0.9.7",
|
||||
"xous-names",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcell"
|
||||
version = "0.1.3"
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ default-members = [
|
|||
"services/dns",
|
||||
"services/modals",
|
||||
"services/usb-device-xous",
|
||||
"services/u2f",
|
||||
"apps/ball",
|
||||
"apps/hello",
|
||||
"apps/repl",
|
||||
"apps/vault",
|
||||
]
|
||||
members = [
|
||||
"xous-ipc",
|
||||
|
|
@ -93,12 +93,12 @@ members = [
|
|||
"apps/ball",
|
||||
"apps/hello",
|
||||
"apps/repl",
|
||||
"apps/vault",
|
||||
"services/libstd-test",
|
||||
"services/ffi-test",
|
||||
"services/tts",
|
||||
"services/usb-test",
|
||||
"services/usb-device-xous",
|
||||
"services/u2f",
|
||||
"kernel",
|
||||
"loader",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
[package]
|
||||
name = "u2f"
|
||||
version = "0.1.0"
|
||||
authors = ["bunnie <bunnie@kosagi.com>"]
|
||||
edition = "2018"
|
||||
description = "U2F server"
|
||||
|
||||
# Dependency policy: fully specify dependencies to the minor version number
|
||||
[dependencies]
|
||||
xous = { path = "../../xous-rs" }
|
||||
xous-ipc = {path="../../xous-ipc"}
|
||||
log-server = { path = "../log-server" }
|
||||
ticktimer-server = { path = "../ticktimer-server" }
|
||||
xous-names = { path = "../xous-names" }
|
||||
log = "0.4.14"
|
||||
num-derive = {version = "0.3.3", default-features = false}
|
||||
num-traits = {version = "0.2.14", default-features = false}
|
||||
rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]}
|
||||
susres = {path = "../susres"}
|
||||
usb-device-xous = {path="../usb-device-xous"}
|
||||
usbd-human-interface-device = {git="https://github.com/betrusted-io/usbd-human-interface-device.git", branch="main"}
|
||||
|
||||
# OpenSK libraries
|
||||
crypto = {path = "libraries/crypto"}
|
||||
cbor = {path = "libraries/cbor"}
|
||||
persistent_store = {path = "libraries/persistent_store"}
|
||||
byteorder = { version = "1.4.3", default-features = false }
|
||||
arrayref = "0.3.6"
|
||||
subtle = { version = "2.2.3", default-features = false }
|
||||
|
||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||
utralib = { path = "../../utralib"}
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
pub(crate) const SERVER_NAME_U2F: &str = "_U2F server_";
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
pub(crate) enum Opcode {
|
||||
/// Exits the server
|
||||
Quit,
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#![cfg_attr(target_os = "none", no_std)]
|
||||
|
||||
pub mod api;
|
||||
pub use api::*;
|
||||
use xous::{CID, send_message};
|
||||
use num_traits::*;
|
||||
|
||||
pub struct U2f {
|
||||
conn: CID,
|
||||
}
|
||||
impl U2f {
|
||||
pub fn new() -> Self {
|
||||
let xns = xous_names::XousNames::new().expect("couldn't connect to XousNames");
|
||||
REFCOUNT.fetch_add(1, Ordering::Relaxed);
|
||||
let conn = xns.request_connection_blocking(api::SERVER_NAME_U2F).expect("Can't connect to U2f server");
|
||||
U2f {
|
||||
conn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
static REFCOUNT: AtomicU32 = AtomicU32::new(0);
|
||||
impl Drop for U2f {
|
||||
fn drop(&mut self) {
|
||||
// the connection to the server side must be reference counted, so that multiple instances of this object within
|
||||
// a single process do not end up de-allocating the CID on other threads before they go out of scope.
|
||||
// Note to future me: you want this. Don't get rid of it because you think, "nah, nobody will ever make more than one copy of this object".
|
||||
if REFCOUNT.fetch_sub(1, Ordering::Relaxed) == 1 {
|
||||
unsafe{xous::disconnect(self.conn).unwrap();}
|
||||
}
|
||||
// if there was object-specific state (such as a one-time use server for async callbacks, specific to the object instance),
|
||||
// de-allocate those items here. They don't need a reference count because they are object-specific
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
#![cfg_attr(target_os = "none", no_std)]
|
||||
#![cfg_attr(target_os = "none", no_main)]
|
||||
|
||||
mod api;
|
||||
use api::*;
|
||||
|
||||
mod ctap;
|
||||
use ctap::hid::{ChannelID, CtapHid, KeepaliveStatus, ProcessedPacket};
|
||||
use ctap::status_code::Ctap2StatusCode;
|
||||
use ctap::CtapState;
|
||||
|
||||
use num_traits::*;
|
||||
use std::thread;
|
||||
use usbd_human_interface_device::device::fido::*;
|
||||
|
||||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Trace);
|
||||
log::info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
// TODO: figure out what, if any, should be the limit of connections to the U2F server?
|
||||
let u2f_sid = xns.register_name(api::SERVER_NAME_U2F, None).expect("can't register server");
|
||||
log::trace!("registered with NS -- {:?}", u2f_sid);
|
||||
|
||||
let _ = thread::spawn({
|
||||
move || {
|
||||
let usb = usb_device_xous::UsbHid::new();
|
||||
loop {
|
||||
match usb.u2f_wait_incoming() {
|
||||
Ok(msg) => {
|
||||
log::info!("FIDO listener got message: {:?}", msg);
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("FIDO listener got an error: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let mut ctap_state = CtapState::new(&mut rng, check_user_presence, boot_time);
|
||||
let mut ctap_hid = CtapHid::new();
|
||||
|
||||
loop {
|
||||
let msg = xous::receive_message(u2f_sid).unwrap();
|
||||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
Some(Opcode::Quit) => {
|
||||
log::warn!("Quit received, goodbye world!");
|
||||
break;
|
||||
},
|
||||
None => {
|
||||
log::error!("couldn't convert opcode: {:?}", msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
// clean up our program
|
||||
log::trace!("main loop exit, destroying servers");
|
||||
xns.unregister_server(u2f_sid).unwrap();
|
||||
xous::destroy_server(u2f_sid).unwrap();
|
||||
log::trace!("quitting");
|
||||
xous::terminate_process(0)
|
||||
}
|
||||
|
|
@ -72,7 +72,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
"pddb",
|
||||
"modals",
|
||||
"usb-device-xous",
|
||||
"u2f",
|
||||
];
|
||||
let app_pkgs = [
|
||||
// "standard" demo apps
|
||||
|
|
|
|||
Loading…
Reference in a new issue