use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.
the class Asn1DecoderTest method testEmptyData.
@SmallTest
@Test
public void testEmptyData() throws TagNotFoundException, InvalidAsn1DataException {
String hex = "e3025a00e3025a00";
Asn1Decoder decoder = new Asn1Decoder(hex);
assertEquals(0, decoder.getPosition());
assertTrue(decoder.hasNextNode());
Asn1Node firstRoot = decoder.nextNode();
assertEquals(hex.length() / 4, decoder.getPosition());
assertTrue(firstRoot.isConstructed());
assertEquals(0xE3, firstRoot.getTag());
Asn1Node childOfFirst = firstRoot.getChild(0x5A);
assertNotNull(childOfFirst);
assertFalse(childOfFirst.isConstructed());
assertEquals(0x5A, childOfFirst.getTag());
assertTrue(childOfFirst.hasValue());
assertArrayEquals(new byte[] {}, childOfFirst.asBytes());
assertTrue(decoder.hasNextNode());
Asn1Node secondRoot = decoder.nextNode();
assertEquals(hex.length() / 2, decoder.getPosition());
assertTrue(secondRoot.isConstructed());
assertEquals(0xE3, secondRoot.getTag());
Asn1Node childOfSecond = secondRoot.getChild(0x5A);
assertNotNull(childOfSecond);
assertFalse(childOfSecond.isConstructed());
assertEquals(0x5A, childOfSecond.getTag());
assertTrue(childOfSecond.hasValue());
assertArrayEquals(new byte[] {}, childOfSecond.asBytes());
assertFalse(decoder.hasNextNode());
assertEquals(hex.length() / 2, decoder.getPosition());
}
use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.
the class Asn1DecoderTest method testLongFormLength.
@SmallTest
@Test
public void testLongFormLength() throws TagNotFoundException, InvalidAsn1DataException {
String hex = "bf37075a820003010203";
Asn1Decoder decoder = new Asn1Decoder(hex);
assertTrue(decoder.hasNextNode());
Asn1Node root = decoder.nextNode();
assertTrue(root.isConstructed());
assertEquals(0xBF37, root.getTag());
assertEquals(10, root.getEncodedLength());
assertTrue(root.isConstructed());
Asn1Node node = root.getChild(0x5A);
assertEquals(5, node.getEncodedLength());
assertArrayEquals(new byte[] { 1, 2, 3 }, node.asBytes());
}
use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.
the class Asn1NodeTest method testBuilderAndGetters.
@SmallTest
@Test
public void testBuilderAndGetters() throws TagNotFoundException, InvalidAsn1DataException {
Asn1Node node = Asn1Node.newBuilder(0x30).addChildAsInteger(0x11, 1234567).addChildAsString(0x12, "This is a test.").addChild(Asn1Node.newBuilder(0x31).addChildAsBits(0x13, 0xF2344).addChildAsBytes(0x14, new byte[] { -1, 0, -1 })).addChildAsBoolean(0x15, true).addChildAsBoolean(0x16, false).addChildren(IccUtils.hexStringToBytes("13040422C4F01403FF00FF")).build();
assertEquals(54, node.getEncodedLength());
assertEquals(52, node.getDataLength());
final String nodeHex = "3034110312D687120F54686973206973206120746573742E310B13040422C4F0" + "1403FF00FF1501FF16010013040422C4F01403FF00FF";
assertEquals(nodeHex, node.toHex());
assertEquals("3034", node.getHeadAsHex());
assertEquals(1234567, node.getChild(0x11).asInteger());
assertEquals("This is a test.", node.getChild(0x12).asString());
assertEquals(0xF2344, node.getChild(0x31).getChild(0x13).asBits());
assertArrayEquals(new byte[] { -1, 0, -1 }, node.getChild(0x31).getChild(0x14).asBytes());
assertTrue(node.getChild(0x15).asBoolean());
assertFalse(node.getChild(0x16).asBoolean());
assertEquals(0xF2344, node.getChild(0x13).asBits());
assertArrayEquals(new byte[] { -1, 0, -1 }, node.getChild(0x14).asBytes());
}
use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.
the class Asn1NodeTest method testWriteToBytes_IndexOutOfBounds.
@SmallTest
@Test(expected = IndexOutOfBoundsException.class)
public void testWriteToBytes_IndexOutOfBounds() throws TagNotFoundException, InvalidAsn1DataException {
Asn1Node node = Asn1Node.newBuilder(0xBF37).addChildAsString(1, "1").build();
byte[] bytes = new byte[1];
node.writeToBytes(bytes, 0);
}
use of com.android.internal.telephony.uicc.asn1.InvalidAsn1DataException in project android_frameworks_opt_telephony by LineageOS.
the class Asn1NodeTest method testAsBoolean_ConstructedTag.
@SmallTest
@Test(expected = IllegalStateException.class)
public void testAsBoolean_ConstructedTag() throws InvalidAsn1DataException {
Asn1Node node = Asn1Node.newBuilder(0xBF37).build();
node.asBoolean();
}
Aggregations