comparison simtool/grcard2.c @ 155:804a5b0797c6

fc-simtool: grcard2-set-puk[12] commands implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Feb 2021 02:34:33 +0000
parents ed34c8b7e2c9
children 6d9d0cfc9ed8
comparison
equal deleted inserted replaced
154:ed34c8b7e2c9 155:804a5b0797c6
51 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); 51 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
52 return(-1); 52 return(-1);
53 } 53 }
54 return(0); 54 return(0);
55 } 55 }
56
57 cmd_grcard2_set_puk(argc, argv)
58 char **argv;
59 {
60 u_char cmd[13];
61 int rc;
62
63 /* Grcard2 proprietary command APDU */
64 cmd[0] = 0xA0;
65 cmd[1] = 0xD4;
66 cmd[2] = 0x3B;
67 switch (argv[0][15]) {
68 case '1':
69 cmd[3] = 0x00;
70 break;
71 case '2':
72 cmd[3] = 0x02;
73 break;
74 default:
75 fprintf(stderr, "BUG in grcard2-set-pukN command\n");
76 return(-1);
77 }
78 cmd[4] = 8;
79 rc = encode_pin_entry(argv[1], cmd + 5);
80 if (rc < 0)
81 return(rc);
82 rc = apdu_exchange(cmd, 13);
83 if (rc < 0)
84 return(rc);
85 if (sim_resp_sw != 0x9000) {
86 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
87 return(-1);
88 }
89 return(0);
90 }