make sure all keys are allowed for transfer call

This commit is contained in:
Vincent Breitmoser 2018-05-01 14:21:03 +02:00
parent be58f2ff4c
commit a63aca623d
2 changed files with 14 additions and 1 deletions

View file

@ -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);

View file

@ -816,6 +816,19 @@ public class OpenPgpService extends Service {
try {
long[] masterKeyIds = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS);
HashSet<Long> 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);