1use std::fmt;
2
3#[derive(Debug)]
4pub enum U2fError {
5 Asm1DecoderError,
6 BadSignature,
7 RandomSecureBytesError,
8 InvalidReservedByte,
9 ChallengeExpired,
10 WrongKeyHandler,
11 InvalidClientData,
12 InvalidSignatureData,
13 InvalidUserPresenceByte,
14 BadCertificate,
15 NotTrustedAnchor,
16 CounterTooLow,
17 OpenSSLNoCurveName,
18 InvalidPublicKey,
19 WebpkiError(webpki::Error),
20 RingError(ring::error::Unspecified),
21}
22
23impl fmt::Display for U2fError {
24 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25 match &self {
26 U2fError::Asm1DecoderError => write!(f, "ASM1 Decoder error"),
27 U2fError::BadSignature => write!(f, "Not able to verify signature"),
28 U2fError::RandomSecureBytesError => write!(f, "Not able to generate random bytes"),
29 U2fError::InvalidReservedByte => write!(f, "Invalid Reserved Byte"),
30 U2fError::ChallengeExpired => write!(f, "Challenge Expired"),
31 U2fError::WrongKeyHandler => write!(f, "Wrong Key Handler"),
32 U2fError::InvalidClientData => write!(f, "Invalid Client Data"),
33 U2fError::InvalidSignatureData => write!(f, "Invalid Signature Data"),
34 U2fError::InvalidUserPresenceByte => write!(f, "Invalid User Presence Byte"),
35 U2fError::BadCertificate => write!(f, "Failed to parse certificate"),
36 U2fError::NotTrustedAnchor => write!(f, "Not Trusted Anchor"),
37 U2fError::CounterTooLow => write!(f, "Counter too low"),
38 U2fError::InvalidPublicKey => write!(f, "Invalid public key"),
39 U2fError::OpenSSLNoCurveName => write!(f, "OpenSSL no curve name"),
40 U2fError::WebpkiError(e) => e.fmt(f),
41 U2fError::RingError(e) => e.fmt(f),
42 }
43 }
44}