Skip to content

Commit b444f32

Browse files
committed
Allow long CTAPHID_INIT responses
1 parent 9f1b3ac commit b444f32

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/u2fprotocol.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,11 @@ pub(crate) mod tests {
244244

245245
// init_resp packet
246246
let mut msg = CID_BROADCAST.to_vec();
247-
msg.extend(vec![HIDCmd::Init.into(), 0x00, 0x11]); // cmd + bcnt
247+
msg.extend(vec![HIDCmd::Init.into(), 0x00, 0x12]); // cmd + bcnt
248248
msg.extend_from_slice(&nonce);
249249
msg.extend_from_slice(&cid); // new channel id
250250
msg.extend(vec![0x02, 0x04, 0x01, 0x08, 0x01]); // versions + flags
251+
msg.extend(vec![0xff]); // grease for future extension
251252
device.add_read(&msg, 0);
252253

253254
init_device(&mut device, &nonce).unwrap();

src/u2ftypes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl U2FHIDInitResp {
156156
pub fn read(data: &[u8], nonce: &[u8]) -> io::Result<U2FHIDInitResp> {
157157
assert_eq!(nonce.len(), INIT_NONCE_SIZE);
158158

159-
if data.len() != INIT_NONCE_SIZE + 9 {
159+
if data.len() < INIT_NONCE_SIZE + 9 {
160160
return Err(io_err("invalid init response"));
161161
}
162162

0 commit comments

Comments
 (0)