зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1459173 - Web Authentication - rustfmt u2f-hid-rs r=jcj
Reviewers: jcj Reviewed By: jcj Bug #: 1459173 Differential Revision: https://phabricator.services.mozilla.com/D1115 --HG-- extra : amend_source : a23a6a2a00f31b8cb3b14c323917aec7b9a660b7
This commit is contained in:
Родитель
50e7b94259
Коммит
c6c270b3f6
|
@ -17,10 +17,12 @@ extern crate log;
|
|||
macro_rules! try_or {
|
||||
($val:expr, $or:expr) => {
|
||||
match $val {
|
||||
Ok(v) => { v }
|
||||
Err(e) => { return $or(e); }
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
return $or(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn u2f_get_key_handle_from_register_response(register_response: &Vec<u8>) -> io::Result<Vec<u8>> {
|
||||
|
|
|
@ -39,8 +39,8 @@ extern crate bitflags;
|
|||
|
||||
mod consts;
|
||||
mod statemachine;
|
||||
mod u2ftypes;
|
||||
mod u2fprotocol;
|
||||
mod u2ftypes;
|
||||
|
||||
mod manager;
|
||||
pub use manager::U2FManager;
|
||||
|
@ -88,9 +88,9 @@ pub enum Error {
|
|||
NotAllowed = 5,
|
||||
}
|
||||
|
||||
#[cfg(fuzzing)]
|
||||
pub use consts::*;
|
||||
#[cfg(fuzzing)]
|
||||
pub use u2fprotocol::*;
|
||||
#[cfg(fuzzing)]
|
||||
pub use u2ftypes::*;
|
||||
#[cfg(fuzzing)]
|
||||
pub use consts::*;
|
||||
|
|
|
@ -11,8 +11,8 @@ use std::os::unix::prelude::*;
|
|||
|
||||
use consts::CID_BROADCAST;
|
||||
use platform::hidraw;
|
||||
use util::from_unix_result;
|
||||
use u2ftypes::U2FDevice;
|
||||
use util::from_unix_result;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Device {
|
||||
|
|
|
@ -50,13 +50,11 @@ const HID_ITEM_TAGTYPE_USAGE_PAGE: u8 = 0b00000100;
|
|||
const HID_MAX_DESCRIPTOR_SIZE: usize = 4096;
|
||||
|
||||
macro_rules! ioctl {
|
||||
($dir:expr, $name:ident, $ioty:expr, $nr:expr; $ty:ty) => (
|
||||
($dir:expr, $name:ident, $ioty:expr, $nr:expr; $ty:ty) => {
|
||||
pub unsafe fn $name(fd: libc::c_int, val: *mut $ty) -> io::Result<libc::c_int> {
|
||||
let size = mem::size_of::<$ty>();
|
||||
let ioc = (($dir as u32) << DIRSHIFT) |
|
||||
(($ioty as u32) << TYPESHIFT) |
|
||||
(($nr as u32) << NRSHIFT) |
|
||||
((size as u32) << SIZESHIFT);
|
||||
let ioc = (($dir as u32) << DIRSHIFT) | (($ioty as u32) << TYPESHIFT)
|
||||
| (($nr as u32) << NRSHIFT) | ((size as u32) << SIZESHIFT);
|
||||
|
||||
#[cfg(not(target_env = "musl"))]
|
||||
type IocType = libc::c_ulong;
|
||||
|
@ -65,7 +63,7 @@ macro_rules! ioctl {
|
|||
|
||||
from_unix_result(libc::ioctl(fd, ioc as IocType, val))
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/hidraw.h
|
||||
|
|
|
@ -65,13 +65,11 @@ where
|
|||
|
||||
// Start listening for new devices.
|
||||
let mut socket = monitor.listen()?;
|
||||
let mut fds = vec![
|
||||
::libc::pollfd {
|
||||
fd: socket.as_raw_fd(),
|
||||
events: POLLIN,
|
||||
revents: 0,
|
||||
},
|
||||
];
|
||||
let mut fds = vec![::libc::pollfd {
|
||||
fd: socket.as_raw_fd(),
|
||||
events: POLLIN,
|
||||
revents: 0,
|
||||
}];
|
||||
|
||||
while alive() {
|
||||
// Wait for new events, break on failure.
|
||||
|
|
|
@ -282,13 +282,13 @@ extern "C" {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use core_foundation_sys::base::*;
|
||||
use core_foundation_sys::runloop::*;
|
||||
use libc::c_void;
|
||||
use std::ptr;
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
use std::thread;
|
||||
use super::*;
|
||||
|
||||
extern "C" fn observe(_: CFRunLoopObserverRef, _: CFRunLoopActivity, context: *mut c_void) {
|
||||
let tx: &Sender<SendableRunLoop> = unsafe { &*(context as *mut _) };
|
||||
|
|
|
@ -10,9 +10,9 @@ use core_foundation_sys::runloop::*;
|
|||
use libc::c_void;
|
||||
use platform::iokit::*;
|
||||
use runloop::RunLoop;
|
||||
use std::{io, slice};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::{io, slice};
|
||||
use util::io_err;
|
||||
|
||||
struct DeviceData {
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::sync::mpsc::{channel, RecvTimeoutError, Sender};
|
|||
use std::time::Duration;
|
||||
|
||||
use consts::PARAMETER_SIZE;
|
||||
use statemachine::StateMachine;
|
||||
use runloop::RunLoop;
|
||||
use statemachine::StateMachine;
|
||||
use util::OnceCallback;
|
||||
|
||||
enum QueueAction {
|
||||
|
|
|
@ -7,8 +7,8 @@ use platform::device::Device;
|
|||
use platform::transaction::Transaction;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use util::OnceCallback;
|
||||
use u2fprotocol::{u2f_init_device, u2f_is_keyhandle_valid, u2f_register, u2f_sign};
|
||||
use util::OnceCallback;
|
||||
|
||||
fn is_valid_transport(transports: ::AuthenticatorTransports) -> bool {
|
||||
transports.is_empty() || transports.contains(::AuthenticatorTransports::USB)
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
extern crate std;
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::ffi::CString;
|
||||
use std::io;
|
||||
use std::io::{Read, Write};
|
||||
use std::ffi::CString;
|
||||
|
||||
use consts::*;
|
||||
use u2ftypes::*;
|
||||
|
|
|
@ -12,10 +12,12 @@ use boxfnonce::SendBoxFnOnce;
|
|||
macro_rules! try_or {
|
||||
($val:expr, $or:expr) => {
|
||||
match $val {
|
||||
Ok(v) => { v }
|
||||
Err(e) => { return $or(e); }
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
return $or(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub trait Signed {
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::io;
|
|||
use std::io::{Read, Write};
|
||||
use std::os::windows::io::AsRawHandle;
|
||||
|
||||
use consts::{FIDO_USAGE_U2FHID, CID_BROADCAST, FIDO_USAGE_PAGE, HID_RPT_SIZE};
|
||||
use super::winapi::DeviceCapabilities;
|
||||
use consts::{FIDO_USAGE_U2FHID, CID_BROADCAST, FIDO_USAGE_PAGE, HID_RPT_SIZE};
|
||||
|
||||
use u2ftypes::U2FDevice;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ extern "stdcall" {
|
|||
macro_rules! offset_of {
|
||||
($ty:ty, $field:ident) => {
|
||||
unsafe { &(*(0 as *const $ty)).$field as *const _ as usize }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn from_wide_ptr(ptr: *const u16, len: usize) -> String {
|
||||
|
|
Загрузка…
Ссылка в новой задаче