passkey_types/u2f.rs
1//! U2F Authenticator API
2mod authenticate;
3mod commands;
4mod register;
5mod version;
6
7pub use {authenticate::*, commands::*, register::*, version::*};
8
9/// ISO 7816-4 Status Words (`SW_*`)
10///
11/// Values are taken from <https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.html#h3_status-codes>
12#[repr(u16)]
13#[derive(Debug)]
14pub enum ResponseStatusWords {
15 /// The command completed successfully without error
16 NoError = 0x9000,
17 /// The request was rejected due to test-of-user-presence being required.
18 ConditionsNotSatisfied = 0x6985,
19 /// The request was rejected due to an invalid key handle.
20 WrongData = 0x6A80,
21 /// The length of the request was invalid.
22 WrongLength = 0x6700,
23 /// The Class byte of the request is not supported. (i.e. CLA != 0)
24 ClaNotSupported = 0x6E00,
25 /// The Instruction of the request is not supported.
26 InsNotSupported = 0x6D00,
27}
28
29impl From<ResponseStatusWords> for u16 {
30 #[expect(clippy::as_conversions)]
31 fn from(sw: ResponseStatusWords) -> Self {
32 sw as u16
33 }
34}
35
36impl ResponseStatusWords {
37 /// Transform a `ResponseStatusWords` to a `u16` as postfix without needing to specify the type.
38 pub fn as_primitive(self) -> u16 {
39 self.into()
40 }
41}