From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../authenticator/src/transport/stub/device.rs | 115 +++++++++++++++++++++ .../rust/authenticator/src/transport/stub/mod.rs | 11 ++ .../src/transport/stub/transaction.rs | 52 ++++++++++ 3 files changed, 178 insertions(+) create mode 100644 third_party/rust/authenticator/src/transport/stub/device.rs create mode 100644 third_party/rust/authenticator/src/transport/stub/mod.rs create mode 100644 third_party/rust/authenticator/src/transport/stub/transaction.rs (limited to 'third_party/rust/authenticator/src/transport/stub') diff --git a/third_party/rust/authenticator/src/transport/stub/device.rs b/third_party/rust/authenticator/src/transport/stub/device.rs new file mode 100644 index 0000000000..29d8a3ab9b --- /dev/null +++ b/third_party/rust/authenticator/src/transport/stub/device.rs @@ -0,0 +1,115 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use crate::ctap2::commands::get_info::AuthenticatorInfo; +use crate::transport::hid::HIDDevice; +use crate::transport::{FidoDevice, FidoProtocol}; +use crate::transport::{HIDError, SharedSecret}; +use crate::u2ftypes::U2FDeviceInfo; +use std::hash::Hash; +use std::io; +use std::io::{Read, Write}; +use std::path::PathBuf; + +#[derive(Debug, Hash, PartialEq, Eq)] +pub struct Device {} + +impl Read for Device { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + unimplemented!(); + } +} + +impl Write for Device { + fn write(&mut self, buf: &[u8]) -> io::Result { + unimplemented!(); + } + + fn flush(&mut self) -> io::Result<()> { + unimplemented!(); + } +} + +impl HIDDevice for Device { + type BuildParameters = PathBuf; + type Id = PathBuf; + + fn new(parameters: Self::BuildParameters) -> Result { + unimplemented!(); + } + + fn id(&self) -> Self::Id { + unimplemented!() + } + + fn get_cid(&self) -> &[u8; 4] { + unimplemented!(); + } + + fn set_cid(&mut self, cid: [u8; 4]) { + unimplemented!(); + } + + fn in_rpt_size(&self) -> usize { + unimplemented!(); + } + + fn out_rpt_size(&self) -> usize { + unimplemented!(); + } + + fn get_property(&self, prop_name: &str) -> io::Result { + unimplemented!(); + } + + fn get_device_info(&self) -> U2FDeviceInfo { + unimplemented!(); + } + + fn set_device_info(&mut self, dev_info: U2FDeviceInfo) { + unimplemented!(); + } +} + +impl FidoDevice for Device { + fn pre_init(&mut self) -> Result<(), HIDError> { + unimplemented!(); + } + + fn should_try_ctap2(&self) -> bool { + unimplemented!(); + } + + fn initialized(&self) -> bool { + unimplemented!(); + } + + fn is_u2f(&mut self) -> bool { + unimplemented!() + } + + fn get_authenticator_info(&self) -> Option<&AuthenticatorInfo> { + unimplemented!() + } + + fn set_authenticator_info(&mut self, authenticator_info: AuthenticatorInfo) { + unimplemented!() + } + + fn set_shared_secret(&mut self, secret: SharedSecret) { + unimplemented!() + } + + fn get_shared_secret(&self) -> Option<&SharedSecret> { + unimplemented!() + } + + fn get_protocol(&self) -> FidoProtocol { + unimplemented!() + } + + fn downgrade_to_ctap1(&mut self) { + unimplemented!() + } +} diff --git a/third_party/rust/authenticator/src/transport/stub/mod.rs b/third_party/rust/authenticator/src/transport/stub/mod.rs new file mode 100644 index 0000000000..0fab62d495 --- /dev/null +++ b/third_party/rust/authenticator/src/transport/stub/mod.rs @@ -0,0 +1,11 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// No-op module to permit compiling token HID support for Android, where +// no results are returned. + +#![allow(unused_variables)] + +pub mod device; +pub mod transaction; diff --git a/third_party/rust/authenticator/src/transport/stub/transaction.rs b/third_party/rust/authenticator/src/transport/stub/transaction.rs new file mode 100644 index 0000000000..d471c94da8 --- /dev/null +++ b/third_party/rust/authenticator/src/transport/stub/transaction.rs @@ -0,0 +1,52 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use crate::errors; +use crate::statecallback::StateCallback; +use crate::transport::device_selector::{ + DeviceBuildParameters, DeviceSelector, DeviceSelectorEvent, +}; +use std::path::PathBuf; +use std::sync::mpsc::Sender; + +pub struct Transaction {} + +impl Transaction { + pub fn new( + timeout: u64, + callback: StateCallback>, + _status: Sender, + new_device_cb: F, + ) -> crate::Result + where + F: Fn( + DeviceBuildParameters, + Sender, + Sender, + &dyn Fn() -> bool, + ) + Sync + + Send + + 'static, + T: 'static, + { + // Just to silence "unused"-warnings + let mut device_selector = DeviceSelector::run(); + let _ = DeviceSelectorEvent::DevicesAdded(vec![]); + let _ = DeviceSelectorEvent::DeviceRemoved(PathBuf::new()); + let _ = device_selector.clone_sender(); + device_selector.stop(); + + callback.call(Err(errors::AuthenticatorError::U2FToken( + errors::U2FTokenError::NotSupported, + ))); + + Err(errors::AuthenticatorError::U2FToken( + errors::U2FTokenError::NotSupported, + )) + } + + pub fn cancel(&mut self) { + /* No-op. */ + } +} -- cgit v1.2.3