yubihsm/opaque/
algorithm.rs1use crate::algorithm;
4
5#[derive(Copy, Clone, Debug, Eq, PartialEq)]
7#[repr(u8)]
8pub enum Algorithm {
9 Data = 0x1e,
11
12 X509Certificate = 0x1f,
14}
15
16impl Algorithm {
17 pub fn from_u8(tag: u8) -> Result<Self, algorithm::Error> {
19 Ok(match tag {
20 0x1e => Algorithm::Data,
21 0x1f => Algorithm::X509Certificate,
22 _ => fail!(
23 algorithm::ErrorKind::TagInvalid,
24 "unknown opaque data ID: 0x{:02x}",
25 tag
26 ),
27 })
28 }
29
30 pub fn to_u8(self) -> u8 {
32 self as u8
33 }
34}
35
36impl_algorithm_serializers!(Algorithm);