changeset 120:a98992e9fe82

fc-uicc-tool: {pin,puk}-attempt-cnt commands implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 19 Feb 2021 23:51:58 +0000
parents 0ac0aee0df11
children 8e70ee7c194f
files uicc/dispatch.c uicc/pins.c
diffstat 2 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/uicc/dispatch.c	Fri Feb 19 23:42:18 2021 +0000
+++ b/uicc/dispatch.c	Fri Feb 19 23:51:58 2021 +0000
@@ -14,6 +14,8 @@
 extern int cmd_enable_pin();
 extern int cmd_exec();
 extern int cmd_iccid();
+extern int cmd_pin_attempt_cnt();
+extern int cmd_puk_attempt_cnt();
 extern int cmd_readbin();
 extern int cmd_readef();
 extern int cmd_readrec();
@@ -47,6 +49,8 @@
 	{"exec", 1, 1, 0, cmd_exec},
 	{"exit", 0, 0, 0, good_exit},
 	{"iccid", 0, 0, 0, cmd_iccid},
+	{"pin-attempt-cnt", 1, 1, 0, cmd_pin_attempt_cnt},
+	{"puk-attempt-cnt", 1, 1, 0, cmd_puk_attempt_cnt},
 	{"quit", 0, 0, 0, good_exit},
 	{"readbin", 2, 2, 1, cmd_readbin},
 	{"readef", 1, 1, 1, cmd_readef},
--- a/uicc/pins.c	Fri Feb 19 23:42:18 2021 +0000
+++ b/uicc/pins.c	Fri Feb 19 23:51:58 2021 +0000
@@ -163,3 +163,43 @@
 	}
 	return(0);
 }
+
+/* retrieving PIN attempt counters from the card */
+
+cmd_pin_attempt_cnt(argc, argv)
+	char **argv;
+{
+	u_char cmd[5];
+	int rc;
+
+	/* VERIFY PIN command APDU */
+	cmd[0] = 0x00;
+	cmd[1] = 0x20;
+	cmd[2] = 0x00;
+	cmd[3] = strtoul(argv[1], 0, 0);
+	cmd[4] = 0;
+	rc = apdu_exchange(cmd, 5);
+	if (rc < 0)
+		return(rc);
+	printf("%04X\n", sim_resp_sw);
+	return(0);
+}
+
+cmd_puk_attempt_cnt(argc, argv)
+	char **argv;
+{
+	u_char cmd[5];
+	int rc;
+
+	/* UNBLOCK PIN command APDU */
+	cmd[0] = 0x00;
+	cmd[1] = 0x2C;
+	cmd[2] = 0x00;
+	cmd[3] = strtoul(argv[1], 0, 0);
+	cmd[4] = 0;
+	rc = apdu_exchange(cmd, 5);
+	if (rc < 0)
+		return(rc);
+	printf("%04X\n", sim_resp_sw);
+	return(0);
+}