From 9e668eadcb5dc5737f3df94339a1fa1e8662f0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 20 Mar 2015 13:38:07 +0100 Subject: Fix PASSPHRASE handling in API --- .../keychain/remote/OpenPgpService.java | 20 ++++++++++++++++++-- extern/openpgp-api-lib | 2 +- 2 files changed, 19 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 98a9ff44f..4707a2ad5 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -240,6 +240,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)); @@ -278,6 +283,7 @@ public class OpenPgpService extends RemoteService { // sign-only PgpSignEncryptInput pseInput = new PgpSignEncryptInput() + .setSignaturePassphrase(passphrase) .setEnableAsciiArmorOutput(asciiArmor) .setCleartextSignature(cleartextSign) .setDetachedSignature(!cleartextSign) @@ -366,6 +372,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) { @@ -391,7 +402,8 @@ public class OpenPgpService extends RemoteService { InputData inputData = new InputData(is, inputLength, originalFilename); PgpSignEncryptInput pseInput = new PgpSignEncryptInput(); - pseInput.setEnableAsciiArmorOutput(asciiArmor) + pseInput.setSignaturePassphrase(passphrase) + .setEnableAsciiArmorOutput(asciiArmor) .setVersionHeader(null) .setCompressionId(compressionId) .setSymmetricEncryptionAlgorithm(PgpConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_PREFERRED) @@ -499,6 +511,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 allowedKeyIds; if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 7) { @@ -509,7 +526,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); diff --git a/extern/openpgp-api-lib b/extern/openpgp-api-lib index d10df1d40..34ccf4df4 160000 --- a/extern/openpgp-api-lib +++ b/extern/openpgp-api-lib @@ -1 +1 @@ -Subproject commit d10df1d40f23475445d0abca217683e911ffa0a0 +Subproject commit 34ccf4df41a30cb586f06eb3b9bc90efc8dd7a2c -- cgit v1.2.3