From 0182f7c951af1d46ca2fcdaf0bb60b162d7c68c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 24 Sep 2014 00:57:57 +0200 Subject: Yubikey text decryption working --- .../sufficientlysecure/keychain/pgp/PgpDecryptVerify.java | 2 +- .../sufficientlysecure/keychain/remote/OpenPgpService.java | 5 ++--- .../keychain/service/results/DecryptVerifyResult.java | 12 +++++++----- .../sufficientlysecure/keychain/ui/DecryptFilesFragment.java | 2 +- .../sufficientlysecure/keychain/ui/DecryptTextFragment.java | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index c21486306..9d21e89b3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -418,7 +418,7 @@ public class PgpDecryptVerify { log.add(LogType.MSG_DC_PENDING_NFC, indent +1); DecryptVerifyResult result = new DecryptVerifyResult(DecryptVerifyResult.RESULT_PENDING_NFC, log); - result.setNfcState(e.encryptedSessionKey, secretEncryptionKey.getKeyId()); + result.setNfcState(e.encryptedSessionKey, mPassphrase); return result; } encryptedData = encryptedDataAsymmetric; 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 090f2ceb6..1b4ad1fc1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -526,9 +526,8 @@ public class OpenPgpService extends RemoteService { "Decryption of symmetric content not supported by API!"); } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) == DecryptVerifyResult.RESULT_PENDING_NFC) { - // we assume that the pin has been cached before - String pin = passphraseCacheInterface.getCachedPassphrase(pgpResult.getNfcKeyId()); - return getNfcDecryptIntent(data, pin, pgpResult.getNfcEncryptedSessionKey()); + return getNfcDecryptIntent( + data, pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey()); } else { throw new PgpGeneralException( "Encountered unhandled type of pending action not supported by API!"); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java index 54241e625..4a0aec548 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/results/DecryptVerifyResult.java @@ -36,7 +36,7 @@ public class DecryptVerifyResult extends OperationResult { long mKeyIdPassphraseNeeded; byte[] mNfcSessionKey; - long mNfcKeyId; + String mNfcPassphrase; OpenPgpSignatureResult mSignatureResult; OpenPgpMetadata mDecryptMetadata; @@ -49,17 +49,17 @@ public class DecryptVerifyResult extends OperationResult { mKeyIdPassphraseNeeded = keyIdPassphraseNeeded; } - public void setNfcState(byte[] sessionKey, long nfcKeyId) { + public void setNfcState(byte[] sessionKey, String passphrase) { mNfcSessionKey = sessionKey; - mNfcKeyId = nfcKeyId; + mNfcPassphrase = passphrase; } public byte[] getNfcEncryptedSessionKey() { return mNfcSessionKey; } - public long getNfcKeyId() { - return mNfcKeyId; + public String getNfcPassphrase() { + return mNfcPassphrase; } public OpenPgpSignatureResult getSignatureResult() { @@ -92,6 +92,7 @@ public class DecryptVerifyResult extends OperationResult { mSignatureResult = source.readParcelable(OpenPgpSignatureResult.class.getClassLoader()); mDecryptMetadata = source.readParcelable(OpenPgpMetadata.class.getClassLoader()); mNfcSessionKey = source.readInt() != 0 ? source.createByteArray() : null; + mNfcPassphrase = source.readString(); } public int describeContents() { @@ -109,6 +110,7 @@ public class DecryptVerifyResult extends OperationResult { } else { dest.writeInt(0); } + dest.writeString(mNfcPassphrase); } public static final Creator CREATOR = new Creator() { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java index fb4fa61b2..33deb548e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java @@ -216,7 +216,7 @@ public class DecryptFilesFragment extends DecryptFragment { startPassphraseDialog(Constants.key.symmetric); } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) == DecryptVerifyResult.RESULT_PENDING_NFC) { - startNfcDecrypt(mPassphrase, pgpResult.getNfcEncryptedSessionKey()); + startNfcDecrypt(pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey()); } else { throw new RuntimeException("Unhandled pending result!"); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java index f6a08b560..62bf1907f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptTextFragment.java @@ -173,7 +173,7 @@ public class DecryptTextFragment extends DecryptFragment { startPassphraseDialog(Constants.key.symmetric); } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) == DecryptVerifyResult.RESULT_PENDING_NFC) { - startNfcDecrypt(mPassphrase, pgpResult.getNfcEncryptedSessionKey()); + startNfcDecrypt(pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey()); } else { throw new RuntimeException("Unhandled pending result!"); } -- cgit v1.2.3