summary refs log tree commit diff
path: root/bounce.c
diff options
context:
space:
mode:
authorIssam E. Maghni <issam.e.maghni@mailbox.org>2020-08-19 19:24:22 -0400
committerJune McEnroe <june@causal.agency>2020-08-23 14:01:00 -0400
commitcd02c9f11ae2f848d44917ffa8f887708b3a93c9 (patch)
treed2dbc02545889e6baed706bc2653802c247aefb2 /bounce.c
parentcontrib/palaver: Add no message preview flags (diff)
downloadpounce-cd02c9f11ae2f848d44917ffa8f887708b3a93c9.tar.gz
pounce-cd02c9f11ae2f848d44917ffa8f887708b3a93c9.zip
Replace “RAND_bytes” by “getentropy”
This removes the dependency on libcrypto.

Signed-off-by: Issam E. Maghni <issam.e.maghni@mailbox.org>
Diffstat (limited to '')
-rw-r--r--bounce.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bounce.c b/bounce.c
index 990a61d..9a72db5 100644
--- a/bounce.c
+++ b/bounce.c
@@ -31,7 +31,6 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <limits.h>
-#include <openssl/rand.h>
 #include <poll.h>
 #include <pwd.h>
 #include <signal.h>
@@ -52,6 +51,11 @@
 #include <sys/capsicum.h>
 #endif
 
+// For getentropy(2):
+#ifdef __APPLE__
+#include <sys/random.h>
+#endif
+
 #ifndef SIGINFO
 #define SIGINFO SIGUSR2
 #endif
@@ -62,8 +66,8 @@ bool verbose;
 
 static void hashPass(void) {
 	byte rand[12];
-	int n = RAND_bytes(rand, sizeof(rand));
-	if (n < 1) errx(EX_OSERR, "RAND_bytes failure");
+	int error = getentropy(rand, sizeof(rand));
+	if (error) err(EX_OSERR, "getentropy");
 
 	char salt[3 + BASE64_SIZE(sizeof(rand))] = "$6$";
 	base64(&salt[3], rand, sizeof(rand));