use crate::algorithm;
use anomaly::fail;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(u8)]
pub enum Algorithm {
YubicoAes = 0x26,
}
impl Algorithm {
pub fn from_u8(tag: u8) -> Result<Self, algorithm::Error> {
Ok(match tag {
0x26 => Algorithm::YubicoAes,
_ => fail!(
algorithm::ErrorKind::TagInvalid,
"unknown auth algorithm ID: 0x{:02x}",
tag
),
})
}
pub fn to_u8(self) -> u8 {
self as u8
}
pub fn key_len(self) -> usize {
match self {
Algorithm::YubicoAes => 32,
}
}
}
impl Default for Algorithm {
fn default() -> Self {
Algorithm::YubicoAes
}
}
impl_algorithm_serializers!(Algorithm);