Skip to content

Fix ed25519 key comparison in dkim_test_key #245

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jcastle-gh
Copy link

@jcastle-gh jcastle-gh commented Mar 15, 2025

dkim_test_key() compares a public DKIM key retrieved from DNS with the public key generated by i2d_PUBKEY_BIO() from a known private key. The output of i2d_PUBKEY_BIO is in SubjectPublicKey ASN encoded format.

That works for RSA where the key in DNS is also in that format but for ed25519 the key in DNS is the DER encoded key by itself. The difference boils down to a 12-byte constant ASN prefix in the i2d_PUBKEY_BIO() output that is not in the DNS version.

Fix it by verifying that the i2d_PUBKEY_BIO() output for ed25519 keys has the expected 12-byte prefix and then comparing what's left to the key from DNS.

dkim_test_key() compares a public DKIM key retrieved from DNS with the
public key generated by i2d_PKEY_BIO() from a known private key. The
output of i2d_PKEY_BIO is in SubjectPublicKey ASN encoded format.

That works for RSA where the key in DNS is also in that format but for
ed25519 the key in DNS is the DER encoded key by itself. The difference
boils down to a 12-byte constant ASN prefix in the i2d_PKEY_BIO()
output that is not in the DNS version.

Fix it by verifying that the i2d_PKEY_BIO() output for ed25519 keys has
the expected 12-byte prefix and then comparing what's left to the key
from DNS.
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.

1 participant