From 979605b5de92314736e43506ca262d5f57675485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 18 Aug 2015 09:59:31 +0200 Subject: Fix CryptoInputParcel handling for YubiKeys --- .../keychain/ui/NfcOperationActivity.java | 25 +++++----------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcOperationActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcOperationActivity.java index e6591595e..6b48dbb4b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcOperationActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcOperationActivity.java @@ -21,7 +21,6 @@ package org.sufficientlysecure.keychain.ui; import android.content.Intent; -import android.content.pm.ActivityInfo; import android.os.AsyncTask; import android.os.Bundle; import android.view.View; @@ -50,15 +49,11 @@ import org.sufficientlysecure.keychain.util.Preferences; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; -import java.util.Date; /** * This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant * NFC devices. - *

* For the full specs, see http://g10code.com/docs/openpgp-card-2.0.pdf - * NOTE: If no CryptoInputParcel is passed via EXTRA_CRYPTO_INPUT, the CryptoInputParcel is created - * internally and is NOT meant to be used by signing operations before adding signature time */ public class NfcOperationActivity extends BaseNfcActivity { @@ -101,13 +96,6 @@ public class NfcOperationActivity extends BaseNfcActivity { mInputParcel = getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT); - if (mInputParcel == null) { - // for compatibility when used from OpenPgpService - // (or any place other than CryptoOperationHelper) - // NOTE: This CryptoInputParcel cannot be used for signing without adding signature time - mInputParcel = new CryptoInputParcel(); - } - setTitle(R.string.nfc_text); vAnimator = (ViewAnimator) findViewById(R.id.view_animator); @@ -163,9 +151,8 @@ public class NfcOperationActivity extends BaseNfcActivity { break; } case NFC_SIGN: { - if (mInputParcel.getSignatureTime() == null) { - mInputParcel.addSignatureTime(new Date()); - } + mInputParcel.addSignatureTime(mRequiredInput.mSignatureTime); + for (int i = 0; i < mRequiredInput.mInputData.length; i++) { byte[] hash = mRequiredInput.mInputData[i]; int algo = mRequiredInput.mSignAlgos[i]; @@ -240,7 +227,7 @@ public class NfcOperationActivity extends BaseNfcActivity { throw new IOException("Inappropriate key flags for smart card key."); } - // TODO: Is this really needed? + // TODO: Is this really used anywhere? mInputParcel.addCryptoData(subkeyBytes, cardSerialNumber); } @@ -261,15 +248,13 @@ public class NfcOperationActivity extends BaseNfcActivity { protected void onNfcPostExecute() throws IOException { if (mServiceIntent != null) { // if we're triggered by OpenPgpService + // save updated cryptoInputParcel in cache CryptoInputParcelCacheService.addCryptoInputParcel(this, mServiceIntent, mInputParcel); - mServiceIntent.putExtra(EXTRA_CRYPTO_INPUT, - getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT)); setResult(RESULT_OK, mServiceIntent); } else { Intent result = new Intent(); + // send back the CryptoInputParcel we received result.putExtra(RESULT_CRYPTO_INPUT, mInputParcel); - // send back the CryptoInputParcel we receive, to conform with the pattern in - // CryptoOperationHelper setResult(RESULT_OK, result); } -- cgit v1.2.3