|
|
@ -1638,6 +1638,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
if (!ActivityBilling.isPro(context) &&
|
|
|
|
if (!ActivityBilling.isPro(context) &&
|
|
|
|
(EntityMessage.SMIME_SIGNONLY.equals(draft.ui_encrypt) ||
|
|
|
|
(EntityMessage.SMIME_SIGNONLY.equals(draft.ui_encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_ENCRYPTONLY.equals(draft.ui_encrypt) ||
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt)))
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt)))
|
|
|
|
draft.ui_encrypt = null;
|
|
|
|
draft.ui_encrypt = null;
|
|
|
|
|
|
|
|
|
|
|
@ -2134,10 +2135,12 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
tv.setText(EntityMessage.PGP_SIGNONLY.equals(encrypt) ? "P" : "S");
|
|
|
|
tv.setText(EntityMessage.PGP_SIGNONLY.equals(encrypt) ? "P" : "S");
|
|
|
|
} else if (EntityMessage.PGP_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
} else if (EntityMessage.PGP_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) ||
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt)) {
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt)) {
|
|
|
|
ibEncrypt.setImageResource(R.drawable.twotone_lock_24);
|
|
|
|
ibEncrypt.setImageResource(R.drawable.twotone_lock_24);
|
|
|
|
ibEncrypt.setImageTintList(ColorStateList.valueOf(colorEncrypt));
|
|
|
|
ibEncrypt.setImageTintList(ColorStateList.valueOf(colorEncrypt));
|
|
|
|
tv.setText(EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt) ? "S" : "P");
|
|
|
|
tv.setText(EntityMessage.SMIME_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt) ? "S" : "P");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ibEncrypt.setImageResource(R.drawable.twotone_lock_open_24);
|
|
|
|
ibEncrypt.setImageResource(R.drawable.twotone_lock_open_24);
|
|
|
|
ibEncrypt.setImageTintList(ColorStateList.valueOf(colorActionForeground));
|
|
|
|
ibEncrypt.setImageTintList(ColorStateList.valueOf(colorActionForeground));
|
|
|
@ -2177,6 +2180,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_send).setTitle(R.string.title_sign);
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_send).setTitle(R.string.title_sign);
|
|
|
|
else if (EntityMessage.PGP_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
else if (EntityMessage.PGP_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) ||
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt))
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt))
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_send).setTitle(R.string.title_encrypt);
|
|
|
|
bottom_navigation.getMenu().findItem(R.id.action_send).setTitle(R.string.title_encrypt);
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -2313,7 +2317,8 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (EntityMessage.ENCRYPT_NONE.equals(encrypt) || encrypt == null)
|
|
|
|
if (EntityMessage.ENCRYPT_NONE.equals(encrypt) || encrypt == null)
|
|
|
|
encrypt = EntityMessage.SMIME_SIGNENCRYPT;
|
|
|
|
encrypt = EntityMessage.SMIME_SIGNENCRYPT;
|
|
|
|
else if (EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt))
|
|
|
|
else if (EntityMessage.SMIME_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt))
|
|
|
|
encrypt = EntityMessage.SMIME_SIGNONLY;
|
|
|
|
encrypt = EntityMessage.SMIME_SIGNONLY;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
encrypt = EntityMessage.ENCRYPT_NONE;
|
|
|
|
encrypt = EntityMessage.ENCRYPT_NONE;
|
|
|
@ -3198,6 +3203,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
private void onEncrypt(final EntityMessage draft, final int action, final Bundle extras, final boolean interactive) {
|
|
|
|
private void onEncrypt(final EntityMessage draft, final int action, final Bundle extras, final boolean interactive) {
|
|
|
|
if (EntityMessage.SMIME_SIGNONLY.equals(draft.ui_encrypt) ||
|
|
|
|
if (EntityMessage.SMIME_SIGNONLY.equals(draft.ui_encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_ENCRYPTONLY.equals(draft.ui_encrypt) ||
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt)) {
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt)) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", draft.id);
|
|
|
|
args.putLong("id", draft.id);
|
|
|
@ -4470,6 +4476,9 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
bpContent.writeTo(fos);
|
|
|
|
bpContent.writeTo(fos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String signAlgorithm = null;
|
|
|
|
|
|
|
|
byte[] signedMessage = null;
|
|
|
|
|
|
|
|
if (!EntityMessage.SMIME_ENCRYPTONLY.equals(type)) {
|
|
|
|
if (EntityMessage.SMIME_SIGNONLY.equals(type)) {
|
|
|
|
if (EntityMessage.SMIME_SIGNONLY.equals(type)) {
|
|
|
|
EntityAttachment cattachment = new EntityAttachment();
|
|
|
|
EntityAttachment cattachment = new EntityAttachment();
|
|
|
|
cattachment.message = draft.id;
|
|
|
|
cattachment.message = draft.id;
|
|
|
@ -4491,7 +4500,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
CMSSignedDataGenerator cmsGenerator = new CMSSignedDataGenerator();
|
|
|
|
CMSSignedDataGenerator cmsGenerator = new CMSSignedDataGenerator();
|
|
|
|
cmsGenerator.addCertificates(store);
|
|
|
|
cmsGenerator.addCertificates(store);
|
|
|
|
|
|
|
|
|
|
|
|
String signAlgorithm = prefs.getString("sign_algo_smime", "SHA-256");
|
|
|
|
signAlgorithm = prefs.getString("sign_algo_smime", "SHA-256");
|
|
|
|
|
|
|
|
|
|
|
|
String algorithm = privkey.getAlgorithm();
|
|
|
|
String algorithm = privkey.getAlgorithm();
|
|
|
|
|
|
|
|
|
|
|
@ -4513,7 +4522,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
CMSTypedData cmsData = new CMSProcessableFile(sinput);
|
|
|
|
CMSTypedData cmsData = new CMSProcessableFile(sinput);
|
|
|
|
CMSSignedData cmsSignedData = cmsGenerator.generate(cmsData);
|
|
|
|
CMSSignedData cmsSignedData = cmsGenerator.generate(cmsData);
|
|
|
|
byte[] signedMessage = cmsSignedData.getEncoded();
|
|
|
|
signedMessage = cmsSignedData.getEncoded();
|
|
|
|
|
|
|
|
|
|
|
|
Helper.secureDelete(sinput);
|
|
|
|
Helper.secureDelete(sinput);
|
|
|
|
|
|
|
|
|
|
|
@ -4540,6 +4549,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<Address> addresses = new ArrayList<>();
|
|
|
|
List<Address> addresses = new ArrayList<>();
|
|
|
|
if (draft.to != null)
|
|
|
|
if (draft.to != null)
|
|
|
@ -4588,6 +4598,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
if (own && SmimeHelper.match(privkey, chain[0]))
|
|
|
|
if (own && SmimeHelper.match(privkey, chain[0]))
|
|
|
|
certs.add(chain[0]);
|
|
|
|
certs.add(chain[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!EntityMessage.SMIME_ENCRYPTONLY.equals(type)) {
|
|
|
|
// Build signature
|
|
|
|
// Build signature
|
|
|
|
BodyPart bpSignature = new MimeBodyPart();
|
|
|
|
BodyPart bpSignature = new MimeBodyPart();
|
|
|
|
bpSignature.setFileName("smime.p7s");
|
|
|
|
bpSignature.setFileName("smime.p7s");
|
|
|
@ -4606,6 +4617,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
multipart.addBodyPart(bpSignature);
|
|
|
|
multipart.addBodyPart(bpSignature);
|
|
|
|
imessage.setContent(multipart);
|
|
|
|
imessage.setContent(multipart);
|
|
|
|
imessage.saveChanges();
|
|
|
|
imessage.saveChanges();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Encrypt
|
|
|
|
// Encrypt
|
|
|
|
CMSEnvelopedDataGenerator cmsEnvelopedDataGenerator = new CMSEnvelopedDataGenerator();
|
|
|
|
CMSEnvelopedDataGenerator cmsEnvelopedDataGenerator = new CMSEnvelopedDataGenerator();
|
|
|
@ -5218,7 +5230,8 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
if (!saved && isEmpty())
|
|
|
|
if (!saved && isEmpty())
|
|
|
|
onAction(R.id.action_delete, "empty");
|
|
|
|
onAction(R.id.action_delete, "empty");
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
boolean finish = EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt) ||
|
|
|
|
boolean finish = EntityMessage.SMIME_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(encrypt) ||
|
|
|
|
EntityMessage.PGP_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
EntityMessage.PGP_ENCRYPTONLY.equals(encrypt) ||
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(encrypt);
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(encrypt);
|
|
|
|
|
|
|
|
|
|
|
@ -7236,7 +7249,8 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
if (!eparts.contains(EntityAttachment.SMIME_SIGNATURE) ||
|
|
|
|
if (!eparts.contains(EntityAttachment.SMIME_SIGNATURE) ||
|
|
|
|
!eparts.contains(EntityAttachment.SMIME_CONTENT))
|
|
|
|
!eparts.contains(EntityAttachment.SMIME_CONTENT))
|
|
|
|
dirty = true;
|
|
|
|
dirty = true;
|
|
|
|
} else if (EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt)) {
|
|
|
|
} else if (EntityMessage.SMIME_ENCRYPTONLY.equals(draft.ui_encrypt) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt)) {
|
|
|
|
if (!eparts.contains(EntityAttachment.SMIME_MESSAGE))
|
|
|
|
if (!eparts.contains(EntityAttachment.SMIME_MESSAGE))
|
|
|
|
dirty = true;
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -7451,6 +7465,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
boolean shouldEncrypt = EntityMessage.PGP_ENCRYPTONLY.equals(draft.ui_encrypt) ||
|
|
|
|
boolean shouldEncrypt = EntityMessage.PGP_ENCRYPTONLY.equals(draft.ui_encrypt) ||
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(draft.ui_encrypt) ||
|
|
|
|
EntityMessage.PGP_SIGNENCRYPT.equals(draft.ui_encrypt) ||
|
|
|
|
(EntityMessage.PGP_SIGNONLY.equals(draft.ui_encrypt) && action == R.id.action_send) ||
|
|
|
|
(EntityMessage.PGP_SIGNONLY.equals(draft.ui_encrypt) && action == R.id.action_send) ||
|
|
|
|
|
|
|
|
EntityMessage.SMIME_ENCRYPTONLY.equals(draft.ui_encrypt) ||
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt) ||
|
|
|
|
EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt) ||
|
|
|
|
(EntityMessage.SMIME_SIGNONLY.equals(draft.ui_encrypt) && action == R.id.action_send);
|
|
|
|
(EntityMessage.SMIME_SIGNONLY.equals(draft.ui_encrypt) && action == R.id.action_send);
|
|
|
|
boolean needsEncryption = (dirty && !encrypted && shouldEncrypt);
|
|
|
|
boolean needsEncryption = (dirty && !encrypted && shouldEncrypt);
|
|
|
@ -7475,6 +7490,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
boolean unencrypted =
|
|
|
|
boolean unencrypted =
|
|
|
|
(!EntityMessage.PGP_ENCRYPTONLY.equals(draft.ui_encrypt) &&
|
|
|
|
(!EntityMessage.PGP_ENCRYPTONLY.equals(draft.ui_encrypt) &&
|
|
|
|
!EntityMessage.PGP_SIGNENCRYPT.equals(draft.ui_encrypt) &&
|
|
|
|
!EntityMessage.PGP_SIGNENCRYPT.equals(draft.ui_encrypt) &&
|
|
|
|
|
|
|
|
!EntityMessage.SMIME_ENCRYPTONLY.equals(draft.ui_encrypt) &&
|
|
|
|
!EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt));
|
|
|
|
!EntityMessage.SMIME_SIGNENCRYPT.equals(draft.ui_encrypt));
|
|
|
|
if ((dirty && unencrypted) || encrypted) {
|
|
|
|
if ((dirty && unencrypted) || encrypted) {
|
|
|
|
if (save_drafts) {
|
|
|
|
if (save_drafts) {
|
|
|
|