1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
use super::Class; use crate::DomainName; use std::fmt::{Display, Formatter, Result as FmtResult}; #[derive(Debug, Clone, FromPrimitive, ToPrimitive, Eq, PartialEq, Hash)] pub enum SSHFPAlgorithm { Reserved = 0, RSA = 1, DSS = 2, } impl Display for SSHFPAlgorithm { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { match self { SSHFPAlgorithm::Reserved => write!(f, "Reserved"), SSHFPAlgorithm::RSA => write!(f, "RSA"), SSHFPAlgorithm::DSS => write!(f, "DSS"), } } } #[derive(Debug, Clone, FromPrimitive, ToPrimitive, Eq, PartialEq, Hash)] pub enum SSHFPType { Reserved = 0, Sha1 = 1, } impl Display for SSHFPType { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { match self { SSHFPType::Reserved => write!(f, "Reserved"), SSHFPType::Sha1 => write!(f, "SHA-1"), } } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SSHFP { pub domain_name: DomainName, pub ttl: u32, pub class: Class, pub algorithm: SSHFPAlgorithm, pub type_: SSHFPType, pub fp: Vec<u8>, } impl_to_type!(SSHFP); impl Display for SSHFP { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { write!( f, "{} {} {} SSHFP {} {} {:x?}", self.domain_name, self.ttl, self.class, self.algorithm, self.type_, self.fp, ) } }