changeset 153:a63e4c64f1f0

fc-simtool: grcard1-set-ki command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Feb 2021 00:46:18 +0000
parents 250d172662ca
children ed34c8b7e2c9
files simtool/dispatch.c simtool/grcard1.c
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/dispatch.c	Sun Feb 07 00:23:06 2021 +0000
+++ b/simtool/dispatch.c	Sun Feb 07 00:46:18 2021 +0000
@@ -15,6 +15,7 @@
 extern int cmd_exec();
 extern int cmd_fix_sysmo_msisdn();
 extern int cmd_grcard1_set_adm();
+extern int cmd_grcard1_set_ki();
 extern int cmd_grcard1_set_pin();
 extern int cmd_iccid();
 extern int cmd_imsi();
@@ -66,6 +67,7 @@
 	{"fix-sysmo-msisdn", 0, 0, cmd_fix_sysmo_msisdn},
 	{"grcard1-set-adm1", 2, 2, cmd_grcard1_set_adm},
 	{"grcard1-set-adm2", 2, 2, cmd_grcard1_set_adm},
+	{"grcard1-set-ki", 1, 1, cmd_grcard1_set_ki},
 	{"grcard1-set-pin1", 2, 2, cmd_grcard1_set_pin},
 	{"grcard1-set-pin2", 2, 2, cmd_grcard1_set_pin},
 	{"iccid", 0, 0, cmd_iccid},
--- a/simtool/grcard1.c	Sun Feb 07 00:23:06 2021 +0000
+++ b/simtool/grcard1.c	Sun Feb 07 00:46:18 2021 +0000
@@ -90,3 +90,28 @@
 	}
 	return(0);
 }
+
+cmd_grcard1_set_ki(argc, argv)
+	char **argv;
+{
+	u_char cmd[21];
+	int rc;
+
+	/* Grcard1 proprietary command APDU */
+	cmd[0] = 0x80;
+	cmd[1] = 0xD4;
+	cmd[2] = 0x02;
+	cmd[3] = 0x00;
+	cmd[4] = 16;
+	rc = decode_hex_data_from_string(argv[1], cmd + 5, 16, 16);
+	if (rc < 0)
+		return(rc);
+	rc = apdu_exchange(cmd, 21);
+	if (rc < 0)
+		return(rc);
+	if (sim_resp_sw != 0x9000) {
+		fprintf(stderr, "bad SW response: %04X\n", sim_resp_sw);
+		return(-1);
+	}
+	return(0);
+}