So, as I move forward, not getting what SHOULD be a relatively simple task. I'm working with a Gemalto smartcard reader. I am using C#, Xamarin working on an Android.
I have proper recognition of the device, card, and get Power On, get ATR, set configuration etc., all coming back as successful process.
So, I am trying to do a UsbConnection.BulkTransfer
to send a request to SELECT MasterFile (root) from the given smart card. From reading over many posts, I find the APDU commands and found many options and have tried them all. They have all given me a result SW1/SW2 of 0x01 0x00 which is obviously wrong from what I have been reading.
Below are the following byte attempts I have been sending and each come back same response.
CLA INS P1 P2 Lc Data Le
00 a4 00 00 02 3f 00 00
00 a4 00 00 02 3f 00
00 a4 00 00 02 00 00 00
00 a4 00 00 02 00 00
00 a4 00 00 00
00 a4 00 00
00 a4
From what I read, if you do not post P1/P2 nor data, it should default to the first file (master record) on the card, hence I tried from all bytes down to just the 00 a4
.
I then tried the same combination changing the class from 00 to A0 as found in other documentation findings. Below is a short stub of code that is specific to me sending the bytes and getting the bytes back. Each byte array is based on above.
The byte response coming back are all the same with
00 00 00 00 00 63 00 65 01 00
Here is the code snippet
public byte[] TrySelectFile(byte[] outByteBuffer)
{
var bufferLen = outByteBuffer.Length;
var howManyBytesSent = _myUsbDeviceConnection.BulkTransfer(_myOutEndpoint, outByteBuffer, bufferLen, READER_TIMEOUT);
var inByteBuffer = new byte[_myInEndpoint.MaxPacketSize];
var howManyBytesBack = _myUsbDeviceConnection.BulkTransfer(_myInEndpoint, inByteBuffer, inByteBuffer.Length, READER_TIMEOUT);
return inByteBuffer;
}