Merge pull request #428 from ia0/env_feedback
Make user feedback fields private
This commit is contained in:
@@ -71,7 +71,7 @@ pub struct CtapHid {
|
||||
// In packets, the ID encoding is Big Endian to match what is used throughout CTAP (with the
|
||||
// u32::to/from_be_bytes methods).
|
||||
allocated_cids: usize,
|
||||
pub wink_permission: TimedPermission,
|
||||
pub(crate) wink_permission: TimedPermission,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -399,6 +399,10 @@ impl CtapHid {
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn should_wink(&self, now: ClockValue) -> bool {
|
||||
self.wink_permission.is_granted(now)
|
||||
}
|
||||
|
||||
#[cfg(feature = "with_ctap1")]
|
||||
fn ctap1_error_message(
|
||||
cid: ChannelID,
|
||||
|
||||
@@ -334,7 +334,7 @@ pub struct CtapState {
|
||||
persistent_store: PersistentStore,
|
||||
client_pin: ClientPin,
|
||||
#[cfg(feature = "with_ctap1")]
|
||||
pub u2f_up_state: U2fUserPresenceState,
|
||||
pub(crate) u2f_up_state: U2fUserPresenceState,
|
||||
// The state initializes to Reset and its timeout, and never goes back to Reset.
|
||||
stateful_command_permission: StatefulPermission,
|
||||
large_blobs: LargeBlobs,
|
||||
@@ -1332,6 +1332,16 @@ impl CtapState {
|
||||
auth_data.extend(&signature_counter);
|
||||
Ok(auth_data)
|
||||
}
|
||||
|
||||
#[cfg(feature = "with_ctap1")]
|
||||
pub fn u2f_grant_user_presence(&mut self, now: ClockValue) {
|
||||
self.u2f_up_state.grant_up(now)
|
||||
}
|
||||
|
||||
#[cfg(feature = "with_ctap1")]
|
||||
pub fn u2f_needs_user_presence(&mut self, now: ClockValue) -> bool {
|
||||
self.u2f_up_state.is_up_needed(now)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -57,4 +57,9 @@ impl<E: Env> Ctap<E> {
|
||||
self.hid
|
||||
.process_hid_packet(&mut self.env, packet, now, &mut self.state)
|
||||
}
|
||||
|
||||
pub fn update_timeouts(&mut self, now: ClockValue) {
|
||||
self.state.update_timeouts(now);
|
||||
self.hid.wink_permission = self.hid.wink_permission.check_expiration(now);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ fn main() {
|
||||
#[cfg(feature = "with_ctap1")]
|
||||
{
|
||||
if button_touched.get() {
|
||||
ctap.state().u2f_up_state.grant_up(now);
|
||||
ctap.state().u2f_grant_user_presence(now);
|
||||
}
|
||||
// Cleanup button callbacks. We miss button presses while processing though.
|
||||
// Heavy computation mostly follows a registered touch luckily. Unregistering
|
||||
@@ -117,8 +117,7 @@ fn main() {
|
||||
|
||||
// These calls are making sure that even for long inactivity, wrapping clock values
|
||||
// don't cause problems with timers.
|
||||
ctap.state().update_timeouts(now);
|
||||
ctap.hid().wink_permission = ctap.hid().wink_permission.check_expiration(now);
|
||||
ctap.update_timeouts(now);
|
||||
|
||||
if has_packet {
|
||||
let reply = ctap.process_hid_packet(&pkt_request, now);
|
||||
@@ -161,14 +160,14 @@ fn main() {
|
||||
last_led_increment = now;
|
||||
}
|
||||
|
||||
if ctap.hid().wink_permission.is_granted(now) {
|
||||
if ctap.hid().should_wink(now) {
|
||||
wink_leds(led_counter);
|
||||
} else {
|
||||
#[cfg(not(feature = "with_ctap1"))]
|
||||
switch_off_leds();
|
||||
#[cfg(feature = "with_ctap1")]
|
||||
{
|
||||
if ctap.state().u2f_up_state.is_up_needed(now) {
|
||||
if ctap.state().u2f_needs_user_presence(now) {
|
||||
// Flash the LEDs with an almost regular pattern. The inaccuracy comes from
|
||||
// delay caused by processing and sending of packets.
|
||||
blink_leds(led_counter);
|
||||
|
||||
Reference in New Issue
Block a user