Added support for PGP encrypt only

pull/212/head
M66B 2 years ago
parent a50ae9d0cf
commit 5f1356038e

@ -3643,6 +3643,7 @@ public class FragmentCompose extends FragmentBase {
// Attach key, signed/encrypted data // Attach key, signed/encrypted data
if (OpenPgpApi.ACTION_GET_KEY.equals(data.getAction()) || if (OpenPgpApi.ACTION_GET_KEY.equals(data.getAction()) ||
OpenPgpApi.ACTION_DETACHED_SIGN.equals(data.getAction()) || OpenPgpApi.ACTION_DETACHED_SIGN.equals(data.getAction()) ||
OpenPgpApi.ACTION_ENCRYPT.equals(data.getAction()) ||
OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction()))
try { try {
db.beginTransaction(); db.beginTransaction();
@ -3661,7 +3662,8 @@ public class FragmentCompose extends FragmentBase {
throw new IllegalArgumentException("micalg missing"); throw new IllegalArgumentException("micalg missing");
ct = new ContentType("application/pgp-signature"); ct = new ContentType("application/pgp-signature");
ct.setParameter("micalg", micalg); ct.setParameter("micalg", micalg);
} else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) { } else if (OpenPgpApi.ACTION_ENCRYPT.equals(data.getAction()) ||
OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) {
name = "encrypted.asc"; name = "encrypted.asc";
encryption = EntityAttachment.PGP_MESSAGE; encryption = EntityAttachment.PGP_MESSAGE;
} else } else
@ -3707,22 +3709,31 @@ public class FragmentCompose extends FragmentBase {
throw new IllegalArgumentException(context.getString(R.string.title_key_missing, throw new IllegalArgumentException(context.getString(R.string.title_key_missing,
TextUtils.join(", ", pgpUserIds))); TextUtils.join(", ", pgpUserIds)));
if (identity.sign_key != null) { if (largs.getBoolean("encrypt-only")) {
pgpSignKeyId = identity.sign_key; // Encrypt message
Intent intent = new Intent(OpenPgpApi.ACTION_ENCRYPT);
// Get public key intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pgpKeyIds);
Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY);
intent.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpSignKeyId);
intent.putExtra(OpenPgpApi.EXTRA_MINIMIZE, true);
intent.putExtra(OpenPgpApi.EXTRA_MINIMIZE_USER_ID, identity.email);
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
intent.putExtra(BuildConfig.APPLICATION_ID, largs); intent.putExtra(BuildConfig.APPLICATION_ID, largs);
return intent; return intent;
} else { } else {
// Get sign key if (identity.sign_key != null) {
Intent intent = new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID); pgpSignKeyId = identity.sign_key;
intent.putExtra(BuildConfig.APPLICATION_ID, largs);
return intent; // Get public key
Intent intent = new Intent(OpenPgpApi.ACTION_GET_KEY);
intent.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpSignKeyId);
intent.putExtra(OpenPgpApi.EXTRA_MINIMIZE, true);
intent.putExtra(OpenPgpApi.EXTRA_MINIMIZE_USER_ID, identity.email);
intent.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
intent.putExtra(BuildConfig.APPLICATION_ID, largs);
return intent;
} else {
// Get sign key
Intent intent = new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
intent.putExtra(BuildConfig.APPLICATION_ID, largs);
return intent;
}
} }
} else if (OpenPgpApi.ACTION_GET_SIGN_KEY_ID.equals(data.getAction())) { } else if (OpenPgpApi.ACTION_GET_SIGN_KEY_ID.equals(data.getAction())) {
pgpSignKeyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, -1); pgpSignKeyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, -1);
@ -3775,7 +3786,8 @@ public class FragmentCompose extends FragmentBase {
args.putInt("action", largs.getInt("action")); args.putInt("action", largs.getInt("action"));
args.putBundle("extras", largs.getBundle("extras")); args.putBundle("extras", largs.getBundle("extras"));
return null; return null;
} else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) { } else if (OpenPgpApi.ACTION_ENCRYPT.equals(data.getAction()) ||
OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) {
input.delete(); input.delete();
// send message // send message

Loading…
Cancel
Save