diff simtool/inval_rehab.c @ 124:d0d1c0b35831

fc-simtool: add low-level cur-ef-{inval,rehab} commands
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Feb 2021 19:05:48 +0000
parents
children e5d534fa5924
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simtool/inval_rehab.c	Sat Feb 20 19:05:48 2021 +0000
@@ -0,0 +1,52 @@
+/*
+ * This module implements the rarely-used INVALIDATE and REHABILITATE
+ * SIM protocol commands.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include "simresp.h"
+
+current_ef_inval()
+{
+	u_char cmd[5];
+	int rc;
+
+	/* INVALIDATE command APDU */
+	cmd[0] = 0xA0;
+	cmd[1] = 0x04;
+	cmd[2] = 0;
+	cmd[3] = 0;
+	cmd[4] = 0;
+	rc = apdu_exchange(cmd, 5);
+	if (rc < 0)
+		return(rc);
+	if (sim_resp_sw != 0x9000) {
+		fprintf(stderr, "bad SW response to INVALIDATE: %04X\n",
+			sim_resp_sw);
+		return(-1);
+	}
+	return(0);
+}
+
+current_ef_rehab()
+{
+	u_char cmd[5];
+	int rc;
+
+	/* REHABILITATE command APDU */
+	cmd[0] = 0xA0;
+	cmd[1] = 0x44;
+	cmd[2] = 0;
+	cmd[3] = 0;
+	cmd[4] = 0;
+	rc = apdu_exchange(cmd, 5);
+	if (rc < 0)
+		return(rc);
+	if (sim_resp_sw != 0x9000) {
+		fprintf(stderr, "bad SW response to REHABILITATE: %04X\n",
+			sim_resp_sw);
+		return(-1);
+	}
+	return(0);
+}