comparison 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
comparison
equal deleted inserted replaced
2104:7755f00a4fc3 2105:882556b3029d
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <string.h> 9 #include <string.h>
10 10
11 #include <openssl/sha.h> 11 #include <openssl/sha.h>
12 #include <openssl/rand.h>
12 13
13 #define PASSSIZE 4 14 #define PASSSIZE 4
14 15
15 int uw_hash_blocksize = 32; 16 int uw_hash_blocksize = 32;
16 17
17 static int password[PASSSIZE]; 18 static int password[PASSSIZE];
18 19
19 char *uw_sig_file = NULL; 20 char *uw_sig_file = NULL;
20 21
21 static void random_password() { 22 static void random_password() {
22 int i; 23 if (!RAND_bytes((unsigned char *)password, sizeof password)) {
23 24 fprintf(stderr, "Error generating random password\n");
24 for (i = 0; i < PASSSIZE; ++i) 25 perror("RAND_bytes");
25 password[i] = rand(); 26 exit(1);
27 }
26 } 28 }
27 29
28 void uw_init_crypto() { 30 void uw_init_crypto() {
29 if (uw_sig_file) { 31 if (uw_sig_file) {
30 int fd; 32 int fd;