comparison simtool/inval_rehab.c @ 124:d0d1c0b35831

fc-simtool: add low-level cur-ef-{inval,rehab} commands
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Feb 2021 19:05:48 +0000
parents
children e5d534fa5924
comparison
equal deleted inserted replaced
123:09a66626647d 124:d0d1c0b35831
1 /*
2 * This module implements the rarely-used INVALIDATE and REHABILITATE
3 * SIM protocol commands.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include "simresp.h"
9
10 current_ef_inval()
11 {
12 u_char cmd[5];
13 int rc;
14
15 /* INVALIDATE command APDU */
16 cmd[0] = 0xA0;
17 cmd[1] = 0x04;
18 cmd[2] = 0;
19 cmd[3] = 0;
20 cmd[4] = 0;
21 rc = apdu_exchange(cmd, 5);
22 if (rc < 0)
23 return(rc);
24 if (sim_resp_sw != 0x9000) {
25 fprintf(stderr, "bad SW response to INVALIDATE: %04X\n",
26 sim_resp_sw);
27 return(-1);
28 }
29 return(0);
30 }
31
32 current_ef_rehab()
33 {
34 u_char cmd[5];
35 int rc;
36
37 /* REHABILITATE command APDU */
38 cmd[0] = 0xA0;
39 cmd[1] = 0x44;
40 cmd[2] = 0;
41 cmd[3] = 0;
42 cmd[4] = 0;
43 rc = apdu_exchange(cmd, 5);
44 if (rc < 0)
45 return(rc);
46 if (sim_resp_sw != 0x9000) {
47 fprintf(stderr, "bad SW response to REHABILITATE: %04X\n",
48 sim_resp_sw);
49 return(-1);
50 }
51 return(0);
52 }