Add private key file parsing and generation #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
RSASHA1-NSEC3-SHA1
,RSAMD5
, andDSA-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 longformat!()
version and using a bunch ofString::push_str()
, but found this easier to read when formatted withrustfmt
.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.