fastmail / mail-dkim

Mail::DKIM Perl module, forked from svn://svn.code.sf.net/p/dkimproxy/code/Mail-DKIM/trunk
8 stars 6 forks source link

Add support for Ed25519 #18

Closed mwander closed 1 year ago

mwander commented 1 year ago

This PR adds support for Ed25519 (closes #9). Depends on Crypt::PK::Ed25519. Added test cases for signing and verification.

Most code has been added to PrivateKey.pm and PublicKey.pm. The ed25519_sha256.pm subclass is basically identical to rsa_sha256pm. I tried to retain existing logic wherever possible, but it was necessary to branch between 'rsa' and 'ed25519' code in serveral locations. Please review carefully.

marcbradshaw commented 1 year ago

@mwander Thanks for this, I have refactored a few places to make the flow clearer, but looks good.

Note: some consumers of this module may assume a RSA key object is returned by $signature->get_public_key(), and the new key type differs. For example, when querying the key size the class for Ed25519 keys doesn't have a size method, which can result in confusing results, or worst case a runtime error.

dkim=pass (0-bit  key sha256) header.d=wander.science
  header.i=@wander.science header.b=85mI8hH/ header.a=-sha256
  header.s=2023-05-ed25519 x-bits=0;

This is something folks will need to consider when upgrading to this version.