aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-10-16 15:30:06 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2015-10-16 15:30:06 +0200
commit8f565296b9503b210cd8edb8cb9ea42a3055c3c6 (patch)
tree55bfb9424a16e9a3fa11c6362ca761ab16bfd3d3 /OpenKeychain/src/main/java
parent930db9061efbed0cc3fd8955a15f3aba84eb53d8 (diff)
downloadopen-keychain-8f565296b9503b210cd8edb8cb9ea42a3055c3c6.tar.gz
open-keychain-8f565296b9503b210cd8edb8cb9ea42a3055c3c6.tar.bz2
open-keychain-8f565296b9503b210cd8edb8cb9ea42a3055c3c6.zip
Integrate yubikey reset method
Diffstat (limited to 'OpenKeychain/src/main/java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/RequiredInputParcel.java7
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateYubiKeyImportResetFragment.java20
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcOperationActivity.java17
3 files changed, 38 insertions, 6 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/RequiredInputParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/RequiredInputParcel.java
index 2c430bc29..1f99836ea 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/RequiredInputParcel.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/input/RequiredInputParcel.java
@@ -15,7 +15,7 @@ public class RequiredInputParcel implements Parcelable {
public enum RequiredInputType {
PASSPHRASE, PASSPHRASE_SYMMETRIC, BACKUP_CODE, NFC_SIGN, NFC_DECRYPT,
- NFC_MOVE_KEY_TO_CARD, ENABLE_ORBOT, UPLOAD_FAIL_RETRY
+ NFC_MOVE_KEY_TO_CARD, NFC_RESET_CARD, ENABLE_ORBOT, UPLOAD_FAIL_RETRY,
}
public Date mSignatureTime;
@@ -100,6 +100,11 @@ public class RequiredInputParcel implements Parcelable {
new byte[][] { encryptedSessionKey }, null, null, masterKeyId, subKeyId);
}
+ public static RequiredInputParcel createNfcReset() {
+ return new RequiredInputParcel(RequiredInputType.NFC_RESET_CARD,
+ null, null, null, null, null);
+ }
+
public static RequiredInputParcel createRequiredSignPassphrase(
long masterKeyId, long subKeyId, Date signatureTime) {
return new RequiredInputParcel(RequiredInputType.PASSPHRASE,
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateYubiKeyImportResetFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateYubiKeyImportResetFragment.java
index 3529f98d8..0a2d52617 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateYubiKeyImportResetFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateYubiKeyImportResetFragment.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
@@ -39,6 +40,8 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
+import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
+import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.NfcListenerFragment;
import org.sufficientlysecure.keychain.ui.base.QueueingCryptoOperationFragment;
@@ -50,6 +53,8 @@ public class CreateYubiKeyImportResetFragment
extends QueueingCryptoOperationFragment<ImportKeyringParcel, ImportKeyResult>
implements NfcListenerFragment {
+ private static final int REQUEST_CODE_RESET = 0x00005001;
+
private static final String ARG_FINGERPRINTS = "fingerprint";
public static final String ARG_AID = "aid";
public static final String ARG_USER_ID = "user_ids";
@@ -230,7 +235,22 @@ public class CreateYubiKeyImportResetFragment
}
public void resetCard() {
+ Intent intent = new Intent(getActivity(), NfcOperationActivity.class);
+ intent.putExtra(NfcOperationActivity.EXTRA_SERVICE_INTENT, (Parcelable[]) null);
+ RequiredInputParcel resetP = RequiredInputParcel.createNfcReset();
+ intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, resetP);
+ intent.putExtra(NfcOperationActivity.EXTRA_CRYPTO_INPUT, new CryptoInputParcel());
+ startActivityForResult(intent, REQUEST_CODE_RESET);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_CODE_RESET && resultCode == Activity.RESULT_OK) {
+ mCreateKeyActivity.loadFragment(null, FragAction.TO_LEFT);
+ return;
+ }
+ super.onActivityResult(requestCode, resultCode, data);
}
@Override
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 b79d3305d..86b0a36d0 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcOperationActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcOperationActivity.java
@@ -110,10 +110,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
public void onClick(View v) {
resumeTagHandling();
- // obtain passphrase for this subkey
- if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.NFC_MOVE_KEY_TO_CARD) {
- obtainYubiKeyPin(mRequiredInput);
- }
+ obtainPassphraseIfRequired();
vAnimator.setDisplayedChild(0);
}
});
@@ -132,8 +129,13 @@ public class NfcOperationActivity extends BaseNfcActivity {
mRequiredInput = data.getParcelable(EXTRA_REQUIRED_INPUT);
mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT);
+ obtainPassphraseIfRequired();
+ }
+
+ private void obtainPassphraseIfRequired() {
// obtain passphrase for this subkey
- if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.NFC_MOVE_KEY_TO_CARD) {
+ if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.NFC_MOVE_KEY_TO_CARD
+ && mRequiredInput.mType != RequiredInputParcel.RequiredInputType.NFC_RESET_CARD) {
obtainYubiKeyPin(mRequiredInput);
}
}
@@ -248,6 +250,11 @@ public class NfcOperationActivity extends BaseNfcActivity {
break;
}
+ case NFC_RESET_CARD: {
+ nfcResetCard();
+
+ break;
+ }
default: {
throw new AssertionError("Unhandled mRequiredInput.mType");
}