Skip to content

Commit

Permalink
Cargo fix all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfioEmanueleFresta committed Jan 5, 2025
1 parent 0cff30b commit 0716708
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 37 deletions.
2 changes: 1 addition & 1 deletion libwebauthn/examples/webauthn_cable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn setup_logging() {
pub async fn main() -> Result<(), Box<dyn Error>> {
setup_logging();

let mut device_info_store: Box<dyn CableKnownDeviceInfoStore> =
let _device_info_store: Box<dyn CableKnownDeviceInfoStore> =
Box::new(EphemeralDeviceInfoStore::default());

// Create QR code
Expand Down
2 changes: 0 additions & 2 deletions libwebauthn/src/proto/ctap2/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use std::convert::TryFrom;
use std::io::Cursor as IOCursor;

use byteorder::{BigEndian, ReadBytesExt};
use ctap_types::ctap2::make_credential::AttestationStatement;
use futures::future::Map;
use num_enum::{IntoPrimitive, TryFromPrimitive};
use serde_bytes::ByteBuf;
use serde_cbor::Value;
Expand Down
1 change: 0 additions & 1 deletion libwebauthn/src/transport/ble/bluez/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::thread::sleep;
use std::time::Duration;

use tracing::{debug, info, instrument, span, trace, warn, Level};
use x509_parser::nom::bytes::complete::tag_no_case;

use super::device::{FidoDevice as Device, FidoEndpoints as Endpoints};
use super::gatt::{get_gatt_characteristic, get_gatt_service};
Expand Down
19 changes: 5 additions & 14 deletions libwebauthn/src/transport/cable/channel.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
use core::error;
use std::fmt::{Display, Formatter};
use std::time::Duration;

use async_trait::async_trait;
use futures::stream::FusedStream;
use futures::SinkExt;
use snow::TransportState;
use tokio::net::TcpStream;
use tokio::sync::mpsc;
use tokio::task;
use tokio_stream::wrappers::ReceiverStream;
use tokio_stream::StreamExt;
use tokio_tungstenite::{MaybeTlsStream, WebSocketStream};
use tracing::{debug, error, instrument, trace, warn};
use tungstenite::protocol::Message; // This brings the `next()` method into scope
use tracing::error;

use crate::proto::{
ctap1::apdu::{ApduRequest, ApduResponse},
Expand Down Expand Up @@ -70,24 +61,24 @@ impl<'d> Channel for CableChannel<'d> {
// TODO Send CableTunnelMessageType#Shutdown and drop the connection
}

async fn apdu_send(&self, request: &ApduRequest, timeout: Duration) -> Result<(), Error> {
async fn apdu_send(&self, _request: &ApduRequest, _timeout: Duration) -> Result<(), Error> {
error!("APDU send not supported in caBLE transport");
Err(Error::Transport(TransportError::TransportUnavailable))
}

async fn apdu_recv(&self, timeout: Duration) -> Result<ApduResponse, Error> {
async fn apdu_recv(&self, _timeout: Duration) -> Result<ApduResponse, Error> {
error!("APDU recv not supported in caBLE transport");
Err(Error::Transport(TransportError::TransportUnavailable))
}

async fn cbor_send(&mut self, request: &CborRequest, timeout: Duration) -> Result<(), Error> {
async fn cbor_send(&mut self, request: &CborRequest, _timeout: Duration) -> Result<(), Error> {
self.cbor_sender
.send(request.clone())
.await
.or(Err(Error::Transport(TransportError::TransportUnavailable)))
}

async fn cbor_recv(&mut self, timeout: Duration) -> Result<CborResponse, Error> {
async fn cbor_recv(&mut self, _timeout: Duration) -> Result<CborResponse, Error> {
self.cbor_receiver
.recv()
.await
Expand Down
2 changes: 1 addition & 1 deletion libwebauthn/src/transport/cable/known_devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct CableKnownDeviceInfo {
#[derive(Debug)]
pub struct CableKnownDevice<'d> {
pub device_info: CableKnownDeviceInfo,
store: &'d mut Box<dyn CableKnownDeviceInfoStore>,
_store: &'d mut Box<dyn CableKnownDeviceInfoStore>,
}

impl<'d> Display for CableKnownDevice<'d> {
Expand Down
3 changes: 1 addition & 2 deletions libwebauthn/src/transport/cable/qr_code_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::fmt::{Debug, Display};
use std::time::{Duration, SystemTime};

use async_trait::async_trait;
use p256::ecdh::EphemeralSecret;
use p256::elliptic_curve::sec1::ToEncodedPoint;
use p256::{NonZeroScalar, SecretKey};
use rand::rngs::OsRng;
Expand Down Expand Up @@ -239,7 +238,7 @@ impl Display for CableQrCodeDevice<'_> {
#[async_trait]
impl<'d> Device<'d, Cable, CableChannel<'d>> for CableQrCodeDevice<'_> {
async fn channel(&'d mut self) -> Result<CableChannel<'d>, Error> {
let (device, advert) = self.await_advertisement().await?;
let (_device, advert) = self.await_advertisement().await?;

let Some(tunnel_domain) =
tunnel::decode_tunnel_server_domain(advert.encoded_tunnel_server_domain)
Expand Down
25 changes: 10 additions & 15 deletions libwebauthn/src/transport/cable/tunnel.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
use ctap_types::serde::cbor_deserialize;
use futures::{Sink, SinkExt, StreamExt};
use p256::ecdh::EphemeralSecret;
use p256::elliptic_curve::sec1::ToEncodedPoint;
use p256::elliptic_curve::FieldBytes;
use p256::{NonZeroScalar, SecretKey};
use futures::{SinkExt, StreamExt};
use p256::NonZeroScalar;
use serde::Deserialize;
use serde_bytes::ByteBuf;
use serde_indexed::DeserializeIndexed;
use sha2::{Digest, Sha256};
use snow::params::NoiseParams;
use snow::{Builder, TransportState};
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::TcpStream;
use tokio::sync::mpsc::{self, Receiver, Sender};
use tokio::task::{self, JoinHandle};
use tokio_tungstenite::tungstenite::http::StatusCode;
use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::{connect_async, MaybeTlsStream, WebSocketStream};
use tracing::{debug, error, info, trace, warn};
use tracing::{debug, error, trace, warn};

use super::channel::{CableChannel, CableChannelDevice};
use super::qr_code_device::CableQrCodeDevice;
use crate::proto::ctap2::cbor::{self, CborRequest, CborResponse};
use crate::proto::ctap2::cbor::{CborRequest, CborResponse};
use crate::proto::ctap2::{Ctap2CommandCode, Ctap2GetInfoResponse};
use crate::transport::error::CtapError;
use crate::transport::error::Error;
use crate::webauthn::TransportError;

Expand All @@ -39,6 +33,7 @@ const PADDING_GRANULARITY: usize = 32;
const CABLE_PROLOGUE_QR_INITIATED: &[u8] = &[1 as u8];

enum TransactionType {
#[allow(dead_code)] // TODO StateAssisted
StateAssisted,
QRInitiated,
}
Expand Down Expand Up @@ -161,7 +156,7 @@ pub async fn connect<'d>(
}
debug!("Tunnel server returned success");

let mut noise_state = do_handshake(
let noise_state = do_handshake(
&mut ws_stream,
psk,
private_key,
Expand Down Expand Up @@ -309,7 +304,7 @@ async fn connection(
mut ws_stream: WebSocketStream<MaybeTlsStream<TcpStream>>,
mut noise_state: TransportState,
mut cbor_tx_recv: Receiver<CborRequest>,
mut cbor_rx_send: Sender<CborResponse>,
cbor_rx_send: Sender<CborResponse>,
) {
// Fetch the inital message
let get_info_response_serialized: Vec<u8> = match ws_stream.next().await {
Expand Down Expand Up @@ -343,7 +338,7 @@ async fn connection(
Ok(message) => {
debug!("Received WSS message");
trace!(?message);
connection_recv(message, &cbor_rx_send, &mut noise_state).await;
let _ = connection_recv(message, &cbor_rx_send, &mut noise_state).await;
}
};
}
Expand All @@ -353,11 +348,11 @@ async fn connection(
Ctap2CommandCode::AuthenticatorGetInfo => {
debug!("Responding to GetInfo request with cached response");
let response = CborResponse::new_success_from_slice(&get_info_response_serialized);
cbor_rx_send.send(response).await;
let _ = cbor_rx_send.send(response).await;
}
_ => {
debug!(?request.command, "Sending CBOR request");
connection_send(request, &mut ws_stream, &mut noise_state).await;
let _ = connection_send(request, &mut ws_stream, &mut noise_state).await;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion libwebauthn/src/transport/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl From<TransportError> for Error {
}

impl From<snow::Error> for Error {
fn from(error: snow::Error) -> Self {
fn from(_error: snow::Error) -> Self {
Error::Transport(TransportError::NegotiationFailed)
}
}

0 comments on commit 0716708

Please sign in to comment.