diff options
Diffstat (limited to 'src/lib/libcrypto/rand')
| -rw-r--r-- | src/lib/libcrypto/rand/Makefile.ssl | 8 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_egd.c | 3 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_win.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 22 |
4 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl index df80702373..e5cbe5319c 100644 --- a/src/lib/libcrypto/rand/Makefile.ssl +++ b/src/lib/libcrypto/rand/Makefile.ssl | |||
| @@ -101,7 +101,8 @@ md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | |||
| 101 | md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 101 | md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 102 | md_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | 102 | md_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h |
| 103 | md_rand.o: md_rand.c rand_lcl.h | 103 | md_rand.o: md_rand.c rand_lcl.h |
| 104 | rand_egd.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h | 104 | rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h |
| 105 | rand_egd.o: ../../include/openssl/opensslconf.h | ||
| 105 | rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | 106 | rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h |
| 106 | rand_egd.o: rand_egd.c | 107 | rand_egd.o: rand_egd.c |
| 107 | rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 108 | rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
| @@ -186,8 +187,9 @@ rand_win.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | |||
| 186 | rand_win.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 187 | rand_win.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 187 | rand_win.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | 188 | rand_win.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h |
| 188 | rand_win.o: ../cryptlib.h rand_lcl.h rand_win.c | 189 | rand_win.o: ../cryptlib.h rand_lcl.h rand_win.c |
| 189 | randfile.o: ../../e_os.h ../../include/openssl/crypto.h | 190 | randfile.o: ../../e_os.h ../../include/openssl/buffer.h |
| 190 | randfile.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h | 191 | randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 192 | randfile.o: ../../include/openssl/opensslconf.h | ||
| 191 | randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 193 | randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 192 | randfile.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 194 | randfile.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 193 | randfile.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 195 | randfile.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c index 895967476e..6f742900a0 100644 --- a/src/lib/libcrypto/rand/rand_egd.c +++ b/src/lib/libcrypto/rand/rand_egd.c | |||
| @@ -56,6 +56,7 @@ | |||
| 56 | 56 | ||
| 57 | #include <openssl/e_os2.h> | 57 | #include <openssl/e_os2.h> |
| 58 | #include <openssl/rand.h> | 58 | #include <openssl/rand.h> |
| 59 | #include <openssl/buffer.h> | ||
| 59 | 60 | ||
| 60 | /* | 61 | /* |
| 61 | * Query the EGD <URL: http://www.lothar.com/tech/crypto/>. | 62 | * Query the EGD <URL: http://www.lothar.com/tech/crypto/>. |
| @@ -145,7 +146,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) | |||
| 145 | addr.sun_family = AF_UNIX; | 146 | addr.sun_family = AF_UNIX; |
| 146 | if (strlen(path) >= sizeof(addr.sun_path)) | 147 | if (strlen(path) >= sizeof(addr.sun_path)) |
| 147 | return (-1); | 148 | return (-1); |
| 148 | strlcpy(addr.sun_path,path,sizeof addr.sun_path); | 149 | BUF_strlcpy(addr.sun_path,path,sizeof addr.sun_path); |
| 149 | len = offsetof(struct sockaddr_un, sun_path) + strlen(path); | 150 | len = offsetof(struct sockaddr_un, sun_path) + strlen(path); |
| 150 | fd = socket(AF_UNIX, SOCK_STREAM, 0); | 151 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
| 151 | if (fd == -1) return (-1); | 152 | if (fd == -1) return (-1); |
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c index 263068d256..3584842224 100644 --- a/src/lib/libcrypto/rand/rand_win.c +++ b/src/lib/libcrypto/rand/rand_win.c | |||
| @@ -646,7 +646,7 @@ static void readtimer(void) | |||
| 646 | * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V. | 646 | * Created 960901 by Gertjan van Oosten, gertjan@West.NL, West Consulting B.V. |
| 647 | * | 647 | * |
| 648 | * Code adapted from | 648 | * Code adapted from |
| 649 | * <URL:http://www.microsoft.com/kb/developr/win_dk/q97193.htm>; | 649 | * <URL:http://support.microsoft.com/default.aspx?scid=kb;[LN];97193>; |
| 650 | * the original copyright message is: | 650 | * the original copyright message is: |
| 651 | * | 651 | * |
| 652 | * (C) Copyright Microsoft Corp. 1993. All rights reserved. | 652 | * (C) Copyright Microsoft Corp. 1993. All rights reserved. |
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index cfbec2ac1f..d88ee0d780 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
| @@ -56,6 +56,9 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | /* We need to define this to get macros like S_IFBLK and S_IFCHR */ | ||
| 60 | #define _XOPEN_SOURCE 1 | ||
| 61 | |||
| 59 | #include <errno.h> | 62 | #include <errno.h> |
| 60 | #include <stdio.h> | 63 | #include <stdio.h> |
| 61 | #include <stdlib.h> | 64 | #include <stdlib.h> |
| @@ -64,6 +67,7 @@ | |||
| 64 | #include "e_os.h" | 67 | #include "e_os.h" |
| 65 | #include <openssl/crypto.h> | 68 | #include <openssl/crypto.h> |
| 66 | #include <openssl/rand.h> | 69 | #include <openssl/rand.h> |
| 70 | #include <openssl/buffer.h> | ||
| 67 | 71 | ||
| 68 | #ifdef OPENSSL_SYS_VMS | 72 | #ifdef OPENSSL_SYS_VMS |
| 69 | #include <unixio.h> | 73 | #include <unixio.h> |
| @@ -106,6 +110,7 @@ int RAND_load_file(const char *file, long bytes) | |||
| 106 | 110 | ||
| 107 | in=fopen(file,"rb"); | 111 | in=fopen(file,"rb"); |
| 108 | if (in == NULL) goto err; | 112 | if (in == NULL) goto err; |
| 113 | #if defined(S_IFBLK) && defined(S_IFCHR) | ||
| 109 | if (sb.st_mode & (S_IFBLK | S_IFCHR)) { | 114 | if (sb.st_mode & (S_IFBLK | S_IFCHR)) { |
| 110 | /* this file is a device. we don't want read an infinite number | 115 | /* this file is a device. we don't want read an infinite number |
| 111 | * of bytes from a random device, nor do we want to use buffered | 116 | * of bytes from a random device, nor do we want to use buffered |
| @@ -114,6 +119,7 @@ int RAND_load_file(const char *file, long bytes) | |||
| 114 | bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */ | 119 | bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */ |
| 115 | setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */ | 120 | setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */ |
| 116 | } | 121 | } |
| 122 | #endif | ||
| 117 | for (;;) | 123 | for (;;) |
| 118 | { | 124 | { |
| 119 | if (bytes > 0) | 125 | if (bytes > 0) |
| @@ -147,6 +153,7 @@ int RAND_write_file(const char *file) | |||
| 147 | 153 | ||
| 148 | i=stat(file,&sb); | 154 | i=stat(file,&sb); |
| 149 | if (i != -1) { | 155 | if (i != -1) { |
| 156 | #if defined(S_IFBLK) && defined(S_IFCHR) | ||
| 150 | if (sb.st_mode & (S_IFBLK | S_IFCHR)) { | 157 | if (sb.st_mode & (S_IFBLK | S_IFCHR)) { |
| 151 | /* this file is a device. we don't write back to it. | 158 | /* this file is a device. we don't write back to it. |
| 152 | * we "succeed" on the assumption this is some sort | 159 | * we "succeed" on the assumption this is some sort |
| @@ -155,6 +162,7 @@ int RAND_write_file(const char *file) | |||
| 155 | */ | 162 | */ |
| 156 | return(1); | 163 | return(1); |
| 157 | } | 164 | } |
| 165 | #endif | ||
| 158 | } | 166 | } |
| 159 | 167 | ||
| 160 | #if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) | 168 | #if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) |
| @@ -219,13 +227,15 @@ const char *RAND_file_name(char *buf, size_t size) | |||
| 219 | { | 227 | { |
| 220 | char *s=NULL; | 228 | char *s=NULL; |
| 221 | int ok = 0; | 229 | int ok = 0; |
| 230 | #ifdef __OpenBSD__ | ||
| 222 | struct stat sb; | 231 | struct stat sb; |
| 232 | #endif | ||
| 223 | 233 | ||
| 224 | if (issetugid() == 0) | 234 | if (issetugid() == 0) |
| 225 | s=getenv("RANDFILE"); | 235 | s=getenv("RANDFILE"); |
| 226 | if (s != NULL && *s && strlen(s) + 1 < size) | 236 | if (s != NULL && *s && strlen(s) + 1 < size) |
| 227 | { | 237 | { |
| 228 | if (strlcpy(buf,s,size) >= size) | 238 | if (BUF_strlcpy(buf,s,size) >= size) |
| 229 | return NULL; | 239 | return NULL; |
| 230 | } | 240 | } |
| 231 | else | 241 | else |
| @@ -240,11 +250,11 @@ const char *RAND_file_name(char *buf, size_t size) | |||
| 240 | #endif | 250 | #endif |
| 241 | if (s && *s && strlen(s)+strlen(RFILE)+2 < size) | 251 | if (s && *s && strlen(s)+strlen(RFILE)+2 < size) |
| 242 | { | 252 | { |
| 243 | strlcpy(buf,s,size); | 253 | BUF_strlcpy(buf,s,size); |
| 244 | #ifndef OPENSSL_SYS_VMS | 254 | #ifndef OPENSSL_SYS_VMS |
| 245 | strlcat(buf,"/",size); | 255 | BUF_strlcat(buf,"/",size); |
| 246 | #endif | 256 | #endif |
| 247 | strlcat(buf,RFILE,size); | 257 | BUF_strlcat(buf,RFILE,size); |
| 248 | ok = 1; | 258 | ok = 1; |
| 249 | } | 259 | } |
| 250 | else | 260 | else |
| @@ -260,11 +270,11 @@ const char *RAND_file_name(char *buf, size_t size) | |||
| 260 | */ | 270 | */ |
| 261 | 271 | ||
| 262 | if (!ok) | 272 | if (!ok) |
| 263 | if (strlcpy(buf,"/dev/arandom",size) >= size) { | 273 | if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) { |
| 264 | return(NULL); | 274 | return(NULL); |
| 265 | } | 275 | } |
| 266 | if (stat(buf,&sb) == -1) | 276 | if (stat(buf,&sb) == -1) |
| 267 | if (strlcpy(buf,"/dev/arandom",size) >= size) { | 277 | if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) { |
| 268 | return(NULL); | 278 | return(NULL); |
| 269 | } | 279 | } |
| 270 | 280 | ||
