Use more generic 'Security Token' where possible, add sutitle to create key what tokens are supported
This commit is contained in:
@@ -105,7 +105,7 @@ public final class Constants {
|
||||
public static final String CACHED_CONSOLIDATE = "cachedConsolidate";
|
||||
public static final String SEARCH_KEYSERVER = "search_keyserver_pref";
|
||||
public static final String SEARCH_KEYBASE = "search_keybase_pref";
|
||||
public static final String USE_NUMKEYPAD_FOR_YUBIKEY_PIN = "useNumKeypadForYubikeyPin";
|
||||
public static final String USE_NUMKEYPAD_FOR_SECURITY_TOKEN_PIN = "useNumKeypadForYubikeyPin";
|
||||
public static final String ENCRYPT_FILENAMES = "encryptFilenames";
|
||||
public static final String FILE_USE_COMPRESSION = "useFileCompression";
|
||||
public static final String TEXT_USE_COMPRESSION = "useTextCompression";
|
||||
|
||||
@@ -562,9 +562,9 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_MF_ERROR_CONFLICTING_NFC_COMMANDS(LogLevel.ERROR, R.string.msg_mf_error_conflicting_nfc_commands),
|
||||
MSG_MF_ERROR_DUPLICATE_KEYTOCARD_FOR_SLOT(LogLevel.ERROR, R.string.msg_mf_error_duplicate_keytocard_for_slot),
|
||||
MSG_MF_ERROR_INVALID_FLAGS_FOR_KEYTOCARD(LogLevel.ERROR, R.string.msg_mf_error_invalid_flags_for_keytocard),
|
||||
MSG_MF_ERROR_BAD_NFC_ALGO(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_algo),
|
||||
MSG_MF_ERROR_BAD_NFC_SIZE(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_size),
|
||||
MSG_MF_ERROR_BAD_NFC_STRIPPED(LogLevel.ERROR, R.string.edit_key_error_bad_nfc_stripped),
|
||||
MSG_MF_ERROR_BAD_SECURITY_TOKEN_ALGO(LogLevel.ERROR, R.string.edit_key_error_bad_security_token_algo),
|
||||
MSG_MF_ERROR_BAD_SECURITY_TOKEN_SIZE(LogLevel.ERROR, R.string.edit_key_error_bad_security_token_size),
|
||||
MSG_MF_ERROR_BAD_SECURITY_TOKEN_STRIPPED(LogLevel.ERROR, R.string.edit_key_error_bad_security_token_stripped),
|
||||
MSG_MF_MASTER (LogLevel.DEBUG, R.string.msg_mf_master),
|
||||
MSG_MF_NOTATION_PIN (LogLevel.DEBUG, R.string.msg_mf_notation_pin),
|
||||
MSG_MF_NOTATION_EMPTY (LogLevel.DEBUG, R.string.msg_mf_notation_empty),
|
||||
|
||||
@@ -413,8 +413,8 @@ public class PgpKeyOperation {
|
||||
boolean hasEncrypt = false;
|
||||
boolean hasAuth = false;
|
||||
for(SaveKeyringParcel.SubkeyChange change : saveParcel.mChangeSubKeys) {
|
||||
if (change.mMoveKeyToCard) {
|
||||
// If this is a keytocard operation, see if it was completed: look for a hash
|
||||
if (change.mMoveKeyToSecurityToken) {
|
||||
// If this is a moveKeyToSecurityToken operation, see if it was completed: look for a hash
|
||||
// matching the given subkey ID in cryptoData.
|
||||
byte[] subKeyId = new byte[8];
|
||||
ByteBuffer buf = ByteBuffer.wrap(subKeyId);
|
||||
@@ -422,13 +422,13 @@ public class PgpKeyOperation {
|
||||
|
||||
byte[] serialNumber = cryptoInput.getCryptoData().get(buf);
|
||||
if (serialNumber != null) {
|
||||
change.mMoveKeyToCard = false;
|
||||
change.mDummyDivert = serialNumber;
|
||||
change.mMoveKeyToSecurityToken = false;
|
||||
change.mSecurityTokenSerialNo = serialNumber;
|
||||
}
|
||||
}
|
||||
|
||||
if (change.mMoveKeyToCard) {
|
||||
// Pending keytocard operation. Need to make sure that we don't have multiple
|
||||
if (change.mMoveKeyToSecurityToken) {
|
||||
// Pending moveKeyToSecurityToken operation. Need to make sure that we don't have multiple
|
||||
// subkeys pending for the same slot.
|
||||
CanonicalizedSecretKey wsK = wsKR.getSecretKey(change.mKeyId);
|
||||
|
||||
@@ -810,26 +810,26 @@ public class PgpKeyOperation {
|
||||
// no really, it is. this operation irrevocably removes the private key data from the key
|
||||
sKey = PGPSecretKey.constructGnuDummyKey(sKey.getPublicKey());
|
||||
sKR = PGPSecretKeyRing.insertSecretKey(sKR, sKey);
|
||||
} else if (change.mMoveKeyToCard) {
|
||||
if (checkSmartCardCompatibility(sKey, log, indent + 1)) {
|
||||
} else if (change.mMoveKeyToSecurityToken) {
|
||||
if (checkSecurityTokenCompatibility(sKey, log, indent + 1)) {
|
||||
log.add(LogType.MSG_MF_KEYTOCARD_START, indent + 1,
|
||||
KeyFormattingUtils.convertKeyIdToHex(change.mKeyId));
|
||||
nfcKeyToCardOps.addSubkey(change.mKeyId);
|
||||
} else {
|
||||
// Appropriate log message already set by checkSmartCardCompatibility
|
||||
// Appropriate log message already set by checkSecurityTokenCompatibility
|
||||
return new PgpEditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
} else if (change.mDummyDivert != null) {
|
||||
} else if (change.mSecurityTokenSerialNo != null) {
|
||||
// NOTE: Does this code get executed? Or always handled in internalRestricted?
|
||||
if (change.mDummyDivert.length != 16) {
|
||||
if (change.mSecurityTokenSerialNo.length != 16) {
|
||||
log.add(LogType.MSG_MF_ERROR_DIVERT_SERIAL,
|
||||
indent + 1, KeyFormattingUtils.convertKeyIdToHex(change.mKeyId));
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
log.add(LogType.MSG_MF_KEYTOCARD_FINISH, indent + 1,
|
||||
KeyFormattingUtils.convertKeyIdToHex(change.mKeyId),
|
||||
Hex.toHexString(change.mDummyDivert, 8, 6));
|
||||
sKey = PGPSecretKey.constructGnuDummyKey(sKey.getPublicKey(), change.mDummyDivert);
|
||||
Hex.toHexString(change.mSecurityTokenSerialNo, 8, 6));
|
||||
sKey = PGPSecretKey.constructGnuDummyKey(sKey.getPublicKey(), change.mSecurityTokenSerialNo);
|
||||
sKR = PGPSecretKeyRing.insertSecretKey(sKR, sKey);
|
||||
}
|
||||
|
||||
@@ -1063,22 +1063,22 @@ public class PgpKeyOperation {
|
||||
indent -= 1;
|
||||
}
|
||||
|
||||
// 7. if requested, change PIN and/or Admin PIN on card
|
||||
if (saveParcel.mCardPin != null) {
|
||||
// 7. if requested, change PIN and/or Admin PIN on security token
|
||||
if (saveParcel.mSecurityTokenPin != null) {
|
||||
progress(R.string.progress_modify_pin, 90);
|
||||
log.add(LogType.MSG_MF_PIN, indent);
|
||||
indent += 1;
|
||||
|
||||
nfcKeyToCardOps.setPin(saveParcel.mCardPin);
|
||||
nfcKeyToCardOps.setPin(saveParcel.mSecurityTokenPin);
|
||||
|
||||
indent -= 1;
|
||||
}
|
||||
if (saveParcel.mCardAdminPin != null) {
|
||||
if (saveParcel.mSecurityTokenAdminPin != null) {
|
||||
progress(R.string.progress_modify_admin_pin, 90);
|
||||
log.add(LogType.MSG_MF_ADMIN_PIN, indent);
|
||||
indent += 1;
|
||||
|
||||
nfcKeyToCardOps.setAdminPin(saveParcel.mCardAdminPin);
|
||||
nfcKeyToCardOps.setAdminPin(saveParcel.mSecurityTokenAdminPin);
|
||||
|
||||
indent -= 1;
|
||||
}
|
||||
@@ -1157,22 +1157,22 @@ public class PgpKeyOperation {
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
|
||||
if (change.mDummyStrip || change.mDummyDivert != null) {
|
||||
if (change.mDummyStrip || change.mSecurityTokenSerialNo != null) {
|
||||
// IT'S DANGEROUS~
|
||||
// no really, it is. this operation irrevocably removes the private key data from the key
|
||||
if (change.mDummyStrip) {
|
||||
sKey = PGPSecretKey.constructGnuDummyKey(sKey.getPublicKey());
|
||||
} else {
|
||||
// the serial number must be 16 bytes in length
|
||||
if (change.mDummyDivert.length != 16) {
|
||||
if (change.mSecurityTokenSerialNo.length != 16) {
|
||||
log.add(LogType.MSG_MF_ERROR_DIVERT_SERIAL,
|
||||
indent + 1, KeyFormattingUtils.convertKeyIdToHex(change.mKeyId));
|
||||
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||
}
|
||||
log.add(LogType.MSG_MF_KEYTOCARD_FINISH, indent + 1,
|
||||
KeyFormattingUtils.convertKeyIdToHex(change.mKeyId),
|
||||
Hex.toHexString(change.mDummyDivert, 8, 6));
|
||||
sKey = PGPSecretKey.constructGnuDummyKey(sKey.getPublicKey(), change.mDummyDivert);
|
||||
Hex.toHexString(change.mSecurityTokenSerialNo, 8, 6));
|
||||
sKey = PGPSecretKey.constructGnuDummyKey(sKey.getPublicKey(), change.mSecurityTokenSerialNo);
|
||||
}
|
||||
sKR = PGPSecretKeyRing.insertSecretKey(sKR, sKey);
|
||||
}
|
||||
@@ -1625,26 +1625,26 @@ public class PgpKeyOperation {
|
||||
&& s2k.getProtectionMode() == S2K.GNU_PROTECTION_MODE_DIVERT_TO_CARD;
|
||||
}
|
||||
|
||||
private static boolean checkSmartCardCompatibility(PGPSecretKey key, OperationLog log, int indent) {
|
||||
private static boolean checkSecurityTokenCompatibility(PGPSecretKey key, OperationLog log, int indent) {
|
||||
PGPPublicKey publicKey = key.getPublicKey();
|
||||
int algorithm = publicKey.getAlgorithm();
|
||||
if (algorithm != PublicKeyAlgorithmTags.RSA_ENCRYPT &&
|
||||
algorithm != PublicKeyAlgorithmTags.RSA_SIGN &&
|
||||
algorithm != PublicKeyAlgorithmTags.RSA_GENERAL) {
|
||||
log.add(LogType.MSG_MF_ERROR_BAD_NFC_ALGO, indent + 1);
|
||||
log.add(LogType.MSG_MF_ERROR_BAD_SECURITY_TOKEN_ALGO, indent + 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Key size must be 2048
|
||||
int keySize = publicKey.getBitStrength();
|
||||
if (keySize != 2048) {
|
||||
log.add(LogType.MSG_MF_ERROR_BAD_NFC_SIZE, indent + 1);
|
||||
log.add(LogType.MSG_MF_ERROR_BAD_SECURITY_TOKEN_SIZE, indent + 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Secret key parts must be available
|
||||
if (isDivertToCard(key) || isDummy(key)) {
|
||||
log.add(LogType.MSG_MF_ERROR_BAD_NFC_STRIPPED, indent + 1);
|
||||
log.add(LogType.MSG_MF_ERROR_BAD_SECURITY_TOKEN_STRIPPED, indent + 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ import org.sufficientlysecure.keychain.remote.ui.SelectSignKeyIdActivity;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.ImportKeysActivity;
|
||||
import org.sufficientlysecure.keychain.ui.NfcOperationActivity;
|
||||
import org.sufficientlysecure.keychain.ui.SecurityTokenOperationActivity;
|
||||
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
||||
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
||||
import org.sufficientlysecure.keychain.util.InputData;
|
||||
@@ -191,12 +191,12 @@ public class OpenPgpService extends Service {
|
||||
case NFC_MOVE_KEY_TO_CARD:
|
||||
case NFC_DECRYPT:
|
||||
case NFC_SIGN: {
|
||||
// build PendingIntent for YubiKey NFC operations
|
||||
Intent intent = new Intent(context, NfcOperationActivity.class);
|
||||
// build PendingIntent for Security Token NFC operations
|
||||
Intent intent = new Intent(context, SecurityTokenOperationActivity.class);
|
||||
// pass params through to activity that it can be returned again later to repeat pgp operation
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_SERVICE_INTENT, data);
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_SERVICE_INTENT, data);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInput);
|
||||
return PendingIntent.getActivity(context, 0, intent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
public ArrayList<String> mRevokeUserIds;
|
||||
public ArrayList<Long> mRevokeSubKeys;
|
||||
|
||||
// if these are non-null, PINs will be changed on the card
|
||||
public Passphrase mCardPin;
|
||||
public Passphrase mCardAdminPin;
|
||||
// if these are non-null, PINs will be changed on the token
|
||||
public Passphrase mSecurityTokenPin;
|
||||
public Passphrase mSecurityTokenAdminPin;
|
||||
|
||||
// private because they have to be set together with setUpdateOptions
|
||||
private boolean mUpload;
|
||||
@@ -89,8 +89,8 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
mChangeSubKeys = new ArrayList<>();
|
||||
mRevokeUserIds = new ArrayList<>();
|
||||
mRevokeSubKeys = new ArrayList<>();
|
||||
mCardPin = null;
|
||||
mCardAdminPin = null;
|
||||
mSecurityTokenPin = null;
|
||||
mSecurityTokenAdminPin = null;
|
||||
mUpload = false;
|
||||
mUploadAtomic = false;
|
||||
mKeyserver = null;
|
||||
@@ -128,7 +128,7 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
|
||||
for (SubkeyChange change : mChangeSubKeys) {
|
||||
if (change.mRecertify || change.mFlags != null || change.mExpiry != null
|
||||
|| change.mMoveKeyToCard) {
|
||||
|| change.mMoveKeyToSecurityToken) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -175,11 +175,11 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
public boolean mRecertify;
|
||||
// if this flag is true, the subkey should be changed to a stripped key
|
||||
public boolean mDummyStrip;
|
||||
// if this flag is true, the subkey should be moved to a card
|
||||
public boolean mMoveKeyToCard;
|
||||
// if this flag is true, the subkey should be moved to a security token
|
||||
public boolean mMoveKeyToSecurityToken;
|
||||
// if this is non-null, the subkey will be changed to a divert-to-card
|
||||
// key for the given serial number
|
||||
public byte[] mDummyDivert;
|
||||
// (security token) key for the given serial number
|
||||
public byte[] mSecurityTokenSerialNo;
|
||||
|
||||
public SubkeyChange(long keyId) {
|
||||
mKeyId = keyId;
|
||||
@@ -196,16 +196,17 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
mExpiry = expiry;
|
||||
}
|
||||
|
||||
public SubkeyChange(long keyId, boolean dummyStrip, boolean moveKeyToCard) {
|
||||
public SubkeyChange(long keyId, boolean dummyStrip, boolean moveKeyToSecurityToken) {
|
||||
this(keyId, null, null);
|
||||
|
||||
// these flags are mutually exclusive!
|
||||
if (dummyStrip && moveKeyToCard) {
|
||||
if (dummyStrip && moveKeyToSecurityToken) {
|
||||
throw new AssertionError(
|
||||
"cannot set strip and keytocard flags at the same time - this is a bug!");
|
||||
"cannot set strip and moveKeyToSecurityToken" +
|
||||
" flags at the same time - this is a bug!");
|
||||
}
|
||||
mDummyStrip = dummyStrip;
|
||||
mMoveKeyToCard = moveKeyToCard;
|
||||
mMoveKeyToSecurityToken = moveKeyToSecurityToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,8 +215,8 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
out += "mFlags: " + mFlags + ", ";
|
||||
out += "mExpiry: " + mExpiry + ", ";
|
||||
out += "mDummyStrip: " + mDummyStrip + ", ";
|
||||
out += "mMoveKeyToCard: " + mMoveKeyToCard + ", ";
|
||||
out += "mDummyDivert: [" + (mDummyDivert == null ? 0 : mDummyDivert.length) + " bytes]";
|
||||
out += "mMoveKeyToSecurityToken: " + mMoveKeyToSecurityToken + ", ";
|
||||
out += "mSecurityTokenSerialNo: [" + (mSecurityTokenSerialNo == null ? 0 : mSecurityTokenSerialNo.length) + " bytes]";
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -259,8 +260,8 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
mRevokeUserIds = source.createStringArrayList();
|
||||
mRevokeSubKeys = (ArrayList<Long>) source.readSerializable();
|
||||
|
||||
mCardPin = source.readParcelable(Passphrase.class.getClassLoader());
|
||||
mCardAdminPin = source.readParcelable(Passphrase.class.getClassLoader());
|
||||
mSecurityTokenPin = source.readParcelable(Passphrase.class.getClassLoader());
|
||||
mSecurityTokenAdminPin = source.readParcelable(Passphrase.class.getClassLoader());
|
||||
|
||||
mUpload = source.readByte() != 0;
|
||||
mUploadAtomic = source.readByte() != 0;
|
||||
@@ -288,8 +289,8 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
destination.writeStringList(mRevokeUserIds);
|
||||
destination.writeSerializable(mRevokeSubKeys);
|
||||
|
||||
destination.writeParcelable(mCardPin, flags);
|
||||
destination.writeParcelable(mCardAdminPin, flags);
|
||||
destination.writeParcelable(mSecurityTokenPin, flags);
|
||||
destination.writeParcelable(mSecurityTokenAdminPin, flags);
|
||||
|
||||
destination.writeByte((byte) (mUpload ? 1 : 0));
|
||||
destination.writeByte((byte) (mUploadAtomic ? 1 : 0));
|
||||
@@ -322,8 +323,8 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
out += "mChangePrimaryUserId: " + mChangePrimaryUserId + "\n";
|
||||
out += "mRevokeUserIds: " + mRevokeUserIds + "\n";
|
||||
out += "mRevokeSubKeys: " + mRevokeSubKeys + "\n";
|
||||
out += "mCardPin: " + mCardPin + "\n";
|
||||
out += "mCardAdminPin: " + mCardAdminPin;
|
||||
out += "mSecurityTokenPin: " + mSecurityTokenPin + "\n";
|
||||
out += "mSecurityTokenAdminPin: " + mSecurityTokenAdminPin;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
@@ -36,16 +36,16 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreateKeyActivity extends BaseNfcActivity {
|
||||
public class CreateKeyActivity extends BaseSecurityTokenNfcActivity {
|
||||
|
||||
public static final String EXTRA_NAME = "name";
|
||||
public static final String EXTRA_EMAIL = "email";
|
||||
public static final String EXTRA_FIRST_TIME = "first_time";
|
||||
public static final String EXTRA_ADDITIONAL_EMAILS = "additional_emails";
|
||||
public static final String EXTRA_PASSPHRASE = "passphrase";
|
||||
public static final String EXTRA_CREATE_YUBI_KEY = "create_yubi_key";
|
||||
public static final String EXTRA_YUBI_KEY_PIN = "yubi_key_pin";
|
||||
public static final String EXTRA_YUBI_KEY_ADMIN_PIN = "yubi_key_admin_pin";
|
||||
public static final String EXTRA_CREATE_SECURITY_TOKEN = "create_yubi_key";
|
||||
public static final String EXTRA_SECURITY_TOKEN_PIN = "yubi_key_pin";
|
||||
public static final String EXTRA_SECURITY_TOKEN_ADMIN_PIN = "yubi_key_admin_pin";
|
||||
|
||||
public static final String EXTRA_NFC_USER_ID = "nfc_user_id";
|
||||
public static final String EXTRA_NFC_AID = "nfc_aid";
|
||||
@@ -58,9 +58,9 @@ public class CreateKeyActivity extends BaseNfcActivity {
|
||||
ArrayList<String> mAdditionalEmails;
|
||||
Passphrase mPassphrase;
|
||||
boolean mFirstTime;
|
||||
boolean mCreateYubiKey;
|
||||
Passphrase mYubiKeyPin;
|
||||
Passphrase mYubiKeyAdminPin;
|
||||
boolean mCreateSecurityToken;
|
||||
Passphrase mSecurityTokenPin;
|
||||
Passphrase mSecurityTokenAdminPin;
|
||||
|
||||
Fragment mCurrentFragment;
|
||||
|
||||
@@ -93,9 +93,9 @@ public class CreateKeyActivity extends BaseNfcActivity {
|
||||
mAdditionalEmails = savedInstanceState.getStringArrayList(EXTRA_ADDITIONAL_EMAILS);
|
||||
mPassphrase = savedInstanceState.getParcelable(EXTRA_PASSPHRASE);
|
||||
mFirstTime = savedInstanceState.getBoolean(EXTRA_FIRST_TIME);
|
||||
mCreateYubiKey = savedInstanceState.getBoolean(EXTRA_CREATE_YUBI_KEY);
|
||||
mYubiKeyPin = savedInstanceState.getParcelable(EXTRA_YUBI_KEY_PIN);
|
||||
mYubiKeyAdminPin = savedInstanceState.getParcelable(EXTRA_YUBI_KEY_ADMIN_PIN);
|
||||
mCreateSecurityToken = savedInstanceState.getBoolean(EXTRA_CREATE_SECURITY_TOKEN);
|
||||
mSecurityTokenPin = savedInstanceState.getParcelable(EXTRA_SECURITY_TOKEN_PIN);
|
||||
mSecurityTokenAdminPin = savedInstanceState.getParcelable(EXTRA_SECURITY_TOKEN_ADMIN_PIN);
|
||||
|
||||
mCurrentFragment = getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG);
|
||||
} else {
|
||||
@@ -105,7 +105,7 @@ public class CreateKeyActivity extends BaseNfcActivity {
|
||||
mName = intent.getStringExtra(EXTRA_NAME);
|
||||
mEmail = intent.getStringExtra(EXTRA_EMAIL);
|
||||
mFirstTime = intent.getBooleanExtra(EXTRA_FIRST_TIME, false);
|
||||
mCreateYubiKey = intent.getBooleanExtra(EXTRA_CREATE_YUBI_KEY, false);
|
||||
mCreateSecurityToken = intent.getBooleanExtra(EXTRA_CREATE_SECURITY_TOKEN, false);
|
||||
|
||||
if (intent.hasExtra(EXTRA_NFC_FINGERPRINTS)) {
|
||||
byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS);
|
||||
@@ -113,13 +113,13 @@ public class CreateKeyActivity extends BaseNfcActivity {
|
||||
byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID);
|
||||
|
||||
if (containsKeys(nfcFingerprints)) {
|
||||
Fragment frag = CreateYubiKeyImportResetFragment.newInstance(
|
||||
Fragment frag = CreateSecurityTokenImportResetFragment.newInstance(
|
||||
nfcFingerprints, nfcAid, nfcUserId);
|
||||
loadFragment(frag, FragAction.START);
|
||||
|
||||
setTitle(R.string.title_import_keys);
|
||||
} else {
|
||||
Fragment frag = CreateYubiKeyBlankFragment.newInstance();
|
||||
Fragment frag = CreateSecurityTokenBlankFragment.newInstance();
|
||||
loadFragment(frag, FragAction.START);
|
||||
setTitle(R.string.title_manage_my_keys);
|
||||
}
|
||||
@@ -169,19 +169,19 @@ public class CreateKeyActivity extends BaseNfcActivity {
|
||||
|
||||
Intent intent = new Intent(this, ViewKeyActivity.class);
|
||||
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mScannedFingerprints);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_FINGERPRINTS, mScannedFingerprints);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Fragment frag = CreateYubiKeyImportResetFragment.newInstance(
|
||||
Fragment frag = CreateSecurityTokenImportResetFragment.newInstance(
|
||||
mScannedFingerprints, mNfcAid, mNfcUserId);
|
||||
loadFragment(frag, FragAction.TO_RIGHT);
|
||||
}
|
||||
} else {
|
||||
Fragment frag = CreateYubiKeyBlankFragment.newInstance();
|
||||
Fragment frag = CreateSecurityTokenBlankFragment.newInstance();
|
||||
loadFragment(frag, FragAction.TO_RIGHT);
|
||||
}
|
||||
}
|
||||
@@ -209,9 +209,9 @@ public class CreateKeyActivity extends BaseNfcActivity {
|
||||
outState.putStringArrayList(EXTRA_ADDITIONAL_EMAILS, mAdditionalEmails);
|
||||
outState.putParcelable(EXTRA_PASSPHRASE, mPassphrase);
|
||||
outState.putBoolean(EXTRA_FIRST_TIME, mFirstTime);
|
||||
outState.putBoolean(EXTRA_CREATE_YUBI_KEY, mCreateYubiKey);
|
||||
outState.putParcelable(EXTRA_YUBI_KEY_PIN, mYubiKeyPin);
|
||||
outState.putParcelable(EXTRA_YUBI_KEY_ADMIN_PIN, mYubiKeyAdminPin);
|
||||
outState.putBoolean(EXTRA_CREATE_SECURITY_TOKEN, mCreateSecurityToken);
|
||||
outState.putParcelable(EXTRA_SECURITY_TOKEN_PIN, mSecurityTokenPin);
|
||||
outState.putParcelable(EXTRA_SECURITY_TOKEN_ADMIN_PIN, mSecurityTokenAdminPin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -235,10 +235,10 @@ public class CreateKeyEmailFragment extends Fragment {
|
||||
|
||||
CreateKeyActivity createKeyActivity = ((CreateKeyActivity) getActivity());
|
||||
|
||||
if (createKeyActivity.mCreateYubiKey) {
|
||||
if (createKeyActivity.mCreateSecurityToken) {
|
||||
hideKeyboard();
|
||||
|
||||
CreateYubiKeyPinFragment frag = CreateYubiKeyPinFragment.newInstance();
|
||||
CreateSecurityTokenPinFragment frag = CreateSecurityTokenPinFragment.newInstance();
|
||||
mCreateKeyActivity.loadFragment(frag, FragAction.TO_RIGHT);
|
||||
} else {
|
||||
CreateKeyPassphraseFragment frag = CreateKeyPassphraseFragment.newInstance();
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Iterator;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -188,7 +187,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
if (mSaveKeyringParcel == null) {
|
||||
mSaveKeyringParcel = new SaveKeyringParcel();
|
||||
|
||||
if (createKeyActivity.mCreateYubiKey) {
|
||||
if (createKeyActivity.mCreateSecurityToken) {
|
||||
mSaveKeyringParcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Algorithm.RSA,
|
||||
2048, null, KeyFlags.SIGN_DATA | KeyFlags.CERTIFY_OTHER, 0L));
|
||||
mSaveKeyringParcel.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(Algorithm.RSA,
|
||||
@@ -263,7 +262,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean createYubiKey = activity.mCreateYubiKey;
|
||||
final boolean createSecurityToken = activity.mCreateSecurityToken;
|
||||
|
||||
CryptoOperationHelper.Callback<SaveKeyringParcel, EditKeyResult> createKeyCallback
|
||||
= new CryptoOperationHelper.Callback<SaveKeyringParcel, EditKeyResult>() {
|
||||
@@ -275,7 +274,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
@Override
|
||||
public void onCryptoOperationSuccess(EditKeyResult result) {
|
||||
|
||||
if (createYubiKey) {
|
||||
if (createSecurityToken) {
|
||||
moveToCard(result);
|
||||
return;
|
||||
}
|
||||
@@ -327,7 +326,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
try {
|
||||
changeKeyringParcel = new SaveKeyringParcel(key.getMasterKeyId(), key.getFingerprint());
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Log.e(Constants.TAG, "Key that should be moved to YubiKey not found in database!");
|
||||
Log.e(Constants.TAG, "Key that should be moved to Security Token not found in database!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -339,7 +338,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
try {
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
long subkeyId = cursor.getLong(0);
|
||||
changeKeyringParcel.getOrCreateSubkeyChange(subkeyId).mMoveKeyToCard = true;
|
||||
changeKeyringParcel.getOrCreateSubkeyChange(subkeyId).mMoveKeyToSecurityToken = true;
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
@@ -348,8 +347,8 @@ public class CreateKeyFinalFragment extends Fragment {
|
||||
}
|
||||
|
||||
// define new PIN and Admin PIN for the card
|
||||
changeKeyringParcel.mCardPin = activity.mYubiKeyPin;
|
||||
changeKeyringParcel.mCardAdminPin = activity.mYubiKeyAdminPin;
|
||||
changeKeyringParcel.mSecurityTokenPin = activity.mSecurityTokenPin;
|
||||
changeKeyringParcel.mSecurityTokenAdminPin = activity.mSecurityTokenAdminPin;
|
||||
|
||||
CryptoOperationHelper.Callback<SaveKeyringParcel, EditKeyResult> callback
|
||||
= new CryptoOperationHelper.Callback<SaveKeyringParcel, EditKeyResult>() {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class CreateKeyStartFragment extends Fragment {
|
||||
|
||||
View mCreateKey;
|
||||
View mImportKey;
|
||||
View mYubiKey;
|
||||
View mSecurityToken;
|
||||
TextView mSkipOrCancel;
|
||||
public static final int REQUEST_CODE_IMPORT_KEY = 0x00007012;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CreateKeyStartFragment extends Fragment {
|
||||
|
||||
mCreateKey = view.findViewById(R.id.create_key_create_key_button);
|
||||
mImportKey = view.findViewById(R.id.create_key_import_button);
|
||||
mYubiKey = view.findViewById(R.id.create_key_yubikey_button);
|
||||
mSecurityToken = view.findViewById(R.id.create_key_security_token_button);
|
||||
mSkipOrCancel = (TextView) view.findViewById(R.id.create_key_cancel);
|
||||
|
||||
if (mCreateKeyActivity.mFirstTime) {
|
||||
@@ -78,10 +78,10 @@ public class CreateKeyStartFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
mYubiKey.setOnClickListener(new View.OnClickListener() {
|
||||
mSecurityToken.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CreateYubiKeyWaitFragment frag = new CreateYubiKeyWaitFragment();
|
||||
CreateSecurityTokenWaitFragment frag = new CreateSecurityTokenWaitFragment();
|
||||
mCreateKeyActivity.loadFragment(frag, FragAction.TO_RIGHT);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ import android.view.ViewGroup;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
|
||||
|
||||
public class CreateYubiKeyBlankFragment extends Fragment {
|
||||
public class CreateSecurityTokenBlankFragment extends Fragment {
|
||||
|
||||
CreateKeyActivity mCreateKeyActivity;
|
||||
View mBackButton;
|
||||
@@ -36,8 +36,8 @@ public class CreateYubiKeyBlankFragment extends Fragment {
|
||||
/**
|
||||
* Creates new instance of this fragment
|
||||
*/
|
||||
public static CreateYubiKeyBlankFragment newInstance() {
|
||||
CreateYubiKeyBlankFragment frag = new CreateYubiKeyBlankFragment();
|
||||
public static CreateSecurityTokenBlankFragment newInstance() {
|
||||
CreateSecurityTokenBlankFragment frag = new CreateSecurityTokenBlankFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
|
||||
@@ -81,7 +81,7 @@ public class CreateYubiKeyBlankFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void nextClicked() {
|
||||
mCreateKeyActivity.mCreateYubiKey = true;
|
||||
mCreateKeyActivity.mCreateSecurityToken = true;
|
||||
|
||||
CreateKeyNameFragment frag = CreateKeyNameFragment.newInstance();
|
||||
mCreateKeyActivity.loadFragment(frag, FragAction.TO_RIGHT);
|
||||
@@ -49,7 +49,7 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
|
||||
public class CreateYubiKeyImportResetFragment
|
||||
public class CreateSecurityTokenImportResetFragment
|
||||
extends QueueingCryptoOperationFragment<ImportKeyringParcel, ImportKeyResult>
|
||||
implements NfcListenerFragment {
|
||||
|
||||
@@ -61,10 +61,10 @@ public class CreateYubiKeyImportResetFragment
|
||||
|
||||
CreateKeyActivity mCreateKeyActivity;
|
||||
|
||||
private byte[] mNfcFingerprints;
|
||||
private byte[] mNfcAid;
|
||||
private String mNfcUserId;
|
||||
private String mNfcFingerprint;
|
||||
private byte[] mTokenFingerprints;
|
||||
private byte[] mTokenAid;
|
||||
private String mTokenUserId;
|
||||
private String mTokenFingerprint;
|
||||
private ImportKeysListFragment mListFragment;
|
||||
private TextView vSerNo;
|
||||
private TextView vUserId;
|
||||
@@ -79,7 +79,7 @@ public class CreateYubiKeyImportResetFragment
|
||||
|
||||
public static Fragment newInstance(byte[] scannedFingerprints, byte[] nfcAid, String userId) {
|
||||
|
||||
CreateYubiKeyImportResetFragment frag = new CreateYubiKeyImportResetFragment();
|
||||
CreateSecurityTokenImportResetFragment frag = new CreateSecurityTokenImportResetFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putByteArray(ARG_FINGERPRINTS, scannedFingerprints);
|
||||
@@ -96,26 +96,26 @@ public class CreateYubiKeyImportResetFragment
|
||||
|
||||
Bundle args = savedInstanceState != null ? savedInstanceState : getArguments();
|
||||
|
||||
mNfcFingerprints = args.getByteArray(ARG_FINGERPRINTS);
|
||||
mNfcAid = args.getByteArray(ARG_AID);
|
||||
mNfcUserId = args.getString(ARG_USER_ID);
|
||||
mTokenFingerprints = args.getByteArray(ARG_FINGERPRINTS);
|
||||
mTokenAid = args.getByteArray(ARG_AID);
|
||||
mTokenUserId = args.getString(ARG_USER_ID);
|
||||
|
||||
byte[] fp = new byte[20];
|
||||
ByteBuffer.wrap(fp).put(mNfcFingerprints, 0, 20);
|
||||
mNfcFingerprint = KeyFormattingUtils.convertFingerprintToHex(fp);
|
||||
ByteBuffer.wrap(fp).put(mTokenFingerprints, 0, 20);
|
||||
mTokenFingerprint = KeyFormattingUtils.convertFingerprintToHex(fp);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.create_yubi_key_import_reset_fragment, container, false);
|
||||
View view = inflater.inflate(R.layout.create_security_token_import_reset_fragment, container, false);
|
||||
|
||||
vSerNo = (TextView) view.findViewById(R.id.yubikey_serno);
|
||||
vUserId = (TextView) view.findViewById(R.id.yubikey_userid);
|
||||
vSerNo = (TextView) view.findViewById(R.id.token_serno);
|
||||
vUserId = (TextView) view.findViewById(R.id.token_userid);
|
||||
mNextButton = (TextView) view.findViewById(R.id.create_key_next_button);
|
||||
mRadioImport = (RadioButton) view.findViewById(R.id.yubikey_decision_import);
|
||||
mRadioReset = (RadioButton) view.findViewById(R.id.yubikey_decision_reset);
|
||||
mResetWarning = view.findViewById(R.id.yubikey_import_reset_warning);
|
||||
mRadioImport = (RadioButton) view.findViewById(R.id.token_decision_import);
|
||||
mRadioReset = (RadioButton) view.findViewById(R.id.token_decision_reset);
|
||||
mResetWarning = view.findViewById(R.id.token_import_reset_warning);
|
||||
|
||||
View mBackButton = view.findViewById(R.id.create_key_back_button);
|
||||
mBackButton.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -142,7 +142,7 @@ public class CreateYubiKeyImportResetFragment
|
||||
});
|
||||
|
||||
mListFragment = ImportKeysListFragment.newInstance(null, null,
|
||||
"0x" + mNfcFingerprint, true, null);
|
||||
"0x" + mTokenFingerprint, true, null);
|
||||
|
||||
mRadioImport.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
@@ -154,7 +154,7 @@ public class CreateYubiKeyImportResetFragment
|
||||
mResetWarning.setVisibility(View.GONE);
|
||||
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.yubikey_import_fragment, mListFragment, "yubikey_import")
|
||||
.replace(R.id.security_token_import_fragment, mListFragment, "token_import")
|
||||
.commit();
|
||||
|
||||
getFragmentManager().executePendingTransactions();
|
||||
@@ -188,9 +188,9 @@ public class CreateYubiKeyImportResetFragment
|
||||
public void onSaveInstanceState(Bundle args) {
|
||||
super.onSaveInstanceState(args);
|
||||
|
||||
args.putByteArray(ARG_FINGERPRINTS, mNfcFingerprints);
|
||||
args.putByteArray(ARG_AID, mNfcAid);
|
||||
args.putString(ARG_USER_ID, mNfcUserId);
|
||||
args.putByteArray(ARG_FINGERPRINTS, mTokenFingerprints);
|
||||
args.putByteArray(ARG_AID, mTokenAid);
|
||||
args.putString(ARG_USER_ID, mTokenUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,25 +200,25 @@ public class CreateYubiKeyImportResetFragment
|
||||
}
|
||||
|
||||
public void setData() {
|
||||
String serno = Hex.toHexString(mNfcAid, 10, 4);
|
||||
vSerNo.setText(getString(R.string.yubikey_serno, serno));
|
||||
String serno = Hex.toHexString(mTokenAid, 10, 4);
|
||||
vSerNo.setText(getString(R.string.security_token_serial_no, serno));
|
||||
|
||||
if (!mNfcUserId.isEmpty()) {
|
||||
vUserId.setText(getString(R.string.yubikey_key_holder, mNfcUserId));
|
||||
if (!mTokenUserId.isEmpty()) {
|
||||
vUserId.setText(getString(R.string.security_token_key_holder, mTokenUserId));
|
||||
} else {
|
||||
vUserId.setText(getString(R.string.yubikey_key_holder_not_set));
|
||||
vUserId.setText(getString(R.string.security_token_key_holder_not_set));
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshSearch() {
|
||||
mListFragment.loadNew(new ImportKeysListFragment.CloudLoaderState("0x" + mNfcFingerprint,
|
||||
mListFragment.loadNew(new ImportKeysListFragment.CloudLoaderState("0x" + mTokenFingerprint,
|
||||
Preferences.getPreferences(getActivity()).getCloudSearchPrefs()));
|
||||
}
|
||||
|
||||
public void importKey() {
|
||||
|
||||
ArrayList<ParcelableKeyRing> keyList = new ArrayList<>();
|
||||
keyList.add(new ParcelableKeyRing(mNfcFingerprint, null));
|
||||
keyList.add(new ParcelableKeyRing(mTokenFingerprint, null));
|
||||
mKeyList = keyList;
|
||||
|
||||
mKeyserver = Preferences.getPreferences(getActivity()).getPreferredKeyserver();
|
||||
@@ -230,11 +230,11 @@ public class CreateYubiKeyImportResetFragment
|
||||
}
|
||||
|
||||
public void resetCard() {
|
||||
Intent intent = new Intent(getActivity(), NfcOperationActivity.class);
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_SERVICE_INTENT, (Parcelable[]) null);
|
||||
Intent intent = new Intent(getActivity(), SecurityTokenOperationActivity.class);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_SERVICE_INTENT, (Parcelable[]) null);
|
||||
RequiredInputParcel resetP = RequiredInputParcel.createNfcReset();
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, resetP);
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_CRYPTO_INPUT, new CryptoInputParcel());
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, resetP);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, new CryptoInputParcel());
|
||||
startActivityForResult(intent, REQUEST_CODE_RESET);
|
||||
}
|
||||
|
||||
@@ -251,13 +251,13 @@ public class CreateYubiKeyImportResetFragment
|
||||
@Override
|
||||
public void doNfcInBackground() throws IOException {
|
||||
|
||||
mNfcFingerprints = mCreateKeyActivity.nfcGetFingerprints();
|
||||
mNfcAid = mCreateKeyActivity.nfcGetAid();
|
||||
mNfcUserId = mCreateKeyActivity.nfcGetUserId();
|
||||
mTokenFingerprints = mCreateKeyActivity.nfcGetFingerprints();
|
||||
mTokenAid = mCreateKeyActivity.nfcGetAid();
|
||||
mTokenUserId = mCreateKeyActivity.nfcGetUserId();
|
||||
|
||||
byte[] fp = new byte[20];
|
||||
ByteBuffer.wrap(fp).put(mNfcFingerprints, 0, 20);
|
||||
mNfcFingerprint = KeyFormattingUtils.convertFingerprintToHex(fp);
|
||||
ByteBuffer.wrap(fp).put(mTokenFingerprints, 0, 20);
|
||||
mTokenFingerprint = KeyFormattingUtils.convertFingerprintToHex(fp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,13 +284,13 @@ public class CreateYubiKeyImportResetFragment
|
||||
Activity activity = getActivity();
|
||||
|
||||
Intent intent = new Intent(activity, ViewKeyActivity.class);
|
||||
// use the imported masterKeyId, not the one from the yubikey, because
|
||||
// use the imported masterKeyId, not the one from the token, because
|
||||
// that one might* just have been a subkey of the imported key
|
||||
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyIds[0]));
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_DISPLAY_RESULT, result);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mNfcFingerprints);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_AID, mTokenAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_USER_ID, mTokenUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_FINGERPRINTS, mTokenFingerprints);
|
||||
startActivity(intent);
|
||||
activity.finish();
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class CreateYubiKeyPinFragment extends Fragment {
|
||||
public class CreateSecurityTokenPinFragment extends Fragment {
|
||||
|
||||
// view
|
||||
CreateKeyActivity mCreateKeyActivity;
|
||||
@@ -65,8 +65,8 @@ public class CreateYubiKeyPinFragment extends Fragment {
|
||||
/**
|
||||
* Creates new instance of this fragment
|
||||
*/
|
||||
public static CreateYubiKeyPinFragment newInstance() {
|
||||
CreateYubiKeyPinFragment frag = new CreateYubiKeyPinFragment();
|
||||
public static CreateSecurityTokenPinFragment newInstance() {
|
||||
CreateSecurityTokenPinFragment frag = new CreateSecurityTokenPinFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
frag.setArguments(args);
|
||||
@@ -109,7 +109,7 @@ public class CreateYubiKeyPinFragment extends Fragment {
|
||||
mBackButton = view.findViewById(R.id.create_key_back_button);
|
||||
mNextButton = view.findViewById(R.id.create_key_next_button);
|
||||
|
||||
if (mCreateKeyActivity.mYubiKeyPin == null) {
|
||||
if (mCreateKeyActivity.mSecurityTokenPin == null) {
|
||||
new AsyncTask<Void, Void, Passphrase>() {
|
||||
@Override
|
||||
protected Passphrase doInBackground(Void... unused) {
|
||||
@@ -129,13 +129,13 @@ public class CreateYubiKeyPinFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Passphrase adminPin) {
|
||||
mCreateKeyActivity.mYubiKeyAdminPin = adminPin;
|
||||
mCreateKeyActivity.mSecurityTokenAdminPin = adminPin;
|
||||
|
||||
mAdminPin.setText(mCreateKeyActivity.mYubiKeyAdminPin.toStringUnsafe());
|
||||
mAdminPin.setText(mCreateKeyActivity.mSecurityTokenAdminPin.toStringUnsafe());
|
||||
}
|
||||
}.execute();
|
||||
} else {
|
||||
mAdminPin.setText(mCreateKeyActivity.mYubiKeyAdminPin.toStringUnsafe());
|
||||
mAdminPin.setText(mCreateKeyActivity.mSecurityTokenAdminPin.toStringUnsafe());
|
||||
}
|
||||
|
||||
mPin.requestFocus();
|
||||
@@ -187,7 +187,7 @@ public class CreateYubiKeyPinFragment extends Fragment {
|
||||
return;
|
||||
}
|
||||
|
||||
mCreateKeyActivity.mYubiKeyPin = new Passphrase(mPin.getText().toString());
|
||||
mCreateKeyActivity.mSecurityTokenPin = new Passphrase(mPin.getText().toString());
|
||||
|
||||
CreateKeyFinalFragment frag = CreateKeyFinalFragment.newInstance();
|
||||
hideKeyboard();
|
||||
@@ -28,14 +28,14 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
|
||||
|
||||
|
||||
public class CreateYubiKeyWaitFragment extends Fragment {
|
||||
public class CreateSecurityTokenWaitFragment extends Fragment {
|
||||
|
||||
CreateKeyActivity mCreateKeyActivity;
|
||||
View mBackButton;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.create_yubi_key_wait_fragment, container, false);
|
||||
View view = inflater.inflate(R.layout.create_security_token_wait_fragment, container, false);
|
||||
|
||||
mBackButton = view.findViewById(R.id.create_key_back_button);
|
||||
|
||||
@@ -435,9 +435,9 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
||||
}
|
||||
// toggle
|
||||
change.mDummyStrip = !change.mDummyStrip;
|
||||
if (change.mDummyStrip && change.mMoveKeyToCard) {
|
||||
if (change.mDummyStrip && change.mMoveKeyToSecurityToken) {
|
||||
// User had chosen to divert key, but now wants to strip it instead.
|
||||
change.mMoveKeyToCard = false;
|
||||
change.mMoveKeyToSecurityToken = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -479,8 +479,8 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
||||
// break;
|
||||
// }
|
||||
// // toggle
|
||||
// change.mMoveKeyToCard = !change.mMoveKeyToCard;
|
||||
// if (change.mMoveKeyToCard && change.mDummyStrip) {
|
||||
// change.mMoveKeyToSecurityToken = !change.mMoveKeyToSecurityToken;
|
||||
// if (change.mMoveKeyToSecurityToken && change.mDummyStrip) {
|
||||
// // User had chosen to strip key, but now wants to divert it.
|
||||
// change.mDummyStrip = false;
|
||||
// }
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
@@ -47,7 +47,7 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ImportKeysActivity extends BaseNfcActivity
|
||||
public class ImportKeysActivity extends BaseSecurityTokenNfcActivity
|
||||
implements CryptoOperationHelper.Callback<ImportKeyringParcel, ImportKeyResult> {
|
||||
|
||||
public static final String ACTION_IMPORT_KEY = OpenKeychainIntents.IMPORT_KEY;
|
||||
|
||||
@@ -40,11 +40,11 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.remote.ui.AppsListFragment;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenNfcActivity;
|
||||
import org.sufficientlysecure.keychain.util.FabContainer;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
public class MainActivity extends BaseNfcActivity implements FabContainer, OnBackStackChangedListener {
|
||||
public class MainActivity extends BaseSecurityTokenNfcActivity implements FabContainer, OnBackStackChangedListener {
|
||||
|
||||
static final int ID_KEYS = 1;
|
||||
static final int ID_ENCRYPT_DECRYPT = 2;
|
||||
|
||||
@@ -261,7 +261,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
hint = getString(R.string.label_pin);
|
||||
break;
|
||||
case DIVERT_TO_CARD:
|
||||
message = getString(R.string.yubikey_pin_for, userId);
|
||||
message = getString(R.string.security_token_pin_for, userId);
|
||||
hint = getString(R.string.label_pin);
|
||||
break;
|
||||
// special case: empty passphrase just returns the empty passphrase
|
||||
@@ -313,7 +313,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
|
||||
mPassphraseEditText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE);
|
||||
mPassphraseEditText.setOnEditorActionListener(this);
|
||||
|
||||
if ((keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForYubiKeyPin())
|
||||
if ((keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForSecurityTokenPin())
|
||||
|| keyType == CanonicalizedSecretKey.SecretKeyType.PIN) {
|
||||
mPassphraseEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
mPassphraseEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@@ -40,12 +39,11 @@ import org.sufficientlysecure.keychain.remote.CryptoInputParcelCacheService;
|
||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.util.ThemeChanger;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.OrientationUtils;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -56,7 +54,7 @@ import java.util.Arrays;
|
||||
* NFC devices.
|
||||
* For the full specs, see http://g10code.com/docs/openpgp-card-2.0.pdf
|
||||
*/
|
||||
public class NfcOperationActivity extends BaseNfcActivity {
|
||||
public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity {
|
||||
|
||||
public static final String EXTRA_REQUIRED_INPUT = "required_input";
|
||||
public static final String EXTRA_CRYPTO_INPUT = "crypto_input";
|
||||
@@ -99,12 +97,12 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
|
||||
mInputParcel = getIntent().getParcelableExtra(EXTRA_CRYPTO_INPUT);
|
||||
|
||||
setTitle(R.string.nfc_text);
|
||||
setTitle(R.string.security_token_nfc_text);
|
||||
|
||||
vAnimator = (ViewAnimator) findViewById(R.id.view_animator);
|
||||
vAnimator.setDisplayedChild(0);
|
||||
vErrorText = (TextView) findViewById(R.id.nfc_activity_3_error_text);
|
||||
vErrorTryAgainButton = (Button) findViewById(R.id.nfc_activity_3_error_try_again);
|
||||
vErrorText = (TextView) findViewById(R.id.security_token_activity_3_error_text);
|
||||
vErrorTryAgainButton = (Button) findViewById(R.id.security_token_activity_3_error_try_again);
|
||||
vErrorTryAgainButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -114,7 +112,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
vAnimator.setDisplayedChild(0);
|
||||
}
|
||||
});
|
||||
Button vCancel = (Button) findViewById(R.id.nfc_activity_0_cancel);
|
||||
Button vCancel = (Button) findViewById(R.id.security_token_activity_0_cancel);
|
||||
vCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -136,13 +134,13 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
// obtain passphrase for this subkey
|
||||
if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.NFC_MOVE_KEY_TO_CARD
|
||||
&& mRequiredInput.mType != RequiredInputParcel.RequiredInputType.NFC_RESET_CARD) {
|
||||
obtainYubiKeyPin(mRequiredInput);
|
||||
obtainSecurityTokenPin(mRequiredInput);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initLayout() {
|
||||
setContentView(R.layout.nfc_operation_activity);
|
||||
setContentView(R.layout.security_token_operation_activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,7 +184,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
KeychainContract.KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(mRequiredInput.getMasterKeyId())
|
||||
);
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
throw new IOException("Couldn't find subkey for key to card operation.");
|
||||
throw new IOException("Couldn't find subkey for key to token operation.");
|
||||
}
|
||||
|
||||
byte[] newPin = mRequiredInput.mInputData[0];
|
||||
@@ -202,7 +200,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
long keyGenerationTimestampMillis = key.getCreationTime().getTime();
|
||||
long keyGenerationTimestamp = keyGenerationTimestampMillis / 1000;
|
||||
byte[] timestampBytes = ByteBuffer.allocate(4).putInt((int) keyGenerationTimestamp).array();
|
||||
byte[] cardSerialNumber = Arrays.copyOf(nfcGetAid(), 16);
|
||||
byte[] tokenSerialNumber = Arrays.copyOf(nfcGetAid(), 16);
|
||||
|
||||
Passphrase passphrase;
|
||||
try {
|
||||
@@ -218,7 +216,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
nfcPutData(0xCE, timestampBytes);
|
||||
nfcPutData(0xC7, key.getFingerprint());
|
||||
} else {
|
||||
throw new IOException("Key slot occupied; card must be reset to put new signature key.");
|
||||
throw new IOException("Key slot occupied; token must be reset to put new signature key.");
|
||||
}
|
||||
} else if (key.canEncrypt()) {
|
||||
if (shouldPutKey(key.getFingerprint(), 1)) {
|
||||
@@ -226,7 +224,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
nfcPutData(0xCF, timestampBytes);
|
||||
nfcPutData(0xC8, key.getFingerprint());
|
||||
} else {
|
||||
throw new IOException("Key slot occupied; card must be reset to put new decryption key.");
|
||||
throw new IOException("Key slot occupied; token must be reset to put new decryption key.");
|
||||
}
|
||||
} else if (key.canAuthenticate()) {
|
||||
if (shouldPutKey(key.getFingerprint(), 2)) {
|
||||
@@ -234,14 +232,14 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
nfcPutData(0xD0, timestampBytes);
|
||||
nfcPutData(0xC9, key.getFingerprint());
|
||||
} else {
|
||||
throw new IOException("Key slot occupied; card must be reset to put new authentication key.");
|
||||
throw new IOException("Key slot occupied; token must be reset to put new authentication key.");
|
||||
}
|
||||
} else {
|
||||
throw new IOException("Inappropriate key flags for smart card key.");
|
||||
throw new IOException("Inappropriate key flags for Security Token key.");
|
||||
}
|
||||
|
||||
// TODO: Is this really used anywhere?
|
||||
mInputParcel.addCryptoData(subkeyBytes, cardSerialNumber);
|
||||
mInputParcel.addCryptoData(subkeyBytes, tokenSerialNumber);
|
||||
}
|
||||
|
||||
// change PINs afterwards
|
||||
@@ -282,7 +280,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
// check all 200ms if YubiKey has been taken away
|
||||
// check all 200ms if Security Token has been taken away
|
||||
while (true) {
|
||||
if (isNfcConnected()) {
|
||||
try {
|
||||
@@ -307,7 +305,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
protected void onNfcError(String error) {
|
||||
pauseTagHandling();
|
||||
|
||||
vErrorText.setText(error + "\n\n" + getString(R.string.nfc_try_again_text));
|
||||
vErrorText.setText(error + "\n\n" + getString(R.string.security_token_nfc_try_again_text));
|
||||
vAnimator.setDisplayedChild(3);
|
||||
}
|
||||
|
||||
@@ -321,17 +319,17 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
}
|
||||
|
||||
private boolean shouldPutKey(byte[] fingerprint, int idx) throws IOException {
|
||||
byte[] cardFingerprint = nfcGetMasterKeyFingerprint(idx);
|
||||
byte[] tokenFingerprint = nfcGetMasterKeyFingerprint(idx);
|
||||
|
||||
// Note: special case: This should not happen, but happens with
|
||||
// https://github.com/FluffyKaon/OpenPGP-Card, thus for now assume true
|
||||
if (cardFingerprint == null) {
|
||||
if (tokenFingerprint == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Slot is empty, or contains this key already. PUT KEY operation is safe
|
||||
if (Arrays.equals(cardFingerprint, BLANK_FINGERPRINT) ||
|
||||
Arrays.equals(cardFingerprint, fingerprint)) {
|
||||
if (Arrays.equals(tokenFingerprint, BLANK_FINGERPRINT) ||
|
||||
Arrays.equals(tokenFingerprint, fingerprint)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.ViewKeyFragment.PostponeType;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenNfcActivity;
|
||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||
@@ -102,13 +102,13 @@ import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
|
||||
public class ViewKeyActivity extends BaseNfcActivity implements
|
||||
public class ViewKeyActivity extends BaseSecurityTokenNfcActivity implements
|
||||
LoaderManager.LoaderCallbacks<Cursor>,
|
||||
CryptoOperationHelper.Callback<ImportKeyringParcel, ImportKeyResult> {
|
||||
|
||||
public static final String EXTRA_NFC_USER_ID = "nfc_user_id";
|
||||
public static final String EXTRA_NFC_AID = "nfc_aid";
|
||||
public static final String EXTRA_NFC_FINGERPRINTS = "nfc_fingerprints";
|
||||
public static final String EXTRA_SECURITY_TOKEN_USER_ID = "security_token_user_id";
|
||||
public static final String EXTRA_SECURITY_TOKEN_AID = "security_token_aid";
|
||||
public static final String EXTRA_SECURITY_TOKEN_FINGERPRINTS = "security_token_fingerprints";
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({REQUEST_QR_FINGERPRINT, REQUEST_BACKUP, REQUEST_CERTIFY, REQUEST_DELETE})
|
||||
@@ -159,7 +159,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
||||
private boolean mIsRevoked = false;
|
||||
private boolean mIsExpired = false;
|
||||
|
||||
private boolean mShowYubikeyAfterCreation = false;
|
||||
private boolean mShowSecurityTokenAfterCreation = false;
|
||||
|
||||
private MenuItem mRefreshItem;
|
||||
private boolean mIsRefreshing;
|
||||
@@ -345,9 +345,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
||||
.commit();
|
||||
}
|
||||
|
||||
// need to postpone loading of the yubikey fragment until after mMasterKeyId
|
||||
// need to postpone loading of the security token fragment until after mMasterKeyId
|
||||
// is available, but we mark here that this should be done
|
||||
mShowYubikeyAfterCreation = true;
|
||||
mShowSecurityTokenAfterCreation = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -656,69 +656,69 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
||||
@Override
|
||||
protected void onNfcPostExecute() {
|
||||
|
||||
long yubiKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(mNfcFingerprints);
|
||||
long tokenId = KeyFormattingUtils.getKeyIdFromFingerprint(mNfcFingerprints);
|
||||
|
||||
try {
|
||||
|
||||
// if the yubikey matches a subkey in any key
|
||||
// if the security token matches a subkey in any key
|
||||
CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(yubiKeyId));
|
||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(tokenId));
|
||||
byte[] candidateFp = ring.getFingerprint();
|
||||
|
||||
// if the master key of that key matches this one, just show the yubikey dialog
|
||||
// if the master key of that key matches this one, just show the token dialog
|
||||
if (KeyFormattingUtils.convertFingerprintToHex(candidateFp).equals(mFingerprintString)) {
|
||||
showYubiKeyFragment(mNfcFingerprints, mNfcUserId, mNfcAid);
|
||||
showSecurityTokenFragment(mNfcFingerprints, mNfcUserId, mNfcAid);
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, offer to go to that key
|
||||
final long masterKeyId = KeyFormattingUtils.getKeyIdFromFingerprint(candidateFp);
|
||||
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
||||
Notify.create(this, R.string.snack_security_token_other, Notify.LENGTH_LONG,
|
||||
Style.WARN, new ActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(
|
||||
ViewKeyActivity.this, ViewKeyActivity.class);
|
||||
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mNfcFingerprints);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_FINGERPRINTS, mNfcFingerprints);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, R.string.snack_yubikey_view).show();
|
||||
}, R.string.snack_security_token_view).show();
|
||||
// and if it's not found, offer import
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Notify.create(this, R.string.snack_yubi_other, Notify.LENGTH_LONG,
|
||||
Notify.create(this, R.string.snack_security_token_other, Notify.LENGTH_LONG,
|
||||
Style.WARN, new ActionListener() {
|
||||
@Override
|
||||
public void onAction() {
|
||||
Intent intent = new Intent(
|
||||
ViewKeyActivity.this, CreateKeyActivity.class);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mNfcFingerprints);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_FINGERPRINTS, mNfcFingerprints);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, R.string.snack_yubikey_import).show();
|
||||
}, R.string.snack_security_token_import).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void showYubiKeyFragment(
|
||||
final byte[] nfcFingerprints, final String nfcUserId, final byte[] nfcAid) {
|
||||
public void showSecurityTokenFragment(
|
||||
final byte[] tokenFingerprints, final String tokenUserId, final byte[] tokenAid) {
|
||||
|
||||
new Handler().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ViewKeyYubiKeyFragment frag = ViewKeyYubiKeyFragment.newInstance(
|
||||
mMasterKeyId, nfcFingerprints, nfcUserId, nfcAid);
|
||||
ViewKeySecurityTokenFragment frag = ViewKeySecurityTokenFragment.newInstance(
|
||||
mMasterKeyId, tokenFingerprints, tokenUserId, tokenAid);
|
||||
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
|
||||
manager.popBackStack("yubikey", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
manager.popBackStack("security_token", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
manager.beginTransaction()
|
||||
.addToBackStack("yubikey")
|
||||
.addToBackStack("security_token")
|
||||
.replace(R.id.view_key_fragment, frag)
|
||||
// if this is called while the activity wasn't resumed, just forget it happened
|
||||
.commitAllowingStateLoss();
|
||||
@@ -888,14 +888,14 @@ public class ViewKeyActivity extends BaseNfcActivity implements
|
||||
mFingerprint = data.getBlob(INDEX_FINGERPRINT);
|
||||
mFingerprintString = KeyFormattingUtils.convertFingerprintToHex(mFingerprint);
|
||||
|
||||
// if it wasn't shown yet, display yubikey fragment
|
||||
if (mShowYubikeyAfterCreation && getIntent().hasExtra(EXTRA_NFC_AID)) {
|
||||
mShowYubikeyAfterCreation = false;
|
||||
// if it wasn't shown yet, display token fragment
|
||||
if (mShowSecurityTokenAfterCreation && getIntent().hasExtra(EXTRA_SECURITY_TOKEN_AID)) {
|
||||
mShowSecurityTokenAfterCreation = false;
|
||||
Intent intent = getIntent();
|
||||
byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS);
|
||||
String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID);
|
||||
byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID);
|
||||
showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
|
||||
byte[] tokenFingerprints = intent.getByteArrayExtra(EXTRA_SECURITY_TOKEN_FINGERPRINTS);
|
||||
String tokenUserId = intent.getStringExtra(EXTRA_SECURITY_TOKEN_USER_ID);
|
||||
byte[] tokenAid = intent.getByteArrayExtra(EXTRA_SECURITY_TOKEN_AID);
|
||||
showSecurityTokenFragment(tokenFingerprints, tokenUserId, tokenAid);
|
||||
}
|
||||
|
||||
mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
|
||||
|
||||
@@ -340,9 +340,9 @@ public class ViewKeyAdvSubkeysFragment extends LoaderFragment implements
|
||||
}
|
||||
// toggle
|
||||
change.mDummyStrip = !change.mDummyStrip;
|
||||
if (change.mDummyStrip && change.mMoveKeyToCard) {
|
||||
if (change.mDummyStrip && change.mMoveKeyToSecurityToken) {
|
||||
// User had chosen to divert key, but now wants to strip it instead.
|
||||
change.mMoveKeyToCard = false;
|
||||
change.mMoveKeyToSecurityToken = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -384,8 +384,8 @@ public class ViewKeyAdvSubkeysFragment extends LoaderFragment implements
|
||||
// break;
|
||||
// }
|
||||
// // toggle
|
||||
// change.mMoveKeyToCard = !change.mMoveKeyToCard;
|
||||
// if (change.mMoveKeyToCard && change.mDummyStrip) {
|
||||
// change.mMoveKeyToSecurityToken = !change.mMoveKeyToSecurityToken;
|
||||
// if (change.mMoveKeyToSecurityToken && change.mDummyStrip) {
|
||||
// // User had chosen to strip key, but now wants to divert it.
|
||||
// change.mDummyStrip = false;
|
||||
// }
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.sufficientlysecure.keychain.ui.base.QueueingCryptoOperationFragment;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
|
||||
public class ViewKeyYubiKeyFragment
|
||||
public class ViewKeySecurityTokenFragment
|
||||
extends QueueingCryptoOperationFragment<PromoteKeyringParcel, PromoteKeyResult>
|
||||
implements LoaderCallbacks<Cursor> {
|
||||
|
||||
@@ -62,9 +62,9 @@ public class ViewKeyYubiKeyFragment
|
||||
private Button vButton;
|
||||
private TextView vStatus;
|
||||
|
||||
public static ViewKeyYubiKeyFragment newInstance(long masterKeyId,
|
||||
public static ViewKeySecurityTokenFragment newInstance(long masterKeyId,
|
||||
byte[] fingerprints, String userId, byte[] aid) {
|
||||
ViewKeyYubiKeyFragment frag = new ViewKeyYubiKeyFragment();
|
||||
ViewKeySecurityTokenFragment frag = new ViewKeySecurityTokenFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putLong(ARG_MASTER_KEY_ID, masterKeyId);
|
||||
@@ -76,7 +76,7 @@ public class ViewKeyYubiKeyFragment
|
||||
return frag;
|
||||
}
|
||||
|
||||
public ViewKeyYubiKeyFragment() {
|
||||
public ViewKeySecurityTokenFragment() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@@ -102,18 +102,18 @@ public class ViewKeyYubiKeyFragment
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.view_key_yubikey, null);
|
||||
View view = inflater.inflate(R.layout.view_key_security_token, null);
|
||||
|
||||
TextView vSerNo = (TextView) view.findViewById(R.id.yubikey_serno);
|
||||
TextView vUserId = (TextView) view.findViewById(R.id.yubikey_userid);
|
||||
TextView vSerNo = (TextView) view.findViewById(R.id.token_serno);
|
||||
TextView vUserId = (TextView) view.findViewById(R.id.token_userid);
|
||||
|
||||
String serno = Hex.toHexString(mCardAid, 10, 4);
|
||||
vSerNo.setText(getString(R.string.yubikey_serno, serno));
|
||||
vSerNo.setText(getString(R.string.security_token_serial_no, serno));
|
||||
|
||||
if (!mUserId.isEmpty()) {
|
||||
vUserId.setText(getString(R.string.yubikey_key_holder, mUserId));
|
||||
vUserId.setText(getString(R.string.security_token_key_holder, mUserId));
|
||||
} else {
|
||||
vUserId.setText(getString(R.string.yubikey_key_holder_not_set));
|
||||
vUserId.setText(getString(R.string.security_token_key_holder_not_set));
|
||||
}
|
||||
|
||||
vButton = (Button) view.findViewById(R.id.button_bind);
|
||||
@@ -124,7 +124,7 @@ public class ViewKeyYubiKeyFragment
|
||||
}
|
||||
});
|
||||
|
||||
vStatus = (TextView) view.findViewById(R.id.yubikey_status);
|
||||
vStatus = (TextView) view.findViewById(R.id.token_status);
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -185,12 +185,12 @@ public class ViewKeyYubiKeyFragment
|
||||
|
||||
if (allBound) {
|
||||
vButton.setVisibility(View.GONE);
|
||||
vStatus.setText(R.string.yubikey_status_bound);
|
||||
vStatus.setText(R.string.security_token_status_bound);
|
||||
} else {
|
||||
vButton.setVisibility(View.VISIBLE);
|
||||
vStatus.setText(noneBound
|
||||
? R.string.yubikey_status_unbound
|
||||
: R.string.yubikey_status_partly);
|
||||
? R.string.security_token_status_unbound
|
||||
: R.string.security_token_status_partly);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class SubkeysAdapter extends CursorAdapter {
|
||||
? mSaveKeyringParcel.getSubkeyChange(keyId)
|
||||
: null;
|
||||
|
||||
if (change != null && (change.mDummyStrip || change.mMoveKeyToCard)) {
|
||||
if (change != null && (change.mDummyStrip || change.mMoveKeyToSecurityToken)) {
|
||||
if (change.mDummyStrip) {
|
||||
algorithmStr.append(", ");
|
||||
final SpannableString boldStripped = new SpannableString(
|
||||
@@ -183,7 +183,7 @@ public class SubkeysAdapter extends CursorAdapter {
|
||||
boldStripped.setSpan(new StyleSpan(Typeface.BOLD), 0, boldStripped.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
algorithmStr.append(boldStripped);
|
||||
}
|
||||
if (change.mMoveKeyToCard) {
|
||||
if (change.mMoveKeyToSecurityToken) {
|
||||
algorithmStr.append(", ");
|
||||
final SpannableString boldDivert = new SpannableString(
|
||||
context.getString(R.string.key_divert)
|
||||
|
||||
@@ -60,9 +60,8 @@ import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
import org.sufficientlysecure.keychain.util.Iso7816TLV;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
public abstract class BaseNfcActivity extends BaseActivity {
|
||||
public abstract class BaseSecurityTokenNfcActivity extends BaseActivity {
|
||||
|
||||
public static final int REQUEST_CODE_PIN = 1;
|
||||
|
||||
@@ -113,9 +112,9 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
|
||||
Intent intent = new Intent(this, ViewKeyActivity.class);
|
||||
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mNfcFingerprints);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_AID, mNfcAid);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_USER_ID, mNfcUserId);
|
||||
intent.putExtra(ViewKeyActivity.EXTRA_SECURITY_TOKEN_FINGERPRINTS, mNfcFingerprints);
|
||||
startActivity(intent);
|
||||
} catch (PgpKeyNotFoundException e) {
|
||||
Intent intent = new Intent(this, CreateKeyActivity.class);
|
||||
@@ -224,12 +223,12 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
private void handleNfcError(IOException e) {
|
||||
|
||||
if (e instanceof TagLostException) {
|
||||
onNfcError(getString(R.string.error_nfc_tag_lost));
|
||||
onNfcError(getString(R.string.security_token_error_tag_lost));
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof IsoDepNotSupportedException) {
|
||||
onNfcError(getString(R.string.error_nfc_iso_dep_not_supported));
|
||||
onNfcError(getString(R.string.security_token_error_iso_dep_not_supported));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -244,69 +243,69 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
if ((status & (short) 0xFFF0) == 0x63C0) {
|
||||
int tries = status & 0x000F;
|
||||
// hook to do something different when PIN is wrong
|
||||
onNfcPinError(getResources().getQuantityString(R.plurals.error_pin, tries, tries));
|
||||
onNfcPinError(getResources().getQuantityString(R.plurals.security_token_error_pin, tries, tries));
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, all status codes are fixed values.
|
||||
switch (status) {
|
||||
// These errors should not occur in everyday use; if they are returned, it means we
|
||||
// made a mistake sending data to the card, or the card is misbehaving.
|
||||
// made a mistake sending data to the token, or the token is misbehaving.
|
||||
case 0x6A80: {
|
||||
onNfcError(getString(R.string.error_nfc_bad_data));
|
||||
onNfcError(getString(R.string.security_token_error_bad_data));
|
||||
break;
|
||||
}
|
||||
case 0x6883: {
|
||||
onNfcError(getString(R.string.error_nfc_chaining_error));
|
||||
onNfcError(getString(R.string.security_token_error_chaining_error));
|
||||
break;
|
||||
}
|
||||
case 0x6B00: {
|
||||
onNfcError(getString(R.string.error_nfc_header, "P1/P2"));
|
||||
onNfcError(getString(R.string.security_token_error_header, "P1/P2"));
|
||||
break;
|
||||
}
|
||||
case 0x6D00: {
|
||||
onNfcError(getString(R.string.error_nfc_header, "INS"));
|
||||
onNfcError(getString(R.string.security_token_error_header, "INS"));
|
||||
break;
|
||||
}
|
||||
case 0x6E00: {
|
||||
onNfcError(getString(R.string.error_nfc_header, "CLA"));
|
||||
onNfcError(getString(R.string.security_token_error_header, "CLA"));
|
||||
break;
|
||||
}
|
||||
// These error conditions are more likely to be experienced by an end user.
|
||||
case 0x6285: {
|
||||
onNfcError(getString(R.string.error_nfc_terminated));
|
||||
onNfcError(getString(R.string.security_token_error_terminated));
|
||||
break;
|
||||
}
|
||||
case 0x6700: {
|
||||
onNfcPinError(getString(R.string.error_nfc_wrong_length));
|
||||
onNfcPinError(getString(R.string.security_token_error_wrong_length));
|
||||
break;
|
||||
}
|
||||
case 0x6982: {
|
||||
onNfcError(getString(R.string.error_nfc_security_not_satisfied));
|
||||
onNfcError(getString(R.string.security_token_error_security_not_satisfied));
|
||||
break;
|
||||
}
|
||||
case 0x6983: {
|
||||
onNfcError(getString(R.string.error_nfc_authentication_blocked));
|
||||
onNfcError(getString(R.string.security_token_error_authentication_blocked));
|
||||
break;
|
||||
}
|
||||
case 0x6985: {
|
||||
onNfcError(getString(R.string.error_nfc_conditions_not_satisfied));
|
||||
onNfcError(getString(R.string.security_token_error_conditions_not_satisfied));
|
||||
break;
|
||||
}
|
||||
// 6A88 is "Not Found" in the spec, but Yubikey also returns 6A83 for this in some cases.
|
||||
case 0x6A88:
|
||||
case 0x6A83: {
|
||||
onNfcError(getString(R.string.error_nfc_data_not_found));
|
||||
onNfcError(getString(R.string.security_token_error_data_not_found));
|
||||
break;
|
||||
}
|
||||
// 6F00 is a JavaCard proprietary status code, SW_UNKNOWN, and usually represents an
|
||||
// unhandled exception on the smart card.
|
||||
// unhandled exception on the security token.
|
||||
case 0x6F00: {
|
||||
onNfcError(getString(R.string.error_nfc_unknown));
|
||||
onNfcError(getString(R.string.security_token_error_unknown));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
onNfcError(getString(R.string.error_nfc, e.getMessage()));
|
||||
onNfcError(getString(R.string.security_token_error, e.getMessage()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -335,7 +334,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
enableNfcForegroundDispatch();
|
||||
}
|
||||
|
||||
protected void obtainYubiKeyPin(RequiredInputParcel requiredInput) {
|
||||
protected void obtainSecurityTokenPin(RequiredInputParcel requiredInput) {
|
||||
|
||||
try {
|
||||
Passphrase passphrase = PassphraseCacheService.getCachedPassphrase(this,
|
||||
@@ -471,7 +470,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
return fptlv.mV;
|
||||
}
|
||||
|
||||
/** Return the PW Status Bytes from the card. This is a simple DO; no TLV decoding needed.
|
||||
/** Return the PW Status Bytes from the token. This is a simple DO; no TLV decoding needed.
|
||||
*
|
||||
* @return Seven bytes in fixed format, plus 0x9000 status word at the end.
|
||||
*/
|
||||
@@ -697,7 +696,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// reactivate card!
|
||||
// reactivate token!
|
||||
String reactivate1 = "00" + "e6" + "00" + "00";
|
||||
String reactivate2 = "00" + "44" + "00" + "00";
|
||||
String response1 = nfcCommunicate(reactivate1);
|
||||
@@ -722,7 +721,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
/** Modifies the user's PW1 or PW3. Before sending, the new PIN will be validated for
|
||||
* conformance to the card's requirements for key length.
|
||||
* conformance to the token's requirements for key length.
|
||||
*
|
||||
* @param pw For PW1, this is 0x81. For PW3 (Admin PIN), mode is 0x83.
|
||||
* @param newPin The new PW1 or PW3.
|
||||
@@ -767,7 +766,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a data object on the card. Automatically validates the proper PIN for the operation.
|
||||
* Stores a data object on the token. Automatically validates the proper PIN for the operation.
|
||||
* Supported for all data objects < 255 bytes in length. Only the cardholder certificate
|
||||
* (0x7F21) can exceed this length.
|
||||
*
|
||||
@@ -800,9 +799,9 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a key on the card in the given slot.
|
||||
* Puts a key on the token in the given slot.
|
||||
*
|
||||
* @param slot The slot on the card where the key should be stored:
|
||||
* @param slot The slot on the token where the key should be stored:
|
||||
* 0xB6: Signature Key
|
||||
* 0xB8: Decipherment Key
|
||||
* 0xA4: Authentication Key
|
||||
@@ -823,12 +822,12 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
|
||||
// Shouldn't happen; the UI should block the user from getting an incompatible key this far.
|
||||
if (crtSecretKey.getModulus().bitLength() > 2048) {
|
||||
throw new IOException("Key too large to export to smart card.");
|
||||
throw new IOException("Key too large to export to Security Token.");
|
||||
}
|
||||
|
||||
// Should happen only rarely; all GnuPG keys since 2006 use public exponent 65537.
|
||||
if (!crtSecretKey.getPublicExponent().equals(new BigInteger("65537"))) {
|
||||
throw new IOException("Invalid public exponent for smart card key.");
|
||||
throw new IOException("Invalid public exponent for smart Security Token.");
|
||||
}
|
||||
|
||||
if (!mPw3Validated) {
|
||||
@@ -884,7 +883,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
String putKeyCommand = "10DB3FFF";
|
||||
String lastPutKeyCommand = "00DB3FFF";
|
||||
|
||||
// Now we're ready to communicate with the card.
|
||||
// Now we're ready to communicate with the token.
|
||||
offset = 0;
|
||||
String response;
|
||||
while(offset < dataToSend.length) {
|
||||
@@ -903,7 +902,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
if (!response.endsWith("9000")) {
|
||||
throw new CardException("Key export to card failed", parseCardStatus(response));
|
||||
throw new CardException("Key export to Security Token failed", parseCardStatus(response));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -914,7 +913,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
/**
|
||||
* Parses out the status word from a JavaCard response string.
|
||||
*
|
||||
* @param response A hex string with the response from the card
|
||||
* @param response A hex string with the response from the token
|
||||
* @return A short indicating the SW1/SW2, or 0 if a status could not be determined.
|
||||
*/
|
||||
short parseCardStatus(String response) {
|
||||
@@ -39,7 +39,7 @@ import org.sufficientlysecure.keychain.service.KeychainService;
|
||||
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
|
||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
|
||||
import org.sufficientlysecure.keychain.ui.NfcOperationActivity;
|
||||
import org.sufficientlysecure.keychain.ui.SecurityTokenOperationActivity;
|
||||
import org.sufficientlysecure.keychain.ui.OrbotRequiredDialogActivity;
|
||||
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
||||
import org.sufficientlysecure.keychain.ui.RetryUploadDialogActivity;
|
||||
@@ -133,9 +133,9 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
||||
case NFC_MOVE_KEY_TO_CARD:
|
||||
case NFC_DECRYPT:
|
||||
case NFC_SIGN: {
|
||||
Intent intent = new Intent(activity, NfcOperationActivity.class);
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||
intent.putExtra(NfcOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInputParcel);
|
||||
Intent intent = new Intent(activity, SecurityTokenOperationActivity.class);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInputParcel);
|
||||
startActivityForResult(intent, REQUEST_CODE_NFC);
|
||||
return;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
||||
case REQUEST_CODE_NFC: {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
CryptoInputParcel cryptoInput =
|
||||
data.getParcelableExtra(NfcOperationActivity.RESULT_CRYPTO_INPUT);
|
||||
data.getParcelableExtra(SecurityTokenOperationActivity.RESULT_CRYPTO_INPUT);
|
||||
cryptoOperation(cryptoInput);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -124,8 +124,8 @@ public class Preferences {
|
||||
return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true);
|
||||
}
|
||||
|
||||
public boolean useNumKeypadForYubiKeyPin() {
|
||||
return mSharedPreferences.getBoolean(Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN, true);
|
||||
public boolean useNumKeypadForSecurityTokenPin() {
|
||||
return mSharedPreferences.getBoolean(Pref.USE_NUMKEYPAD_FOR_SECURITY_TOKEN_PIN, true);
|
||||
}
|
||||
|
||||
public void setFirstTime(boolean value) {
|
||||
|
||||
Reference in New Issue
Block a user