summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2000-05-15 04:20:54 +0000
committerkris <kris@FreeBSD.org>2000-05-15 04:20:54 +0000
commitd8a32b7ba02191af5f53e9fc6d9b63fc39c7383b (patch)
tree4675dd70941926dbda62ed06d94f4c6d7863d3e7
parent85a224d8383c06cac609fb99e5729f78a232d286 (diff)
downloadFreeBSD-src-d8a32b7ba02191af5f53e9fc6d9b63fc39c7383b.zip
FreeBSD-src-d8a32b7ba02191af5f53e9fc6d9b63fc39c7383b.tar.gz
Add some extra functions adapted from OpenBSD, in preparation for
OpenSSH OPIE support.
-rw-r--r--contrib/opie/opie.h9
-rw-r--r--lib/libopie/Makefile1
-rw-r--r--lib/libopie/opieextra.c96
3 files changed, 105 insertions, 1 deletions
diff --git a/contrib/opie/opie.h b/contrib/opie/opie.h
index c41fabf..7ac9b21 100644
--- a/contrib/opie/opie.h
+++ b/contrib/opie/opie.h
@@ -64,8 +64,11 @@ struct opie {
/* Maximum length of a seed */
#define OPIE_SEED_MAX 16
+/* Max length of hash algorithm name (md4/md5) */
+#define OPIE_HASHNAME_MAX 3
+
/* Maximum length of a challenge (otp-md? 9999 seed) */
-#define OPIE_CHALLENGE_MAX (7+1+4+1+OPIE_SEED_MAX)
+#define OPIE_CHALLENGE_MAX (4+OPIE_HASHNAME_MAX+1+4+1+OPIE_SEED_MAX)
/* Maximum length of a response that we allow */
#define OPIE_RESPONSE_MAX (9+1+19+1+9+OPIE_SEED_MAX+1+19+1+19+1+19)
@@ -105,6 +108,10 @@ int opieverify __P((struct opie *,char *));
int opiepasswd __P((struct opie *, int, char *, int, char *, char *));
char *opiereadpass __P((char *, int, int));
int opielogin __P((char *line, char *name, char *host));
+const char *opie_get_algorithm __P((void));
+int opie_haskey __P((char *username));
+char *opie_keyinfo __P((char *));
+int opie_passverify __P((char *username, char *passwd));
__END_DECLS
#if _OPIE
diff --git a/lib/libopie/Makefile b/lib/libopie/Makefile
index 1613878..c79415a 100644
--- a/lib/libopie/Makefile
+++ b/lib/libopie/Makefile
@@ -18,6 +18,7 @@ SRCS= atob8.c btoa8.c btoh.c challenge.c getsequence.c hash.c hashlen.c \
btoe.c accessfile.c generator.c insecure.c getutmpentry.c \
readrec.c writerec.c login.c open.c logwtmp.c \
getutline.c pututline.c endutent.c setutent.c # from libmissing
+SRCS+= opieextra.c
INCS= ${OPIE_DIST}/opie.h
CFLAGS+=-I${.CURDIR} -I${OPIE_DIST} -I${DIST_DIR} \
diff --git a/lib/libopie/opieextra.c b/lib/libopie/opieextra.c
new file mode 100644
index 0000000..874c278
--- /dev/null
+++ b/lib/libopie/opieextra.c
@@ -0,0 +1,96 @@
+/*
+ * This file contains routines modified from OpenBSD. Parts are contributed
+ * by Todd Miller <millert@openbsd.org>, Theo De Raadt <deraadt@openbsd.org>
+ * and possibly others.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdio.h>
+#include <opie.h>
+
+/*
+ * opie_haopie()
+ *
+ * Returns: 1 user doesnt exist, -1 file error, 0 user exists.
+ *
+ */
+int
+opie_haskey(username)
+char *username;
+{
+ struct opie opie;
+
+ return opielookup(&opie, username);
+}
+
+/*
+ * opie_keyinfo()
+ *
+ * Returns the current sequence number and
+ * seed for the passed user.
+ *
+ */
+char *
+opie_keyinfo(username)
+char *username;
+{
+ int i;
+ static char str[OPIE_CHALLENGE_MAX];
+ struct opie opie;
+
+ i = opiechallenge(&opie, username, str);
+ if (i == -1)
+ return(0);
+
+ return(str);
+}
+
+/*
+ * opie_passverify()
+ *
+ * Check to see if answer is the correct one to the current
+ * challenge.
+ *
+ * Returns: 0 success, -1 failure
+ *
+ */
+int
+opie_passverify(username, passwd)
+char *username;
+char *passwd;
+{
+ int i;
+ struct opie opie;
+
+ i = opielookup(&opie, username);
+ if (i == -1 || i == 1)
+ return(-1);
+
+ if (opieverify(&opie, passwd) == 0)
+ return(opie.opie_n);
+
+ return(-1);
+}
+
+#define OPIE_HASH_DEFAULT 1
+
+/* Current hash type (index into opie_hash_types array) */
+static int opie_hash_type = OPIE_HASH_DEFAULT;
+
+struct opie_algorithm_table {
+ const char *name;
+};
+
+static struct opie_algorithm_table opie_algorithm_table[] = {
+ "md4", "md5"
+};
+
+/* Get current hash type */
+const char *
+opie_get_algorithm()
+{
+ return(opie_algorithm_table[opie_hash_type].name);
+}
+
+
OpenPOWER on IntegriCloud