comparison uicc/select.c @ 155:cb3c40ff443e

fc-uicc-tool bfsearch: handle more weird SW response cases
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 25 Feb 2021 20:17:10 +0000
parents 77832c9f2001
children
comparison
equal deleted inserted replaced
154:6d93a51f01dc 155:cb3c40ff443e
10 u_char std_aid_isim[7] = {0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x04}; 10 u_char std_aid_isim[7] = {0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x04};
11 11
12 unsigned last_sel_file_record_len; 12 unsigned last_sel_file_record_len;
13 13
14 elem_select_op(file_id) 14 elem_select_op(file_id)
15 unsigned file_id;
16 {
17 u_char cmd[7];
18 int rc;
19
20 last_sel_file_record_len = 0;
21 /* SELECT command APDU */
22 cmd[0] = 0x00;
23 cmd[1] = 0xA4;
24 cmd[2] = 0x00;
25 cmd[3] = 0x04;
26 cmd[4] = 2;
27 cmd[5] = file_id >> 8;
28 cmd[6] = file_id;
29 return apdu_exchange(cmd, 7);
30 }
31
32 select_op(file_id)
15 unsigned file_id; 33 unsigned file_id;
16 { 34 {
17 u_char cmd[7]; 35 u_char cmd[7];
18 int rc; 36 int rc;
19 unsigned expect_resp_len; 37 unsigned expect_resp_len;
28 cmd[5] = file_id >> 8; 46 cmd[5] = file_id >> 8;
29 cmd[6] = file_id; 47 cmd[6] = file_id;
30 rc = apdu_exchange(cmd, 7); 48 rc = apdu_exchange(cmd, 7);
31 if (rc < 0) 49 if (rc < 0)
32 return(rc); 50 return(rc);
33 if (sim_resp_sw == 0x6A82)
34 return(0);
35 if ((sim_resp_sw & 0xFF00) == 0x6100)
36 return(1);
37 fprintf(stderr,
38 "error or unexpected SW response to SELECT of 0x%04X: %04X\n",
39 file_id, sim_resp_sw);
40 return(-1);
41 }
42
43 select_op(file_id)
44 unsigned file_id;
45 {
46 u_char cmd[7];
47 int rc;
48 unsigned expect_resp_len;
49
50 last_sel_file_record_len = 0;
51 /* SELECT command APDU */
52 cmd[0] = 0x00;
53 cmd[1] = 0xA4;
54 cmd[2] = 0x00;
55 cmd[3] = 0x04;
56 cmd[4] = 2;
57 cmd[5] = file_id >> 8;
58 cmd[6] = file_id;
59 rc = apdu_exchange(cmd, 7);
60 if (rc < 0)
61 return(rc);
62 if ((sim_resp_sw & 0xFF00) != 0x6100) { 51 if ((sim_resp_sw & 0xFF00) != 0x6100) {
63 fprintf(stderr, 52 fprintf(stderr,
64 "error or unexpected SW response to SELECT of 0x%04X: %04X\n", 53 "error or unexpected SW response to SELECT of 0x%04X: %04X\n",
65 file_id, sim_resp_sw); 54 file_id, sim_resp_sw);
66 return(-1); 55 return(-1);