# HG changeset patch # User Mychaela Falconia # Date 1613782102 0 # Node ID 8e70ee7c194f226374f019807e2434a7bcfaedba # Parent a98992e9fe82b96826e4b5ef222ea2c98c74ebb2 fc-simtool & fc-uicc-tool: raw apdu command implemented diff -r a98992e9fe82 -r 8e70ee7c194f libcommon/Makefile --- a/libcommon/Makefile Fri Feb 19 23:51:58 2021 +0000 +++ b/libcommon/Makefile Sat Feb 20 00:48:22 2021 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -I/usr/include/PCSC -OBJS= alpha_decode.o alpha_fromfile.o alpha_valid.o apdu.o atr.o \ +OBJS= alpha_decode.o alpha_fromfile.o alpha_valid.o apdu.o apducmd.o atr.o \ cardconnect.o chkblank.o decimal_str.o dumpdirfunc.o exit.o \ globalopts.o gsm7_decode.o gsm7_encode.o gsm7_encode_table.o \ gsm7_unpack.o hexdump.o hexread.o hexstr.o names.o number_decode.o \ diff -r a98992e9fe82 -r 8e70ee7c194f libcommon/apducmd.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libcommon/apducmd.c Sat Feb 20 00:48:22 2021 +0000 @@ -0,0 +1,26 @@ +/* + * This module implements a low-level debug command + * for users to manually send arbitrary APDUs. + */ + +#include +#include +#include "simresp.h" + +cmd_apdu(argc, argv) + char **argv; +{ + u_char cmd[260]; + int rc; + unsigned len; + + rc = decode_hex_data_from_string(argv[1], cmd, 5, 260); + if (rc < 0) + return(rc); + len = rc; + rc = apdu_exchange(cmd, len); + if (rc < 0) + return(rc); + printf("%04X\n", sim_resp_sw); + return(0); +} diff -r a98992e9fe82 -r 8e70ee7c194f simtool/dispatch.c --- a/simtool/dispatch.c Fri Feb 19 23:51:58 2021 +0000 +++ b/simtool/dispatch.c Sat Feb 20 00:48:22 2021 +0000 @@ -9,6 +9,7 @@ #include extern int cmd_a38(); +extern int cmd_apdu(); extern int cmd_change_chv(); extern int cmd_disable_chv(); extern int cmd_enable_chv(); @@ -93,6 +94,7 @@ int (*func)(); } cmdtab[] = { {"a38", 1, 1, 1, cmd_a38}, + {"apdu", 1, 1, 0, cmd_apdu}, {"atr", 0, 0, 0, retrieve_atr}, {"change-chv1", 2, 2, 0, cmd_change_chv}, {"change-chv2", 2, 2, 0, cmd_change_chv}, diff -r a98992e9fe82 -r 8e70ee7c194f uicc/dispatch.c --- a/uicc/dispatch.c Fri Feb 19 23:51:58 2021 +0000 +++ b/uicc/dispatch.c Sat Feb 20 00:48:22 2021 +0000 @@ -8,6 +8,7 @@ #include #include +extern int cmd_apdu(); extern int cmd_change_pin(); extern int cmd_dir(); extern int cmd_disable_pin(); @@ -41,6 +42,7 @@ int allow_redir; int (*func)(); } cmdtab[] = { + {"apdu", 1, 1, 0, cmd_apdu}, {"atr", 0, 0, 0, retrieve_atr}, {"change-pin", 3, 3, 0, cmd_change_pin}, {"dir", 0, 0, 1, cmd_dir},