summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-09-29 16:13:20 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-09-29 16:13:20 +0000
commit8e44c9ffc2ad2113db233ba65359524821d4e366 (patch)
tree9d2e05a32c2397859b736452a1e11d88aa231ec4
parentc9262bcc75ddb6b8a2532f7b0c361af53b175a0f (diff)
Added sha1 (secure hash function).
-rw-r--r--include/Makefile9
-rw-r--r--include/sha1.h52
2 files changed, 56 insertions, 5 deletions
diff --git a/include/Makefile b/include/Makefile
index 1939df8287f..27381978aa2 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.23 1996/09/27 14:58:21 millert Exp $
+# $OpenBSD: Makefile,v 1.24 1996/09/29 16:13:19 millert Exp $
# $NetBSD: Makefile,v 1.59 1996/05/15 21:36:43 jtc Exp $
# @(#)Makefile 5.45.1.1 (Berkeley) 5/6/91
@@ -13,10 +13,9 @@ FILES= a.out.h ar.h assert.h bitstring.h bm.h cpio.h ctype.h db.h dirent.h \
grp.h ieeefp.h iso646.h kvm.h langinfo.h limits.h locale.h \
malloc.h math.h md2.h md4.h md5.h memory.h mpool.h ndbm.h netdb.h \
netgroup.h nlist.h nl_types.h paths.h poll.h pwd.h ranlib.h re_comp.h \
- regex.h resolv.h \
- search.h setjmp.h sgtty.h signal.h stab.h stddef.h stdio.h stdlib.h \
- string.h strings.h struct.h sysexits.h tar.h time.h ttyent.h tzfile.h \
- unistd.h utime.h utmp.h vis.h
+ regex.h resolv.h search.h setjmp.h sgtty.h sha1.h signal.h stab.h \
+ stddef.h stdio.h stdlib.h string.h strings.h struct.h sysexits.h \
+ tar.h time.h ttyent.h tzfile.h unistd.h utime.h utmp.h vis.h
.if (${MACHINE_ARCH} != "alpha") && (${MACHINE_ARCH} != "mips")
FILES+= dlfcn.h link.h
diff --git a/include/sha1.h b/include/sha1.h
new file mode 100644
index 00000000000..1afa8ce3469
--- /dev/null
+++ b/include/sha1.h
@@ -0,0 +1,52 @@
+/* --------------------------------- SHA1.H ------------------------------- */
+
+/* NIST proposed Secure Hash Standard.
+
+ Written 2 September 1992, Peter C. Gutmann.
+ This implementation placed in the public domain.
+
+ Comments to pgut1@cs.aukuni.ac.nz */
+
+/* Useful defines/typedefs */
+
+typedef unsigned char BYTE;
+typedef u_int32_t LONG;
+
+/* The SHA1 block size and message digest sizes, in bytes */
+
+#define SHA1_BLOCKSIZE 64
+#define SHA1_DIGESTSIZE 20
+
+/* The structure for storing SHA1 info */
+
+typedef struct {
+ LONG digest[ 5 ]; /* Message digest */
+ LONG countLo, countHi; /* 64-bit bit count */
+ LONG data[ 16 ]; /* SHA1 data buffer */
+ } SHA1_INFO;
+
+/* The next def turns on the change to the algorithm introduced by NIST at
+ * the behest of the NSA. It supposedly corrects a weakness in the original
+ * formulation. Bruce Schneier described it thus in a posting to the
+ * Cypherpunks mailing list on June 21, 1994 (as told to us by Steve Bellovin):
+ *
+ * This is the fix to the Secure Hash Standard, NIST FIPS PUB 180:
+ *
+ * In Section 7 of FIPS 180 (page 9), the line which reads
+ *
+ * "b) For t=16 to 79 let Wt = Wt-3 XOR Wt-8 XOR Wt-14 XOR
+ * Wt-16."
+ *
+ * is to be replaced by
+ *
+ * "b) For t=16 to 79 let Wt = S1(Wt-3 XOR Wt-8 XOR Wt-14 XOR
+ * Wt-16)."
+ *
+ * where S1 is a left circular shift by one bit as defined in
+ * Section 3 of FIPS 180 (page 6):
+ *
+ * S1(X) = (X<<1) OR (X>>31).
+ *
+ */
+
+#define NEW_SHA1