diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 2c44e79f43..eb5a1ee94f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -1874,8 +1874,11 @@ public class FragmentCompose extends FragmentBase { } else if (OpenPgpApi.ACTION_DETACHED_SIGN.equals(data.getAction())) { name = "signature.asc"; encryption = EntityAttachment.PGP_SIGNATURE; + String micalg = result.getStringExtra(OpenPgpApi.RESULT_SIGNATURE_MICALG); + if (TextUtils.isEmpty(micalg)) + throw new IllegalArgumentException("micalg missing"); ct = new ContentType("application/pgp-signature"); - ct.setParameter("micalg", result.getStringExtra(OpenPgpApi.RESULT_SIGNATURE_MICALG)); + ct.setParameter("micalg", micalg); } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) { name = "encrypted.asc"; encryption = EntityAttachment.PGP_MESSAGE; diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 016cae36bb..1962ae874b 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -297,8 +297,11 @@ public class MessageHelper { final ContentType cts = new ContentType(attachment.type); String micalg = cts.getParameter("micalg"); + if (TextUtils.isEmpty(micalg)) + Log.e("PGP micalg missing"); ParameterList params = cts.getParameterList(); - params.remove("micalg"); + if (params != null) + params.remove("micalg"); cts.setParameterList(params); // Build signature @@ -378,8 +381,13 @@ public class MessageHelper { final ContentType cts = new ContentType(attachment.type); String micalg = cts.getParameter("micalg"); + if (TextUtils.isEmpty(micalg)) { + Log.e("S/MIME micalg missing"); + micalg = "sha-256"; + } ParameterList params = cts.getParameterList(); - params.remove("micalg"); + if (params != null) + params.remove("micalg"); cts.setParameterList(params); // Build signature