Util { public static byte[] fixMakeCredentialBlobForWindows(byte[] in) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos); final int SECRET_SIZE = 134; ByteBuffer buf = ByteBuffer.wrap(in); int secretLength = buf.order(ByteOrder.LITTLE_ENDIAN).getShort(); out.writeShort((short)secretLength); byte[] b = new byte[secretLength]; buf.get(b); out.write(b); buf.position(SECRET_SIZE); int asymLength = buf.order(ByteOrder.LITTLE_ENDIAN).getShort(); out.writeShort((short)asymLength); byte [] c = new byte[asymLength]; buf.get(c); out.write(c); return bos.toByteArray(); }  static boolean isOwner(byte[] secret); static boolean isEndorsementCertificatePresent(byte[] secret); static byte[] fixMakeCredentialBlobForWindows(byte[] in);  }
@Test public void TestMakeCredentialFix() throws IOException { byte[] fixed = fixMakeCredentialBlobForWindows(fromCit); Assert.assertArrayEquals(expected, fixed); }