diff src/c/openssl.c @ 2105:882556b3029d

Fix silly mistake from last commit; also switch away from rand() in openssl.c
author Adam Chlipala <adam@chlipala.net>
date Thu, 22 Jan 2015 09:46:20 -0500
parents b2bc8bcd546f
children 8a01e8f21de9
line wrap: on
line diff
--- a/src/c/openssl.c	Mon Jan 12 12:02:54 2015 -0500
+++ b/src/c/openssl.c	Thu Jan 22 09:46:20 2015 -0500
@@ -9,6 +9,7 @@
 #include <string.h>
 
 #include <openssl/sha.h>
+#include <openssl/rand.h>
 
 #define PASSSIZE 4
 
@@ -19,10 +20,11 @@
 char *uw_sig_file = NULL;
 
 static void random_password() {
-  int i;
-
-  for (i = 0; i < PASSSIZE; ++i)
-    password[i] = rand();
+  if (!RAND_bytes((unsigned char *)password, sizeof password)) {
+    fprintf(stderr, "Error generating random password\n");
+    perror("RAND_bytes");
+    exit(1);
+  }
 }
 
 void uw_init_crypto() {