OTG: Rename smartcard -> security token
This commit is contained in:
parent
db57cf3e7e
commit
28a352a288
|
@ -50,9 +50,9 @@ public class ApiPendingIntentFactory {
|
|||
CryptoInputParcel cryptoInput) {
|
||||
|
||||
switch (requiredInput.mType) {
|
||||
case SMARTCARD_MOVE_KEY_TO_CARD:
|
||||
case SMARTCARD_DECRYPT:
|
||||
case SMARTCARD_SIGN: {
|
||||
case SECURITY_TOKEN_MOVE_KEY_TO_CARD:
|
||||
case SECURITY_TOKEN_DECRYPT:
|
||||
case SECURITY_TOKEN_SIGN: {
|
||||
return createNfcOperationPendingIntent(data, requiredInput, cryptoInput);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.Date;
|
|||
public class RequiredInputParcel implements Parcelable {
|
||||
|
||||
public enum RequiredInputType {
|
||||
PASSPHRASE, PASSPHRASE_SYMMETRIC, BACKUP_CODE, SMARTCARD_SIGN, SMARTCARD_DECRYPT,
|
||||
SMARTCARD_MOVE_KEY_TO_CARD, SMARTCARD_RESET_CARD, ENABLE_ORBOT, UPLOAD_FAIL_RETRY,
|
||||
PASSPHRASE, PASSPHRASE_SYMMETRIC, BACKUP_CODE, SECURITY_TOKEN_SIGN, SECURITY_TOKEN_DECRYPT,
|
||||
SECURITY_TOKEN_MOVE_KEY_TO_CARD, SECURITY_TOKEN_RESET_CARD, ENABLE_ORBOT, UPLOAD_FAIL_RETRY,
|
||||
}
|
||||
|
||||
public Date mSignatureTime;
|
||||
|
@ -92,19 +92,19 @@ public class RequiredInputParcel implements Parcelable {
|
|||
public static RequiredInputParcel createNfcSignOperation(
|
||||
long masterKeyId, long subKeyId,
|
||||
byte[] inputHash, int signAlgo, Date signatureTime) {
|
||||
return new RequiredInputParcel(RequiredInputType.SMARTCARD_SIGN,
|
||||
return new RequiredInputParcel(RequiredInputType.SECURITY_TOKEN_SIGN,
|
||||
new byte[][] { inputHash }, new int[] { signAlgo },
|
||||
signatureTime, masterKeyId, subKeyId);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createNfcDecryptOperation(
|
||||
long masterKeyId, long subKeyId, byte[] encryptedSessionKey) {
|
||||
return new RequiredInputParcel(RequiredInputType.SMARTCARD_DECRYPT,
|
||||
return new RequiredInputParcel(RequiredInputType.SECURITY_TOKEN_DECRYPT,
|
||||
new byte[][] { encryptedSessionKey }, null, null, masterKeyId, subKeyId);
|
||||
}
|
||||
|
||||
public static RequiredInputParcel createNfcReset() {
|
||||
return new RequiredInputParcel(RequiredInputType.SMARTCARD_RESET_CARD,
|
||||
return new RequiredInputParcel(RequiredInputType.SECURITY_TOKEN_RESET_CARD,
|
||||
null, null, null, null, null);
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ public class RequiredInputParcel implements Parcelable {
|
|||
signAlgos[i] = mSignAlgos.get(i);
|
||||
}
|
||||
|
||||
return new RequiredInputParcel(RequiredInputType.SMARTCARD_SIGN,
|
||||
return new RequiredInputParcel(RequiredInputType.SECURITY_TOKEN_SIGN,
|
||||
inputHashes, signAlgos, mSignatureTime, mMasterKeyId, mSubKeyId);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class RequiredInputParcel implements Parcelable {
|
|||
if (!mSignatureTime.equals(input.mSignatureTime)) {
|
||||
throw new AssertionError("input times must match, this is a programming error!");
|
||||
}
|
||||
if (input.mType != RequiredInputType.SMARTCARD_SIGN) {
|
||||
if (input.mType != RequiredInputType.SECURITY_TOKEN_SIGN) {
|
||||
throw new AssertionError("operation types must match, this is a progrmming error!");
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ public class RequiredInputParcel implements Parcelable {
|
|||
ByteBuffer buf = ByteBuffer.wrap(mSubkeysToExport.get(0));
|
||||
|
||||
// We need to pass in a subkey here...
|
||||
return new RequiredInputParcel(RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD,
|
||||
return new RequiredInputParcel(RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD,
|
||||
inputData, null, null, mMasterKeyId, buf.getLong());
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ public class RequiredInputParcel implements Parcelable {
|
|||
if (!mMasterKeyId.equals(input.mMasterKeyId)) {
|
||||
throw new AssertionError("Master keys must match, this is a programming error!");
|
||||
}
|
||||
if (input.mType != RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD) {
|
||||
if (input.mType != RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD) {
|
||||
throw new AssertionError("Operation types must match, this is a programming error!");
|
||||
}
|
||||
|
||||
|
|
|
@ -136,8 +136,8 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||
|
||||
private void obtainPassphraseIfRequired() {
|
||||
// obtain passphrase for this subkey
|
||||
if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD
|
||||
&& mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SMARTCARD_RESET_CARD) {
|
||||
if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD
|
||||
&& mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SECURITY_TOKEN_RESET_CARD) {
|
||||
obtainSecurityTokenPin(mRequiredInput);
|
||||
checkPinAvailability();
|
||||
} else {
|
||||
|
@ -182,7 +182,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||
protected void doSecurityTokenInBackground() throws IOException {
|
||||
|
||||
switch (mRequiredInput.mType) {
|
||||
case SMARTCARD_DECRYPT: {
|
||||
case SECURITY_TOKEN_DECRYPT: {
|
||||
for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
|
||||
byte[] encryptedSessionKey = mRequiredInput.mInputData[i];
|
||||
byte[] decryptedSessionKey = mSecurityTokenHelper.decryptSessionKey(encryptedSessionKey);
|
||||
|
@ -190,7 +190,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SMARTCARD_SIGN: {
|
||||
case SECURITY_TOKEN_SIGN: {
|
||||
mInputParcel.addSignatureTime(mRequiredInput.mSignatureTime);
|
||||
|
||||
for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
|
||||
|
@ -201,7 +201,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||
}
|
||||
break;
|
||||
}
|
||||
case SMARTCARD_MOVE_KEY_TO_CARD: {
|
||||
case SECURITY_TOKEN_MOVE_KEY_TO_CARD: {
|
||||
// TODO: assume PIN and Admin PIN to be default for this operation
|
||||
mSecurityTokenHelper.setPin(new Passphrase("123456"));
|
||||
mSecurityTokenHelper.setAdminPin(new Passphrase("12345678"));
|
||||
|
@ -247,7 +247,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||
|
||||
break;
|
||||
}
|
||||
case SMARTCARD_RESET_CARD: {
|
||||
case SECURITY_TOKEN_RESET_CARD: {
|
||||
mSecurityTokenHelper.resetAndWipeToken();
|
||||
|
||||
break;
|
||||
|
@ -277,7 +277,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
|
|||
protected Void doInBackground(Void... params) {
|
||||
// check all 200ms if Security Token has been taken away
|
||||
while (true) {
|
||||
if (isSmartcardConnected()) {
|
||||
if (isSecurityTokenConnected()) {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException ignored) {
|
||||
|
|
|
@ -155,7 +155,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
|
|||
}
|
||||
|
||||
public void securityTokenDiscovered(final Transport transport) {
|
||||
// Actual Smartcard operations are executed in doInBackground to not block the UI thread
|
||||
// Actual Security Token operations are executed in doInBackground to not block the UI thread
|
||||
if (!mTagHandlingEnabled)
|
||||
return;
|
||||
new AsyncTask<Void, Void, IOException>() {
|
||||
|
@ -168,7 +168,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
|
|||
@Override
|
||||
protected IOException doInBackground(Void... params) {
|
||||
try {
|
||||
handleSmartcard(transport);
|
||||
handleSecurityToken(transport);
|
||||
} catch (IOException e) {
|
||||
return e;
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
|
|||
super.onPostExecute(exception);
|
||||
|
||||
if (exception != null) {
|
||||
handleSmartcardError(exception);
|
||||
handleSecurityTokenError(exception);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
|
|||
mTagDispatcher.interceptIntent(intent);
|
||||
}
|
||||
|
||||
private void handleSmartcardError(IOException e) {
|
||||
private void handleSecurityTokenError(IOException e) {
|
||||
|
||||
if (e instanceof TagLostException) {
|
||||
onSecurityTokenError(getString(R.string.security_token_error_tag_lost));
|
||||
|
@ -403,7 +403,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
|
|||
}
|
||||
}
|
||||
|
||||
protected void handleSmartcard(Transport transport) throws IOException {
|
||||
protected void handleSecurityToken(Transport transport) throws IOException {
|
||||
// Don't reconnect if device was already connected
|
||||
if (!(mSecurityTokenHelper.isPersistentConnectionAllowed()
|
||||
&& mSecurityTokenHelper.isConnected()
|
||||
|
@ -414,7 +414,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
|
|||
doSecurityTokenInBackground();
|
||||
}
|
||||
|
||||
public boolean isSmartcardConnected() {
|
||||
public boolean isSecurityTokenConnected() {
|
||||
return mSecurityTokenHelper.isConnected();
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
|
|||
}
|
||||
|
||||
/**
|
||||
* Run smartcard routines if last used token is connected and supports
|
||||
* Run Security Token routines if last used token is connected and supports
|
||||
* persistent connections
|
||||
*/
|
||||
public void checkDeviceConnection() {
|
||||
|
|
|
@ -130,9 +130,9 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||
|
||||
switch (requiredInput.mType) {
|
||||
// always use CryptoOperationHelper.startActivityForResult!
|
||||
case SMARTCARD_MOVE_KEY_TO_CARD:
|
||||
case SMARTCARD_DECRYPT:
|
||||
case SMARTCARD_SIGN: {
|
||||
case SECURITY_TOKEN_MOVE_KEY_TO_CARD:
|
||||
case SECURITY_TOKEN_DECRYPT:
|
||||
case SECURITY_TOKEN_SIGN: {
|
||||
Intent intent = new Intent(activity, SecurityTokenOperationActivity.class);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||
intent.putExtra(SecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInputParcel);
|
||||
|
|
|
@ -876,7 +876,7 @@ public class PgpKeyOperationTest {
|
|||
|
||||
long keyId = KeyringTestingHelper.getSubkeyId(ringSecurityToken, 1);
|
||||
|
||||
{ // moveKeyToSecurityToken should return a pending SMARTCARD_MOVE_KEY_TO_CARD result when presented with the RSA-2048
|
||||
{ // moveKeyToSecurityToken should return a pending SECURITY_TOKEN_MOVE_KEY_TO_CARD result when presented with the RSA-2048
|
||||
// key, and then make key divert-to-card when it gets a serial in the cryptoInputParcel.
|
||||
parcelSecurityToken.reset();
|
||||
parcelSecurityToken.mChangeSubKeys.add(new SubkeyChange(keyId, false, true));
|
||||
|
@ -886,8 +886,8 @@ public class PgpKeyOperationTest {
|
|||
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||
PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken);
|
||||
Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending());
|
||||
Assert.assertEquals("required input should be RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD",
|
||||
result.getRequiredInputParcel().mType, RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD);
|
||||
Assert.assertEquals("required input should be RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD",
|
||||
result.getRequiredInputParcel().mType, RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD);
|
||||
|
||||
// Create a cryptoInputParcel that matches what the SecurityTokenOperationActivity would return.
|
||||
byte[] keyIdBytes = new byte[8];
|
||||
|
@ -920,8 +920,8 @@ public class PgpKeyOperationTest {
|
|||
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||
PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken);
|
||||
Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending());
|
||||
Assert.assertEquals("required input should be RequiredInputType.SMARTCARD_SIGN",
|
||||
RequiredInputType.SMARTCARD_SIGN, result.getRequiredInputParcel().mType);
|
||||
Assert.assertEquals("required input should be RequiredInputType.SECURITY_TOKEN_SIGN",
|
||||
RequiredInputType.SECURITY_TOKEN_SIGN, result.getRequiredInputParcel().mType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue