changeset 129:2adb802b2a98

fc-simtool: verify-ext command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 02 Feb 2021 17:12:17 +0000
parents 95c2a67e1219
children f691a19f191d
files simtool/chv.c simtool/dispatch.c
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/chv.c	Tue Feb 02 04:32:42 2021 +0000
+++ b/simtool/chv.c	Tue Feb 02 17:12:17 2021 +0000
@@ -72,6 +72,31 @@
 	return(0);
 }
 
+cmd_verify_ext(argc, argv)
+	char **argv;
+{
+	u_char cmd[13];
+	int rc;
+
+	/* VERIFY CHV command APDU */
+	cmd[0] = 0xA0;
+	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_change_chv(argc, argv)
 	char **argv;
 {
--- a/simtool/dispatch.c	Tue Feb 02 04:32:42 2021 +0000
+++ b/simtool/dispatch.c	Tue Feb 02 17:12:17 2021 +0000
@@ -38,6 +38,7 @@
 extern int cmd_update_bin_imm();
 extern int cmd_update_rec();
 extern int cmd_verify_chv();
+extern int cmd_verify_ext();
 
 extern int display_sim_resp_in_hex();
 extern int good_exit();
@@ -90,6 +91,7 @@
 	{"update-rec", 2, 2, cmd_update_rec},
 	{"verify-chv1", 1, 1, cmd_verify_chv},
 	{"verify-chv2", 1, 1, cmd_verify_chv},
+	{"verify-ext", 2, 2, cmd_verify_ext},
 	{"verify-pin1", 1, 1, cmd_verify_chv},
 	{"verify-pin2", 1, 1, cmd_verify_chv},
 	{0, 0, 0, 0}