diff --git a/Cargo.lock b/Cargo.lock index 4c3ef5f4f..5989ff756 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml index f5d978efc..86e000a2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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", ] diff --git a/services/u2f/src/ctap/apdu.rs b/apps/vault/fido2/ctap/apdu.rs similarity index 100% rename from services/u2f/src/ctap/apdu.rs rename to apps/vault/fido2/ctap/apdu.rs diff --git a/services/u2f/src/ctap/command.rs b/apps/vault/fido2/ctap/command.rs similarity index 100% rename from services/u2f/src/ctap/command.rs rename to apps/vault/fido2/ctap/command.rs diff --git a/services/u2f/src/ctap/ctap1.rs b/apps/vault/fido2/ctap/ctap1.rs similarity index 100% rename from services/u2f/src/ctap/ctap1.rs rename to apps/vault/fido2/ctap/ctap1.rs diff --git a/services/u2f/src/ctap/data_formats.rs b/apps/vault/fido2/ctap/data_formats.rs similarity index 100% rename from services/u2f/src/ctap/data_formats.rs rename to apps/vault/fido2/ctap/data_formats.rs diff --git a/services/u2f/src/ctap/hid/mod.rs b/apps/vault/fido2/ctap/hid/mod.rs similarity index 100% rename from services/u2f/src/ctap/hid/mod.rs rename to apps/vault/fido2/ctap/hid/mod.rs diff --git a/services/u2f/src/ctap/hid/receive.rs b/apps/vault/fido2/ctap/hid/receive.rs similarity index 100% rename from services/u2f/src/ctap/hid/receive.rs rename to apps/vault/fido2/ctap/hid/receive.rs diff --git a/services/u2f/src/ctap/hid/send.rs b/apps/vault/fido2/ctap/hid/send.rs similarity index 100% rename from services/u2f/src/ctap/hid/send.rs rename to apps/vault/fido2/ctap/hid/send.rs diff --git a/services/u2f/src/ctap/key_material.rs b/apps/vault/fido2/ctap/key_material.rs similarity index 100% rename from services/u2f/src/ctap/key_material.rs rename to apps/vault/fido2/ctap/key_material.rs diff --git a/services/u2f/src/ctap/mod.rs b/apps/vault/fido2/ctap/mod.rs similarity index 100% rename from services/u2f/src/ctap/mod.rs rename to apps/vault/fido2/ctap/mod.rs diff --git a/services/u2f/src/ctap/pin_protocol_v1.rs b/apps/vault/fido2/ctap/pin_protocol_v1.rs similarity index 100% rename from services/u2f/src/ctap/pin_protocol_v1.rs rename to apps/vault/fido2/ctap/pin_protocol_v1.rs diff --git a/services/u2f/src/ctap/response.rs b/apps/vault/fido2/ctap/response.rs similarity index 100% rename from services/u2f/src/ctap/response.rs rename to apps/vault/fido2/ctap/response.rs diff --git a/services/u2f/src/ctap/status_code.rs b/apps/vault/fido2/ctap/status_code.rs similarity index 100% rename from services/u2f/src/ctap/status_code.rs rename to apps/vault/fido2/ctap/status_code.rs diff --git a/services/u2f/src/ctap/storage.rs b/apps/vault/fido2/ctap/storage.rs similarity index 100% rename from services/u2f/src/ctap/storage.rs rename to apps/vault/fido2/ctap/storage.rs diff --git a/services/u2f/src/ctap/storage/key.rs b/apps/vault/fido2/ctap/storage/key.rs similarity index 100% rename from services/u2f/src/ctap/storage/key.rs rename to apps/vault/fido2/ctap/storage/key.rs diff --git a/services/u2f/src/ctap/timed_permission.rs b/apps/vault/fido2/ctap/timed_permission.rs similarity index 100% rename from services/u2f/src/ctap/timed_permission.rs rename to apps/vault/fido2/ctap/timed_permission.rs diff --git a/services/u2f/libraries/cbor/Cargo.toml b/apps/vault/fido2/libraries/cbor/Cargo.toml similarity index 100% rename from services/u2f/libraries/cbor/Cargo.toml rename to apps/vault/fido2/libraries/cbor/Cargo.toml diff --git a/services/u2f/libraries/cbor/fuzz/Cargo.toml b/apps/vault/fido2/libraries/cbor/fuzz/Cargo.toml similarity index 100% rename from services/u2f/libraries/cbor/fuzz/Cargo.toml rename to apps/vault/fido2/libraries/cbor/fuzz/Cargo.toml diff --git a/services/u2f/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs b/apps/vault/fido2/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs similarity index 100% rename from services/u2f/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs rename to apps/vault/fido2/libraries/cbor/fuzz/fuzz_targets/fuzz_target_cbor.rs diff --git a/services/u2f/libraries/cbor/src/lib.rs b/apps/vault/fido2/libraries/cbor/src/lib.rs similarity index 100% rename from services/u2f/libraries/cbor/src/lib.rs rename to apps/vault/fido2/libraries/cbor/src/lib.rs diff --git a/services/u2f/libraries/cbor/src/macros.rs b/apps/vault/fido2/libraries/cbor/src/macros.rs similarity index 100% rename from services/u2f/libraries/cbor/src/macros.rs rename to apps/vault/fido2/libraries/cbor/src/macros.rs diff --git a/services/u2f/libraries/cbor/src/reader.rs b/apps/vault/fido2/libraries/cbor/src/reader.rs similarity index 100% rename from services/u2f/libraries/cbor/src/reader.rs rename to apps/vault/fido2/libraries/cbor/src/reader.rs diff --git a/services/u2f/libraries/cbor/src/values.rs b/apps/vault/fido2/libraries/cbor/src/values.rs similarity index 100% rename from services/u2f/libraries/cbor/src/values.rs rename to apps/vault/fido2/libraries/cbor/src/values.rs diff --git a/services/u2f/libraries/cbor/src/writer.rs b/apps/vault/fido2/libraries/cbor/src/writer.rs similarity index 100% rename from services/u2f/libraries/cbor/src/writer.rs rename to apps/vault/fido2/libraries/cbor/src/writer.rs diff --git a/services/u2f/libraries/crypto/Cargo.toml b/apps/vault/fido2/libraries/crypto/Cargo.toml similarity index 100% rename from services/u2f/libraries/crypto/Cargo.toml rename to apps/vault/fido2/libraries/crypto/Cargo.toml diff --git a/services/u2f/libraries/crypto/src/aes256.rs b/apps/vault/fido2/libraries/crypto/src/aes256.rs similarity index 100% rename from services/u2f/libraries/crypto/src/aes256.rs rename to apps/vault/fido2/libraries/crypto/src/aes256.rs diff --git a/services/u2f/libraries/crypto/src/cbc.rs b/apps/vault/fido2/libraries/crypto/src/cbc.rs similarity index 100% rename from services/u2f/libraries/crypto/src/cbc.rs rename to apps/vault/fido2/libraries/crypto/src/cbc.rs diff --git a/services/u2f/libraries/crypto/src/ec/exponent256.rs b/apps/vault/fido2/libraries/crypto/src/ec/exponent256.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ec/exponent256.rs rename to apps/vault/fido2/libraries/crypto/src/ec/exponent256.rs diff --git a/services/u2f/libraries/crypto/src/ec/gfp256.rs b/apps/vault/fido2/libraries/crypto/src/ec/gfp256.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ec/gfp256.rs rename to apps/vault/fido2/libraries/crypto/src/ec/gfp256.rs diff --git a/services/u2f/libraries/crypto/src/ec/int256.rs b/apps/vault/fido2/libraries/crypto/src/ec/int256.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ec/int256.rs rename to apps/vault/fido2/libraries/crypto/src/ec/int256.rs diff --git a/services/u2f/libraries/crypto/src/ec/mod.rs b/apps/vault/fido2/libraries/crypto/src/ec/mod.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ec/mod.rs rename to apps/vault/fido2/libraries/crypto/src/ec/mod.rs diff --git a/services/u2f/libraries/crypto/src/ec/montgomery.rs b/apps/vault/fido2/libraries/crypto/src/ec/montgomery.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ec/montgomery.rs rename to apps/vault/fido2/libraries/crypto/src/ec/montgomery.rs diff --git a/services/u2f/libraries/crypto/src/ec/point.rs b/apps/vault/fido2/libraries/crypto/src/ec/point.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ec/point.rs rename to apps/vault/fido2/libraries/crypto/src/ec/point.rs diff --git a/services/u2f/libraries/crypto/src/ec/precomputed.rs b/apps/vault/fido2/libraries/crypto/src/ec/precomputed.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ec/precomputed.rs rename to apps/vault/fido2/libraries/crypto/src/ec/precomputed.rs diff --git a/services/u2f/libraries/crypto/src/ecdh.rs b/apps/vault/fido2/libraries/crypto/src/ecdh.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ecdh.rs rename to apps/vault/fido2/libraries/crypto/src/ecdh.rs diff --git a/services/u2f/libraries/crypto/src/ecdsa.rs b/apps/vault/fido2/libraries/crypto/src/ecdsa.rs similarity index 100% rename from services/u2f/libraries/crypto/src/ecdsa.rs rename to apps/vault/fido2/libraries/crypto/src/ecdsa.rs diff --git a/services/u2f/libraries/crypto/src/hmac.rs b/apps/vault/fido2/libraries/crypto/src/hmac.rs similarity index 100% rename from services/u2f/libraries/crypto/src/hmac.rs rename to apps/vault/fido2/libraries/crypto/src/hmac.rs diff --git a/services/u2f/libraries/crypto/src/lib.rs b/apps/vault/fido2/libraries/crypto/src/lib.rs similarity index 100% rename from services/u2f/libraries/crypto/src/lib.rs rename to apps/vault/fido2/libraries/crypto/src/lib.rs diff --git a/services/u2f/libraries/crypto/src/rng256.rs b/apps/vault/fido2/libraries/crypto/src/rng256.rs similarity index 100% rename from services/u2f/libraries/crypto/src/rng256.rs rename to apps/vault/fido2/libraries/crypto/src/rng256.rs diff --git a/services/u2f/libraries/crypto/src/sha256.rs b/apps/vault/fido2/libraries/crypto/src/sha256.rs similarity index 100% rename from services/u2f/libraries/crypto/src/sha256.rs rename to apps/vault/fido2/libraries/crypto/src/sha256.rs diff --git a/services/u2f/libraries/crypto/src/util.rs b/apps/vault/fido2/libraries/crypto/src/util.rs similarity index 100% rename from services/u2f/libraries/crypto/src/util.rs rename to apps/vault/fido2/libraries/crypto/src/util.rs diff --git a/services/u2f/libraries/crypto/tests/aesavs.rs b/apps/vault/fido2/libraries/crypto/tests/aesavs.rs similarity index 100% rename from services/u2f/libraries/crypto/tests/aesavs.rs rename to apps/vault/fido2/libraries/crypto/tests/aesavs.rs diff --git a/services/u2f/libraries/crypto/tests/asn1.rs b/apps/vault/fido2/libraries/crypto/tests/asn1.rs similarity index 100% rename from services/u2f/libraries/crypto/tests/asn1.rs rename to apps/vault/fido2/libraries/crypto/tests/asn1.rs diff --git a/services/u2f/libraries/crypto/tests/data/ECBVarKey256.rsp b/apps/vault/fido2/libraries/crypto/tests/data/ECBVarKey256.rsp similarity index 100% rename from services/u2f/libraries/crypto/tests/data/ECBVarKey256.rsp rename to apps/vault/fido2/libraries/crypto/tests/data/ECBVarKey256.rsp diff --git a/services/u2f/libraries/crypto/tests/data/ECBVarTxt256.rsp b/apps/vault/fido2/libraries/crypto/tests/data/ECBVarTxt256.rsp similarity index 100% rename from services/u2f/libraries/crypto/tests/data/ECBVarTxt256.rsp rename to apps/vault/fido2/libraries/crypto/tests/data/ECBVarTxt256.rsp diff --git a/services/u2f/libraries/crypto/tests/data/ecdsa_secp256r1_sha256_test.json b/apps/vault/fido2/libraries/crypto/tests/data/ecdsa_secp256r1_sha256_test.json similarity index 100% rename from services/u2f/libraries/crypto/tests/data/ecdsa_secp256r1_sha256_test.json rename to apps/vault/fido2/libraries/crypto/tests/data/ecdsa_secp256r1_sha256_test.json diff --git a/services/u2f/libraries/crypto/tests/wycheproof.rs b/apps/vault/fido2/libraries/crypto/tests/wycheproof.rs similarity index 100% rename from services/u2f/libraries/crypto/tests/wycheproof.rs rename to apps/vault/fido2/libraries/crypto/tests/wycheproof.rs diff --git a/services/u2f/libraries/persistent_store/Cargo.toml b/apps/vault/fido2/libraries/persistent_store/Cargo.toml similarity index 100% rename from services/u2f/libraries/persistent_store/Cargo.toml rename to apps/vault/fido2/libraries/persistent_store/Cargo.toml diff --git a/services/u2f/libraries/persistent_store/fuzz/.gitignore b/apps/vault/fido2/libraries/persistent_store/fuzz/.gitignore similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/.gitignore rename to apps/vault/fido2/libraries/persistent_store/fuzz/.gitignore diff --git a/services/u2f/libraries/persistent_store/fuzz/Cargo.toml b/apps/vault/fido2/libraries/persistent_store/fuzz/Cargo.toml similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/Cargo.toml rename to apps/vault/fido2/libraries/persistent_store/fuzz/Cargo.toml diff --git a/services/u2f/libraries/persistent_store/fuzz/examples/store.rs b/apps/vault/fido2/libraries/persistent_store/fuzz/examples/store.rs similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/examples/store.rs rename to apps/vault/fido2/libraries/persistent_store/fuzz/examples/store.rs diff --git a/services/u2f/libraries/persistent_store/fuzz/fuzz_targets/store.rs b/apps/vault/fido2/libraries/persistent_store/fuzz/fuzz_targets/store.rs similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/fuzz_targets/store.rs rename to apps/vault/fido2/libraries/persistent_store/fuzz/fuzz_targets/store.rs diff --git a/services/u2f/libraries/persistent_store/fuzz/src/histogram.rs b/apps/vault/fido2/libraries/persistent_store/fuzz/src/histogram.rs similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/src/histogram.rs rename to apps/vault/fido2/libraries/persistent_store/fuzz/src/histogram.rs diff --git a/services/u2f/libraries/persistent_store/fuzz/src/lib.rs b/apps/vault/fido2/libraries/persistent_store/fuzz/src/lib.rs similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/src/lib.rs rename to apps/vault/fido2/libraries/persistent_store/fuzz/src/lib.rs diff --git a/services/u2f/libraries/persistent_store/fuzz/src/stats.rs b/apps/vault/fido2/libraries/persistent_store/fuzz/src/stats.rs similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/src/stats.rs rename to apps/vault/fido2/libraries/persistent_store/fuzz/src/stats.rs diff --git a/services/u2f/libraries/persistent_store/fuzz/src/store.rs b/apps/vault/fido2/libraries/persistent_store/fuzz/src/store.rs similarity index 100% rename from services/u2f/libraries/persistent_store/fuzz/src/store.rs rename to apps/vault/fido2/libraries/persistent_store/fuzz/src/store.rs diff --git a/services/u2f/libraries/persistent_store/src/buffer.rs b/apps/vault/fido2/libraries/persistent_store/src/buffer.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/buffer.rs rename to apps/vault/fido2/libraries/persistent_store/src/buffer.rs diff --git a/services/u2f/libraries/persistent_store/src/driver.rs b/apps/vault/fido2/libraries/persistent_store/src/driver.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/driver.rs rename to apps/vault/fido2/libraries/persistent_store/src/driver.rs diff --git a/services/u2f/libraries/persistent_store/src/format.rs b/apps/vault/fido2/libraries/persistent_store/src/format.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/format.rs rename to apps/vault/fido2/libraries/persistent_store/src/format.rs diff --git a/services/u2f/libraries/persistent_store/src/format/bitfield.rs b/apps/vault/fido2/libraries/persistent_store/src/format/bitfield.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/format/bitfield.rs rename to apps/vault/fido2/libraries/persistent_store/src/format/bitfield.rs diff --git a/services/u2f/libraries/persistent_store/src/lib.rs b/apps/vault/fido2/libraries/persistent_store/src/lib.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/lib.rs rename to apps/vault/fido2/libraries/persistent_store/src/lib.rs diff --git a/services/u2f/libraries/persistent_store/src/model.rs b/apps/vault/fido2/libraries/persistent_store/src/model.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/model.rs rename to apps/vault/fido2/libraries/persistent_store/src/model.rs diff --git a/services/u2f/libraries/persistent_store/src/storage.rs b/apps/vault/fido2/libraries/persistent_store/src/storage.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/storage.rs rename to apps/vault/fido2/libraries/persistent_store/src/storage.rs diff --git a/services/u2f/libraries/persistent_store/src/store.rs b/apps/vault/fido2/libraries/persistent_store/src/store.rs similarity index 100% rename from services/u2f/libraries/persistent_store/src/store.rs rename to apps/vault/fido2/libraries/persistent_store/src/store.rs diff --git a/services/u2f/Cargo.toml b/services/u2f/Cargo.toml deleted file mode 100644 index cacdebebf..000000000 --- a/services/u2f/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "u2f" -version = "0.1.0" -authors = ["bunnie "] -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 = [] diff --git a/services/u2f/src/api.rs b/services/u2f/src/api.rs deleted file mode 100644 index 06ca72d1a..000000000 --- a/services/u2f/src/api.rs +++ /dev/null @@ -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, -} diff --git a/services/u2f/src/lib.rs b/services/u2f/src/lib.rs deleted file mode 100644 index b948fa367..000000000 --- a/services/u2f/src/lib.rs +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/services/u2f/src/main.rs b/services/u2f/src/main.rs deleted file mode 100644 index ca7185842..000000000 --- a/services/u2f/src/main.rs +++ /dev/null @@ -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) -} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 2c99c34af..8f5b2ca93 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -72,7 +72,6 @@ fn main() -> Result<(), Box> { "pddb", "modals", "usb-device-xous", - "u2f", ]; let app_pkgs = [ // "standard" demo apps