0
votes

Am working on a project to read from and write data to SLE 4442 smart cards. The Card Reader am using is ACR38 from ACS. Following their APDU commands, I have being able to get access to the card and read some data. But am suspecting that I still have not being able to read the exact data inside. This is because, anytime my application is started, it brings out new data. I really don't know why is behaving that way, can somebody please spot where am getting wrong here? Below is my Java code:

CardChannel channel = card.getBasicChannel(); byte[] read_memory_card = {(byte) 0xFF, (byte) 0xB0, (byte) 0xA7A6A5A4, (byte) 0xA3A2A1A0, (byte) 0x00}; ResponseAPDU read_data_resp = channel.transmit(new CommandAPDU(read_memory_card)); if (read_data_resp.getSW1() == 0x90 && read_data_resp.getSW2() == 0x00) { System.out.println("Data in Card: " + read_data_resp.getData() + "and SW1: " + read_data_resp.getSW1()); }

What I get as a result:
Data in Card: [B@378bf509 and SW1: 144

Please note that Data in Card changes every time, the application is restarted.

1
why are you casting 0xA7A6A5A4 as a byte? this will only send the reader 0xA4. Same goes with 0xA3A2A1A0. Also you should output sw1 as hex, but you already know that sw1 is 0x90 becaues of your if statement.Robert Snyder
@RobertSnyder, I saw the write-up exactly like that on their manual. I never knew it can be that easily compressed. Thanks for the correctionMr Heart
Are you looking at section 4.6.2 for that? if so then you are doing it wrong. I'm not sure how to read what they are asking but they are referring to the bits. Therefor you asked for address(es) 1010 0100 and if i'm reading the document correcty 1000 000 has special meaning.Robert Snyder
am actually looking at section 4.6.2, that's the one applicable to my type of smart cardMr Heart

1 Answers

1
votes

I'm assuming that you seeing "different" data isn't so much that it is truly different but rather you are printing out the pointer in memory that Java uses as a default toString(). I can only assume that read_data_resp.getData() retuurns a byte[] in which case you'll want to convert each value into a string if you want to visualize it. If you search google on how to convert a byte array to a hex string you'll find lots of answers.