Use more generic 'Security Token' where possible, add sutitle to create key what tokens are supported

This commit is contained in:
Dominik Schürmann
2016-01-10 17:17:57 +01:00
parent 9163b93a90
commit 0fd5b45df9
57 changed files with 753 additions and 727 deletions

View File

@@ -829,7 +829,7 @@ public class PgpKeyOperationTest {
}
@Test
public void testKeyToCard() throws Exception {
public void testKeyToSecurityToken() throws Exception {
// Special keyring for security token tests with 2048 bit RSA as a subkey
SaveKeyringParcel parcelKey = new SaveKeyringParcel();
@@ -857,27 +857,27 @@ public class PgpKeyOperationTest {
UncachedKeyRing modified;
{ // keytocard should fail with BAD_NFC_SIZE when presented with the RSA-3072 key
{ // moveKeyToSecurityToken should fail with BAD_NFC_SIZE when presented with the RSA-3072 key
long keyId = KeyringTestingHelper.getSubkeyId(ringSecurityToken, 2);
parcelSecurityToken.reset();
parcelSecurityToken.mChangeSubKeys.add(new SubkeyChange(keyId, false, true));
assertModifyFailure("keytocard operation should fail on invalid key size", ringSecurityToken,
parcelSecurityToken, cryptoInput, LogType.MSG_MF_ERROR_BAD_NFC_SIZE);
assertModifyFailure("moveKeyToSecurityToken operation should fail on invalid key size", ringSecurityToken,
parcelSecurityToken, cryptoInput, LogType.MSG_MF_ERROR_BAD_SECURITY_TOKEN_SIZE);
}
{ // keytocard should fail with BAD_NFC_ALGO when presented with the DSA-1024 key
{ // moveKeyToSecurityToken should fail with BAD_NFC_ALGO when presented with the DSA-1024 key
long keyId = KeyringTestingHelper.getSubkeyId(ringSecurityToken, 0);
parcelSecurityToken.reset();
parcelSecurityToken.mChangeSubKeys.add(new SubkeyChange(keyId, false, true));
assertModifyFailure("keytocard operation should fail on invalid key algorithm", ringSecurityToken,
parcelSecurityToken, cryptoInput, LogType.MSG_MF_ERROR_BAD_NFC_ALGO);
assertModifyFailure("moveKeyToSecurityToken operation should fail on invalid key algorithm", ringSecurityToken,
parcelSecurityToken, cryptoInput, LogType.MSG_MF_ERROR_BAD_SECURITY_TOKEN_ALGO);
}
long keyId = KeyringTestingHelper.getSubkeyId(ringSecurityToken, 1);
{ // keytocard should return a pending NFC_MOVE_KEY_TO_CARD result when presented with the RSA-2048
{ // moveKeyToSecurityToken should return a pending NFC_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,11 +886,11 @@ public class PgpKeyOperationTest {
new CanonicalizedSecretKeyRing(ringSecurityToken.getEncoded(), false, 0);
PgpKeyOperation op = new PgpKeyOperation(null);
PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken);
Assert.assertTrue("keytocard operation should be pending", result.isPending());
Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending());
Assert.assertEquals("required input should be RequiredInputType.NFC_MOVE_KEY_TO_CARD",
result.getRequiredInputParcel().mType, RequiredInputType.NFC_MOVE_KEY_TO_CARD);
// Create a cryptoInputParcel that matches what the NFCOperationActivity would return.
// Create a cryptoInputParcel that matches what the SecurityTokenOperationActivity would return.
byte[] keyIdBytes = new byte[8];
ByteBuffer buf = ByteBuffer.wrap(keyIdBytes);
buf.putLong(keyId).rewind();
@@ -920,7 +920,7 @@ public class PgpKeyOperationTest {
new CanonicalizedSecretKeyRing(modified.getEncoded(), false, 0);
PgpKeyOperation op = new PgpKeyOperation(null);
PgpEditKeyResult result = op.modifySecretKeyRing(secretRing, cryptoInput, parcelSecurityToken);
Assert.assertTrue("keytocard operation should be pending", result.isPending());
Assert.assertTrue("moveKeyToSecurityToken operation should be pending", result.isPending());
Assert.assertEquals("required input should be RequiredInputType.NFC_SIGN",
RequiredInputType.NFC_SIGN, result.getRequiredInputParcel().mType);
}

View File

@@ -40,7 +40,7 @@ public class Iso7816TLVTest {
@Test
public void testDecode() throws Exception {
// this is an Application Related Data packet, received from my Yubikey
// this is an Application Related Data packet, received from my YubiKey NEO
String input = "6e81dd4f10d27600012401020000000000000100005f520f0073000080000000000000000000007300c00af00000ff04c000ff00ffc106010800001103c206010800001103c306010800001103c407007f7f7f030303c53c1efdb4845ca242ca6977fddb1f788094fd3b430af1114c28a08d8c5afda81191cc50ca9bf51bc99fe8e6ca03a9d4d40e7b5925cd154813df381655b2c63c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cd0c5423590e5423590e5423590e9000";
byte[] data = Hex.decode(input);