@Test public void testOIDEncoding2() { // created using wireshark int[] oid = new int[] {1, 2, 840, 113549, 1, 1, 1}; byte[] expected = new byte[] { (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x01 }; byte[] result = RawPublicKey.encodeOID(oid); assertArrayEquals(expected, result); int[] decoded = RawPublicKey.decodeOID(result); assertArrayEquals(decoded, oid); }
@Test public void testOIDEncoding1() { // Found here: // http://msdn.microsoft.com/en-us/library/windows/desktop/bb540809(v=vs.85).aspx int[] oid = new int[] {1, 3, 6, 1, 4, 1, 311, 21, 20}; byte[] expected = new byte[] { (byte) 0x2b, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0x82, (byte) 0x37, (byte) 0x15, (byte) 0x14 }; byte[] result = RawPublicKey.encodeOID(oid); assertArrayEquals(expected, result); int[] decoded = RawPublicKey.decodeOID(result); assertArrayEquals(decoded, oid); }