comparison simtool/grcard2.c @ 74:8562d8508cf2

grcard2-set-{adm,super}-hex commands implemented It appears that GrcardSIM2 cards allow arbitrary 64-bit keys for ADM and SUPER ADM, not necessarily consisting of ASCII digits like the specs require for standard PIN and PUK, and pySim-prog.py in fact sets the ADM key to 4444444444444444 in hex by default, which is not an ASCII digit string. If the cards allow such keys, we need to support them too.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 16 Feb 2021 04:10:36 +0000
parents 744fabd6bd3f
children 8a5c132fe871
comparison
equal deleted inserted replaced
73:a56bbd6b0277 74:8562d8508cf2
108 return(-1); 108 return(-1);
109 } 109 }
110 return(0); 110 return(0);
111 } 111 }
112 112
113 cmd_grcard2_set_adm_hex(argc, argv)
114 char **argv;
115 {
116 u_char cmd[13];
117 int rc;
118
119 /* Grcard2 proprietary command APDU */
120 cmd[0] = 0xA0;
121 cmd[1] = 0xD4;
122 cmd[2] = 0x3A;
123 cmd[3] = 0x05;
124 cmd[4] = 8;
125 rc = decode_hex_data_from_string(argv[1], cmd + 5, 8, 8);
126 if (rc < 0)
127 return(rc);
128 rc = apdu_exchange(cmd, 13);
129 if (rc < 0)
130 return(rc);
131 if (sim_resp_sw != 0x9000) {
132 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
133 return(-1);
134 }
135 return(0);
136 }
137
113 cmd_grcard2_set_super(argc, argv) 138 cmd_grcard2_set_super(argc, argv)
114 char **argv; 139 char **argv;
115 { 140 {
116 u_char cmd[13]; 141 u_char cmd[13];
117 int rc; 142 int rc;
132 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); 157 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
133 return(-1); 158 return(-1);
134 } 159 }
135 return(0); 160 return(0);
136 } 161 }
162
163 cmd_grcard2_set_super_hex(argc, argv)
164 char **argv;
165 {
166 u_char cmd[13];
167 int rc;
168
169 /* Grcard2 proprietary command APDU */
170 cmd[0] = 0xA0;
171 cmd[1] = 0xD4;
172 cmd[2] = 0x3A;
173 cmd[3] = 0x0B;
174 cmd[4] = 8;
175 rc = decode_hex_data_from_string(argv[1], cmd + 5, 8, 8);
176 if (rc < 0)
177 return(rc);
178 rc = apdu_exchange(cmd, 13);
179 if (rc < 0)
180 return(rc);
181 if (sim_resp_sw != 0x9000) {
182 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
183 return(-1);
184 }
185 return(0);
186 }