OTG: Rename smartcard -> security token

This commit is contained in:
Nikita Mikhailov
2016-04-15 02:02:11 +06:00
parent db57cf3e7e
commit 28a352a288
6 changed files with 34 additions and 34 deletions

View File

@@ -50,9 +50,9 @@ public class ApiPendingIntentFactory {
CryptoInputParcel cryptoInput) { CryptoInputParcel cryptoInput) {
switch (requiredInput.mType) { switch (requiredInput.mType) {
case SMARTCARD_MOVE_KEY_TO_CARD: case SECURITY_TOKEN_MOVE_KEY_TO_CARD:
case SMARTCARD_DECRYPT: case SECURITY_TOKEN_DECRYPT:
case SMARTCARD_SIGN: { case SECURITY_TOKEN_SIGN: {
return createNfcOperationPendingIntent(data, requiredInput, cryptoInput); return createNfcOperationPendingIntent(data, requiredInput, cryptoInput);
} }

View File

@@ -14,8 +14,8 @@ import java.util.Date;
public class RequiredInputParcel implements Parcelable { public class RequiredInputParcel implements Parcelable {
public enum RequiredInputType { public enum RequiredInputType {
PASSPHRASE, PASSPHRASE_SYMMETRIC, BACKUP_CODE, SMARTCARD_SIGN, SMARTCARD_DECRYPT, PASSPHRASE, PASSPHRASE_SYMMETRIC, BACKUP_CODE, SECURITY_TOKEN_SIGN, SECURITY_TOKEN_DECRYPT,
SMARTCARD_MOVE_KEY_TO_CARD, SMARTCARD_RESET_CARD, ENABLE_ORBOT, UPLOAD_FAIL_RETRY, SECURITY_TOKEN_MOVE_KEY_TO_CARD, SECURITY_TOKEN_RESET_CARD, ENABLE_ORBOT, UPLOAD_FAIL_RETRY,
} }
public Date mSignatureTime; public Date mSignatureTime;
@@ -92,19 +92,19 @@ public class RequiredInputParcel implements Parcelable {
public static RequiredInputParcel createNfcSignOperation( public static RequiredInputParcel createNfcSignOperation(
long masterKeyId, long subKeyId, long masterKeyId, long subKeyId,
byte[] inputHash, int signAlgo, Date signatureTime) { 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 }, new byte[][] { inputHash }, new int[] { signAlgo },
signatureTime, masterKeyId, subKeyId); signatureTime, masterKeyId, subKeyId);
} }
public static RequiredInputParcel createNfcDecryptOperation( public static RequiredInputParcel createNfcDecryptOperation(
long masterKeyId, long subKeyId, byte[] encryptedSessionKey) { 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); new byte[][] { encryptedSessionKey }, null, null, masterKeyId, subKeyId);
} }
public static RequiredInputParcel createNfcReset() { public static RequiredInputParcel createNfcReset() {
return new RequiredInputParcel(RequiredInputType.SMARTCARD_RESET_CARD, return new RequiredInputParcel(RequiredInputType.SECURITY_TOKEN_RESET_CARD,
null, null, null, null, null); null, null, null, null, null);
} }
@@ -209,7 +209,7 @@ public class RequiredInputParcel implements Parcelable {
signAlgos[i] = mSignAlgos.get(i); signAlgos[i] = mSignAlgos.get(i);
} }
return new RequiredInputParcel(RequiredInputType.SMARTCARD_SIGN, return new RequiredInputParcel(RequiredInputType.SECURITY_TOKEN_SIGN,
inputHashes, signAlgos, mSignatureTime, mMasterKeyId, mSubKeyId); inputHashes, signAlgos, mSignatureTime, mMasterKeyId, mSubKeyId);
} }
@@ -222,7 +222,7 @@ public class RequiredInputParcel implements Parcelable {
if (!mSignatureTime.equals(input.mSignatureTime)) { if (!mSignatureTime.equals(input.mSignatureTime)) {
throw new AssertionError("input times must match, this is a programming error!"); 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!"); 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)); ByteBuffer buf = ByteBuffer.wrap(mSubkeysToExport.get(0));
// We need to pass in a subkey here... // 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()); inputData, null, null, mMasterKeyId, buf.getLong());
} }
@@ -287,7 +287,7 @@ public class RequiredInputParcel implements Parcelable {
if (!mMasterKeyId.equals(input.mMasterKeyId)) { if (!mMasterKeyId.equals(input.mMasterKeyId)) {
throw new AssertionError("Master keys must match, this is a programming error!"); 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!"); throw new AssertionError("Operation types must match, this is a programming error!");
} }

View File

@@ -136,8 +136,8 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
private void obtainPassphraseIfRequired() { private void obtainPassphraseIfRequired() {
// obtain passphrase for this subkey // obtain passphrase for this subkey
if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD if (mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD
&& mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SMARTCARD_RESET_CARD) { && mRequiredInput.mType != RequiredInputParcel.RequiredInputType.SECURITY_TOKEN_RESET_CARD) {
obtainSecurityTokenPin(mRequiredInput); obtainSecurityTokenPin(mRequiredInput);
checkPinAvailability(); checkPinAvailability();
} else { } else {
@@ -182,7 +182,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
protected void doSecurityTokenInBackground() throws IOException { protected void doSecurityTokenInBackground() throws IOException {
switch (mRequiredInput.mType) { switch (mRequiredInput.mType) {
case SMARTCARD_DECRYPT: { case SECURITY_TOKEN_DECRYPT: {
for (int i = 0; i < mRequiredInput.mInputData.length; i++) { for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
byte[] encryptedSessionKey = mRequiredInput.mInputData[i]; byte[] encryptedSessionKey = mRequiredInput.mInputData[i];
byte[] decryptedSessionKey = mSecurityTokenHelper.decryptSessionKey(encryptedSessionKey); byte[] decryptedSessionKey = mSecurityTokenHelper.decryptSessionKey(encryptedSessionKey);
@@ -190,7 +190,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
} }
break; break;
} }
case SMARTCARD_SIGN: { case SECURITY_TOKEN_SIGN: {
mInputParcel.addSignatureTime(mRequiredInput.mSignatureTime); mInputParcel.addSignatureTime(mRequiredInput.mSignatureTime);
for (int i = 0; i < mRequiredInput.mInputData.length; i++) { for (int i = 0; i < mRequiredInput.mInputData.length; i++) {
@@ -201,7 +201,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
} }
break; 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 // TODO: assume PIN and Admin PIN to be default for this operation
mSecurityTokenHelper.setPin(new Passphrase("123456")); mSecurityTokenHelper.setPin(new Passphrase("123456"));
mSecurityTokenHelper.setAdminPin(new Passphrase("12345678")); mSecurityTokenHelper.setAdminPin(new Passphrase("12345678"));
@@ -247,7 +247,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
break; break;
} }
case SMARTCARD_RESET_CARD: { case SECURITY_TOKEN_RESET_CARD: {
mSecurityTokenHelper.resetAndWipeToken(); mSecurityTokenHelper.resetAndWipeToken();
break; break;
@@ -277,7 +277,7 @@ public class SecurityTokenOperationActivity extends BaseSecurityTokenNfcActivity
protected Void doInBackground(Void... params) { protected Void doInBackground(Void... params) {
// check all 200ms if Security Token has been taken away // check all 200ms if Security Token has been taken away
while (true) { while (true) {
if (isSmartcardConnected()) { if (isSecurityTokenConnected()) {
try { try {
Thread.sleep(200); Thread.sleep(200);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {

View File

@@ -155,7 +155,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
} }
public void securityTokenDiscovered(final Transport transport) { 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) if (!mTagHandlingEnabled)
return; return;
new AsyncTask<Void, Void, IOException>() { new AsyncTask<Void, Void, IOException>() {
@@ -168,7 +168,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
@Override @Override
protected IOException doInBackground(Void... params) { protected IOException doInBackground(Void... params) {
try { try {
handleSmartcard(transport); handleSecurityToken(transport);
} catch (IOException e) { } catch (IOException e) {
return e; return e;
} }
@@ -181,7 +181,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
super.onPostExecute(exception); super.onPostExecute(exception);
if (exception != null) { if (exception != null) {
handleSmartcardError(exception); handleSecurityTokenError(exception);
return; return;
} }
@@ -237,7 +237,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
mTagDispatcher.interceptIntent(intent); mTagDispatcher.interceptIntent(intent);
} }
private void handleSmartcardError(IOException e) { private void handleSecurityTokenError(IOException e) {
if (e instanceof TagLostException) { if (e instanceof TagLostException) {
onSecurityTokenError(getString(R.string.security_token_error_tag_lost)); 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 // Don't reconnect if device was already connected
if (!(mSecurityTokenHelper.isPersistentConnectionAllowed() if (!(mSecurityTokenHelper.isPersistentConnectionAllowed()
&& mSecurityTokenHelper.isConnected() && mSecurityTokenHelper.isConnected()
@@ -414,7 +414,7 @@ public abstract class BaseSecurityTokenNfcActivity extends BaseActivity
doSecurityTokenInBackground(); doSecurityTokenInBackground();
} }
public boolean isSmartcardConnected() { public boolean isSecurityTokenConnected() {
return mSecurityTokenHelper.isConnected(); 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 * persistent connections
*/ */
public void checkDeviceConnection() { public void checkDeviceConnection() {

View File

@@ -130,9 +130,9 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
switch (requiredInput.mType) { switch (requiredInput.mType) {
// always use CryptoOperationHelper.startActivityForResult! // always use CryptoOperationHelper.startActivityForResult!
case SMARTCARD_MOVE_KEY_TO_CARD: case SECURITY_TOKEN_MOVE_KEY_TO_CARD:
case SMARTCARD_DECRYPT: case SECURITY_TOKEN_DECRYPT:
case SMARTCARD_SIGN: { case SECURITY_TOKEN_SIGN: {
Intent intent = new Intent(activity, SecurityTokenOperationActivity.class); Intent intent = new Intent(activity, SecurityTokenOperationActivity.class);
intent.putExtra(SecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput); intent.putExtra(SecurityTokenOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
intent.putExtra(SecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInputParcel); intent.putExtra(SecurityTokenOperationActivity.EXTRA_CRYPTO_INPUT, cryptoInputParcel);

View File

@@ -876,7 +876,7 @@ public class PgpKeyOperationTest {
long keyId = KeyringTestingHelper.getSubkeyId(ringSecurityToken, 1); 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. // key, and then make key divert-to-card when it gets a serial in the cryptoInputParcel.
parcelSecurityToken.reset(); parcelSecurityToken.reset();
parcelSecurityToken.mChangeSubKeys.add(new SubkeyChange(keyId, false, true)); parcelSecurityToken.mChangeSubKeys.add(new SubkeyChange(keyId, false, true));
@@ -886,8 +886,8 @@ public class PgpKeyOperationTest {
PgpKeyOperation op = new PgpKeyOperation(null); PgpKeyOperation op = new PgpKeyOperation(null);
PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken); PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken);
Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending()); Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending());
Assert.assertEquals("required input should be RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD", Assert.assertEquals("required input should be RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD",
result.getRequiredInputParcel().mType, RequiredInputType.SMARTCARD_MOVE_KEY_TO_CARD); result.getRequiredInputParcel().mType, RequiredInputType.SECURITY_TOKEN_MOVE_KEY_TO_CARD);
// Create a cryptoInputParcel that matches what the SecurityTokenOperationActivity would return. // Create a cryptoInputParcel that matches what the SecurityTokenOperationActivity would return.
byte[] keyIdBytes = new byte[8]; byte[] keyIdBytes = new byte[8];
@@ -920,8 +920,8 @@ public class PgpKeyOperationTest {
PgpKeyOperation op = new PgpKeyOperation(null); PgpKeyOperation op = new PgpKeyOperation(null);
PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken); PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken);
Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending()); Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending());
Assert.assertEquals("required input should be RequiredInputType.SMARTCARD_SIGN", Assert.assertEquals("required input should be RequiredInputType.SECURITY_TOKEN_SIGN",
RequiredInputType.SMARTCARD_SIGN, result.getRequiredInputParcel().mType); RequiredInputType.SECURITY_TOKEN_SIGN, result.getRequiredInputParcel().mType);
} }
} }