Repository navigation
Refuse to sign with RSA keys of sizes the RFCs rule out - #194
Merged
Merged
Conversation
RFC 3110 and RFC 5702 have an RSA modulus 512 to 4096 bits long, or 1024
to 4096 for RSA/SHA-512, and an exponent of at most 4096 bits. A DNSKEY
with any other key is refused when loaded and verifies nothing, but
signing still signed with one, making RRSIGs no DNSKEY verifying them
could be published for.
Signing with an RSA key now lays out its public half as
dnskey_public_key/2 does, as signing with a DSA key already did, and
raises {badarg, {rsa_modulus_bits, Bits}} or
{badarg, {rsa_exponent_bits, Bits}}, and {badarg, key_shape} for a key
of other than [E, N, D] or those and the CRT's five, where crypto raised
its own errors. None holds the key.
The test that a 768-bit RSA/SHA-512 key verifies nothing has crypto sign
over signed data built by hand, as signing refuses that key.
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
RFC 3110 §3 and RFC 5702 §2 have an RSA modulus 512 to 4096 bits long, or 1024 to 4096 for RSA/SHA-512, and RFC 3110 §2 an exponent of at most 4096 bits. In 6.0.0, a DNSKEY with any other key is refused when loaded,
verify_rrsig/4verifies nothing with it, anddnskey_public_key/2lays out none for it, but signing still signed with it, making RRSIGs no DNSKEY verifying them could be published for.Signing with an RSA key now lays out its public half as
dnskey_public_key/2does, as signing with a DSA key already did, and raises what that raises:{badarg, {rsa_modulus_bits, 4104}}{badarg, {rsa_modulus_bits, 1016}}[E, N, D]or those and the CRT's five{badarg, {"pkey.c", 506}, "Couldn't get RSA private key"}or{error, {"pkey.c", 884}, "Can't EVP_PKEY_sign"}{badarg, key_shape}erldns signs with the 8 numbers its zone decoder takes from a PEM key, which sign as before.
sign_rrset/6's docs now list these errors, and none of them, nor its stacktrace, holds the key, as crypto's did not either.Tests:
sign_with_rsa_key_rfcs_rule_out_raisessigns with keys of 512, 1016 and 1024 bits where the RFCs allow them, the same with the CRT's numbers as without, and refuses 4104 bits for every RSA algorithm and 1016 for RSA/SHA-512, exactly wherednskey_public_key/2refuses them; and it refuses seven key shapes without the key in the error or the stacktrace.rsa_key_rfc3110_rules_out_verifies_nothingsigned with a 768-bit key for RSA/SHA-512 to see that it verifies nothing; crypto signs that over signed data built by hand now. Taking out the size check or the shape check makes the new test fail.Part of #169 (S3). DSA keys were already held to RFC 2536 when signing.