FreeCalypso > hg > fc-sim-tools
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simtool/chvfunc.c Wed Mar 17 00:42:47 2021 +0000 @@ -0,0 +1,35 @@ +/* + * This module implements a functional interface to CHV commands, + * intended for high-level wrappers like sws-*. + */ + +#include <sys/types.h> +#include <stdio.h> +#include "simresp.h" + +verify_chv_func(p2, pin) + unsigned p2; + char *pin; +{ + u_char cmd[13]; + int rc; + + /* VERIFY CHV command APDU */ + cmd[0] = 0xA0; + cmd[1] = 0x20; + cmd[2] = 0x00; + cmd[3] = p2; + cmd[4] = 8; + rc = encode_pin_entry(pin, cmd + 5); + if (rc < 0) + return(rc); + rc = apdu_exchange(cmd, 13); + if (rc < 0) + return(rc); + if (sim_resp_sw != 0x9000) { + fprintf(stderr, "bad SW response to VERIFY CHV: %04X\n", + sim_resp_sw); + return(-1); + } + return(0); +}