FreeCalypso > hg > fc-sim-tools
comparison simtool/chvfunc.c @ 33:c83ec3bd9d67
fc-simtool sws-pin1-{dis,en}able implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 17 Mar 2021 01:14:19 +0000 |
parents | cca7d0528f89 |
children |
comparison
equal
deleted
inserted
replaced
32:d0be3802410a | 33:c83ec3bd9d67 |
---|---|
31 sim_resp_sw); | 31 sim_resp_sw); |
32 return(-1); | 32 return(-1); |
33 } | 33 } |
34 return(0); | 34 return(0); |
35 } | 35 } |
36 | |
37 disable_chv_func(p2, pin) | |
38 unsigned p2; | |
39 char *pin; | |
40 { | |
41 u_char cmd[13]; | |
42 int rc; | |
43 | |
44 /* DISABLE CHV command APDU */ | |
45 cmd[0] = 0xA0; | |
46 cmd[1] = 0x26; | |
47 cmd[2] = 0x00; | |
48 cmd[3] = p2; | |
49 cmd[4] = 8; | |
50 rc = encode_pin_entry(pin, cmd + 5); | |
51 if (rc < 0) | |
52 return(rc); | |
53 rc = apdu_exchange(cmd, 13); | |
54 if (rc < 0) | |
55 return(rc); | |
56 if (sim_resp_sw != 0x9000 && sim_resp_sw != 0x9808) { | |
57 fprintf(stderr, "bad SW response to DISABLE CHV: %04X\n", | |
58 sim_resp_sw); | |
59 return(-1); | |
60 } | |
61 return(0); | |
62 } | |
63 | |
64 enable_chv_func(p2, pin) | |
65 unsigned p2; | |
66 char *pin; | |
67 { | |
68 u_char cmd[13]; | |
69 int rc; | |
70 | |
71 /* ENABLE CHV command APDU */ | |
72 cmd[0] = 0xA0; | |
73 cmd[1] = 0x28; | |
74 cmd[2] = 0x00; | |
75 cmd[3] = p2; | |
76 cmd[4] = 8; | |
77 rc = encode_pin_entry(pin, cmd + 5); | |
78 if (rc < 0) | |
79 return(rc); | |
80 rc = apdu_exchange(cmd, 13); | |
81 if (rc < 0) | |
82 return(rc); | |
83 if (sim_resp_sw != 0x9000 && sim_resp_sw != 0x9808) { | |
84 fprintf(stderr, "bad SW response to ENABLE CHV: %04X\n", | |
85 sim_resp_sw); | |
86 return(-1); | |
87 } | |
88 return(0); | |
89 } |