diff --git a/Cargo.toml b/Cargo.toml index 37506caaa..c92730623 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,13 @@ pretty_env_logger = "0.4.0" [features] default = ["apdu-dispatch"] -devel = ["apdu-dispatch", "log-all", "delog/std-log"] +devel = ["apdu-dispatch", "log-all", "delog/std-log", "devel-counters", "devel-ctaphid-bug"] + +# Count accesses to the read-only and read-write persistence storage +devel-counters = [] + +# Account ctaphid bug about 3072 buffer size. To be removed once fixed. +devel-ctaphid-bug = [] # Allow to use application over CTAPHID interface ctaphid = ["ctaphid-dispatch", "usbd-ctaphid"] diff --git a/src/authenticator.rs b/src/authenticator.rs index 78584c165..c98e858fe 100644 --- a/src/authenticator.rs +++ b/src/authenticator.rs @@ -335,8 +335,10 @@ where reply.push((credential.label.len() + 1) as u8)?; reply.push(oath::combine(credential.kind, credential.algorithm))?; reply.extend_from_slice(&credential.label).map_err(|_| 0)?; - #[cfg(feature = "devel")] + #[cfg(feature = "devel-ctaphid-bug")] if reply.len() > 3072 { + // Finish early due to the usbd-ctaphid bug, which panics on bigger buffers than this + // FIXME Remove once fixed return Err(1); } Ok(()) diff --git a/src/state.rs b/src/state.rs index 50a4435a9..e8eecb809 100644 --- a/src/state.rs +++ b/src/state.rs @@ -21,9 +21,11 @@ pub struct State { // temporary "state", to be removed again // pub hack: Hack, // trussed: RefCell>, - #[cfg(feature = "devel")] + // Count read-write access to the persistence storage. Development only. + #[cfg(feature = "devel-counters")] counter_read_write: u32, - #[cfg(feature = "devel")] + // Count read-only access to the persistence storage. Development only. + #[cfg(feature = "devel-counters")] counter_read_only: u32, } @@ -173,7 +175,7 @@ impl State { { let mut state: Persistent = Self::get_persistent_or_default(trussed); - #[cfg(feature = "devel")] + #[cfg(feature = "devel-counters")] { self.counter_read_write += 1; debug_now!("Getting the state RW {}", self.counter_read_write); @@ -202,7 +204,7 @@ impl State { { let state: Persistent = Self::get_persistent_or_default(trussed); - #[cfg(feature = "devel")] + #[cfg(feature = "devel-counters")] { self.counter_read_only += 1; debug_now!("Getting the state RO {}", self.counter_read_only);