Skip to content

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