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

The great rename plus cleanup. #488

Merged
merged 56 commits into from
Mar 31, 2025

Conversation

Philip-NLnetLabs
Copy link
Member

@Philip-NLnetLabs Philip-NLnetLabs commented Feb 5, 2025

Move DNSSEC modules around. This PR removes the validate module. The validate module becomes dnssec::validator::base.

Remove apex_owner from sign_rrset_in.

Move DNSKEY generation and signing to the application.

@Philip-NLnetLabs Philip-NLnetLabs marked this pull request as draft February 5, 2025 16:18
@Philip-NLnetLabs Philip-NLnetLabs changed the title The great rename. The great rename plus cleanup. Feb 6, 2025

impl std::error::Error for FromBytesError {}

//----------- GenerateError --------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like GenerateError (excluding the conversion impl below) is the same for openssl and ring - would it be an idea to move it into common?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, if more crypto implementations are added, they could potentially bring new kinds of generation errors here (e.g. HSM I/O error? IDK). It makes sense to me to avoid unifying them and requiring a single generation error type across all implementations, unless we have a clearer perspective on how future crypto implementations might operate.

Ok(n.len() * 8 - n[0].leading_zeros() as usize)
}
SecAlg::ECDSAP256SHA256 | SecAlg::ECDSAP384SHA384 => {
// ECDSA public keys have two points.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code said that ECDSA public keys have a marker byte as well and subtracted one from the len to account for this. Is that no longer the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ring and openssl that have the marker byte and DNSKEY doesn't.

Copy link
Contributor

@bal-e bal-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed everything yet, but I'm pretty happy with it overall.

Comment on lines 99 to 118
/// A message digest.
pub enum Digest {
#[cfg(feature = "ring")]
/// A message digest computed using ring.
Ring(ring::Digest),
#[cfg(feature = "openssl")]
/// A message digest computed using openssl.
Openssl(openssl::Digest),
}

impl AsRef<[u8]> for Digest {
fn as_ref(&self) -> &[u8] {
match self {
#[cfg(feature = "ring")]
Digest::Ring(digest) => digest.as_ref(),
#[cfg(feature = "openssl")]
Digest::Openssl(digest) => digest.as_ref(),
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that Digest needs to be an enum over all the cryptographic backends. At the end of the day, it's just a (DigestType, Vec<u8>), right? Perhaps we should define it that way for simplicity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that that would require an extra Vec. No it just gets AsRef from the underlying ring or openssl type.

key.extend(&exp_len.to_be_bytes());
} else {
unreachable!(
"RSA exponents are (much) shorter than 64KiB"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I had originally written this in a call to .expect(). It should be rephrased now (and can in fact include the detected length in the error message).


impl std::error::Error for FromBytesError {}

//----------- GenerateError --------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, if more crypto implementations are added, they could potentially bring new kinds of generation errors here (e.g. HSM I/O error? IDK). It makes sense to me to avoid unifying them and requiring a single generation error type across all implementations, unless we have a clearer perspective on how future crypto implementations might operate.

@Philip-NLnetLabs Philip-NLnetLabs merged commit 5562faa into initial-nsec3-generation Mar 31, 2025
17 checks passed
@Philip-NLnetLabs Philip-NLnetLabs deleted the dnssec-restructure branch March 31, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants