annotate simtool/grcard2.c @ 179:efe944a5c4e3

doc/Brute-force-search: update for data directory rename
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 02 Mar 2021 05:20:19 +0000
parents 8a5c132fe871
children 36e7fc58f065
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
165
8a5c132fe871 simtool/grcard2.c comment update
Mychaela Falconia <falcon@freecalypso.org>
parents: 74
diff changeset
2 * This module implements special commands for the grcard.cn card model
8a5c132fe871 simtool/grcard2.c comment update
Mychaela Falconia <falcon@freecalypso.org>
parents: 74
diff changeset
3 * which is known in the Osmocom community as GrcardSIM2:
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 *
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * https://osmocom.org/projects/cellular-infrastructure/wiki/GrcardSIM2
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 *
165
8a5c132fe871 simtool/grcard2.c comment update
Mychaela Falconia <falcon@freecalypso.org>
parents: 74
diff changeset
7 * The sample cards which Mother Mychaela received from Grcard in 2021-02
8a5c132fe871 simtool/grcard2.c comment update
Mychaela Falconia <falcon@freecalypso.org>
parents: 74
diff changeset
8 * are GrcardSIM2, and so are historical sysmoSIM-GR2 and 30C3 cards.
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 */
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <sys/types.h>
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdio.h>
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "simresp.h"
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 cmd_grcard2_set_pin(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 u_char cmd[13];
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 /* Grcard2 proprietary command APDU */
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 cmd[0] = 0xA0;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 cmd[1] = 0xD4;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 cmd[2] = 0x3A;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 switch (argv[0][15]) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 case '1':
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 cmd[3] = 0x01;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 break;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 case '2':
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 cmd[3] = 0x02;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 break;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 default:
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 fprintf(stderr, "BUG in grcard2-set-pinN command\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 cmd[4] = 8;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 rc = encode_pin_entry(argv[1], cmd + 5);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 rc = apdu_exchange(cmd, 13);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (sim_resp_sw != 0x9000) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return(0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 cmd_grcard2_set_puk(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 u_char cmd[13];
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 /* Grcard2 proprietary command APDU */
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 cmd[0] = 0xA0;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 cmd[1] = 0xD4;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 cmd[2] = 0x3B;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 switch (argv[0][15]) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 case '1':
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 cmd[3] = 0x00;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 break;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 case '2':
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 cmd[3] = 0x02;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 break;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 default:
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 fprintf(stderr, "BUG in grcard2-set-pukN command\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 cmd[4] = 8;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 rc = encode_pin_entry(argv[1], cmd + 5);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 rc = apdu_exchange(cmd, 13);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 if (sim_resp_sw != 0x9000) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 return(0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 cmd_grcard2_set_adm(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 u_char cmd[13];
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 /* Grcard2 proprietary command APDU */
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 cmd[0] = 0xA0;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 cmd[1] = 0xD4;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 cmd[2] = 0x3A;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 cmd[3] = 0x05;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 cmd[4] = 8;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 rc = encode_pin_entry(argv[1], cmd + 5);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 rc = apdu_exchange(cmd, 13);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 if (sim_resp_sw != 0x9000) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 return(0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109
74
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
110 cmd_grcard2_set_adm_hex(argc, argv)
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
111 char **argv;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
112 {
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
113 u_char cmd[13];
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
114 int rc;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
115
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
116 /* Grcard2 proprietary command APDU */
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
117 cmd[0] = 0xA0;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
118 cmd[1] = 0xD4;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
119 cmd[2] = 0x3A;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
120 cmd[3] = 0x05;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
121 cmd[4] = 8;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
122 rc = decode_hex_data_from_string(argv[1], cmd + 5, 8, 8);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
123 if (rc < 0)
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
124 return(rc);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
125 rc = apdu_exchange(cmd, 13);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
126 if (rc < 0)
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
127 return(rc);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
128 if (sim_resp_sw != 0x9000) {
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
129 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
130 return(-1);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
131 }
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
132 return(0);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
133 }
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
134
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 cmd_grcard2_set_super(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 u_char cmd[13];
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 /* Grcard2 proprietary command APDU */
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 cmd[0] = 0xA0;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 cmd[1] = 0xD4;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 cmd[2] = 0x3A;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 cmd[3] = 0x0B;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 cmd[4] = 8;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 rc = encode_pin_entry(argv[1], cmd + 5);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 rc = apdu_exchange(cmd, 13);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 if (sim_resp_sw != 0x9000) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 return(0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 }
74
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
159
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
160 cmd_grcard2_set_super_hex(argc, argv)
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
161 char **argv;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
162 {
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
163 u_char cmd[13];
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
164 int rc;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
165
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
166 /* Grcard2 proprietary command APDU */
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
167 cmd[0] = 0xA0;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
168 cmd[1] = 0xD4;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
169 cmd[2] = 0x3A;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
170 cmd[3] = 0x0B;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
171 cmd[4] = 8;
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
172 rc = decode_hex_data_from_string(argv[1], cmd + 5, 8, 8);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
173 if (rc < 0)
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
174 return(rc);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
175 rc = apdu_exchange(cmd, 13);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
176 if (rc < 0)
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
177 return(rc);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
178 if (sim_resp_sw != 0x9000) {
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
179 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
180 return(-1);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
181 }
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
182 return(0);
8562d8508cf2 grcard2-set-{adm,super}-hex commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
183 }