summary refs log tree commit diff
path: root/bounce.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-31 23:35:12 -0400
committerJune McEnroe <june@causal.agency>2020-07-31 23:35:12 -0400
commit04ad4ecc7b4b5db1bbe10372a6820ed88e2799e8 (patch)
tree1d2e37d449f46029b2610a0a4576637c5780c102 /bounce.c
parentRewrite configure script for all platforms (diff)
downloadpounce-04ad4ecc7b4b5db1bbe10372a6820ed88e2799e8.tar.gz
pounce-04ad4ecc7b4b5db1bbe10372a6820ed88e2799e8.zip
Use RAND_bytes instead of arc4random_buf
This adds an actual dependency on libcrypto, but removes a dependency on
BSD (or LibreSSL libcrypto specifically).
Diffstat (limited to 'bounce.c')
-rw-r--r--bounce.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bounce.c b/bounce.c
index 8ed4234..c9b27b0 100644
--- a/bounce.c
+++ b/bounce.c
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <limits.h>
+#include <openssl/rand.h>
 #include <poll.h>
 #include <pwd.h>
 #include <signal.h>
@@ -56,11 +57,14 @@
 bool verbose;
 
 static void hashPass(void) {
-	char *pass = getpass("Password: ");
 	byte rand[12];
-	arc4random_buf(rand, sizeof(rand));
+	int n = RAND_bytes(rand, sizeof(rand));
+	if (n < 1) errx(EX_OSERR, "RAND_bytes failure");
+
 	char salt[3 + BASE64_SIZE(sizeof(rand))] = "$6$";
 	base64(&salt[3], rand, sizeof(rand));
+
+	char *pass = getpass("Password: ");
 	printf("%s\n", crypt(pass, salt));
 }