FreeCalypso > hg > fc-pcsc-tools
annotate uicc/pins.c @ 189:123dc7370581
top Makefile: install scripts
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Mar 2021 21:11:21 +0000 |
parents | a98992e9fe82 |
children |
rev | line source |
---|---|
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
118
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
2 * This module implements the standard set of commands for working |
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
3 * with UICC PINs; because all of these commands take a user-specified |
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
4 * P2 key ID, they should work with ADM PINs as well. |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/types.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include "simresp.h" |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
118
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
11 cmd_verify_pin(argc, argv) |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 char **argv; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 u_char cmd[13]; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int rc; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
118
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
17 /* VERIFY PIN command APDU */ |
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
18 cmd[0] = 0x00; |
1
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 cmd[1] = 0x20; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 cmd[2] = 0x00; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 cmd[3] = strtoul(argv[1], 0, 0); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 cmd[4] = 8; |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 rc = encode_pin_entry(argv[2], cmd + 5); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (rc < 0) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return(rc); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 rc = apdu_exchange(cmd, 13); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (rc < 0) |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return(rc); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (sim_resp_sw != 0x9000) { |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 return(-1); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return(0); |
2071b28cd0c7
simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
47
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
35 |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
36 cmd_verify_hex(argc, argv) |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
37 char **argv; |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
38 { |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
39 u_char cmd[13]; |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
40 int rc; |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
41 |
118
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
42 /* VERIFY PIN command APDU */ |
5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
47
diff
changeset
|
43 cmd[0] = 0x00; |
47
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
44 cmd[1] = 0x20; |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
45 cmd[2] = 0x00; |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
46 cmd[3] = strtoul(argv[1], 0, 0); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
47 cmd[4] = 8; |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
48 rc = decode_hex_data_from_string(argv[2], cmd + 5, 8, 8); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
49 if (rc < 0) |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
50 return(rc); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
51 rc = apdu_exchange(cmd, 13); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
52 if (rc < 0) |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
53 return(rc); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
54 if (sim_resp_sw != 0x9000) { |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
55 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
56 return(-1); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
57 } |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
58 return(0); |
ae3342497fea
fc-simtool verify-hex command added
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
59 } |
119
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
60 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
61 cmd_change_pin(argc, argv) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
62 char **argv; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
63 { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
64 u_char cmd[21]; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
65 int rc; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
66 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
67 /* CHANGE PIN command APDU */ |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
68 cmd[0] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
69 cmd[1] = 0x24; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
70 cmd[2] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
71 cmd[3] = strtoul(argv[1], 0, 0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
72 cmd[4] = 16; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
73 rc = encode_pin_entry(argv[2], cmd + 5); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
74 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
75 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
76 rc = encode_pin_entry(argv[3], cmd + 13); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
77 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
78 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
79 rc = apdu_exchange(cmd, 21); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
80 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
81 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
82 if (sim_resp_sw != 0x9000) { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
83 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
84 return(-1); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
85 } |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
86 return(0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
87 } |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
88 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
89 cmd_disable_pin(argc, argv) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
90 char **argv; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
91 { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
92 u_char cmd[13]; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
93 int rc; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
94 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
95 /* DISABLE PIN command APDU */ |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
96 cmd[0] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
97 cmd[1] = 0x26; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
98 cmd[2] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
99 cmd[3] = strtoul(argv[1], 0, 0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
100 cmd[4] = 8; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
101 rc = encode_pin_entry(argv[2], cmd + 5); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
102 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
103 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
104 rc = apdu_exchange(cmd, 13); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
105 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
106 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
107 if (sim_resp_sw != 0x9000) { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
108 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
109 return(-1); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
110 } |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
111 return(0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
112 } |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
113 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
114 cmd_enable_pin(argc, argv) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
115 char **argv; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
116 { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
117 u_char cmd[13]; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
118 int rc; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
119 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
120 /* ENABLE PIN command APDU */ |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
121 cmd[0] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
122 cmd[1] = 0x28; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
123 cmd[2] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
124 cmd[3] = strtoul(argv[1], 0, 0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
125 cmd[4] = 8; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
126 rc = encode_pin_entry(argv[2], cmd + 5); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
127 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
128 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
129 rc = apdu_exchange(cmd, 13); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
130 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
131 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
132 if (sim_resp_sw != 0x9000) { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
133 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
134 return(-1); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
135 } |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
136 return(0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
137 } |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
138 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
139 cmd_unblock_pin(argc, argv) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
140 char **argv; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
141 { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
142 u_char cmd[21]; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
143 int rc; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
144 |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
145 /* UNBLOCK PIN command APDU */ |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
146 cmd[0] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
147 cmd[1] = 0x2C; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
148 cmd[2] = 0x00; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
149 cmd[3] = strtoul(argv[1], 0, 0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
150 cmd[4] = 16; |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
151 rc = encode_pin_entry(argv[2], cmd + 5); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
152 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
153 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
154 rc = encode_pin_entry(argv[3], cmd + 13); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
155 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
156 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
157 rc = apdu_exchange(cmd, 21); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
158 if (rc < 0) |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
159 return(rc); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
160 if (sim_resp_sw != 0x9000) { |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
161 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
162 return(-1); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
163 } |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
164 return(0); |
0ac0aee0df11
fc-uicc-tool: remaining PIN commands from fc-simtool
Mychaela Falconia <falcon@freecalypso.org>
parents:
118
diff
changeset
|
165 } |
120
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
166 |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
167 /* retrieving PIN attempt counters from the card */ |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
168 |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
169 cmd_pin_attempt_cnt(argc, argv) |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
170 char **argv; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
171 { |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
172 u_char cmd[5]; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
173 int rc; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
174 |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
175 /* VERIFY PIN command APDU */ |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
176 cmd[0] = 0x00; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
177 cmd[1] = 0x20; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
178 cmd[2] = 0x00; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
179 cmd[3] = strtoul(argv[1], 0, 0); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
180 cmd[4] = 0; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
181 rc = apdu_exchange(cmd, 5); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
182 if (rc < 0) |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
183 return(rc); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
184 printf("%04X\n", sim_resp_sw); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
185 return(0); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
186 } |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
187 |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
188 cmd_puk_attempt_cnt(argc, argv) |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
189 char **argv; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
190 { |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
191 u_char cmd[5]; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
192 int rc; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
193 |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
194 /* UNBLOCK PIN command APDU */ |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
195 cmd[0] = 0x00; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
196 cmd[1] = 0x2C; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
197 cmd[2] = 0x00; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
198 cmd[3] = strtoul(argv[1], 0, 0); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
199 cmd[4] = 0; |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
200 rc = apdu_exchange(cmd, 5); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
201 if (rc < 0) |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
202 return(rc); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
203 printf("%04X\n", sim_resp_sw); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
204 return(0); |
a98992e9fe82
fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
119
diff
changeset
|
205 } |