-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathctaphid.rs
44 lines (39 loc) · 1.25 KB
/
ctaphid.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use ctaphid_dispatch::app as ctaphid;
#[allow(unused_imports)]
use crate::msp;
use crate::{Authenticator, TrussedRequirements, UserPresence};
impl<UP, T> ctaphid::App for Authenticator<UP, T>
where
UP: UserPresence,
T: TrussedRequirements,
{
fn commands(&self) -> &'static [ctaphid::Command] {
&[ctaphid::Command::Cbor, ctaphid::Command::Msg]
}
#[inline(never)]
fn call(
&mut self,
command: ctaphid::Command,
request: &ctaphid::Message,
response: &mut ctaphid::Message,
) -> ctaphid::AppResult {
debug_now!(
"ctaphid-dispatch: remaining stack: {} bytes",
msp() - 0x2000_0000
);
if request.is_empty() {
debug_now!("invalid request length in ctaphid.call");
return Err(ctaphid::Error::InvalidLength);
}
// info_now!("request: ");
// blocking::dump_hex(request, request.len());
match command {
ctaphid::Command::Cbor => super::handle_ctap2(self, request, response),
ctaphid::Command::Msg => super::handle_ctap1_from_hid(self, request, response),
_ => {
debug_now!("ctaphid trying to dispatch {:?}", command);
}
};
Ok(())
}
}