aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-08-12 15:58:41 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2015-08-12 15:58:41 +0200
commita7392eb99d4393382f8b0553853fd1a163403fba (patch)
tree1c82529f1513c85deb9d8313e01f46d1270d6435 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
parent8ce4a9a252fd994d6d5c3166d52f8af4d4ac9915 (diff)
downloadopen-keychain-a7392eb99d4393382f8b0553853fd1a163403fba.tar.gz
open-keychain-a7392eb99d4393382f8b0553853fd1a163403fba.tar.bz2
open-keychain-a7392eb99d4393382f8b0553853fd1a163403fba.zip
API: Better fallback for OpenPgpDecryptionResult
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.java26
1 files changed, 21 insertions, 5 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 86c4f3597..ea016c657 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -594,11 +594,27 @@ public class OpenPgpService extends RemoteService {
result.putExtra(OpenPgpApi.RESULT_SIGNATURE, (Parcelable[]) null);
}
- OpenPgpDecryptionResult decryptionResult = pgpResult.getDecryptionResult();
- if (decryptionResult.getResult() != OpenPgpDecryptionResult.RESULT_ENCRYPTED
- && signatureResult.getResult() != OpenPgpSignatureResult.RESULT_NO_SIGNATURE) {
- // not encrypted and signed, set deprecated signatureOnly variable
- signatureResult.setSignatureOnly(true);
+ // OpenPgpDecryptionResult does not exist in API < 8
+ {
+ OpenPgpDecryptionResult decryptionResult = pgpResult.getDecryptionResult();
+
+ // case RESULT_NOT_ENCRYPTED, but a signature, fallback to deprecated signatureOnly variable
+ if (decryptionResult.getResult() == OpenPgpDecryptionResult.RESULT_NOT_ENCRYPTED
+ && signatureResult.getResult() != OpenPgpSignatureResult.RESULT_NO_SIGNATURE) {
+ signatureResult.setSignatureOnly(true);
+ }
+
+ // case RESULT_INSECURE, fallback to an error
+ if (decryptionResult.getResult() == OpenPgpDecryptionResult.RESULT_INSECURE) {
+ Intent resultError = new Intent();
+ resultError.putExtra(OpenPgpApi.RESULT_ERROR, new OpenPgpError(OpenPgpError.GENERIC_ERROR,
+ "Insecure encryption: An outdated algorithm has been used!"));
+ resultError.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
+ return resultError;
+ }
+
+ // case RESULT_ENCRYPTED
+ // nothing to do!
}
}