hickory_proto/rr/dnssec/
mod.rs

1/*
2 * Copyright (C) 2015 Benjamin Fry <benjaminfry@me.com>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! dns security extension related modules
18
19mod algorithm;
20mod digest_type;
21#[cfg(any(feature = "openssl", feature = "ring"))]
22mod ec_public_key;
23mod key_format;
24mod keypair;
25mod nsec3;
26pub mod public_key;
27pub mod rdata;
28#[cfg(any(feature = "openssl", feature = "ring"))]
29mod rsa_public_key;
30mod signer;
31mod supported_algorithm;
32pub mod tbs;
33mod trust_anchor;
34pub mod tsig;
35mod verifier;
36
37pub use self::algorithm::Algorithm;
38pub use self::digest_type::DigestType;
39pub use self::nsec3::Nsec3HashAlgorithm;
40pub use self::public_key::PublicKey;
41pub use self::public_key::PublicKeyBuf;
42pub use self::public_key::PublicKeyEnum;
43pub use self::supported_algorithm::SupportedAlgorithms;
44pub use self::tbs::TBS;
45pub use self::trust_anchor::TrustAnchor;
46pub use self::verifier::Verifier;
47pub use crate::error::DnsSecResult;
48
49#[cfg(all(not(feature = "ring"), feature = "openssl"))]
50#[cfg_attr(docsrs, doc(cfg(all(not(feature = "ring"), feature = "openssl"))))]
51pub use openssl::hash::DigestBytes as Digest;
52
53#[cfg(feature = "ring")]
54#[cfg_attr(docsrs, doc(cfg(feature = "ring")))]
55pub use ring::digest::Digest;
56
57/// This is an empty type, enable Ring or OpenSSL for this feature
58#[cfg(not(any(feature = "openssl", feature = "ring")))]
59#[cfg_attr(docsrs, doc(cfg(not(any(feature = "openssl", feature = "ring")))))]
60#[derive(Clone, Copy, Debug)]
61pub struct Digest;
62
63#[cfg(not(any(feature = "openssl", feature = "ring")))]
64#[cfg_attr(docsrs, doc(cfg(not(any(feature = "openssl", feature = "ring")))))]
65#[allow(clippy::should_implement_trait)]
66impl Digest {
67    /// This is an empty type, enable Ring or OpenSSL for this feature
68    pub fn as_ref(&self) -> &Self {
69        self
70    }
71
72    /// This is an empty type, enable Ring or OpenSSL for this feature
73    #[allow(clippy::wrong_self_convention)]
74    pub fn to_owned(&self) -> Vec<u8> {
75        vec![]
76    }
77}
78
79#[cfg(any(feature = "openssl", feature = "ring"))]
80#[cfg_attr(docsrs, doc(cfg(any(feature = "openssl", feature = "ring"))))]
81pub use self::key_format::KeyFormat;
82pub use self::keypair::KeyPair;
83#[allow(deprecated)]
84pub use self::signer::{SigSigner, Signer};
85
86#[cfg(feature = "openssl")]
87#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
88pub use openssl::pkey::{HasPrivate, HasPublic, Private, Public};
89
90#[cfg(not(feature = "openssl"))]
91#[cfg_attr(docsrs, doc(cfg(not(feature = "openssl"))))]
92pub use self::faux_key_type::{HasPrivate, HasPublic, Private, Public};
93
94#[cfg(not(feature = "openssl"))]
95#[cfg_attr(docsrs, doc(cfg(not(feature = "openssl"))))]
96mod faux_key_type {
97    /// A key that contains public key material
98    pub trait HasPublic {}
99
100    /// A key that contains private key material
101    pub trait HasPrivate {}
102
103    impl<K: HasPrivate> HasPublic for K {}
104
105    /// Faux implementation of the Openssl Public key types
106    #[derive(Clone, Copy)]
107    pub enum Public {}
108
109    impl HasPublic for Public {}
110
111    /// Faux implementation of the Openssl Public key types
112    #[derive(Clone, Copy)]
113    pub enum Private {}
114
115    impl HasPrivate for Private {}
116}