From a63aca623ddc53d1bfcb1957970cd760e21ead77 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Tue, 1 May 2018 14:21:03 +0200 Subject: [PATCH] make sure all keys are allowed for transfer call --- .../keychain/remote/ApiPendingIntentFactory.java | 2 +- .../keychain/remote/OpenPgpService.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java index e665322f0..18a467299 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java @@ -121,7 +121,7 @@ public class ApiPendingIntentFactory { return createInternal(data, intent); } - PendingIntent createRequestKeyPermissionPendingIntent(Intent data, String packageName, long[] masterKeyIds) { + PendingIntent createRequestKeyPermissionPendingIntent(Intent data, String packageName, long... masterKeyIds) { Intent intent = new Intent(mContext, RequestKeyPermissionActivity.class); intent.putExtra(RequestKeyPermissionActivity.EXTRA_PACKAGE_NAME, packageName); intent.putExtra(RequestKeyPermissionActivity.EXTRA_REQUESTED_KEY_IDS, masterKeyIds); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index cd0082f14..46475c015 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -816,6 +816,19 @@ public class OpenPgpService extends Service { try { long[] masterKeyIds = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); + HashSet allowedKeyIds = getAllowedKeyIds(); + for (long masterKeyId : masterKeyIds) { + if (!allowedKeyIds.contains(masterKeyId)) { + Intent result = new Intent(); + String packageName = mApiPermissionHelper.getCurrentCallingPackage(); + result.putExtra(OpenPgpApi.RESULT_INTENT, + mApiPendingIntentFactory.createRequestKeyPermissionPendingIntent( + data, packageName, masterKeyId)); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); + return result; + } + } + Passphrase autocryptTransferCode = Numeric9x4PassphraseUtil.generateNumeric9x4Passphrase(); CryptoInputParcel inputParcel = CryptoInputParcel.createCryptoInputParcel(autocryptTransferCode);