aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-08-11 17:29:41 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-08-11 17:29:41 +0200
commitd5b40de70a9a53372a3c538ad4ec2656a63b7984 (patch)
treee84254cbb2cf4ff731c2fe034a6f94ffd8f324c6 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
parent59096b37fdfef1d9294990a64c755080585b1da6 (diff)
downloadopen-keychain-d5b40de70a9a53372a3c538ad4ec2656a63b7984.tar.gz
open-keychain-d5b40de70a9a53372a3c538ad4ec2656a63b7984.tar.bz2
open-keychain-d5b40de70a9a53372a3c538ad4ec2656a63b7984.zip
Decrypt metadata api
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java20
1 files changed, 17 insertions, 3 deletions
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 d3a38c5d7..5c94f4796 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -25,6 +25,7 @@ import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import org.openintents.openpgp.IOpenPgpService;
+import org.openintents.openpgp.OpenPgpDecryptMetadata;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
@@ -326,7 +327,8 @@ public class OpenPgpService extends RemoteService {
}
private Intent decryptAndVerifyImpl(Intent data, ParcelFileDescriptor input,
- ParcelFileDescriptor output, Set<Long> allowedKeyIds) {
+ ParcelFileDescriptor output, Set<Long> allowedKeyIds,
+ boolean decryptMetadataOnly) {
try {
// Get Input- and OutputStream from ParcelFileDescriptor
InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input);
@@ -353,7 +355,8 @@ public class OpenPgpService extends RemoteService {
builder.setAllowSymmetricDecryption(false) // no support for symmetric encryption
.setAllowedKeyIds(allowedKeyIds) // allow only private keys associated with
// accounts of this app
- .setPassphrase(passphrase);
+ .setPassphrase(passphrase)
+ .setDecryptMetadataOnly(decryptMetadataOnly);
PgpDecryptVerifyResult decryptVerifyResult;
try {
@@ -403,6 +406,11 @@ public class OpenPgpService extends RemoteService {
}
}
+ OpenPgpDecryptMetadata metadata = decryptVerifyResult.getDecryptMetadata();
+ if (metadata != null) {
+ result.putExtra(OpenPgpApi.RESULT_METADATA, metadata);
+ }
+
} finally {
is.close();
os.close();
@@ -561,7 +569,13 @@ public class OpenPgpService extends RemoteService {
Set<Long> allowedKeyIds =
mProviderHelper.getAllKeyIdsForApp(
ApiAccounts.buildBaseUri(currentPkg));
- return decryptAndVerifyImpl(data, input, output, allowedKeyIds);
+ return decryptAndVerifyImpl(data, input, output, allowedKeyIds, false);
+ } else if (OpenPgpApi.ACTION_DECRYPT_METADATA.equals(action)) {
+ String currentPkg = getCurrentCallingPackage();
+ Set<Long> allowedKeyIds =
+ mProviderHelper.getAllKeyIdsForApp(
+ ApiAccounts.buildBaseUri(currentPkg));
+ return decryptAndVerifyImpl(data, input, output, allowedKeyIds, true);
} else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) {
return getKeyImpl(data);
} else if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(action)) {