FreeCalypso > hg > fc-sim-tools
comparison simtool/chvfunc.c @ 31:cca7d0528f89
fc-simtool sws-auth-adm1 implemented
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 17 Mar 2021 00:42:47 +0000 |
| parents | |
| children | c83ec3bd9d67 |
comparison
equal
deleted
inserted
replaced
| 30:25530c262137 | 31:cca7d0528f89 |
|---|---|
| 1 /* | |
| 2 * This module implements a functional interface to CHV commands, | |
| 3 * intended for high-level wrappers like sws-*. | |
| 4 */ | |
| 5 | |
| 6 #include <sys/types.h> | |
| 7 #include <stdio.h> | |
| 8 #include "simresp.h" | |
| 9 | |
| 10 verify_chv_func(p2, pin) | |
| 11 unsigned p2; | |
| 12 char *pin; | |
| 13 { | |
| 14 u_char cmd[13]; | |
| 15 int rc; | |
| 16 | |
| 17 /* VERIFY CHV command APDU */ | |
| 18 cmd[0] = 0xA0; | |
| 19 cmd[1] = 0x20; | |
| 20 cmd[2] = 0x00; | |
| 21 cmd[3] = p2; | |
| 22 cmd[4] = 8; | |
| 23 rc = encode_pin_entry(pin, cmd + 5); | |
| 24 if (rc < 0) | |
| 25 return(rc); | |
| 26 rc = apdu_exchange(cmd, 13); | |
| 27 if (rc < 0) | |
| 28 return(rc); | |
| 29 if (sim_resp_sw != 0x9000) { | |
| 30 fprintf(stderr, "bad SW response to VERIFY CHV: %04X\n", | |
| 31 sim_resp_sw); | |
| 32 return(-1); | |
| 33 } | |
| 34 return(0); | |
| 35 } |
