diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-21 15:57:35 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-21 15:57:35 +0100 |
commit | 9ef2795fcd04fc228b4e3f30342f9eb79bab59fc (patch) | |
tree | 6d6705a2dc71bdb2ad7545e768f22460971190db /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java | |
parent | 93c7eb72fbbf93938043566dfc1707b6714f325b (diff) | |
parent | c7efaacc9d1abc03036625b29961b5dad2672c44 (diff) | |
download | open-keychain-9ef2795fcd04fc228b4e3f30342f9eb79bab59fc.tar.gz open-keychain-9ef2795fcd04fc228b4e3f30342f9eb79bab59fc.tar.bz2 open-keychain-9ef2795fcd04fc228b4e3f30342f9eb79bab59fc.zip |
Merge remote-tracking branch 'origin/development' into v/crypto-input-parcel
Conflicts:
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
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.java | 28 |
1 files changed, 24 insertions, 4 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 7d8aa993d..204af1b67 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -241,6 +241,11 @@ public class OpenPgpService extends RemoteService { try { boolean asciiArmor = cleartextSign || data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + Passphrase passphrase = null; + if (data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE) != null) { + passphrase = new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE)); + } + byte[] nfcSignedHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH); if (nfcSignedHash != null) { Log.d(Constants.TAG, "nfcSignedHash:" + Hex.toHexString(nfcSignedHash)); @@ -284,6 +289,7 @@ public class OpenPgpService extends RemoteService { // sign-only PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel() + .setSignaturePassphrase(passphrase) .setEnableAsciiArmorOutput(asciiArmor) .setCleartextSignature(cleartextSign) .setDetachedSignature(!cleartextSign) @@ -372,6 +378,11 @@ public class OpenPgpService extends RemoteService { compressionId = CompressionAlgorithmTags.UNCOMPRESSED; } + Passphrase passphrase = null; + if (data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE) != null) { + passphrase = new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE)); + } + // first try to get key ids from non-ambiguous key id extra long[] keyIds = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); if (keyIds == null) { @@ -397,7 +408,8 @@ public class OpenPgpService extends RemoteService { InputData inputData = new InputData(is, inputLength, originalFilename); PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(); - pseInput.setEnableAsciiArmorOutput(asciiArmor) + pseInput.setSignaturePassphrase(passphrase) + .setEnableAsciiArmorOutput(asciiArmor) .setVersionHeader(null) .setCompressionId(compressionId) .setSymmetricEncryptionAlgorithm(PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED) @@ -510,6 +522,11 @@ public class OpenPgpService extends RemoteService { os = new ParcelFileDescriptor.AutoCloseOutputStream(output); } + Passphrase passphrase = null; + if (data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE) != null) { + passphrase = new Passphrase(data.getCharArrayExtra(OpenPgpApi.EXTRA_PASSPHRASE)); + } + String currentPkg = getCurrentCallingPackage(); Set<Long> allowedKeyIds; if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 7) { @@ -520,7 +537,6 @@ public class OpenPgpService extends RemoteService { KeychainContract.ApiAllowedKeys.buildBaseUri(currentPkg)); } - Passphrase passphrase = data.getParcelableExtra(OpenPgpApi.EXTRA_PASSPHRASE); long inputLength = is.available(); InputData inputData = new InputData(is, inputLength); @@ -566,15 +582,16 @@ public class OpenPgpService extends RemoteService { } } else if (pgpResult.success()) { Intent result = new Intent(); - int resultType = OpenPgpApi.RESULT_TYPE_UNENCRYPTED_UNSIGNED; OpenPgpSignatureResult signatureResult = pgpResult.getSignatureResult(); + // TODO: currently RESULT_TYPE_UNENCRYPTED_UNSIGNED is never returned + // instead an error is returned when no pgp data has been found + int resultType = OpenPgpApi.RESULT_TYPE_UNENCRYPTED_UNSIGNED; if (signatureResult != null) { resultType |= OpenPgpApi.RESULT_TYPE_SIGNED; if (!signatureResult.isSignatureOnly()) { resultType |= OpenPgpApi.RESULT_TYPE_ENCRYPTED; } - result.putExtra(OpenPgpApi.RESULT_TYPE, resultType); result.putExtra(OpenPgpApi.RESULT_SIGNATURE, signatureResult); @@ -594,7 +611,10 @@ public class OpenPgpService extends RemoteService { // If signature key is known, return PendingIntent to show key result.putExtra(OpenPgpApi.RESULT_INTENT, getShowKeyPendingIntent(signatureResult.getKeyId())); } + } else { + resultType |= OpenPgpApi.RESULT_TYPE_ENCRYPTED; } + result.putExtra(OpenPgpApi.RESULT_TYPE, resultType); if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) >= 4) { OpenPgpMetadata metadata = pgpResult.getDecryptMetadata(); |