Time to dialog with the smartcard...
It is now time to exchange APDU with the smartcard. By example, a file_select...
This does not work with the FNAC card :
And, according to the ISO7816-4 standard, the code <6A><87> is an error code for 'Lc inconsistent with P1-P2'. There is something wrong with our APDU. ...But, the smartcard responds!, we are a step further. :-)
If I try a 'read_binary' (command),
Time to read some doc again.
However, let's try to select all files (by number?) from 0000 to FFFF. Allmost all attempts (on the FNAC card) return 6A:82 (ISO: File not found) except a few which return 61:0C (? more data available (0xC bytes) with a get_response?) ...
If I do a get_response (with the right length (0x0c)), I get :
(I hope there is nothing I should keep secret here...) After a get_response (90:00 seems good news), a read_binary returns 6D:00 (?)
int MCU_root_select(struct usb_dev_handle *udp)
{
const u_char MCU_FILE_SELECT[] = {0x01, 0xa0, 0x00, 0x05, 0x00, 0xA4, 0x00, 0x00, 0x00};
u_char buf_in[128];
u_char cmd[9];
if (ACR_xchange(udp, MCU_FILE_SELECT, 9, buf_in, sizeof(buf_in)) < 0)
{
perror("MCU_file_select");
return(-1);
}
printf("MCU_root_select status : 0x%02X\n", buf_in[1]);
xdump("MCU_root_select:", buf_in, 32);
return(0);
}
This does not work with the FNAC card :
SND -> 01 a0 00 05 00 a4 00 00 00 (?select master file)
RCV <- 01 00 00 02 6a 87
And, according to the ISO7816-4 standard, the code <6A><87> is an error code for 'Lc inconsistent with P1-P2'. There is something wrong with our APDU. ...But, the smartcard responds!, we are a step further. :-)
If I try a 'read_binary' (command
I get a <6D><00> error, which is ?? unexpected.
SND -> 01 a0 00 05 00 b0 00 00 00
RCV <- 01 00 00 02 6d 00
Time to read some doc again.
However, let's try to select all files (by number?) from 0000 to FFFF. Allmost all attempts (on the FNAC card) return 6A:82 (ISO: File not found) except a few which return 61:0C (? more data available (0xC bytes) with a get_response?) ...
sending '01 a0 00 08 00 A4 00 00 02 xx yy 10' (select file 'xxyy')
00 01| : : 01 00 00 02 6a 82
(a couple of 6a:82)
00 13| : : 01 00 00 02 61 0c
00 14| : : 01 00 00 02 61 0c
00 15| : : 01 00 00 02 61 0c
(a couple of 6a:82)
00 1a| : : 01 00 00 02 61 0c
(a lot of 6a:82)
3f 00| : : 01 00 00 02 61 0c
(a lot of 6a:82)
ff ff| : : 01 00 00 02 6a 82
If I do a get_response (with the right length (0x0c)), I get :
snd-> 01 a0 00 05 00 C0 00 00 0c (get_response() with length=0x0c)
MCU_get_response: : 01 00 00 0e 6f 0a c5 08 00 13 04 00 01 0f ff ff 90 00 (file 0013)
MCU_get_response: : 01 00 00 0e 6f 0a c5 08 00 14 04 00 02 ff f4 ff 90 00 (file 0014)
MCU_get_response: : 01 00 00 0e 6f 0a c5 08 00 15 04 00 02 ff f4 ff 90 00 (file 0015)
MCU_get_response: : 01 00 00 0e 6f 0a c5 08 00 1a 04 00 03 08 f4 ff 90 00 (file 001a)
(I hope there is nothing I should keep secret here...) After a get_response (90:00 seems good news), a read_binary returns 6D:00 (?)
0 Comments:
Enregistrer un commentaire
<< Home