@Test @Ignore public void runApduEngineCliApp() { new ApduEngineCli( new MockTransmitter(DesfireKeyType.AES_128, new byte[16])).go(); }
public void go() { StatusResponse status = null; ApduSession session = new ApduSession(new GetVersion()); status = session.transmit(transmitter); byte[] piccDivData = session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(); byte[] appDivData = Bytes.concat(piccDivData, new byte[] {(byte)0xFF, 0x54, 0x53}); session.nextCommands( new SelectPicc(), new GetKeySettings(), new DesfireAuth(DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ResetTo2K3DesKey() ); status = session.transmit(transmitter); session.nextCommands( new GetVersion(), new SelectPicc(), new DesfireAuth(new byte[24], DesfireKeyType.TWO_KEY_3DES), new ChangeKey(DesfireUtils.cmacKeyDivAes128( session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(), new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ChangeKeySettings((byte) 0x0B), new FormatCard(), new CreateTsApplication(), new SelectTsApplication(), new DesfireAuth(new byte[16], DesfireKeyType.AES_128), new ChangeReadKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("00112233445566778899AABBCCDDEEFF")))), new ChangeWriteKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100"))), DesfireKeyType.AES_128), new CreateStdFile("0A08220625C0513DDF98".length()/2), new WriteData(Hex.decode("0A08220625C0513DDF98")), new ReadData() ); session.transmit(transmitter); }
ApduEngineCli { public void go() { StatusResponse status = null; ApduSession session = new ApduSession(new GetVersion()); status = session.transmit(transmitter); byte[] piccDivData = session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(); byte[] appDivData = Bytes.concat(piccDivData, new byte[] {(byte)0xFF, 0x54, 0x53}); session.nextCommands( new SelectPicc(), new GetKeySettings(), new DesfireAuth(DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ResetTo2K3DesKey() ); status = session.transmit(transmitter); session.nextCommands( new GetVersion(), new SelectPicc(), new DesfireAuth(new byte[24], DesfireKeyType.TWO_KEY_3DES), new ChangeKey(DesfireUtils.cmacKeyDivAes128( session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(), new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ChangeKeySettings((byte) 0x0B), new FormatCard(), new CreateTsApplication(), new SelectTsApplication(), new DesfireAuth(new byte[16], DesfireKeyType.AES_128), new ChangeReadKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("00112233445566778899AABBCCDDEEFF")))), new ChangeWriteKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100"))), DesfireKeyType.AES_128), new CreateStdFile("0A08220625C0513DDF98".length()/2), new WriteData(Hex.decode("0A08220625C0513DDF98")), new ReadData() ); session.transmit(transmitter); } }
ApduEngineCli { public void go() { StatusResponse status = null; ApduSession session = new ApduSession(new GetVersion()); status = session.transmit(transmitter); byte[] piccDivData = session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(); byte[] appDivData = Bytes.concat(piccDivData, new byte[] {(byte)0xFF, 0x54, 0x53}); session.nextCommands( new SelectPicc(), new GetKeySettings(), new DesfireAuth(DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ResetTo2K3DesKey() ); status = session.transmit(transmitter); session.nextCommands( new GetVersion(), new SelectPicc(), new DesfireAuth(new byte[24], DesfireKeyType.TWO_KEY_3DES), new ChangeKey(DesfireUtils.cmacKeyDivAes128( session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(), new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ChangeKeySettings((byte) 0x0B), new FormatCard(), new CreateTsApplication(), new SelectTsApplication(), new DesfireAuth(new byte[16], DesfireKeyType.AES_128), new ChangeReadKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("00112233445566778899AABBCCDDEEFF")))), new ChangeWriteKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100"))), DesfireKeyType.AES_128), new CreateStdFile("0A08220625C0513DDF98".length()/2), new WriteData(Hex.decode("0A08220625C0513DDF98")), new ReadData() ); session.transmit(transmitter); } ApduEngineCli(ApduTransmitter transmitter); }
ApduEngineCli { public void go() { StatusResponse status = null; ApduSession session = new ApduSession(new GetVersion()); status = session.transmit(transmitter); byte[] piccDivData = session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(); byte[] appDivData = Bytes.concat(piccDivData, new byte[] {(byte)0xFF, 0x54, 0x53}); session.nextCommands( new SelectPicc(), new GetKeySettings(), new DesfireAuth(DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ResetTo2K3DesKey() ); status = session.transmit(transmitter); session.nextCommands( new GetVersion(), new SelectPicc(), new DesfireAuth(new byte[24], DesfireKeyType.TWO_KEY_3DES), new ChangeKey(DesfireUtils.cmacKeyDivAes128( session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(), new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ChangeKeySettings((byte) 0x0B), new FormatCard(), new CreateTsApplication(), new SelectTsApplication(), new DesfireAuth(new byte[16], DesfireKeyType.AES_128), new ChangeReadKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("00112233445566778899AABBCCDDEEFF")))), new ChangeWriteKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100"))), DesfireKeyType.AES_128), new CreateStdFile("0A08220625C0513DDF98".length()/2), new WriteData(Hex.decode("0A08220625C0513DDF98")), new ReadData() ); session.transmit(transmitter); } ApduEngineCli(ApduTransmitter transmitter); static void main(String[] ignored); void go(); StatusResponse andThen(ApduCommand... commands); void listApplications(ApduSession session, ApduTransmitter transmitter); StatusResponse authenticate(byte[] key); StatusResponse authenticate(); ApduSession getSession(); }
ApduEngineCli { public void go() { StatusResponse status = null; ApduSession session = new ApduSession(new GetVersion()); status = session.transmit(transmitter); byte[] piccDivData = session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(); byte[] appDivData = Bytes.concat(piccDivData, new byte[] {(byte)0xFF, 0x54, 0x53}); session.nextCommands( new SelectPicc(), new GetKeySettings(), new DesfireAuth(DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ResetTo2K3DesKey() ); status = session.transmit(transmitter); session.nextCommands( new GetVersion(), new SelectPicc(), new DesfireAuth(new byte[24], DesfireKeyType.TWO_KEY_3DES), new ChangeKey(DesfireUtils.cmacKeyDivAes128( session.getRequiredParameter(DesfireGetCardUID.CARD_UID_KEY).getValueAsBytes(), new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( piccDivData, new JceAesCryptor(Hex.decode("0F1E2D3C4B5A69788796A5B4C3D2E1F0"))), DesfireKeyType.AES_128), new ChangeKeySettings((byte) 0x0B), new FormatCard(), new CreateTsApplication(), new SelectTsApplication(), new DesfireAuth(new byte[16], DesfireKeyType.AES_128), new ChangeReadKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("00112233445566778899AABBCCDDEEFF")))), new ChangeWriteKey(DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100")))), new DesfireAuth( DesfireUtils.cmacKeyDivAes128( appDivData, new JceAesCryptor(Hex.decode("FFEEDDCCBBAA99887766554433221100"))), DesfireKeyType.AES_128), new CreateStdFile("0A08220625C0513DDF98".length()/2), new WriteData(Hex.decode("0A08220625C0513DDF98")), new ReadData() ); session.transmit(transmitter); } ApduEngineCli(ApduTransmitter transmitter); static void main(String[] ignored); void go(); StatusResponse andThen(ApduCommand... commands); void listApplications(ApduSession session, ApduTransmitter transmitter); StatusResponse authenticate(byte[] key); StatusResponse authenticate(); ApduSession getSession();  }