Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSEC3 generation support. #416

Draft
wants to merge 134 commits into
base: dnssec-key
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
4022c81
[sign] Define 'KeyPair' and impl key export
Oct 2, 2024
7b51569
[sign] Define trait 'Sign'
Oct 2, 2024
cb97321
[sign] Implement parsing from the DNS format
Oct 2, 2024
db51ae6
[sign] Provide some error information
Oct 2, 2024
a505415
[sign] Move 'KeyPair' to 'generic::SecretKey'
Oct 4, 2024
ea80694
[sign/generic] Add 'PublicKey'
Oct 7, 2024
7c94006
[sign] Rewrite the 'ring' module to use the 'Sign' trait
Oct 7, 2024
f9564c1
Implement DNSSEC signing with OpenSSL
Oct 9, 2024
c705428
[sign/openssl] Implement key generation
Oct 9, 2024
68476e7
[sign/openssl] Test key generation and import/export
Oct 9, 2024
b68b639
[sign/openssl] Add support for ECDSA
Oct 9, 2024
79b2a08
[sign/openssl] satisfy clippy
Oct 9, 2024
1aeeede
[sign/openssl] Implement the 'Sign' trait
Oct 9, 2024
90af63d
Install OpenSSL in CI builds
Oct 9, 2024
6370035
Ensure 'openssl' dep supports 3.x.x
Oct 9, 2024
d53f85a
[workflows/ci] Use 'vcpkg' instead of vendoring OpenSSL
Oct 9, 2024
5148bd3
Ensure 'openssl' dep exposes necessary interfaces
Oct 9, 2024
13bebd7
[workflows/ci] Record location of 'vcpkg'
Oct 9, 2024
c86f234
[workflows/ci] Use a YAML def for 'VCPKG_ROOT'
Oct 9, 2024
8939603
[workflows/ci] Fix a vcpkg triplet to use
Oct 9, 2024
9ed1f44
Upgrade openssl to 0.10.57 for bitflags 2.x
Oct 9, 2024
24b443c
[workflows/ci] Use dynamic linking for vcpkg openssl
Oct 9, 2024
d3a071d
[workflows/ci] Correctly annotate 'vcpkg'
Oct 9, 2024
669da93
[sign/openssl] Implement exporting public keys
Oct 9, 2024
8a0c59a
[sign/ring] Implement exporting public keys
Oct 9, 2024
7c6cde1
[sign/generic] Test (de)serialization for generic secret keys
Oct 9, 2024
d6a5313
[sign] Thoroughly test import/export in both backends
Oct 9, 2024
8321bbf
[sign] Remove debugging code and satisfy clippy
Oct 9, 2024
db6820e
[sign] Account for CR LF in tests
Oct 9, 2024
e7f9709
[sign/openssl] Fix bugs in the signing procedure
Oct 11, 2024
2663093
Initial NSEC3 generation support. Lacks collision detection and tests.
ximon18 Oct 15, 2024
bd31ebb
Clippy.
ximon18 Oct 15, 2024
bbf110f
TOOD -> TODO ;-)
ximon18 Oct 15, 2024
fbfbdea
Fix doctest failure.
ximon18 Oct 15, 2024
dba5a8a
Refactor the 'sign' module
Oct 15, 2024
b494f3c
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 15, 2024
25402ed
[sign] Define 'KeyPair' and impl key export
Oct 2, 2024
a62139a
[sign] Define trait 'Sign'
Oct 2, 2024
a4f2056
[sign] Implement parsing from the DNS format
Oct 2, 2024
f00a9ac
[sign] Provide some error information
Oct 2, 2024
6535747
[sign] Move 'KeyPair' to 'generic::SecretKey'
Oct 4, 2024
69e5066
[sign/generic] Add 'PublicKey'
Oct 7, 2024
3c80b2f
[sign] Rewrite the 'ring' module to use the 'Sign' trait
Oct 7, 2024
eace7b6
Implement DNSSEC signing with OpenSSL
Oct 9, 2024
c698403
[sign/openssl] Implement key generation
Oct 9, 2024
89dfdfc
[sign/openssl] Test key generation and import/export
Oct 9, 2024
4d912fb
[sign/openssl] Add support for ECDSA
Oct 9, 2024
24f6043
[sign/openssl] satisfy clippy
Oct 9, 2024
1b5d640
[sign/openssl] Implement the 'Sign' trait
Oct 9, 2024
fbafbf0
Install OpenSSL in CI builds
Oct 9, 2024
3358747
Ensure 'openssl' dep supports 3.x.x
Oct 9, 2024
e26b68d
[workflows/ci] Use 'vcpkg' instead of vendoring OpenSSL
Oct 9, 2024
c1f3178
Ensure 'openssl' dep exposes necessary interfaces
Oct 9, 2024
9c4f7b4
[workflows/ci] Record location of 'vcpkg'
Oct 9, 2024
2cae3cc
[workflows/ci] Use a YAML def for 'VCPKG_ROOT'
Oct 9, 2024
9ed98ed
[workflows/ci] Fix a vcpkg triplet to use
Oct 9, 2024
a1a5a0b
Upgrade openssl to 0.10.57 for bitflags 2.x
Oct 9, 2024
0b85a4f
[workflows/ci] Use dynamic linking for vcpkg openssl
Oct 9, 2024
e6bf6d9
[workflows/ci] Correctly annotate 'vcpkg'
Oct 9, 2024
2ab7178
[sign/openssl] Implement exporting public keys
Oct 9, 2024
d8c9b5f
[sign/ring] Implement exporting public keys
Oct 9, 2024
90ed936
[sign/generic] Test (de)serialization for generic secret keys
Oct 9, 2024
fff9595
[sign] Thoroughly test import/export in both backends
Oct 9, 2024
4c6aa4d
[sign] Remove debugging code and satisfy clippy
Oct 9, 2024
fe29593
[sign] Account for CR LF in tests
Oct 9, 2024
8536c4c
[sign/openssl] Fix bugs in the signing procedure
Oct 11, 2024
07b52ce
Refactor the 'sign' module
Oct 15, 2024
c419297
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 15, 2024
48c006c
[sign] Define 'KeyPair' and impl key export
Oct 2, 2024
66c8f4a
[sign] Define trait 'Sign'
Oct 2, 2024
b613705
[sign] Implement parsing from the DNS format
Oct 2, 2024
5e86496
[sign] Provide some error information
Oct 2, 2024
c33f6f6
[sign] Move 'KeyPair' to 'generic::SecretKey'
Oct 4, 2024
d2d0646
[sign/generic] Add 'PublicKey'
Oct 7, 2024
6dae3a1
[sign] Rewrite the 'ring' module to use the 'Sign' trait
Oct 7, 2024
4fccf7f
Implement DNSSEC signing with OpenSSL
Oct 9, 2024
0ae002f
[sign/openssl] Implement key generation
Oct 9, 2024
157a3b9
[sign/openssl] Test key generation and import/export
Oct 9, 2024
0a6e992
[sign/openssl] Add support for ECDSA
Oct 9, 2024
3a5d55b
[sign/openssl] satisfy clippy
Oct 9, 2024
a2d64b4
[sign/openssl] Implement the 'Sign' trait
Oct 9, 2024
ad69e1f
Install OpenSSL in CI builds
Oct 9, 2024
46f3f7f
Ensure 'openssl' dep supports 3.x.x
Oct 9, 2024
23ea439
[workflows/ci] Use 'vcpkg' instead of vendoring OpenSSL
Oct 9, 2024
b9fe3cb
Ensure 'openssl' dep exposes necessary interfaces
Oct 9, 2024
2469a78
[workflows/ci] Record location of 'vcpkg'
Oct 9, 2024
30951e8
[workflows/ci] Use a YAML def for 'VCPKG_ROOT'
Oct 9, 2024
174f0f4
[workflows/ci] Fix a vcpkg triplet to use
Oct 9, 2024
6add5c7
Upgrade openssl to 0.10.57 for bitflags 2.x
Oct 9, 2024
9395e44
[workflows/ci] Use dynamic linking for vcpkg openssl
Oct 9, 2024
67987c8
[workflows/ci] Correctly annotate 'vcpkg'
Oct 9, 2024
d4c6bdf
[sign/openssl] Implement exporting public keys
Oct 9, 2024
18d9a7d
[sign/ring] Implement exporting public keys
Oct 9, 2024
792cb9f
[sign/generic] Test (de)serialization for generic secret keys
Oct 9, 2024
306429b
[sign] Thoroughly test import/export in both backends
Oct 9, 2024
0c3fb8b
[sign] Remove debugging code and satisfy clippy
Oct 9, 2024
e2bb31d
[sign] Account for CR LF in tests
Oct 9, 2024
9820be2
[sign/openssl] Fix bugs in the signing procedure
Oct 11, 2024
94541da
Refactor the 'sign' module
Oct 15, 2024
c56b3fe
Move 'sign' and 'validate' to unstable feature gates
Oct 16, 2024
b2f0bbb
[workflows/ci] Document the vcpkg env vars
Oct 16, 2024
bbc3fb1
Rename public/secret key interfaces to '*Raw*'
Oct 16, 2024
1fc5309
[sign/ring] Store the RNG in an 'Arc'
Oct 16, 2024
2556e2a
[validate] Enhance 'Signature' API
Oct 16, 2024
b3b3f01
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 16, 2024
8086b45
[validate] Add high-level 'Key' type
Oct 16, 2024
ba774bb
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 16, 2024
6388387
[sign/openssl] Pad ECDSA keys when exporting
Oct 16, 2024
b2cfa7b
[validate] Implement 'Key::key_tag()'
Oct 16, 2024
e0344a6
[validate] Correct bit offsets for flags
Oct 16, 2024
f65c5cc
[validate] Implement support for digests
Oct 16, 2024
a0c2e4f
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 17, 2024
735712c
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 28, 2024
4447cc6
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 29, 2024
d84e2c0
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 29, 2024
02c625b
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Oct 29, 2024
8bf2c9f
Move nsec3_hash() back into the validator module per review feedback.
ximon18 Oct 30, 2024
beb8e52
Move nsec3_hash() to the validate (not validator!) module per review …
ximon18 Oct 30, 2024
a04c917
Extend test file with records useful for manual testing of NSEC3.
ximon18 Oct 28, 2024
abaab27
Revert "Extend test file with records useful for manual testing of NS…
ximon18 Oct 31, 2024
3c53e9e
Review feedback.
ximon18 Oct 31, 2024
50433f0
Review feedback.
ximon18 Oct 31, 2024
70e998a
Review feedback inspired change (though not actually what was suggest…
ximon18 Oct 31, 2024
9268dd3
Display NSEC3 without trailing space if the bitmap is empty.
ximon18 Nov 4, 2024
fb7e9ef
Backport NSEC3 improvements and upstream dnssec-key branch compatibil…
ximon18 Nov 4, 2024
414ea6c
[sign,validate] Add 'display_as_bind()' to key bytes types
Oct 30, 2024
2bde7aa
[sign,validate] remove unused imports
Oct 30, 2024
98db88b
[sign] Document everything
Oct 31, 2024
8877c22
Update to work with changes in the upstream dnssec-key branch using a…
ximon18 Nov 4, 2024
40d65ac
Minor tweaks.
ximon18 Nov 4, 2024
c0fc11b
Merge branch 'dnssec-key' into initial-nsec3-generation
ximon18 Nov 4, 2024
bdeddde
Add some Arbitrary impls to support cargo-fuzz based fuzz testing.
ximon18 Nov 6, 2024
f2cabc3
Impl Display for Nsec3HashError.
ximon18 Nov 6, 2024
109370d
Cargo fmt.
ximon18 Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ name = "domain"
path = "src/lib.rs"

[dependencies]
arbitrary = { version = "1.4.1", optional = true, features = ["derive"] }
octseq = { version = "0.5.2", default-features = false }
time = { version = "0.3.1", default-features = false }
rand = { version = "0.8", optional = true }
Expand Down
1 change: 1 addition & 0 deletions src/base/iana/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ macro_rules! int_enum {
$value:expr, $mnemonic:expr) )* ) => {
$(#[$attr])*
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct $ianatype($inttype);

impl $ianatype {
Expand Down
1 change: 1 addition & 0 deletions src/base/name/absolute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use std::vec::Vec;
/// [`Display`]: std::fmt::Display
#[derive(Clone)]
#[repr(transparent)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Name<Octs: ?Sized>(Octs);

impl Name<()> {
Expand Down
5 changes: 5 additions & 0 deletions src/rdata/dnssec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2169,6 +2169,11 @@ impl<Octs: AsRef<[u8]>> RtypeBitmap<Octs> {
) -> Result<(), Target::AppendError> {
target.append_slice(self.0.as_ref())
}

#[must_use]
pub fn is_empty(&self) -> bool {
self.iter().next().is_none()
}
}

//--- AsRef
Expand Down
43 changes: 42 additions & 1 deletion src/rdata/nsec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl<Octs> Nsec3<Octs> {
&self.next_owner
}

pub fn set_next_owner(&mut self, next_owner: OwnerHash<Octs>) {
self.next_owner = next_owner;
}

pub fn types(&self) -> &RtypeBitmap<Octs> {
&self.types
}
Expand Down Expand Up @@ -354,7 +358,10 @@ impl<Octs: AsRef<[u8]>> fmt::Display for Nsec3<Octs> {
self.hash_algorithm, self.flags, self.iterations, self.salt
)?;
base32::display_hex(&self.next_owner, f)?;
write!(f, " {}", self.types)
if !self.types.is_empty() {
write!(f, " {}", self.types)?;
}
Ok(())
}
}

Expand Down Expand Up @@ -453,6 +460,10 @@ impl<Octs> Nsec3param<Octs> {
&self.salt
}

pub fn into_salt(self) -> Nsec3Salt<Octs> {
self.salt
}

pub(super) fn convert_octets<Target>(
self,
) -> Result<Nsec3param<Target>, Target::Error>
Expand Down Expand Up @@ -496,6 +507,35 @@ impl<Octs> Nsec3param<Octs> {
}
}

//--- Default

impl<Octs> Default for Nsec3param<Octs>
where
Octs: From<&'static [u8]>,
{
/// Best practice default values for NSEC3 hashing.
///
/// Per [RFC 9276] section 3.1:
///
/// - _SHA-1, no extra iterations, empty salt._
///
/// Per [RFC 5155] section 4.1.2:
///
/// - _The Opt-Out flag is not used and is set to zero._
/// - _All other flags are reserved for future use, and must be zero._
///
/// [RFC 5155]: https://www.rfc-editor.org/rfc/rfc5155.html
/// [RFC 9276]: https://www.rfc-editor.org/rfc/rfc9276.html
fn default() -> Self {
Self {
hash_algorithm: Nsec3HashAlg::SHA1,
flags: 0,
iterations: 0,
salt: Nsec3Salt::empty(),
}
}
}

//--- OctetsFrom

impl<Octs, SrcOcts> OctetsFrom<Nsec3param<SrcOcts>> for Nsec3param<Octs>
Expand Down Expand Up @@ -712,6 +752,7 @@ impl<Octs: AsRef<[u8]>> ZonefileFmt for Nsec3param<Octs> {
/// no whitespace allowed.
#[derive(Clone)]
#[repr(transparent)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Nsec3Salt<Octs: ?Sized>(Octs);

impl Nsec3Salt<()> {
Expand Down
1 change: 1 addition & 0 deletions src/sign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub use self::bytes::{RsaSecretKeyBytes, SecretKeyBytes};

pub mod common;
pub mod openssl;
pub mod records;
pub mod ring;

//----------- SigningKey -----------------------------------------------------
Expand Down
Loading
Loading