1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #[macro_use] 6 mod util; 7 8 #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "netbsd"))] 9 pub mod hidproto; 10 11 #[cfg(any(target_os = "linux"))] 12 extern crate libudev; 13 14 #[cfg(any(target_os = "linux"))] 15 #[path = "linux/mod.rs"] 16 pub mod platform; 17 18 #[cfg(any(target_os = "freebsd"))] 19 extern crate devd_rs; 20 21 #[cfg(any(target_os = "freebsd"))] 22 #[path = "freebsd/mod.rs"] 23 pub mod platform; 24 25 #[cfg(any(target_os = "netbsd"))] 26 #[path = "netbsd/mod.rs"] 27 pub mod platform; 28 29 #[cfg(any(target_os = "openbsd"))] 30 #[path = "openbsd/mod.rs"] 31 pub mod platform; 32 33 #[cfg(any(target_os = "macos"))] 34 extern crate core_foundation; 35 36 #[cfg(any(target_os = "macos"))] 37 #[path = "macos/mod.rs"] 38 pub mod platform; 39 40 #[cfg(any(target_os = "windows"))] 41 #[path = "windows/mod.rs"] 42 pub mod platform; 43 44 #[cfg(not(any( 45 target_os = "linux", 46 target_os = "freebsd", 47 target_os = "openbsd", 48 target_os = "netbsd", 49 target_os = "macos", 50 target_os = "windows" 51 )))] 52 #[path = "stub/mod.rs"] 53 pub mod platform; 54 55 extern crate libc; 56 #[macro_use] 57 extern crate log; 58 extern crate rand; 59 extern crate runloop; 60 61 #[macro_use] 62 extern crate bitflags; 63 64 pub mod authenticatorservice; 65 mod consts; 66 mod statemachine; 67 mod u2fprotocol; 68 mod u2ftypes; 69 70 mod manager; 71 pub use crate::manager::U2FManager; 72 73 mod capi; 74 pub use crate::capi::*; 75 76 pub mod errors; 77 pub mod statecallback; 78 mod virtualdevices; 79 80 // Keep this in sync with the constants in u2fhid-capi.h. 81 bitflags! { 82 pub struct RegisterFlags: u64 { 83 const REQUIRE_RESIDENT_KEY = 1; 84 const REQUIRE_USER_VERIFICATION = 2; 85 const REQUIRE_PLATFORM_ATTACHMENT = 4; 86 } 87 } 88 bitflags! { 89 pub struct SignFlags: u64 { 90 const REQUIRE_USER_VERIFICATION = 1; 91 } 92 } 93 bitflags! { 94 pub struct AuthenticatorTransports: u8 { 95 const USB = 1; 96 const NFC = 2; 97 const BLE = 4; 98 } 99 } 100 101 #[derive(Clone)] 102 pub struct KeyHandle { 103 pub credential: Vec<u8>, 104 pub transports: AuthenticatorTransports, 105 } 106 107 pub type AppId = Vec<u8>; 108 pub type RegisterResult = (Vec<u8>, u2ftypes::U2FDeviceInfo); 109 pub type SignResult = (AppId, Vec<u8>, Vec<u8>, u2ftypes::U2FDeviceInfo); 110 111 pub type Result<T> = std::result::Result<T, errors::AuthenticatorError>; 112 113 #[derive(Debug, Clone)] 114 pub enum StatusUpdate { 115 DeviceAvailable { dev_info: u2ftypes::U2FDeviceInfo }, 116 DeviceUnavailable { dev_info: u2ftypes::U2FDeviceInfo }, 117 Success { dev_info: u2ftypes::U2FDeviceInfo }, 118 } 119 120 #[cfg(test)] 121 #[macro_use] 122 extern crate assert_matches; 123 124 #[cfg(fuzzing)] 125 pub use consts::*; 126 #[cfg(fuzzing)] 127 pub use u2fprotocol::*; 128 #[cfg(fuzzing)] 129 pub use u2ftypes::*; 130