cleanup pass on spew and warnings

This commit is contained in:
bunnie 2022-06-04 00:56:47 +08:00
parent b2b4529c40
commit 272abfd157
4 changed files with 16 additions and 11 deletions

View file

@ -196,7 +196,9 @@ impl Ctap1Command {
challenge, challenge,
application, application,
} => { } => {
log::debug!("REGISTER");
if !ctap_state.u2f_up_state.consume_up(clock_value) { if !ctap_state.u2f_up_state.consume_up(clock_value) {
log::debug!("consume_up did not work");
return Err(Ctap1StatusCode::SW_COND_USE_NOT_SATISFIED); return Err(Ctap1StatusCode::SW_COND_USE_NOT_SATISFIED);
} }
Ctap1Command::process_register(challenge, application, ctap_state) Ctap1Command::process_register(challenge, application, ctap_state)
@ -208,6 +210,7 @@ impl Ctap1Command {
key_handle, key_handle,
flags, flags,
} => { } => {
log::debug!("AUTHENTICATE");
// The order is important due to side effects of checking user presence. // The order is important due to side effects of checking user presence.
if flags == Ctap1Flags::EnforceUpAndSign if flags == Ctap1Flags::EnforceUpAndSign
&& !ctap_state.u2f_up_state.consume_up(clock_value) && !ctap_state.u2f_up_state.consume_up(clock_value)
@ -224,10 +227,16 @@ impl Ctap1Command {
} }
// U2F raw message format specification (version 20170411) section 6.3 // U2F raw message format specification (version 20170411) section 6.3
U2fCommand::Version => Ok(Vec::<u8>::from(super::U2F_VERSION_STRING)), U2fCommand::Version => {
log::debug!("VERSION");
Ok(Vec::<u8>::from(super::U2F_VERSION_STRING))
},
// TODO: should we return an error instead such as SW_INS_NOT_SUPPORTED? // TODO: should we return an error instead such as SW_INS_NOT_SUPPORTED?
U2fCommand::VendorSpecific { .. } => Err(Ctap1StatusCode::SW_SUCCESS), U2fCommand::VendorSpecific { .. } => {
log::debug!("VENDOR");
Err(Ctap1StatusCode::SW_SUCCESS)
},
} }
} }

View file

@ -31,7 +31,7 @@ use arrayref::array_ref;
use cbor::cbor_array_vec; use cbor::cbor_array_vec;
use core::convert::TryInto; use core::convert::TryInto;
use ctap_crypto::rng256::Rng256; use ctap_crypto::rng256::Rng256;
use pddb::{Pddb, PddbRequestCode}; use pddb::Pddb;
use rand_core::{OsRng, RngCore}; use rand_core::{OsRng, RngCore};
use std::cell::RefCell; use std::cell::RefCell;

View file

@ -95,13 +95,13 @@ fn main() -> ! {
let now = ClockValue::new(tt.elapsed_ms() as i64, 1000); let now = ClockValue::new(tt.elapsed_ms() as i64, 1000);
let reply = ctap_hid.process_hid_packet(&msg.packet, now, &mut ctap_state); let reply = ctap_hid.process_hid_packet(&msg.packet, now, &mut ctap_state);
// This block handles sending packets. // This block handles sending packets.
for mut pkt_reply in reply { for pkt_reply in reply {
let mut reply = FidoMsg::default(); let mut reply = FidoMsg::default();
reply.packet.copy_from_slice(&pkt_reply); reply.packet.copy_from_slice(&pkt_reply);
let status = usb.u2f_send(reply); let status = usb.u2f_send(reply);
match status { match status {
Ok(()) => { Ok(()) => {
log::debug!("Sent U2F packet"); log::trace!("Sent U2F packet");
} }
Err(e) => { Err(e) => {
log::error!("Error sending U2F packet: {:?}", e); log::error!("Error sending U2F packet: {:?}", e);

View file

@ -211,11 +211,7 @@ fn main() -> ! {
buf.code = U2fCode::RxAck; buf.code = U2fCode::RxAck;
response.replace(buf).unwrap(); response.replace(buf).unwrap();
} else { } else {
{ log::trace!("registering deferred listener");
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
let u2f_ipc = buffer.to_original::<U2fMsgIpc, _>().unwrap();
log::trace!("registering deferred listener");
}
fido_listener = Some(msg); fido_listener = Some(msg);
} }
} else { } else {
@ -274,7 +270,7 @@ fn main() -> ! {
buf.code = U2fCode::RxAck; buf.code = U2fCode::RxAck;
response.replace(buf).unwrap(); response.replace(buf).unwrap();
} else { } else {
log::warn!("Got U2F packet, but no server to respond...queuing."); log::debug!("Got U2F packet, but no server to respond...queuing.");
fido_rx_queue.push_back(u2f_report.packet); fido_rx_queue.push_back(u2f_report.packet);
} }
}, },