use crate::base::iana::SecurityAlgorithm;
use crate::base::Name;
use crate::crypto::sign::SignRaw;
use crate::rdata::Dnskey;
use std::fmt::Debug;
use std::vec::Vec;
#[derive(Debug)]
pub struct SigningKey<Octs, Inner: SignRaw>
where
Octs: AsRef<[u8]> + Debug,
{
owner: Name<Octs>,
flags: u16,
inner: Inner,
}
impl<Octs, Inner: SignRaw> SigningKey<Octs, Inner>
where
Octs: AsRef<[u8]> + Debug,
{
pub fn new(owner: Name<Octs>, flags: u16, inner: Inner) -> Self {
Self {
owner,
flags,
inner,
}
}
}
impl<Octs, Inner: SignRaw> SigningKey<Octs, Inner>
where
Octs: AsRef<[u8]> + Debug,
{
pub fn owner(&self) -> &Name<Octs> {
&self.owner
}
pub fn flags(&self) -> u16 {
self.flags
}
pub fn raw_secret_key(&self) -> &Inner {
&self.inner
}
pub fn is_zone_signing_key(&self) -> bool {
self.flags & (1 << 8) != 0
}
pub fn is_revoked(&self) -> bool {
self.flags & (1 << 7) != 0
}
pub fn is_secure_entry_point(&self) -> bool {
self.flags & 1 != 0
}
pub fn algorithm(&self) -> SecurityAlgorithm {
self.inner.algorithm()
}
pub fn dnskey(&self) -> Dnskey<Vec<u8>> {
self.inner.dnskey()
}
}