FreeCalypso > hg > freecalypso-hwlab
annotate simtool/select.c @ 87:2a0d1d5b9313
fc-simtool: symbolic file names implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 24 Jan 2021 03:43:01 +0000 |
parents | 54c444eb084b |
children | fb75855a74a9 |
rev | line source |
---|---|
85
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <ctype.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <string.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <strings.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <pcsclite.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <winscard.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "globals.h" |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 select_op(file_id) |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 unsigned file_id; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 u_char cmd[7]; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int rc; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 unsigned expect_resp_len; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 /* SELECT command APDU */ |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 cmd[0] = 0xA0; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 cmd[1] = 0xA4; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 cmd[2] = 0; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 cmd[3] = 0; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 cmd[4] = 2; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 cmd[5] = file_id >> 8; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 cmd[6] = file_id; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 rc = apdu_exchange(cmd, 7); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (rc < 0) |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return(rc); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if ((sim_resp_sw & 0xFF00) != 0x9F00) { |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 fprintf(stderr, |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 "error or unexpected SW response to SELECT of 0x%04X: %04X\n", |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 file_id, sim_resp_sw); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return(-1); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 expect_resp_len = sim_resp_sw & 0xFF; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 /* GET RESPONSE follow-up */ |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 cmd[1] = 0xC0; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 cmd[4] = expect_resp_len; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 rc = apdu_exchange(cmd, 5); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (rc < 0) |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 return(rc); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 if (sim_resp_sw != 0x9000) { |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 fprintf(stderr, |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 "bad SW resp to GET RESPONSE after SELECT: %04X\n", |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 sim_resp_sw); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(-1); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (sim_resp_data_len != expect_resp_len) { |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 fprintf(stderr, |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 "error: GET RESPONSE after SELECT returned %u bytes, expected %u\n", |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 sim_resp_data_len, expect_resp_len); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 return(-1); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 return(0); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
86
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
57 static void |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
58 show_secret_code_status(name, byte) |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
59 char *name; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
60 unsigned byte; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
61 { |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
62 printf("Status of %s: %s, %u attempts left\n", name, |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
63 byte & 0x80 ? "initialized" : "not initialized", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
64 byte & 0x0F); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
65 } |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
66 |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
67 static void |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
68 show_access_conditions(oper_name, cond_code) |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
69 char *oper_name; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
70 unsigned cond_code; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
71 { |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
72 static char *cond_names[16] = |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
73 {"ALW", "CHV1", "CHV2", "RFU3", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
74 "ADM4", "ADM5", "ADM6", "ADM7", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
75 "ADM8", "ADM9", "ADM10", "ADM11", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
76 "ADM12", "ADM13", "ADM14", "NEV"}; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
77 |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
78 printf("Access condition for %s: %s\n", oper_name, |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
79 cond_names[cond_code]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
80 } |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
81 |
85
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 cmd_select(argc, argv) |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 char **argv; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 { |
87
2a0d1d5b9313
fc-simtool: symbolic file names implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
86
diff
changeset
|
85 int file_id, rc; |
85
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 file_id = strtoul(argv[1], 0, 16); |
87
2a0d1d5b9313
fc-simtool: symbolic file names implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
86
diff
changeset
|
90 else |
2a0d1d5b9313
fc-simtool: symbolic file names implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
86
diff
changeset
|
91 file_id = find_symbolic_file_name(argv[1]); |
2a0d1d5b9313
fc-simtool: symbolic file names implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
86
diff
changeset
|
92 if (file_id < 0) { |
85
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 fprintf(stderr, |
87
2a0d1d5b9313
fc-simtool: symbolic file names implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
86
diff
changeset
|
94 "error: file ID argument is not a hex value or a recognized symbolic name\n"); |
85
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 return(-1); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 } |
86
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
97 rc = select_op(file_id); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
98 if (rc < 0) |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
99 return(rc); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
100 if (sim_resp_data_len < 14) { |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
101 fprintf(stderr, |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
102 "error: response length of %u bytes is too short for any file type\n", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
103 sim_resp_data_len); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
104 return(-1); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
105 } |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
106 switch (sim_resp_data[6]) { |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
107 case 0x01: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
108 printf("File type: MF\n"); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
109 goto mf_or_df; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
110 case 0x02: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
111 printf("File type: DF\n"); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
112 mf_or_df: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
113 if (sim_resp_data_len < 22) { |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
114 fprintf(stderr, |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
115 "error: response length of %u bytes is too short for MF/DF\n", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
116 sim_resp_data_len); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
117 return(-1); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
118 } |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
119 printf("File characteristics: %02X\n", sim_resp_data[13]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
120 printf("Number of DF children: %u\n", sim_resp_data[14]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
121 printf("Number of EF children: %u\n", sim_resp_data[15]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
122 printf("Number of secret codes: %u\n", sim_resp_data[16]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
123 show_secret_code_status("PIN1", sim_resp_data[18]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
124 show_secret_code_status("PUK1", sim_resp_data[19]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
125 show_secret_code_status("PIN2", sim_resp_data[20]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
126 show_secret_code_status("PUK2", sim_resp_data[21]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
127 break; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
128 case 0x04: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
129 printf("File type: EF\n"); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
130 printf("File size: %u\n", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
131 (sim_resp_data[2] << 8) | sim_resp_data[3]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
132 switch (sim_resp_data[13]) { |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
133 case 0x00: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
134 printf("Structure: transparent\n"); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
135 break; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
136 case 0x01: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
137 printf("Structure: linear fixed\n"); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
138 goto ef_record_based; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
139 case 0x03: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
140 printf("Structure: cyclic\n"); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
141 ef_record_based: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
142 if (sim_resp_data_len < 15) { |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
143 fprintf(stderr, |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
144 "error: response length of %u bytes is too short for record-based EF\n", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
145 sim_resp_data_len); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
146 return(-1); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
147 } |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
148 printf("Record length: %u\n", sim_resp_data[14]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
149 break; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
150 default: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
151 printf("Structure: %02X (unknown)\n", |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
152 sim_resp_data[13]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
153 } |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
154 printf("File status: %02X\n", sim_resp_data[11]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
155 show_access_conditions("UPDATE", sim_resp_data[8] & 0xF); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
156 show_access_conditions("READ & SEEK", sim_resp_data[8] >> 4); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
157 show_access_conditions("INCREASE", sim_resp_data[9] >> 4); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
158 show_access_conditions("INVALIDATE", sim_resp_data[10] & 0xF); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
159 show_access_conditions("REHABILITATE", sim_resp_data[10] >> 4); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
160 break; |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
161 default: |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
162 printf("File type: %02X (unknown)\n", sim_resp_data[6]); |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
163 } |
54c444eb084b
fc-simtool: SELECT response decoding implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
85
diff
changeset
|
164 return(0); |
85
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } |