Fix CryptoInputParcel handling for YubiKeys
This commit is contained in:
@@ -21,7 +21,6 @@
|
|||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -50,15 +49,11 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant
|
* This class provides a communication interface to OpenPGP applications on ISO SmartCard compliant
|
||||||
* NFC devices.
|
* NFC devices.
|
||||||
* <p/>
|
|
||||||
* For the full specs, see http://g10code.com/docs/openpgp-card-2.0.pdf
|
* 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 {
|
public class NfcOperationActivity extends BaseNfcActivity {
|
||||||
|
|
||||||
@@ -101,13 +96,6 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
|
|
||||||
mInputParcel = getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT);
|
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);
|
setTitle(R.string.nfc_text);
|
||||||
|
|
||||||
vAnimator = (ViewAnimator) findViewById(R.id.view_animator);
|
vAnimator = (ViewAnimator) findViewById(R.id.view_animator);
|
||||||
@@ -163,9 +151,8 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NFC_SIGN: {
|
case NFC_SIGN: {
|
||||||
if (mInputParcel.getSignatureTime() == null) {
|
mInputParcel.addSignatureTime(mRequiredInput.mSignatureTime);
|
||||||
mInputParcel.addSignatureTime(new Date());
|
|
||||||
}
|
|
||||||
for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
|
for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
|
||||||
byte[] hash = mRequiredInput.mInputData[i];
|
byte[] hash = mRequiredInput.mInputData[i];
|
||||||
int algo = mRequiredInput.mSignAlgos[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.");
|
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);
|
mInputParcel.addCryptoData(subkeyBytes, cardSerialNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,15 +248,13 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
|||||||
protected void onNfcPostExecute() throws IOException {
|
protected void onNfcPostExecute() throws IOException {
|
||||||
if (mServiceIntent != null) {
|
if (mServiceIntent != null) {
|
||||||
// if we're triggered by OpenPgpService
|
// if we're triggered by OpenPgpService
|
||||||
|
// save updated cryptoInputParcel in cache
|
||||||
CryptoInputParcelCacheService.addCryptoInputParcel(this, mServiceIntent, mInputParcel);
|
CryptoInputParcelCacheService.addCryptoInputParcel(this, mServiceIntent, mInputParcel);
|
||||||
mServiceIntent.putExtra(EXTRA_CRYPTO_INPUT,
|
|
||||||
getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT));
|
|
||||||
setResult(RESULT_OK, mServiceIntent);
|
setResult(RESULT_OK, mServiceIntent);
|
||||||
} else {
|
} else {
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
|
// send back the CryptoInputParcel we received
|
||||||
result.putExtra(RESULT_CRYPTO_INPUT, mInputParcel);
|
result.putExtra(RESULT_CRYPTO_INPUT, mInputParcel);
|
||||||
// send back the CryptoInputParcel we receive, to conform with the pattern in
|
|
||||||
// CryptoOperationHelper
|
|
||||||
setResult(RESULT_OK, result);
|
setResult(RESULT_OK, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user