changeset 121:8e70ee7c194f

fc-simtool & fc-uicc-tool: raw apdu command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Feb 2021 00:48:22 +0000
parents a98992e9fe82
children c0cd0d4635bb
files libcommon/Makefile libcommon/apducmd.c simtool/dispatch.c uicc/dispatch.c
diffstat 4 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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 \
--- /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 <sys/types.h>
+#include <stdio.h>
+#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);
+}
--- 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 <stdlib.h>
 
 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},
--- 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 <strings.h>
 #include <stdlib.h>
 
+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},