FreeCalypso > hg > freecalypso-hwlab
comparison simtool/grcard1.c @ 149:451ed3bbfe96
fc-simtool: grcard1-set-adm[12] commands implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Feb 2021 00:01:55 +0000 |
parents | 1232dea1d66a |
children | a63e4c64f1f0 |
comparison
equal
deleted
inserted
replaced
148:1232dea1d66a | 149:451ed3bbfe96 |
---|---|
48 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); | 48 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); |
49 return(-1); | 49 return(-1); |
50 } | 50 } |
51 return(0); | 51 return(0); |
52 } | 52 } |
53 | |
54 cmd_grcard1_set_adm(argc, argv) | |
55 char **argv; | |
56 { | |
57 u_char cmd[23]; | |
58 int rc; | |
59 | |
60 /* Grcard1 proprietary command APDU */ | |
61 cmd[0] = 0x80; | |
62 cmd[1] = 0xD4; | |
63 cmd[2] = 0x01; | |
64 switch (argv[0][15]) { | |
65 case '1': | |
66 cmd[3] = 0x04; | |
67 break; | |
68 case '2': | |
69 cmd[3] = 0x05; | |
70 break; | |
71 default: | |
72 fprintf(stderr, "BUG in grcard1-set-admN command\n"); | |
73 return(-1); | |
74 } | |
75 cmd[4] = 18; | |
76 cmd[5] = 0x03; | |
77 cmd[6] = 0x00; | |
78 rc = encode_pin_entry(argv[1], cmd + 7); | |
79 if (rc < 0) | |
80 return(rc); | |
81 rc = encode_pin_entry(argv[2], cmd + 15); | |
82 if (rc < 0) | |
83 return(rc); | |
84 rc = apdu_exchange(cmd, 23); | |
85 if (rc < 0) | |
86 return(rc); | |
87 if (sim_resp_sw != 0x9000) { | |
88 fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw); | |
89 return(-1); | |
90 } | |
91 return(0); | |
92 } |