diff options
author | Adam Chlipala <adam@chlipala.net> | 2015-01-22 09:46:20 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2015-01-22 09:46:20 -0500 |
commit | 2207f580efc424d40c81d4dd98fb414e29eaa7f9 (patch) | |
tree | 1c47d0195ff76fe9a111e155c6ff78e3fe84cd00 /src/c/openssl.c | |
parent | 9b8fc824ae3fe7176abf67fecb811dd5bdb89cda (diff) |
Fix silly mistake from last commit; also switch away from rand() in openssl.c
Diffstat (limited to 'src/c/openssl.c')
-rw-r--r-- | src/c/openssl.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/c/openssl.c b/src/c/openssl.c index 6a998e29..1d820a34 100644 --- a/src/c/openssl.c +++ b/src/c/openssl.c @@ -9,6 +9,7 @@ #include <string.h> #include <openssl/sha.h> +#include <openssl/rand.h> #define PASSSIZE 4 @@ -19,10 +20,11 @@ static int password[PASSSIZE]; 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() { |