comparison simtool/grcard1.c @ 148:1232dea1d66a

fc-simtool: grcard1-set-pin[12] commands implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Feb 2021 23:52:53 +0000
parents
children 451ed3bbfe96
comparison
equal deleted inserted replaced
147:43463dc91431 148:1232dea1d66a
1 /*
2 * This module implements a few special commands for those very few
3 * incredibly lucky people on Earth who have no-longer-available
4 * sysmoSIM-GR1 cards, or any other branded variant of the same card
5 * from Grcard.
6 */
7
8 #include <sys/types.h>
9 #include <ctype.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <pcsclite.h>
13 #include <winscard.h>
14 #include "globals.h"
15
16 cmd_grcard1_set_pin(argc, argv)
17 char **argv;
18 {
19 u_char cmd[21];
20 int rc;
21
22 /* Grcard1 proprietary command APDU */
23 cmd[0] = 0x80;
24 cmd[1] = 0xD4;
25 cmd[2] = 0x00;
26 switch (argv[0][15]) {
27 case '1':
28 cmd[3] = 0x01;
29 break;
30 case '2':
31 cmd[3] = 0x02;
32 break;
33 default:
34 fprintf(stderr, "BUG in grcard1-set-pinN command\n");
35 return(-1);
36 }
37 cmd[4] = 16;
38 rc = encode_pin_entry(argv[1], cmd + 5);
39 if (rc < 0)
40 return(rc);
41 rc = encode_pin_entry(argv[2], cmd + 13);
42 if (rc < 0)
43 return(rc);
44 rc = apdu_exchange(cmd, 21);
45 if (rc < 0)
46 return(rc);
47 if (sim_resp_sw != 0x9000) {
48 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
49 return(-1);
50 }
51 return(0);
52 }