diff options
| author | beck <> | 2002-05-15 02:29:21 +0000 |
|---|---|---|
| committer | beck <> | 2002-05-15 02:29:21 +0000 |
| commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
| tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libcrypto/rand/randfile.c | |
| parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
| download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip | |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index c4eb79ac5f..4b221e08f5 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
| @@ -61,7 +61,11 @@ | |||
| 61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
| 62 | #include <string.h> | 62 | #include <string.h> |
| 63 | 63 | ||
| 64 | #ifdef VMS | 64 | #include "e_os.h" |
| 65 | #include <openssl/crypto.h> | ||
| 66 | #include <openssl/rand.h> | ||
| 67 | |||
| 68 | #ifdef OPENSSL_SYS_VMS | ||
| 65 | #include <unixio.h> | 69 | #include <unixio.h> |
| 66 | #endif | 70 | #endif |
| 67 | #ifndef NO_SYS_TYPES_H | 71 | #ifndef NO_SYS_TYPES_H |
| @@ -73,10 +77,6 @@ | |||
| 73 | # include <sys/stat.h> | 77 | # include <sys/stat.h> |
| 74 | #endif | 78 | #endif |
| 75 | 79 | ||
| 76 | #include "openssl/e_os.h" | ||
| 77 | #include <openssl/crypto.h> | ||
| 78 | #include <openssl/rand.h> | ||
| 79 | |||
| 80 | #undef BUFSIZE | 80 | #undef BUFSIZE |
| 81 | #define BUFSIZE 1024 | 81 | #define BUFSIZE 1024 |
| 82 | #define RAND_DATA 1024 | 82 | #define RAND_DATA 1024 |
| @@ -158,7 +158,7 @@ int RAND_write_file(const char *file) | |||
| 158 | } | 158 | } |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | #if defined(O_CREAT) && !defined(WIN32) | 161 | #if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) |
| 162 | /* For some reason Win32 can't write to files created this way */ | 162 | /* For some reason Win32 can't write to files created this way */ |
| 163 | 163 | ||
| 164 | /* chmod(..., 0600) is too late to protect the file, | 164 | /* chmod(..., 0600) is too late to protect the file, |
| @@ -190,7 +190,7 @@ int RAND_write_file(const char *file) | |||
| 190 | ret+=i; | 190 | ret+=i; |
| 191 | if (n <= 0) break; | 191 | if (n <= 0) break; |
| 192 | } | 192 | } |
| 193 | #ifdef VMS | 193 | #ifdef OPENSSL_SYS_VMS |
| 194 | /* Try to delete older versions of the file, until there aren't | 194 | /* Try to delete older versions of the file, until there aren't |
| 195 | any */ | 195 | any */ |
| 196 | { | 196 | { |
| @@ -208,7 +208,7 @@ int RAND_write_file(const char *file) | |||
| 208 | some point... */ | 208 | some point... */ |
| 209 | } | 209 | } |
| 210 | } | 210 | } |
| 211 | #endif /* VMS */ | 211 | #endif /* OPENSSL_SYS_VMS */ |
| 212 | 212 | ||
| 213 | fclose(out); | 213 | fclose(out); |
| 214 | memset(buf,0,BUFSIZE); | 214 | memset(buf,0,BUFSIZE); |
| @@ -242,7 +242,7 @@ const char *RAND_file_name(char *buf, size_t size) | |||
| 242 | if (s && *s && strlen(s)+strlen(RFILE)+2 < size) | 242 | if (s && *s && strlen(s)+strlen(RFILE)+2 < size) |
| 243 | { | 243 | { |
| 244 | strlcpy(buf,s,size); | 244 | strlcpy(buf,s,size); |
| 245 | #ifndef VMS | 245 | #ifndef OPENSSL_SYS_VMS |
| 246 | strcat(buf,"/"); | 246 | strcat(buf,"/"); |
| 247 | #endif | 247 | #endif |
| 248 | strlcat(buf,RFILE,size); | 248 | strlcat(buf,RFILE,size); |
| @@ -252,20 +252,20 @@ const char *RAND_file_name(char *buf, size_t size) | |||
| 252 | buf[0] = '\0'; /* no file name */ | 252 | buf[0] = '\0'; /* no file name */ |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | #ifdef DEVRANDOM | 255 | #ifdef __OpenBSD__ |
| 256 | /* given that all random loads just fail if the file can't be | 256 | /* given that all random loads just fail if the file can't be |
| 257 | * seen on a stat, we stat the file we're returning, if it | 257 | * seen on a stat, we stat the file we're returning, if it |
| 258 | * fails, use DEVRANDOM instead. this allows the user to | 258 | * fails, use /dev/arandom instead. this allows the user to |
| 259 | * use their own source for good random data, but defaults | 259 | * use their own source for good random data, but defaults |
| 260 | * to something hopefully decent if that isn't available. | 260 | * to something hopefully decent if that isn't available. |
| 261 | */ | 261 | */ |
| 262 | 262 | ||
| 263 | if (!ok) | 263 | if (!ok) |
| 264 | if (strlcpy(buf,DEVRANDOM,size) >= size) { | 264 | if (strlcpy(buf,"/dev/arandom",size) >= size) { |
| 265 | return(NULL); | 265 | return(NULL); |
| 266 | } | 266 | } |
| 267 | if (stat(buf,&sb) == -1) | 267 | if (stat(buf,&sb) == -1) |
| 268 | if (strlcpy(buf,DEVRANDOM,size) >= size) { | 268 | if (strlcpy(buf,"/dev/arandom",size) >= size) { |
| 269 | return(NULL); | 269 | return(NULL); |
| 270 | } | 270 | } |
| 271 | 271 | ||
