FreeCalypso > hg > fc-pcsc-tools
changeset 118:5d45cde6e4b2
fc-uicc-tool: verify-pin command family implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 19 Feb 2021 23:23:13 +0000 |
parents | b89bc690dec4 |
children | 0ac0aee0df11 |
files | uicc/Makefile uicc/dispatch.c uicc/pins.c |
diffstat | 3 files changed, 66 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/uicc/Makefile Fri Feb 19 07:39:26 2021 +0000 +++ b/uicc/Makefile Fri Feb 19 23:23:13 2021 +0000 @@ -1,8 +1,8 @@ CC= gcc CFLAGS= -O2 -I/usr/include/PCSC -I../libcommon PROG= fc-uicc-tool -OBJS= dispatch.o dumpdir.o hlread.o main.o readcmd.o readops.o script.o \ - select.o writecmd.o writeops.o +OBJS= dispatch.o dumpdir.o hlread.o main.o pins.o readcmd.o readops.o \ + script.o select.o writecmd.o writeops.o LIBS= ../libcommon/libcommon.a INSTBIN=/opt/freecalypso/bin
--- a/uicc/dispatch.c Fri Feb 19 07:39:26 2021 +0000 +++ b/uicc/dispatch.c Fri Feb 19 23:23:13 2021 +0000 @@ -22,6 +22,8 @@ extern int cmd_update_bin(); extern int cmd_update_bin_imm(); extern int cmd_update_rec(); +extern int cmd_verify_hex(); +extern int cmd_verify_pin(); extern int good_exit(); extern int retrieve_atr(); @@ -50,6 +52,9 @@ {"update-bin", 2, 2, 0, cmd_update_bin}, {"update-bin-imm", 2, 2, 0, cmd_update_bin_imm}, {"update-rec", 2, 2, 0, cmd_update_rec}, + {"verify-ext", 2, 2, 0, cmd_verify_pin}, + {"verify-hex", 2, 2, 0, cmd_verify_hex}, + {"verify-pin", 2, 2, 0, cmd_verify_pin}, {0, 0, 0, 0, 0} };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/uicc/pins.c Fri Feb 19 23:23:13 2021 +0000 @@ -0,0 +1,59 @@ +/* + * This module implements the standard set of commands for working + * with UICC PINs; because all of these commands take a user-specified + * P2 key ID, they should work with ADM PINs as well. + */ + +#include <sys/types.h> +#include <stdio.h> +#include "simresp.h" + +cmd_verify_pin(argc, argv) + char **argv; +{ + u_char cmd[13]; + int rc; + + /* VERIFY PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x20; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 8; + rc = encode_pin_entry(argv[2], 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: %04X\n", sim_resp_sw); + return(-1); + } + return(0); +} + +cmd_verify_hex(argc, argv) + char **argv; +{ + u_char cmd[13]; + int rc; + + /* VERIFY PIN command APDU */ + cmd[0] = 0x00; + cmd[1] = 0x20; + cmd[2] = 0x00; + cmd[3] = strtoul(argv[1], 0, 0); + cmd[4] = 8; + rc = decode_hex_data_from_string(argv[2], cmd + 5, 8, 8); + 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: %04X\n", sim_resp_sw); + return(-1); + } + return(0); +}