Yubikey text decryption working

This commit is contained in:
Dominik Schürmann 2014-09-24 00:57:57 +02:00
parent 07704c2726
commit 0182f7c951
5 changed files with 12 additions and 11 deletions

View File

@ -418,7 +418,7 @@ public class PgpDecryptVerify {
log.add(LogType.MSG_DC_PENDING_NFC, indent +1); log.add(LogType.MSG_DC_PENDING_NFC, indent +1);
DecryptVerifyResult result = DecryptVerifyResult result =
new DecryptVerifyResult(DecryptVerifyResult.RESULT_PENDING_NFC, log); new DecryptVerifyResult(DecryptVerifyResult.RESULT_PENDING_NFC, log);
result.setNfcState(e.encryptedSessionKey, secretEncryptionKey.getKeyId()); result.setNfcState(e.encryptedSessionKey, mPassphrase);
return result; return result;
} }
encryptedData = encryptedDataAsymmetric; encryptedData = encryptedDataAsymmetric;

View File

@ -526,9 +526,8 @@ public class OpenPgpService extends RemoteService {
"Decryption of symmetric content not supported by API!"); "Decryption of symmetric content not supported by API!");
} else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) == } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) ==
DecryptVerifyResult.RESULT_PENDING_NFC) { DecryptVerifyResult.RESULT_PENDING_NFC) {
// we assume that the pin has been cached before return getNfcDecryptIntent(
String pin = passphraseCacheInterface.getCachedPassphrase(pgpResult.getNfcKeyId()); data, pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey());
return getNfcDecryptIntent(data, pin, pgpResult.getNfcEncryptedSessionKey());
} else { } else {
throw new PgpGeneralException( throw new PgpGeneralException(
"Encountered unhandled type of pending action not supported by API!"); "Encountered unhandled type of pending action not supported by API!");

View File

@ -36,7 +36,7 @@ public class DecryptVerifyResult extends OperationResult {
long mKeyIdPassphraseNeeded; long mKeyIdPassphraseNeeded;
byte[] mNfcSessionKey; byte[] mNfcSessionKey;
long mNfcKeyId; String mNfcPassphrase;
OpenPgpSignatureResult mSignatureResult; OpenPgpSignatureResult mSignatureResult;
OpenPgpMetadata mDecryptMetadata; OpenPgpMetadata mDecryptMetadata;
@ -49,17 +49,17 @@ public class DecryptVerifyResult extends OperationResult {
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded; mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
} }
public void setNfcState(byte[] sessionKey, long nfcKeyId) { public void setNfcState(byte[] sessionKey, String passphrase) {
mNfcSessionKey = sessionKey; mNfcSessionKey = sessionKey;
mNfcKeyId = nfcKeyId; mNfcPassphrase = passphrase;
} }
public byte[] getNfcEncryptedSessionKey() { public byte[] getNfcEncryptedSessionKey() {
return mNfcSessionKey; return mNfcSessionKey;
} }
public long getNfcKeyId() { public String getNfcPassphrase() {
return mNfcKeyId; return mNfcPassphrase;
} }
public OpenPgpSignatureResult getSignatureResult() { public OpenPgpSignatureResult getSignatureResult() {
@ -92,6 +92,7 @@ public class DecryptVerifyResult extends OperationResult {
mSignatureResult = source.readParcelable(OpenPgpSignatureResult.class.getClassLoader()); mSignatureResult = source.readParcelable(OpenPgpSignatureResult.class.getClassLoader());
mDecryptMetadata = source.readParcelable(OpenPgpMetadata.class.getClassLoader()); mDecryptMetadata = source.readParcelable(OpenPgpMetadata.class.getClassLoader());
mNfcSessionKey = source.readInt() != 0 ? source.createByteArray() : null; mNfcSessionKey = source.readInt() != 0 ? source.createByteArray() : null;
mNfcPassphrase = source.readString();
} }
public int describeContents() { public int describeContents() {
@ -109,6 +110,7 @@ public class DecryptVerifyResult extends OperationResult {
} else { } else {
dest.writeInt(0); dest.writeInt(0);
} }
dest.writeString(mNfcPassphrase);
} }
public static final Creator<DecryptVerifyResult> CREATOR = new Creator<DecryptVerifyResult>() { public static final Creator<DecryptVerifyResult> CREATOR = new Creator<DecryptVerifyResult>() {

View File

@ -216,7 +216,7 @@ public class DecryptFilesFragment extends DecryptFragment {
startPassphraseDialog(Constants.key.symmetric); startPassphraseDialog(Constants.key.symmetric);
} else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) == } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) ==
DecryptVerifyResult.RESULT_PENDING_NFC) { DecryptVerifyResult.RESULT_PENDING_NFC) {
startNfcDecrypt(mPassphrase, pgpResult.getNfcEncryptedSessionKey()); startNfcDecrypt(pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey());
} else { } else {
throw new RuntimeException("Unhandled pending result!"); throw new RuntimeException("Unhandled pending result!");
} }

View File

@ -173,7 +173,7 @@ public class DecryptTextFragment extends DecryptFragment {
startPassphraseDialog(Constants.key.symmetric); startPassphraseDialog(Constants.key.symmetric);
} else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) == } else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) ==
DecryptVerifyResult.RESULT_PENDING_NFC) { DecryptVerifyResult.RESULT_PENDING_NFC) {
startNfcDecrypt(mPassphrase, pgpResult.getNfcEncryptedSessionKey()); startNfcDecrypt(pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey());
} else { } else {
throw new RuntimeException("Unhandled pending result!"); throw new RuntimeException("Unhandled pending result!");
} }