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

Add private key file parsing and generation #5

Closed
wants to merge 6 commits into from

Conversation

mozzieongit
Copy link
Member

I've implemented parsing and generating the private key file format used to store the private key components for dnssec/tsig keys in the format used by bind and nsd.
The ...KeyData structs are (potentially) temporary data stores for the needed key components, until it's clear where and how these functions will get integrated.
I tested the parsing and generation together by reading/parsing test key files (generated with ldns) and comparing the output of the generate function (with the data of the just parsed file) to the original key files.

Known quirks:

  • The human readable algorithm "comment" in the private key files differs from ldns in the cases of RSASHA1-NSEC3-SHA1, RSAMD5, and DSA-NSEC3-SHA1, because ldns doesn't use the iana provided mnemonic/name but slightly different ones (RSASHA1_NSEC3, RSA, DSA_NSEC3)

In gen_private_key_file_text() I tried both the long format!() version and using a bunch of String::push_str(), but found this easier to read when formatted with rustfmt.
I didn't find a formal definition of the Private-key-format, so I created one in ABNF (comment in parse_private_key_file()) mostly for fun, but might also be something useful in the future? (Can of course be put somewhere else or removed entirely)

This code doesn't have to be put in dnst, but I wanted to create a PR so that we can track its existence.

Also feel free to nit pick my use of Rust.

Copy link
Member

@partim partim left a comment

Choose a reason for hiding this comment

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

This is just a quick review before I’m leaving.

src/utils/private_key_file_parser.rs Outdated Show resolved Hide resolved
src/utils/private_key_file_parser.rs Outdated Show resolved Hide resolved
src/utils/private_key_file_parser.rs Outdated Show resolved Hide resolved
src/utils/private_key_file_parser.rs Outdated Show resolved Hide resolved
@ximon18 ximon18 closed this Nov 5, 2024
@ximon18
Copy link
Member

ximon18 commented Nov 5, 2024

See PR #9 and NLnetLabs/domain#406 instead.

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