changeset 166:febcbc6082df

fc-simtool: repeatable {dis,en}able-pin1-rpt commands implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 26 Feb 2021 23:18:29 +0000
parents 8a5c132fe871
children ca2e62a9691e
files simtool/chv.c simtool/dispatch.c
diffstat 2 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/chv.c	Fri Feb 26 22:03:12 2021 +0000
+++ b/simtool/chv.c	Fri Feb 26 23:18:29 2021 +0000
@@ -105,6 +105,31 @@
 	return(0);
 }
 
+cmd_disable_chv1_rpt(argc, argv)
+	char **argv;
+{
+	u_char cmd[13];
+	int rc;
+
+	/* DISABLE CHV command APDU */
+	cmd[0] = 0xA0;
+	cmd[1] = 0x26;
+	cmd[2] = 0x00;
+	cmd[3] = 0x01;
+	cmd[4] = 8;
+	rc = encode_pin_entry(argv[1], cmd + 5);
+	if (rc < 0)
+		return(rc);
+	rc = apdu_exchange(cmd, 13);
+	if (rc < 0)
+		return(rc);
+	if (sim_resp_sw != 0x9000 && sim_resp_sw != 0x9808) {
+		fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
+		return(-1);
+	}
+	return(0);
+}
+
 cmd_enable_chv(argc, argv)
 	char **argv;
 {
@@ -130,6 +155,31 @@
 	return(0);
 }
 
+cmd_enable_chv1_rpt(argc, argv)
+	char **argv;
+{
+	u_char cmd[13];
+	int rc;
+
+	/* ENABLE CHV command APDU */
+	cmd[0] = 0xA0;
+	cmd[1] = 0x28;
+	cmd[2] = 0x00;
+	cmd[3] = 0x01;
+	cmd[4] = 8;
+	rc = encode_pin_entry(argv[1], cmd + 5);
+	if (rc < 0)
+		return(rc);
+	rc = apdu_exchange(cmd, 13);
+	if (rc < 0)
+		return(rc);
+	if (sim_resp_sw != 0x9000 && sim_resp_sw != 0x9808) {
+		fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
+		return(-1);
+	}
+	return(0);
+}
+
 cmd_unblock_chv(argc, argv)
 	char **argv;
 {
--- a/simtool/dispatch.c	Fri Feb 26 22:03:12 2021 +0000
+++ b/simtool/dispatch.c	Fri Feb 26 23:18:29 2021 +0000
@@ -15,7 +15,9 @@
 extern int cmd_cd();
 extern int cmd_change_chv();
 extern int cmd_disable_chv();
+extern int cmd_disable_chv1_rpt();
 extern int cmd_enable_chv();
+extern int cmd_enable_chv1_rpt();
 extern int cmd_envelope();
 extern int cmd_envelope_imm();
 extern int cmd_exec();
@@ -122,12 +124,16 @@
 	{"cur-ef-rehab", 0, 0, 0, current_ef_rehab},
 	{"disable-chv", 1, 1, 0, cmd_disable_chv},
 	{"disable-chv1", 1, 1, 0, cmd_disable_chv},
+	{"disable-chv1-rpt", 1, 1, 0, cmd_disable_chv1_rpt},
 	{"disable-pin", 1, 1, 0, cmd_disable_chv},
 	{"disable-pin1", 1, 1, 0, cmd_disable_chv},
+	{"disable-pin1-rpt", 1, 1, 0, cmd_disable_chv1_rpt},
 	{"enable-chv", 1, 1, 0, cmd_enable_chv},
 	{"enable-chv1", 1, 1, 0, cmd_enable_chv},
+	{"enable-chv1-rpt", 1, 1, 0, cmd_enable_chv1_rpt},
 	{"enable-pin", 1, 1, 0, cmd_enable_chv},
 	{"enable-pin1", 1, 1, 0, cmd_enable_chv},
+	{"enable-pin1-rpt", 1, 1, 0, cmd_enable_chv1_rpt},
 	{"envelope", 1, 1, 0, cmd_envelope},
 	{"envelope-imm", 1, 1, 0, cmd_envelope_imm},
 	{"exec", 1, 1, 0, cmd_exec},