changeset 95:c06c0e2da24c

fc-simtool terminal-resp command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 21 Apr 2021 06:40:33 +0000
parents 3d9c50880ae7
children a5cfe5135701
files simtool/cmdtab.c simtool/stktest.c
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/cmdtab.c	Wed Apr 21 05:50:45 2021 +0000
+++ b/simtool/cmdtab.c	Wed Apr 21 06:40:33 2021 +0000
@@ -99,6 +99,7 @@
 extern int cmd_sws_pin1_enable();
 extern int cmd_telecom_sum();
 extern int cmd_terminal_profile();
+extern int cmd_terminal_resp();
 extern int cmd_uicc_dir();
 extern int cmd_unblock_chv();
 extern int cmd_update_bin();
@@ -234,6 +235,7 @@
 	{"sws-pin1-enable", 0, 0, 0, cmd_sws_pin1_enable},
 	{"telecom-sum", 0, 0, 0, cmd_telecom_sum},
 	{"terminal-profile", 1, 1, 0, cmd_terminal_profile},
+	{"terminal-resp", 1, 1, 0, cmd_terminal_resp},
 	{"uicc-dir", 0, 0, 1, cmd_uicc_dir},
 	{"unblock-chv1", 2, 2, 0, cmd_unblock_chv},
 	{"unblock-chv2", 2, 2, 0, cmd_unblock_chv},
--- a/simtool/stktest.c	Wed Apr 21 05:50:45 2021 +0000
+++ b/simtool/stktest.c	Wed Apr 21 06:40:33 2021 +0000
@@ -110,3 +110,27 @@
 	display_sim_resp_in_hex(outf);
 	return(0);
 }
+
+cmd_terminal_resp(argc, argv)
+	char **argv;
+{
+	u_char cmd[260];
+	int rc;
+	unsigned len;
+
+	rc = decode_hex_data_from_string(argv[1], cmd + 5, 1, 255);
+	if (rc < 0)
+		return(rc);
+	len = rc;
+	/* TERMINAL RESPONSE command APDU */
+	cmd[0] = 0xA0;
+	cmd[1] = 0x14;
+	cmd[2] = 0;
+	cmd[3] = 0;
+	cmd[4] = len;
+	rc = apdu_exchange(cmd, len + 5);
+	if (rc < 0)
+		return(rc);
+	printf("%04X\n", sim_resp_sw);
+	return(0);
+}