From a9e635b997d5bddf4327dbb04aa1c82cc795c226 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 18 Sep 2021 13:15:47 +0200 Subject: [PATCH] Fixed S/MIME canonicalization --- CHANGELOG.md | 3 ++- app/build.gradle | 2 +- app/src/main/java/eu/faircode/email/MessageHelper.java | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54e7e2186d..5105709273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,11 @@ ### [Yaverlandia](https://en.wikipedia.org/wiki/Yaverlandia) -### 1.1726b +### 1.1726c * Following dark/light theme for original message view * Added message menu item / optional button to force light theme for original message view +* Fixed verifying some S/MIME signatures ### 1.1726 diff --git a/app/build.gradle b/app/build.gradle index 46a9945cc0..8ce6166ad5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'kotlin-android' apply plugin: 'de.undercouch.download' def getVersionCode = { -> return 1726 } -def getRevision = { -> "\"c\"" } +def getRevision = { -> "\"d\"" } def getReleaseName = { -> return "\"Yaverlandia\"" } // https://en.wikipedia.org/wiki/List_of_dinosaur_genera diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 824bb01dfe..d31b35c81f 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -2333,9 +2333,13 @@ public class MessageHelper { if (parts.length < 2) throw new ParseException("Signed part missing"); + // PGP: https://datatracker.ietf.org/doc/html/rfc3156#section-5 + // S/MIME: https://datatracker.ietf.org/doc/html/rfc8551#section-3.1.1 String c = parts[1] - .replaceAll(" +$", "") // trim trailing spaces .replaceAll("\\r?\\n", "\r\n"); // normalize new lines + if (EntityAttachment.PGP_CONTENT.equals(apart.encrypt)) + c = c.replaceAll(" +$", ""); // trim trailing spaces + try (OutputStream os = new FileOutputStream(file)) { os.write(c.getBytes()); }