changeset 46:32d6186668cf

simtool code: chvext.c split from chv.c
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Feb 2021 00:01:38 +0000
parents 5bca197e7495
children ae3342497fea
files simtool/Makefile simtool/chv.c simtool/chvext.c
diffstat 3 files changed, 35 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/simtool/Makefile	Fri Feb 12 23:54:12 2021 +0000
+++ b/simtool/Makefile	Sat Feb 13 00:01:38 2021 +0000
@@ -1,8 +1,8 @@
 CC=	gcc
 CFLAGS=	-O2 -I/usr/include/PCSC -I../libcommon
 PROG=	fc-simtool
-OBJS=	a38.o chv.o curfile.o dispatch.o dumpdir.o grcard1.o grcard2.o hlread.o\
-	main.o pbcommon.o pbdump.o pberase.o pbupd_file.o pbupd_imm.o \
+OBJS=	a38.o chv.o chvext.o curfile.o dispatch.o dumpdir.o grcard1.o grcard2.o\
+	hlread.o main.o pbcommon.o pbdump.o pberase.o pbupd_file.o pbupd_imm.o \
 	pbupd_immhex.o readcmd.o readops.o restorebin.o savebin.o script.o \
 	select.o smserase.o smsp_common.o smsp_dump.o smsp_erase.o \
 	smsp_restore.o smsp_set.o sysmo.o telsum.o writecmd.o writeops.o
--- a/simtool/chv.c	Fri Feb 12 23:54:12 2021 +0000
+++ b/simtool/chv.c	Sat Feb 13 00:01:38 2021 +0000
@@ -42,31 +42,6 @@
 	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;
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simtool/chvext.c	Sat Feb 13 00:01:38 2021 +0000
@@ -0,0 +1,33 @@
+/*
+ * This module implements some commands for extended (non-standard)
+ * CHV-like operations which some cards use for ADM access control.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include "simresp.h"
+
+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);
+}