Skip to content

Commit

Permalink
Merge branch 'release-v1.0.2-rc.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
szszszsz committed Jan 25, 2022
2 parents ca14845 + dff0019 commit 4f96c6a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 18 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Unreleased

Update to upstream release 1.0.9.

## Bugfixes

- usbd-ctaphid: fix ctaphid keepalive messages - fixes "busy" issue under Windows ([#21][])


[#21]: https://github.com/Nitrokey/nitrokey-3-firmware/issues/21

# v1.0.1 (2022-01-15)

## Bugfixes
Expand Down
39 changes: 27 additions & 12 deletions components/usbd-ctaphid/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ pub struct Pipe<'alloc, Bus: UsbBus> {

// a "read once" indicator if now we're waiting on the application processing
started_processing: bool,

needs_keepalive: bool,
}

impl<'alloc, Bus: UsbBus> Pipe<'alloc, Bus> {
Expand All @@ -176,6 +178,7 @@ impl<'alloc, Bus: UsbBus> Pipe<'alloc, Bus> {
implements: 0x80,
last_milliseconds: initial_milliseconds,
started_processing: false,
needs_keepalive: false,
}
}

Expand Down Expand Up @@ -469,6 +472,11 @@ impl<'alloc, Bus: UsbBus> Pipe<'alloc, Bus> {
},

_ => {
if request.command == Command::Cbor {
self.needs_keepalive = true;
} else {
self.needs_keepalive = false;
}
if self.interchange.state() == interchange::State::Responded {
info!("dumping stale response");
self.interchange.take_response();
Expand Down Expand Up @@ -502,23 +510,30 @@ impl<'alloc, Bus: UsbBus> Pipe<'alloc, Bus> {

pub fn send_keepalive(&mut self, is_waiting_for_user_presence: bool) -> bool {
if let State::WaitingOnAuthenticator(request) = &self.state {
info!("keepalive");
if !self.needs_keepalive {
// let response go out normally in idle loop
info!("cmd does not need keepalive messages");
false
} else {

let mut packet = [0u8; PACKET_SIZE];
info!("keepalive");

packet[..4].copy_from_slice(&request.channel.to_be_bytes());
packet[4] = 0x80 | 0x3B;
packet[5..7].copy_from_slice(&1u16.to_be_bytes());
let mut packet = [0u8; PACKET_SIZE];

if is_waiting_for_user_presence {
packet[7] = KeepaliveStatus::UpNeeded as u8;
} else {
packet[7] = KeepaliveStatus::Processing as u8;
}
packet[..4].copy_from_slice(&request.channel.to_be_bytes());
packet[4] = 0x80 | 0x3B;
packet[5..7].copy_from_slice(&1u16.to_be_bytes());

if is_waiting_for_user_presence {
packet[7] = KeepaliveStatus::UpNeeded as u8;
} else {
packet[7] = KeepaliveStatus::Processing as u8;
}

self.write_endpoint.write(&packet).ok();
self.write_endpoint.write(&packet).ok();

true
true
}
} else {
info!("keepalive done");
false
Expand Down
2 changes: 1 addition & 1 deletion runners/lpc55/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion runners/lpc55/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "runner"
version = "1.0.1"
version = "1.0.2-rc.1"
authors = ["Nicolas Stalder <[email protected]>", "Conor Patrick <[email protected]>"]
edition = "2018"
resolver = "2"
Expand Down
8 changes: 4 additions & 4 deletions runners/lpc55/config/commands.bd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
options {
flags = 0x8;
buildNumber = 0x1;
productVersion = "1.0.1";
componentVersion = "1.0.1";
productVersion = "1.0.2";
componentVersion = "1.0.2";
secureBinaryVersion = "2.1";
}

Expand All @@ -11,8 +11,8 @@ sources {
}

section (0) {
version_check sec 4194305;
version_check nsec 4194305;
version_check sec 4194306;
version_check nsec 4194306;
erase 0x0..0x93000;
load inputFile > 0x0;
}

0 comments on commit 4f96c6a

Please sign in to comment.