about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-06-22 13:08:29 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-06-22 13:08:29 +0200
commite66a7f9fab601e35d435e97e450e647d92cc05ae (patch)
tree071cce0729662a91ed464e89323e4f0d0689512b
parent57adb92eb05e0eab41342d6d1896d18624fd1619 (diff)
downloadoutils-e66a7f9fab601e35d435e97e450e647d92cc05ae.tar.gz
outils-e66a7f9fab601e35d435e97e450e647d92cc05ae.tar.xz
outils-e66a7f9fab601e35d435e97e450e647d92cc05ae.zip
getentropy_linux: use included SHA512.
Revamp Makefile to only use -lcrypto for gzsig.

Idea by @dalias.
-rw-r--r--Makefile14
-rw-r--r--README2
-rw-r--r--src/liboutils/getentropy_linux.c18
3 files changed, 18 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index b5a8742..de36f88 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,19 @@
 CFLAGS?=-Wall -O2
 CPPFLAGS=-include src/liboutils/outils.h -isystem src/liboutils/include -Isrc/bin/md5 -D_GNU_SOURCE -D_DEFAULT_SOURCE -DNO_UTIL
 LDFLAGS=-Wl,--as-needed
-LIBS=-lcrypto -lm
-
-%: %.o
-	$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
+LIBS=-lm
 
 ALL=src/usr.bin/apply/apply src/usr.bin/jot/jot src/usr.bin/lam/lam src/usr.bin/lndir/lndir src/bin/md5/md5 src/usr.bin/rs/rs src/usr.bin/gzsig/gzsig src/usr.bin/signify/signify src/usr.bin/calendar/calendar src/usr.bin/vis/vis src/usr.bin/unvis/unvis src/usr.bin/what/what src/usr.sbin/rdate/rdate 
 all: $(ALL)
 
+%: %.o
+	$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
+src/usr.bin/gzsig/gzsig:
+	$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) -lcrypto
+
 src/usr.bin/apply/apply: src/usr.bin/apply/apply.o src/liboutils/pledge.o src/liboutils/strlcpy.o
 
-src/usr.bin/jot/jot: src/usr.bin/jot/jot.o src/liboutils/strlcpy.o src/liboutils/strlcat.o src/liboutils/strtonum.o src/liboutils/arc4random.o src/liboutils/arc4random_uniform.o src/liboutils/getentropy_linux.o src/liboutils/explicit_bzero.o src/liboutils/pledge.o src/liboutils/sha512.o src/liboutils/mem_clr.o
+src/usr.bin/jot/jot: src/usr.bin/jot/jot.o src/liboutils/strlcpy.o src/liboutils/strlcat.o src/liboutils/strtonum.o src/liboutils/arc4random.o src/liboutils/arc4random_uniform.o src/liboutils/getentropy_linux.o src/liboutils/explicit_bzero.o src/liboutils/pledge.o src/liboutils/sha2.o src/liboutils/mem_clr.o
 
 src/usr.bin/lam/lam: src/usr.bin/lam/lam.o src/liboutils/pledge.o src/liboutils/strlcpy.o
 
@@ -33,7 +35,7 @@ src/usr.bin/unvis/unvis: src/usr.bin/unvis/unvis.o src/liboutils/pledge.o src/li
 
 src/usr.bin/what/what: src/usr.bin/what/what.o src/liboutils/pledge.o src/liboutils/strlcpy.o
 
-src/usr.sbin/rdate/rdate: src/usr.sbin/rdate/ntp.o src/usr.sbin/rdate/rfc868time.o src/usr.sbin/rdate/rdate.o src/usr.sbin/rdate/ntpleaps.o src/liboutils/arc4random.o src/liboutils/reallocarray.o src/liboutils/getentropy_linux.o src/liboutils/explicit_bzero.o
+src/usr.sbin/rdate/rdate: src/usr.sbin/rdate/ntp.o src/usr.sbin/rdate/rfc868time.o src/usr.sbin/rdate/rdate.o src/usr.sbin/rdate/ntpleaps.o src/liboutils/arc4random.o src/liboutils/reallocarray.o src/liboutils/getentropy_linux.o src/liboutils/explicit_bzero.o src/liboutils/sha2.o
 
 clean:
 	rm -f src/*/*/*.o
diff --git a/README b/README
index 21c038f..7435005 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
 This is outils, a port of some non-standard OpenBSD tools to Linux.
-You need OpenSSL/LibreSSL to build it.
+You need OpenSSL/LibreSSL to build gzsig.
 
 Included are:
 
diff --git a/src/liboutils/getentropy_linux.c b/src/liboutils/getentropy_linux.c
index f0e3d40..adfd2fe 100644
--- a/src/liboutils/getentropy_linux.c
+++ b/src/liboutils/getentropy_linux.c
@@ -47,7 +47,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <time.h>
-#include <openssl/sha.h>
+#include <sha2.h>
 
 #include <linux/types.h>
 #include <linux/random.h>
@@ -67,9 +67,9 @@
 			HD(b); \
 	} while (0)
 
-#define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l)))
-#define HD(x)	 (SHA512_Update(&ctx, (char *)&(x), sizeof (x)))
-#define HF(x)    (SHA512_Update(&ctx, (char *)&(x), sizeof (void*)))
+#define HR(x, l) (SHA512Update(&ctx, (void *)(x), (l)))
+#define HD(x)	 (SHA512Update(&ctx, (void *)&(x), sizeof (x)))
+#define HF(x)    (SHA512Update(&ctx, (void *)&(x), sizeof (void*)))
 
 int	getentropy(void *buf, size_t len);
 
@@ -327,9 +327,9 @@ static const int cl[] = {
 static int
 getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data)
 {
-	SHA512_CTX *ctx = data;
+	SHA2_CTX *ctx = data;
 
-	SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr));
+	SHA512Update(ctx, (void *)&info->dlpi_addr, sizeof (info->dlpi_addr));
 	return (0);
 }
 
@@ -344,7 +344,7 @@ getentropy_fallback(void *buf, size_t len)
 	struct rusage ru;
 	sigset_t sigset;
 	struct stat st;
-	SHA512_CTX ctx;
+	SHA2_CTX ctx;
 	static pid_t lastpid;
 	pid_t pid;
 	size_t i, ii, m;
@@ -361,7 +361,7 @@ getentropy_fallback(void *buf, size_t len)
 	}
 	for (i = 0; i < len; ) {
 		int j;
-		SHA512_Init(&ctx);
+		SHA512Init(&ctx);
 		for (j = 0; j < repeat; j++) {
 			HX((e = gettimeofday(&tv, NULL)) == -1, tv);
 			if (e != -1) {
@@ -532,7 +532,7 @@ getentropy_fallback(void *buf, size_t len)
 #endif
 #endif
 
-		SHA512_Final(results, &ctx);
+		SHA512Final(results, &ctx);
 		memcpy((char *)buf + i, results, min(sizeof(results), len - i));
 		i += min(sizeof(results), len - i);
 	}