Implement touch_required() for TouchPolicy
This commit is contained in:
parent
f9d69dbefb
commit
e9bac43cad
1 changed files with 12 additions and 0 deletions
|
@ -316,6 +316,7 @@ impl Display for UIF {
|
|||
///
|
||||
/// Touch policies were introduced in YubiKey Version 4.2.0 with modes ON, OFF and FIXED.
|
||||
/// YubiKey Version >= 5.2.1 added support for modes CACHED and CACHED_FIXED.
|
||||
#[derive(Eq, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum TouchPolicy {
|
||||
Off,
|
||||
|
@ -326,6 +327,17 @@ pub enum TouchPolicy {
|
|||
Unknown(u8),
|
||||
}
|
||||
|
||||
impl TouchPolicy {
|
||||
/// Returns "true" if this TouchPolicy (probably) requires touch confirmation.
|
||||
///
|
||||
/// Note: When the Policy is set to `Cached` or `CachedFixed`, there is no way to be sure if a
|
||||
/// previous touch confirmation is still valid (touch confirmations are valid for 15s, in
|
||||
/// Cached mode)
|
||||
pub fn touch_required(&self) -> bool {
|
||||
!matches!(self, Self::Off)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for TouchPolicy {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
|
|
Loading…
Reference in a new issue