changeset 3:e9e8ce12f5a5

encode_pin_entry() factored out into libcommon
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 11 Feb 2021 23:11:57 +0000
parents 5b69dfc789f2
children 744fabd6bd3f
files libcommon/Makefile libcommon/pinentry.c simtool/chv.c
diffstat 3 files changed, 29 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/Makefile	Thu Feb 11 23:08:39 2021 +0000
+++ b/libcommon/Makefile	Thu Feb 11 23:11:57 2021 +0000
@@ -1,7 +1,7 @@
 CC=	gcc
 CFLAGS=	-O2 -I/usr/include/PCSC
 OBJS=	alpha_decode.o alpha_valid.o apdu.o atr.o cardconnect.o exit.o \
-	hexdump.o hexread.o hexstr.o names.o
+	hexdump.o hexread.o hexstr.o names.o pinentry.o
 LIB=	libcommon.a
 
 all:	${LIB}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libcommon/pinentry.c	Thu Feb 11 23:11:57 2021 +0000
@@ -0,0 +1,28 @@
+#include <sys/types.h>
+#include <ctype.h>
+#include <stdio.h>
+
+encode_pin_entry(arg, dest)
+	char *arg;
+	u_char *dest;
+{
+	unsigned n;
+
+	n = 0;
+	while (*arg) {
+		if (!isdigit(*arg)) {
+			fprintf(stderr,
+			"error: PIN argument contains a non-digit character\n");
+			return(-1);
+		}
+		if (n >= 8) {
+			fprintf(stderr, "error: PIN argument is too long\n");
+			return(-1);
+		}
+		*dest++ = *arg++;
+		n++;
+	}
+	for (; n < 8; n++)
+		*dest++ = 0xFF;
+	return(0);
+}
--- a/simtool/chv.c	Thu Feb 11 23:08:39 2021 +0000
+++ b/simtool/chv.c	Thu Feb 11 23:11:57 2021 +0000
@@ -4,36 +4,9 @@
  */
 
 #include <sys/types.h>
-#include <ctype.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include "simresp.h"
 
-encode_pin_entry(arg, dest)
-	char *arg;
-	u_char *dest;
-{
-	unsigned n;
-
-	n = 0;
-	while (*arg) {
-		if (!isdigit(*arg)) {
-			fprintf(stderr,
-			"error: PIN argument contains a non-digit character\n");
-			return(-1);
-		}
-		if (n >= 8) {
-			fprintf(stderr, "error: PIN argument is too long\n");
-			return(-1);
-		}
-		*dest++ = *arg++;
-		n++;
-	}
-	for (; n < 8; n++)
-		*dest++ = 0xFF;
-	return(0);
-}
-
 cmd_verify_chv(argc, argv)
 	char **argv;
 {