From 82253119fc12055f303bd7f7c986fc2f40554b7b Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 2 Aug 2023 19:08:39 +0200 Subject: [PATCH] Added Ed25519 DKIM support --- app/src/main/java/eu/faircode/email/MessageHelper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 6586784dfd..962c3813f5 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -2304,8 +2304,10 @@ public class MessageHelper { } else if ("rsa-sha256".equals(a)) { halgo = "SHA-256"; salgo = "SHA256withRSA"; + } else if ("ed25519-sha256".equals(a)) { + halgo = "SHA-256"; + salgo = "Ed25519"; } else { - // TODO: Ed25519 Log.i("DKIM a=" + a); return null; } @@ -2448,7 +2450,7 @@ public class MessageHelper { Log.i("DKIM pubkey=" + p); X509EncodedKeySpec pubKeySpec = new X509EncodedKeySpec(Base64.decode(p, Base64.DEFAULT)); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + KeyFactory keyFactory = KeyFactory.getInstance("Ed25519".equals(salgo) ? "Ed25519" : "RSA"); PublicKey pubKey = keyFactory.generatePublic(pubKeySpec); Signature sig = Signature.getInstance(salgo); // a=