summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>1999-05-24 01:29:23 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>1999-05-24 01:29:23 +0000
commitb36dd35ca4cc80c69896001221a73b10da13706d (patch)
tree2dd65255e7fd1470ca2eb9edbaad7fce25573c1b
parent9792cd16345e95c23a39cde6f53753de54edd484 (diff)
Unified tool for keynote utils.
-rw-r--r--lib/libkeynote/Makefile.dist180
-rw-r--r--lib/libkeynote/keynote-keygen.c16
-rw-r--r--lib/libkeynote/keynote-main.c60
-rw-r--r--lib/libkeynote/keynote-sign.c62
-rw-r--r--lib/libkeynote/keynote-sigver.c16
-rw-r--r--lib/libkeynote/keynote-verify.c22
6 files changed, 98 insertions, 258 deletions
diff --git a/lib/libkeynote/Makefile.dist b/lib/libkeynote/Makefile.dist
deleted file mode 100644
index b893d505050..00000000000
--- a/lib/libkeynote/Makefile.dist
+++ /dev/null
@@ -1,180 +0,0 @@
-#
-# The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
-#
-# This code was written by Angelos D. Keromytis in Philadelphia, PA, USA,
-# in April-May 1998
-#
-# Copyright (C) 1998, 1999 by Angelos D. Keromytis.
-#
-# Permission to use, copy, and modify this software without fee
-# is hereby granted, provided that this entire notice is included in
-# all copies of any software which is or includes a copy or
-# modification of this software.
-#
-# THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
-# IMPLIED WARRANTY. IN PARTICULAR, THE AUTHORS MAKES NO
-# REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
-# MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
-# PURPOSE.
-
-VERSION = 2-beta2
-DISTFILE = keynote-${VERSION}.tar.gz
-KNSUBDIR = KeyNote-${VERSION}
-
-RANLIB = ranlib
-MKDIR = mkdir
-YACC = yacc
-#YACC = bison
-TRUE = true
-LEX = flex
-TAR = tar
-CC = gcc
-RM = rm
-AR = ar
-NROFF = nroff
-
-TARFLAGS = -cvzf ${DISTFILE}
-YACCFLAGS2 = -d -p kv -b z
-YACCFLAGS = -d -p kn -b k
-LEXFLAGS2 = -Pkv -s -i
-LEXFLAGS = -Cr -Pkn -s -i
-CFLAGS = -O2 #-Wall -g
-RMFLAGS2 = -rf
-RMFLAGS = -f
-NROFFFLAGS = -mandoc
-
-# SSLeay/OpenSSL pointers
-SSLINC = -I/usr/local/include -I/usr/local/ssl/include \
- -I/usr/local/openssl/include
-SSLLIB = -L/usr/lib -L/usr/local/lib -L/usr/local/ssl/lib \
- -L/usr/local/openssl/lib -L/usr/local/openssl/ -lcrypto
-
-# No-crypto compile/link flags and definitions
-NOCRYPTODEFS = #-DPGPLIB -DNO_SNPRINTF -DNEED_GETOPT -DPILOT
-NOCRYPTOINC = -I.
-NOCRYPTOLIBS = -L. -lkeynote -lm
-
-# Final compile/link flags and definitions
-DEFS = -DCRYPTO ${NOCRYPTODEFS}
-INC = $(SSLINC) ${NOCRYPTOINC}
-LIBS = ${NOCRYPTOLIBS} ${SSLLIB}
-
-TARGET = libkeynote.a
-TARGET2 = keynote-verify
-TARGET3 = keynote-sign
-TARGET4 = keynote-sigver
-TARGET5 = keynote-keygen
-
-#GETOPT = getopt.o
-OBJS = k.tab.o lex.kn.o environment.o parse_assertion.o \
- signature.o aux.o base64.o $(GETOPT)
-OBJS2 = z.tab.o lex.kv.o keynote-verify.o
-OBJS3 = keynote-sign.o
-OBJS4 = keynote-sigver.o
-OBJS5 = keynote-keygen.o
-
-crypto: all
-
-nocrypto:
- ${MAKE} LIBS="${NOCRYPTOLIBS}" INC="${NOCRYPTOINC}" \
- DEFS="${NOCRYPTODEFS}"
-
-all: $(TARGET) $(TARGET2) $(TARGET3) $(TARGET4) $(TARGET5)
-
-library: $(TARGET)
-
-$(TARGET): $(OBJS)
- $(AR) -cvr $(TARGET) $(OBJS)
- $(RANLIB) $(TARGET)
-
-$(TARGET2): $(TARGET) $(OBJS2)
- $(CC) $(CFLAGS) -o $(TARGET2) $(OBJS2) $(LIBS)
-
-$(TARGET3): $(TARGET) $(OBJS3)
- $(CC) $(CFLAGS) -o $(TARGET3) $(OBJS3) $(LIBS)
-
-$(TARGET4): $(TARGET) $(OBJS4)
- $(CC) $(CFLAGS) -o $(TARGET4) $(OBJS4) $(LIBS)
-
-$(TARGET5): $(TARGET) $(OBJS5)
- $(CC) $(CFLAGS) -o $(TARGET5) $(OBJS5) $(LIBS)
-
-k.tab.c: keynote.y environment.h signature.h
- $(YACC) $(YACCFLAGS) keynote.y
-
-z.tab.c: keynote-ver.y keynote.h
- $(YACC) $(YACCFLAGS2) keynote-ver.y
-
-lex.kn.c: keynote.l k.tab.h environment.h assertion.h signature.h
- $(LEX) $(LEXFLAGS) keynote.l
-
-lex.kv.c: keynote-ver.l z.tab.h keynote.h
- $(LEX) $(LEXFLAGS2) keynote-ver.l
-
-.c.o:
- $(CC) $(CFLAGS) $(DEFS) $(INC) -c $<
-
-aux.c: environment.h signature.h
-parse_assertion.c: assertion.h environment.h signature.h
-environment.c: environment.h
-keynote-verify.c: keynote.h
-environment.h: keynote.h
-assertion.h: keynote.h
-signature.h: assertion.h
-signature.c: signature.h
-keynote-keygen.c: signature.h
-keynote-sign.c: signature.h
-keynote-sigver.c: signature.h
-base64.c: keynote.h
-
-clean:
- $(RM) $(RMFLAGS) $(OBJS) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5)
- $(RM) $(RMFLAGS) a.out *.core *~ */*~
-
-cleandir: cleanall
-
-cleanall: clean
- $(RM) $(RMFLAGS) *.o k.tab.c lex.kn.c k.tab.h z.tab.c z.tab.h
- $(RM) $(RMFLAGS) lex.kv.c y.output z.output ${DISTFILE}
- $(RM) $(RMFLAGS) $(TARGET) $(TARGET2) $(TARGET3)
- $(RM) $(RMFLAGS) $(TARGET4) $(TARGET5) man/*.0
-
-test: all
- ./$(TARGET2) -e testsuite/test-env \
- -r false,maybe,probably,true \
- -k testsuite/auth1 -k testsuite/auth2 -k testsuite/auth3 \
- -k testsuite/auth4 \
- -l testsuite/test-assertion1 -l testsuite/test-assertion2 \
- -l testsuite/test-assertion3 -l testsuite/test-assertion4 \
- -l testsuite/test-assertion5 -l testsuite/test-assertion6 \
- -l testsuite/test-assertion7 || ${TRUE}
-
-manpages: mankeynote mansystem mansign manver mansigver mankeygen
-
-mankeynote:
- ${NROFF} ${NROFFFLAGS} man/keynote.3 > man/keynote.0
-
-mansystem:
- ${NROFF} ${NROFFFLAGS} man/keynote.4 > man/keynote-system.0
-
-mansign:
- ${NROFF} ${NROFFFLAGS} man/keynote-sign.1 > man/keynote-sign.0
-
-mansigver:
- ${NROFF} ${NROFFFLAGS} man/keynote-sigver.1 > man/keynote-sigver.0
-
-manver:
- ${NROFF} ${NROFFFLAGS} man/keynote-verify.1 > man/keynote-verify.0
-
-mankeygen:
- ${NROFF} ${NROFFFLAGS} man/keynote-keygen.1 > man/keynote-keygen.0
-
-distribution: test cleanall manpages
- ${MKDIR} ${KNSUBDIR}
- $(TAR) cf - . | (cd ${KNSUBDIR}; ${TAR} xf -)
- ${RM} ${RMFLAGS2} ${KNSUBDIR}/CVS ${KNSUBDIR}/testsuite/CVS \
- ${KNSUBDIR}/Misc/CVS ${KNSUBDIR}/${KNSUBDIR} \
- ${KNSUBDIR}/.cvsignore ${KNSUBDIR}/man/CVS \
- ${KNSUBDIR}/man/.cvsignore ${KNSUBDIR}/doc/CVS
- $(TAR) $(TARFLAGS) ${KNSUBDIR}
- ${RM} ${RMFLAGS2} ${KNSUBDIR}
diff --git a/lib/libkeynote/keynote-keygen.c b/lib/libkeynote/keynote-keygen.c
index 11dcfc371cc..745f8bb58ea 100644
--- a/lib/libkeynote/keynote-keygen.c
+++ b/lib/libkeynote/keynote-keygen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keynote-keygen.c,v 1.1 1999/05/23 22:11:06 angelos Exp $ */
+/* $OpenBSD: keynote-keygen.c,v 1.2 1999/05/24 01:29:22 angelos Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
@@ -30,16 +30,16 @@
#ifdef WIN32
#include <ctype.h>
#include <io.h>
-#else
+#else /* WIN32 */
#include <unistd.h>
-#endif
+#endif /* WIN32 */
#include "signature.h"
#define DEFAULT_PUBLIC 0x10001
void
-usage(void)
+keygenusage(void)
{
fprintf(stderr, "Arguments:\n");
fprintf(stderr, "\t<AlgorithmName> <keysize> "
@@ -98,10 +98,10 @@ print_key(FILE *fp, char *algname, char *key, int start, int length)
#ifdef WIN32
void
-#else
+#else /* WIN32 */
int
-#endif
-main(int argc, char *argv[])
+#endif /* WIN32 */
+keynote_keygen(int argc, char *argv[])
{
int begin = KEY_PRINT_OFFSET, prlen = KEY_PRINT_LENGTH;
#if defined(CRYPTO) || defined(PGPLIB)
@@ -120,7 +120,7 @@ main(int argc, char *argv[])
if ((argc != 5) && (argc != 6) && (argc != 7))
{
- usage();
+ keygenusage();
exit(0);
}
diff --git a/lib/libkeynote/keynote-main.c b/lib/libkeynote/keynote-main.c
new file mode 100644
index 00000000000..352bbed466c
--- /dev/null
+++ b/lib/libkeynote/keynote-main.c
@@ -0,0 +1,60 @@
+/*
+ * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
+ *
+ * This code was written by Angelos D. Keromytis in Philadelphia, PA, USA,
+ * in April-May 1998
+ *
+ * Copyright (C) 1998, 1999 by Angelos D. Keromytis.
+ *
+ * Permission to use, copy, and modify this software without fee
+ * is hereby granted, provided that this entire notice is included in
+ * all copies of any software which is or includes a copy or
+ * modification of this software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTY. IN PARTICULAR, THE AUTHORS MAKES NO
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
+ * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
+ * PURPOSE.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <ctype.h>
+
+#ifdef WIN32
+#include <ctype.h>
+#include <io.h>
+#else
+#include <unistd.h>
+#endif /* WIN32 */
+
+extern int keynote_sign(int, char **), keynote_sigver(int, char **);
+extern int keynote_verify(int, char **), keynote_keygen(int, char **);
+
+#ifdef WIN32
+void
+#else
+int
+#endif
+main(int argc, char *argv[])
+{
+ if (!strcmp(argv[0], "keynote-sign"))
+ keynote_sign(argc, argv);
+ else
+ if (!strcmp(argv[0], "keynote-verify"))
+ keynote_verify(argc, argv);
+ else
+ if (!strcmp(argv[0], "keynote-sigver"))
+ keynote_sigver(argc, argv);
+ else
+ if (!strcmp(argv[0], "keynote-keygen"))
+ keynote_keygen(argc, argv);
+
+ fprintf(stderr, "%s: invoked under unknown name.\n", argv[0]);
+ exit(-1);
+}
diff --git a/lib/libkeynote/keynote-sign.c b/lib/libkeynote/keynote-sign.c
index 459ddf35fa8..deca4d24ebb 100644
--- a/lib/libkeynote/keynote-sign.c
+++ b/lib/libkeynote/keynote-sign.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keynote-sign.c,v 1.2 1999/05/24 00:51:25 angelos Exp $ */
+/* $OpenBSD: keynote-sign.c,v 1.3 1999/05/24 01:29:22 angelos Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
@@ -31,9 +31,9 @@
#ifdef WIN32
#include <ctype.h>
#include <io.h>
-#else
+#else /* WIN32 */
#include <unistd.h>
-#endif
+#endif /* WIN32 */
#include "assertion.h"
#include "signature.h"
@@ -41,63 +41,23 @@
#define SIG_PRINT_OFFSET 12
#define SIG_PRINT_LENGTH 50
+extern void print_space(FILE *, int), print_key(FILE *, char *, int, int);
+
void
-usage(void)
+signusage(void)
{
fprintf(stderr, "Arguments:\n");
fprintf(stderr, "\t[-v] <AlgorithmName> <AssertionFile> "
"<PrivateKeyFile>\n");
}
-/*
- * Print the specified number of spaces.
- */
-void
-print_space(FILE *fp, int n)
-{
- while (n--)
- fprintf(fp, " ");
-}
-
-/*
- * Output a signature, properly formatted.
- */
-void
-print_sig(FILE *fp, char *sig, int start, int length)
-{
- int i, k;
-
- print_space(fp, start);
- fprintf(fp, "\"");
-
- for (i = 0, k = 2; i < strlen(sig); i++, k++)
- {
- if (k == length)
- {
- if (i == strlen(sig))
- {
- fprintf(fp, "\"\n");
- return;
- }
-
- fprintf(fp, "\\\n");
- print_space(fp, start);
- i--;
- k = 0;
- }
- else
- fprintf(fp, "%c", sig[i]);
- }
-
- fprintf(fp, "\"\n");
-}
#ifdef WIN32
void
-#else
+#else /* WIN32 */
int
-#endif
-main(int argc, char *argv[])
+#endif /* WIN32 */
+keynote_sign(int argc, char *argv[])
{
int begin = SIG_PRINT_OFFSET, prlen = SIG_PRINT_LENGTH;
char *buf, *buf2, *sig, *algname;
@@ -107,7 +67,7 @@ main(int argc, char *argv[])
if ((argc != 4) &&
(argc != 5))
{
- usage();
+ signusage();
exit(-1);
}
@@ -240,7 +200,7 @@ main(int argc, char *argv[])
}
/* Print signature string */
- print_sig(stdout, sig, begin, prlen);
+ print_key(stdout, sig, begin, prlen);
free(sig); /* Just a reminder that the result is malloc'ed */
diff --git a/lib/libkeynote/keynote-sigver.c b/lib/libkeynote/keynote-sigver.c
index c73af47982b..a7eafdec2aa 100644
--- a/lib/libkeynote/keynote-sigver.c
+++ b/lib/libkeynote/keynote-sigver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keynote-sigver.c,v 1.1 1999/05/23 22:11:06 angelos Exp $ */
+/* $OpenBSD: keynote-sigver.c,v 1.2 1999/05/24 01:29:22 angelos Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
@@ -31,15 +31,15 @@
#ifdef WIN32
#include <ctype.h>
#include <io.h>
-#else
+#else /* WIN32 */
#include <unistd.h>
-#endif
+#endif /* WIN32 */
#include "assertion.h"
#include "signature.h"
void
-usage(void)
+sigverusage(void)
{
fprintf(stderr, "Arguments:\n");
fprintf(stderr, "\t<AssertionFile>\n");
@@ -47,10 +47,10 @@ usage(void)
#ifdef WIN32
void
-#else
+#else /* WIN32 */
int
-#endif
-main(int argc, char *argv[])
+#endif /* WIN32 */
+keynote_sigver(int argc, char *argv[])
{
struct stat sb;
int fd, i;
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
if (argc != 2)
{
- usage();
+ sigverusage();
exit(0);
}
diff --git a/lib/libkeynote/keynote-verify.c b/lib/libkeynote/keynote-verify.c
index fde510c8667..4477fbcc961 100644
--- a/lib/libkeynote/keynote-verify.c
+++ b/lib/libkeynote/keynote-verify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keynote-verify.c,v 1.1 1999/05/23 22:11:04 angelos Exp $ */
+/* $OpenBSD: keynote-verify.c,v 1.2 1999/05/24 01:29:22 angelos Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
@@ -31,12 +31,12 @@
#ifdef WIN32
#include <io.h>
#include "getopt.h"
-#else
+#else /* WIN32 */
#include <unistd.h>
#ifdef NEED_GETOPT
#include "getopt.h"
-#endif
-#endif
+#endif /* NEED_GETOPT */
+#endif /* WIN32 */
#include "keynote.h"
@@ -46,7 +46,7 @@ extern void parse_key(char *);
int sessid;
void
-usage(void)
+verifyusage(void)
{
fprintf(stderr, "Arguments:\n");
fprintf(stderr, "\t-h: This message\n");
@@ -61,10 +61,10 @@ usage(void)
#ifdef WIN32
void
-#else
+#else /* WIN32 */
int
-#endif
-main(int argc, char *argv[])
+#endif /* WIN32 */
+keynote_verify(int argc, char *argv[])
{
#ifdef LoopTesting
int loopvar = 1000;
@@ -76,7 +76,7 @@ main(int argc, char *argv[])
if (argc == 1)
{
- usage();
+ verifyusage();
exit(-1);
}
@@ -178,7 +178,7 @@ main(int argc, char *argv[])
break;
case 'h':
- usage();
+ verifyusage();
exit(0);
case 'r':
@@ -289,7 +289,7 @@ main(int argc, char *argv[])
case '?':
default:
- usage();
+ verifyusage();
exit(-1);
}
}