extend DNSKEY API

This commit is contained in:
Jorge Aparicio 2024-03-05 18:48:32 +01:00
parent dc19776107
commit 31048f5cd0

View File

@ -239,6 +239,8 @@ pub struct DNSKEY {
} }
impl DNSKEY { impl DNSKEY {
const KSK_BIT: u16 = 1;
/// formats the `DNSKEY` in the format `delv` expects /// formats the `DNSKEY` in the format `delv` expects
pub(super) fn delv(&self) -> String { pub(super) fn delv(&self) -> String {
let Self { let Self {
@ -252,6 +254,19 @@ impl DNSKEY {
format!("{zone} static-key {flags} {protocol} {algorithm} \"{public_key}\";\n") format!("{zone} static-key {flags} {protocol} {algorithm} \"{public_key}\";\n")
} }
pub fn clear_key_signing_key_bit(&mut self) {
self.flags &= !Self::KSK_BIT;
}
pub fn is_key_signing_key(&self) -> bool {
let mask = Self::KSK_BIT;
self.flags & mask == mask
}
pub fn is_zone_signing_key(&self) -> bool {
!self.is_key_signing_key()
}
} }
impl FromStr for DNSKEY { impl FromStr for DNSKEY {