Integrate yubikey reset method
This commit is contained in:
parent
930db9061e
commit
8f565296b9
|
@ -15,7 +15,7 @@ public class RequiredInputParcel implements Parcelable {
|
||||||
|
|
||||||
public enum RequiredInputType {
|
public enum RequiredInputType {
|
||||||
PASSPHRASE, PASSPHRASE_SYMMETRIC, BACKUP_CODE, NFC_SIGN, NFC_DECRYPT,
|
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;
|
public Date mSignatureTime;
|
||||||
|
@ -100,6 +100,11 @@ public class RequiredInputParcel implements Parcelable {
|
||||||
new byte[][] { encryptedSessionKey }, null, null, masterKeyId, subKeyId);
|
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(
|
public static RequiredInputParcel createRequiredSignPassphrase(
|
||||||
long masterKeyId, long subKeyId, Date signatureTime) {
|
long masterKeyId, long subKeyId, Date signatureTime) {
|
||||||
return new RequiredInputParcel(RequiredInputType.PASSPHRASE,
|
return new RequiredInputParcel(RequiredInputType.PASSPHRASE,
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
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.operations.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
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.FragAction;
|
||||||
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.NfcListenerFragment;
|
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.NfcListenerFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.base.QueueingCryptoOperationFragment;
|
import org.sufficientlysecure.keychain.ui.base.QueueingCryptoOperationFragment;
|
||||||
|
@ -50,6 +53,8 @@ public class CreateYubiKeyImportResetFragment
|
||||||
extends QueueingCryptoOperationFragment<ImportKeyringParcel, ImportKeyResult>
|
extends QueueingCryptoOperationFragment<ImportKeyringParcel, ImportKeyResult>
|
||||||
implements NfcListenerFragment {
|
implements NfcListenerFragment {
|
||||||
|
|
||||||
|
private static final int REQUEST_CODE_RESET = 0x00005001;
|
||||||
|
|
||||||
private static final String ARG_FINGERPRINTS = "fingerprint";
|
private static final String ARG_FINGERPRINTS = "fingerprint";
|
||||||
public static final String ARG_AID = "aid";
|
public static final String ARG_AID = "aid";
|
||||||
public static final String ARG_USER_ID = "user_ids";
|
public static final String ARG_USER_ID = "user_ids";
|
||||||
|
@ -230,7 +235,22 @@ public class CreateYubiKeyImportResetFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetCard() {
|
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
|
@Override
|
||||||
|
|
|
@ -110,10 +110,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
resumeTagHandling();
|
resumeTagHandling();
|
||||||
|
|
||||||
// obtain passphrase for this subkey
|
obtainPassphraseIfRequired();
|
||||||
if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.NFC_MOVE_KEY_TO_CARD) {
|
|
||||||
obtainYubiKeyPin(mRequiredInput);
|
|
||||||
}
|
|
||||||
vAnimator.setDisplayedChild(0);
|
vAnimator.setDisplayedChild(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -132,8 +129,13 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||||
mRequiredInput = data.getParcelable(EXTRA_REQUIRED_INPUT);
|
mRequiredInput = data.getParcelable(EXTRA_REQUIRED_INPUT);
|
||||||
mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT);
|
mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT);
|
||||||
|
|
||||||
|
obtainPassphraseIfRequired();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void obtainPassphraseIfRequired() {
|
||||||
// obtain passphrase for this subkey
|
// 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);
|
obtainYubiKeyPin(mRequiredInput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,6 +250,11 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case NFC_RESET_CARD: {
|
||||||
|
nfcResetCard();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
throw new AssertionError("Unhandled mRequiredInput.mType");
|
throw new AssertionError("Unhandled mRequiredInput.mType");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue