annotate simtool/grcard2.c @ 162:72eac15f0917

fc-simtool and fc-uicc-tool moved once again to fc-sim-tools
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Mar 2021 17:36:43 +0000
parents 239ebdb8f2af
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
154
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * I, Mother Mychaela, am hoping to get some SIM cards from Grcard
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * that follow the protocol which the Osmocom community has nicknamed
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * GrcardSIM2:
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 *
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * https://osmocom.org/projects/cellular-infrastructure/wiki/GrcardSIM2
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 *
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 * I haven't got these cards yet and may not get them for a long time,
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 * hence the following code has been written blindly, untested.
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * If anyone in the community happens to have a sysmoSIM-GR2 card
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 * that was once (aeons ago) sold by Sysmocom, please test this code!
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 */
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <sys/types.h>
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <ctype.h>
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include <stdio.h>
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include <stdlib.h>
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include <pcsclite.h>
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include <winscard.h>
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #include "globals.h"
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 cmd_grcard2_set_pin(argc, argv)
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 char **argv;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 u_char cmd[13];
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 int rc;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 /* Grcard2 proprietary command APDU */
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 cmd[0] = 0xA0;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 cmd[1] = 0xD4;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 cmd[2] = 0x3A;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 switch (argv[0][15]) {
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 case '1':
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 cmd[3] = 0x01;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 break;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 case '2':
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 cmd[3] = 0x02;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 break;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 default:
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 fprintf(stderr, "BUG in grcard2-set-pinN command\n");
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return(-1);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 cmd[4] = 8;
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 rc = encode_pin_entry(argv[1], cmd + 5);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (rc < 0)
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return(rc);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 rc = apdu_exchange(cmd, 13);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 if (rc < 0)
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 return(rc);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (sim_resp_sw != 0x9000) {
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 return(-1);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 return(0);
ed34c8b7e2c9 fc-simtool: grcard2-set-pin[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 }
155
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
56
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
57 cmd_grcard2_set_puk(argc, argv)
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
58 char **argv;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
59 {
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
60 u_char cmd[13];
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
61 int rc;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
62
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
63 /* Grcard2 proprietary command APDU */
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
64 cmd[0] = 0xA0;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
65 cmd[1] = 0xD4;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
66 cmd[2] = 0x3B;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
67 switch (argv[0][15]) {
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
68 case '1':
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
69 cmd[3] = 0x00;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
70 break;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
71 case '2':
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
72 cmd[3] = 0x02;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
73 break;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
74 default:
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
75 fprintf(stderr, "BUG in grcard2-set-pukN command\n");
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
76 return(-1);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
77 }
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
78 cmd[4] = 8;
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
79 rc = encode_pin_entry(argv[1], cmd + 5);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
80 if (rc < 0)
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
81 return(rc);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
82 rc = apdu_exchange(cmd, 13);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
83 if (rc < 0)
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
84 return(rc);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
85 if (sim_resp_sw != 0x9000) {
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
86 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
87 return(-1);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
88 }
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
89 return(0);
804a5b0797c6 fc-simtool: grcard2-set-puk[12] commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 154
diff changeset
90 }
156
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
91
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
92 cmd_grcard2_set_adm(argc, argv)
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
93 char **argv;
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
94 {
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
95 u_char cmd[13];
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
96 int rc;
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
97
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
98 /* Grcard2 proprietary command APDU */
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
99 cmd[0] = 0xA0;
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
100 cmd[1] = 0xD4;
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
101 cmd[2] = 0x3A;
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
102 cmd[3] = 0x05;
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
103 cmd[4] = 8;
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
104 rc = encode_pin_entry(argv[1], cmd + 5);
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
105 if (rc < 0)
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
106 return(rc);
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
107 rc = apdu_exchange(cmd, 13);
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
108 if (rc < 0)
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
109 return(rc);
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
110 if (sim_resp_sw != 0x9000) {
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
111 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
112 return(-1);
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
113 }
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
114 return(0);
6d9d0cfc9ed8 fc-simtool: grcard2-set-adm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
115 }
157
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
116
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
117 cmd_grcard2_set_super(argc, argv)
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
118 char **argv;
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
119 {
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
120 u_char cmd[13];
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
121 int rc;
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
122
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
123 /* Grcard2 proprietary command APDU */
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
124 cmd[0] = 0xA0;
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
125 cmd[1] = 0xD4;
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
126 cmd[2] = 0x3A;
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
127 cmd[3] = 0x0B;
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
128 cmd[4] = 8;
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
129 rc = encode_pin_entry(argv[1], cmd + 5);
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
130 if (rc < 0)
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
131 return(rc);
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
132 rc = apdu_exchange(cmd, 13);
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
133 if (rc < 0)
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
134 return(rc);
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
135 if (sim_resp_sw != 0x9000) {
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
136 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
137 return(-1);
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
138 }
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
139 return(0);
239ebdb8f2af fc-simtool: grcard2-set-super command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 156
diff changeset
140 }