adds style fix and updates Cargo.lock (#576)
This commit is contained in:
@@ -344,8 +344,8 @@ impl CtapHid {
|
||||
}
|
||||
|
||||
/// Helper function to parse a raw packet.
|
||||
pub fn process_single_packet(packet: &HidPacket) -> (&ChannelID, ProcessedPacket) {
|
||||
let (cid, rest) = array_refs![packet, 4, 60];
|
||||
pub fn process_single_packet(packet: &HidPacket) -> (ChannelID, ProcessedPacket) {
|
||||
let (&cid, rest) = array_refs![packet, 4, 60];
|
||||
if rest[0] & CtapHid::PACKET_TYPE_MASK != 0 {
|
||||
let cmd = rest[0] & !CtapHid::PACKET_TYPE_MASK;
|
||||
let len = (rest[1] as usize) << 8 | (rest[2] as usize);
|
||||
@@ -605,7 +605,7 @@ mod test {
|
||||
packet[..4].copy_from_slice(&cid);
|
||||
packet[4..9].copy_from_slice(&[0x81, 0x00, 0x02, 0x99, 0x99]);
|
||||
let (processed_cid, processed_packet) = CtapHid::process_single_packet(&packet);
|
||||
assert_eq!(processed_cid, &cid);
|
||||
assert_eq!(processed_cid, cid);
|
||||
let expected_packet = ProcessedPacket::InitPacket {
|
||||
cmd: CtapHidCommand::Ping as u8,
|
||||
len: 2,
|
||||
|
||||
@@ -89,8 +89,8 @@ impl MessageAssembler {
|
||||
|
||||
// If the packet is from the timed-out channel, send back a timeout error.
|
||||
// Otherwise, proceed with processing the packet.
|
||||
if *cid == current_cid {
|
||||
return Err((*cid, CtapHidError::MsgTimeout));
|
||||
if cid == current_cid {
|
||||
return Err((cid, CtapHidError::MsgTimeout));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,12 +98,12 @@ impl MessageAssembler {
|
||||
// Expecting an initialization packet.
|
||||
match processed_packet {
|
||||
ProcessedPacket::InitPacket { cmd, len, data } => {
|
||||
self.parse_init_packet(env, *cid, cmd, len, data, timestamp)
|
||||
self.parse_init_packet(env, cid, cmd, len, data, timestamp)
|
||||
}
|
||||
ProcessedPacket::ContinuationPacket { .. } => {
|
||||
// CTAP specification (version 20190130) section 8.1.5.4
|
||||
// Spurious continuation packets will be ignored.
|
||||
Err((*cid, CtapHidError::UnexpectedContinuation))
|
||||
Err((cid, CtapHidError::UnexpectedContinuation))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -111,8 +111,8 @@ impl MessageAssembler {
|
||||
|
||||
// CTAP specification (version 20190130) section 8.1.5.1
|
||||
// Reject packets from other channels.
|
||||
if *cid != self.cid {
|
||||
return Err((*cid, CtapHidError::ChannelBusy));
|
||||
if cid != self.cid {
|
||||
return Err((cid, CtapHidError::ChannelBusy));
|
||||
}
|
||||
|
||||
match processed_packet {
|
||||
@@ -120,16 +120,16 @@ impl MessageAssembler {
|
||||
ProcessedPacket::InitPacket { cmd, len, data } => {
|
||||
self.reset();
|
||||
if cmd == CtapHidCommand::Init as u8 {
|
||||
self.parse_init_packet(env, *cid, cmd, len, data, timestamp)
|
||||
self.parse_init_packet(env, cid, cmd, len, data, timestamp)
|
||||
} else {
|
||||
Err((*cid, CtapHidError::InvalidSeq))
|
||||
Err((cid, CtapHidError::InvalidSeq))
|
||||
}
|
||||
}
|
||||
ProcessedPacket::ContinuationPacket { seq, data } => {
|
||||
if seq != self.seq {
|
||||
// Reject packets with the wrong sequence number.
|
||||
self.reset();
|
||||
Err((*cid, CtapHidError::InvalidSeq))
|
||||
Err((cid, CtapHidError::InvalidSeq))
|
||||
} else {
|
||||
// Update the last timestamp.
|
||||
self.last_timestamp = timestamp;
|
||||
|
||||
@@ -251,7 +251,7 @@ fn send_keepalive_up_needed(
|
||||
|
||||
// We only parse one packet, because we only care about CANCEL.
|
||||
let (received_cid, processed_packet) = CtapHid::process_single_packet(&pkt);
|
||||
if received_cid != &cid {
|
||||
if received_cid != cid {
|
||||
debug_ctap!(
|
||||
env,
|
||||
"Received a packet on channel ID {:?} while sending a KEEPALIVE packet",
|
||||
|
||||
Reference in New Issue
Block a user