ipmi_rs/connection/impls/rmcp/v2_0/crypto/
integrity.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
2pub enum IntegrityAlgorithm {
3 None,
4 HmacSha1_96,
5 HmacMd5_128,
6 Md5_128,
7 HmacSha256_128,
8}
9
10impl TryFrom<u8> for IntegrityAlgorithm {
11 type Error = ();
12
13 fn try_from(value: u8) -> Result<Self, Self::Error> {
14 let value = match value {
15 0x00 => Self::None,
16 0x01 => Self::HmacSha1_96,
17 0x02 => Self::HmacMd5_128,
18 0x03 => Self::Md5_128,
19 0x04 => Self::HmacSha256_128,
20 _ => return Err(()),
21 };
22
23 Ok(value)
24 }
25}
26
27impl From<IntegrityAlgorithm> for u8 {
28 fn from(value: IntegrityAlgorithm) -> Self {
29 match value {
30 IntegrityAlgorithm::None => 0x00,
31 IntegrityAlgorithm::HmacSha1_96 => 0x01,
32 IntegrityAlgorithm::HmacMd5_128 => 0x02,
33 IntegrityAlgorithm::Md5_128 => 0x03,
34 IntegrityAlgorithm::HmacSha256_128 => 0x04,
35 }
36 }
37}