diff options
author | markus <> | 2003-05-12 02:18:40 +0000 |
---|---|---|
committer | markus <> | 2003-05-12 02:18:40 +0000 |
commit | d4fcd82bb7f6d603bd61e19a81ba97337b89dfca (patch) | |
tree | d52e3a0f1f08f65ad283027e560e17ed0d720462 /src/lib/libcrypto/rand | |
parent | 582bbd139cd2afd58d10dc051c5b0b989b441074 (diff) | |
download | openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.tar.gz openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.tar.bz2 openbsd-d4fcd82bb7f6d603bd61e19a81ba97337b89dfca.zip |
merge 0.9.7b with local changes; crank majors for libssl/libcrypto
Diffstat (limited to 'src/lib/libcrypto/rand')
-rw-r--r-- | src/lib/libcrypto/rand/Makefile.ssl | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/md_rand.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand.h | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand_egd.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand_lib.c | 10 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand_unix.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand_win.c | 84 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/randtest.c | 4 |
9 files changed, 90 insertions, 41 deletions
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl index 73b5f568e8..df80702373 100644 --- a/src/lib/libcrypto/rand/Makefile.ssl +++ b/src/lib/libcrypto/rand/Makefile.ssl | |||
@@ -70,7 +70,7 @@ lint: | |||
70 | lint -DLINT $(INCLUDES) $(SRC)>fluff | 70 | lint -DLINT $(INCLUDES) $(SRC)>fluff |
71 | 71 | ||
72 | depend: | 72 | depend: |
73 | $(MAKEDEPEND) $(CFLAG) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) | 73 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) |
74 | 74 | ||
75 | dclean: | 75 | dclean: |
76 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | 76 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new |
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c index a00ed70718..eeffc0df4c 100644 --- a/src/lib/libcrypto/rand/md_rand.c +++ b/src/lib/libcrypto/rand/md_rand.c | |||
@@ -177,10 +177,10 @@ RAND_METHOD *RAND_SSLeay(void) | |||
177 | 177 | ||
178 | static void ssleay_rand_cleanup(void) | 178 | static void ssleay_rand_cleanup(void) |
179 | { | 179 | { |
180 | memset(state,0,sizeof(state)); | 180 | OPENSSL_cleanse(state,sizeof(state)); |
181 | state_num=0; | 181 | state_num=0; |
182 | state_index=0; | 182 | state_index=0; |
183 | memset(md,0,MD_DIGEST_LENGTH); | 183 | OPENSSL_cleanse(md,MD_DIGEST_LENGTH); |
184 | md_count[0]=0; | 184 | md_count[0]=0; |
185 | md_count[1]=0; | 185 | md_count[1]=0; |
186 | entropy=0; | 186 | entropy=0; |
diff --git a/src/lib/libcrypto/rand/rand.h b/src/lib/libcrypto/rand/rand.h index 66e39991ec..606382dd21 100644 --- a/src/lib/libcrypto/rand/rand.h +++ b/src/lib/libcrypto/rand/rand.h | |||
@@ -87,7 +87,9 @@ extern int rand_predictable; | |||
87 | 87 | ||
88 | int RAND_set_rand_method(const RAND_METHOD *meth); | 88 | int RAND_set_rand_method(const RAND_METHOD *meth); |
89 | const RAND_METHOD *RAND_get_rand_method(void); | 89 | const RAND_METHOD *RAND_get_rand_method(void); |
90 | #ifndef OPENSSL_NO_ENGINE | ||
90 | int RAND_set_rand_engine(ENGINE *engine); | 91 | int RAND_set_rand_engine(ENGINE *engine); |
92 | #endif | ||
91 | RAND_METHOD *RAND_SSLeay(void); | 93 | RAND_METHOD *RAND_SSLeay(void); |
92 | void RAND_cleanup(void ); | 94 | void RAND_cleanup(void ); |
93 | int RAND_bytes(unsigned char *buf,int num); | 95 | int RAND_bytes(unsigned char *buf,int num); |
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c index 96019c07a6..895967476e 100644 --- a/src/lib/libcrypto/rand/rand_egd.c +++ b/src/lib/libcrypto/rand/rand_egd.c | |||
@@ -94,7 +94,7 @@ | |||
94 | * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. | 94 | * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. |
95 | */ | 95 | */ |
96 | 96 | ||
97 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(__DJGPP__) | 97 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) |
98 | int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) | 98 | int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) |
99 | { | 99 | { |
100 | return(-1); | 100 | return(-1); |
@@ -114,7 +114,7 @@ int RAND_egd_bytes(const char *path,int bytes) | |||
114 | #include <sys/types.h> | 114 | #include <sys/types.h> |
115 | #include <sys/socket.h> | 115 | #include <sys/socket.h> |
116 | #ifndef NO_SYS_UN_H | 116 | #ifndef NO_SYS_UN_H |
117 | # ifdef OPENSSL_SYS_VSWORKS | 117 | # ifdef OPENSSL_SYS_VXWORKS |
118 | # include <streams/un.h> | 118 | # include <streams/un.h> |
119 | # else | 119 | # else |
120 | # include <sys/un.h> | 120 | # include <sys/un.h> |
@@ -143,7 +143,7 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) | |||
143 | 143 | ||
144 | memset(&addr, 0, sizeof(addr)); | 144 | memset(&addr, 0, sizeof(addr)); |
145 | addr.sun_family = AF_UNIX; | 145 | addr.sun_family = AF_UNIX; |
146 | if (strlen(path) > sizeof(addr.sun_path)) | 146 | if (strlen(path) >= sizeof(addr.sun_path)) |
147 | return (-1); | 147 | return (-1); |
148 | strlcpy(addr.sun_path,path,sizeof addr.sun_path); | 148 | strlcpy(addr.sun_path,path,sizeof addr.sun_path); |
149 | len = offsetof(struct sockaddr_un, sun_path) + strlen(path); | 149 | len = offsetof(struct sockaddr_un, sun_path) + strlen(path); |
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c index 5cf5dc1188..513e338985 100644 --- a/src/lib/libcrypto/rand/rand_lib.c +++ b/src/lib/libcrypto/rand/rand_lib.c | |||
@@ -60,19 +60,25 @@ | |||
60 | #include <time.h> | 60 | #include <time.h> |
61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
62 | #include <openssl/rand.h> | 62 | #include <openssl/rand.h> |
63 | #ifndef OPENSSL_NO_ENGINE | ||
63 | #include <openssl/engine.h> | 64 | #include <openssl/engine.h> |
65 | #endif | ||
64 | 66 | ||
67 | #ifndef OPENSSL_NO_ENGINE | ||
65 | /* non-NULL if default_RAND_meth is ENGINE-provided */ | 68 | /* non-NULL if default_RAND_meth is ENGINE-provided */ |
66 | static ENGINE *funct_ref =NULL; | 69 | static ENGINE *funct_ref =NULL; |
70 | #endif | ||
67 | static const RAND_METHOD *default_RAND_meth = NULL; | 71 | static const RAND_METHOD *default_RAND_meth = NULL; |
68 | 72 | ||
69 | int RAND_set_rand_method(const RAND_METHOD *meth) | 73 | int RAND_set_rand_method(const RAND_METHOD *meth) |
70 | { | 74 | { |
75 | #ifndef OPENSSL_NO_ENGINE | ||
71 | if(funct_ref) | 76 | if(funct_ref) |
72 | { | 77 | { |
73 | ENGINE_finish(funct_ref); | 78 | ENGINE_finish(funct_ref); |
74 | funct_ref = NULL; | 79 | funct_ref = NULL; |
75 | } | 80 | } |
81 | #endif | ||
76 | default_RAND_meth = meth; | 82 | default_RAND_meth = meth; |
77 | return 1; | 83 | return 1; |
78 | } | 84 | } |
@@ -81,6 +87,7 @@ const RAND_METHOD *RAND_get_rand_method(void) | |||
81 | { | 87 | { |
82 | if (!default_RAND_meth) | 88 | if (!default_RAND_meth) |
83 | { | 89 | { |
90 | #ifndef OPENSSL_NO_ENGINE | ||
84 | ENGINE *e = ENGINE_get_default_RAND(); | 91 | ENGINE *e = ENGINE_get_default_RAND(); |
85 | if(e) | 92 | if(e) |
86 | { | 93 | { |
@@ -94,11 +101,13 @@ const RAND_METHOD *RAND_get_rand_method(void) | |||
94 | if(e) | 101 | if(e) |
95 | funct_ref = e; | 102 | funct_ref = e; |
96 | else | 103 | else |
104 | #endif | ||
97 | default_RAND_meth = RAND_SSLeay(); | 105 | default_RAND_meth = RAND_SSLeay(); |
98 | } | 106 | } |
99 | return default_RAND_meth; | 107 | return default_RAND_meth; |
100 | } | 108 | } |
101 | 109 | ||
110 | #ifndef OPENSSL_NO_ENGINE | ||
102 | int RAND_set_rand_engine(ENGINE *engine) | 111 | int RAND_set_rand_engine(ENGINE *engine) |
103 | { | 112 | { |
104 | const RAND_METHOD *tmp_meth = NULL; | 113 | const RAND_METHOD *tmp_meth = NULL; |
@@ -118,6 +127,7 @@ int RAND_set_rand_engine(ENGINE *engine) | |||
118 | funct_ref = engine; | 127 | funct_ref = engine; |
119 | return 1; | 128 | return 1; |
120 | } | 129 | } |
130 | #endif | ||
121 | 131 | ||
122 | void RAND_cleanup(void) | 132 | void RAND_cleanup(void) |
123 | { | 133 | { |
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c index fa2bab57c6..0599719dd1 100644 --- a/src/lib/libcrypto/rand/rand_unix.c +++ b/src/lib/libcrypto/rand/rand_unix.c | |||
@@ -115,7 +115,7 @@ | |||
115 | #include <openssl/rand.h> | 115 | #include <openssl/rand.h> |
116 | #include "rand_lcl.h" | 116 | #include "rand_lcl.h" |
117 | 117 | ||
118 | #if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2)) | 118 | #if !(defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_OS2) || defined(OPENSSL_SYS_VXWORKS)) |
119 | 119 | ||
120 | #include <sys/types.h> | 120 | #include <sys/types.h> |
121 | #include <sys/time.h> | 121 | #include <sys/time.h> |
@@ -233,7 +233,7 @@ int RAND_poll(void) | |||
233 | if (n > 0) | 233 | if (n > 0) |
234 | { | 234 | { |
235 | RAND_add(tmpbuf,sizeof tmpbuf,n); | 235 | RAND_add(tmpbuf,sizeof tmpbuf,n); |
236 | memset(tmpbuf,0,n); | 236 | OPENSSL_cleanse(tmpbuf,n); |
237 | } | 237 | } |
238 | #endif | 238 | #endif |
239 | 239 | ||
@@ -255,3 +255,10 @@ int RAND_poll(void) | |||
255 | 255 | ||
256 | #endif | 256 | #endif |
257 | #endif | 257 | #endif |
258 | |||
259 | #if defined(OPENSSL_SYS_VXWORKS) | ||
260 | int RAND_poll(void) | ||
261 | { | ||
262 | return 0; | ||
263 | } | ||
264 | #endif | ||
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c index c1b955b06f..113b58678f 100644 --- a/src/lib/libcrypto/rand/rand_win.c +++ b/src/lib/libcrypto/rand/rand_win.c | |||
@@ -125,7 +125,7 @@ | |||
125 | * http://developer.intel.com/design/security/rng/redist_license.htm | 125 | * http://developer.intel.com/design/security/rng/redist_license.htm |
126 | */ | 126 | */ |
127 | #define PROV_INTEL_SEC 22 | 127 | #define PROV_INTEL_SEC 22 |
128 | #define INTEL_DEF_PROV "Intel Hardware Cryptographic Service Provider" | 128 | #define INTEL_DEF_PROV TEXT("Intel Hardware Cryptographic Service Provider") |
129 | 129 | ||
130 | static void readtimer(void); | 130 | static void readtimer(void); |
131 | static void readscreen(void); | 131 | static void readscreen(void); |
@@ -170,7 +170,9 @@ typedef BOOL (WINAPI *THREAD32)(HANDLE, LPTHREADENTRY32); | |||
170 | typedef BOOL (WINAPI *MODULE32)(HANDLE, LPMODULEENTRY32); | 170 | typedef BOOL (WINAPI *MODULE32)(HANDLE, LPMODULEENTRY32); |
171 | 171 | ||
172 | #include <lmcons.h> | 172 | #include <lmcons.h> |
173 | #ifndef OPENSSL_SYS_WINCE | ||
173 | #include <lmstats.h> | 174 | #include <lmstats.h> |
175 | #endif | ||
174 | #if 1 /* The NET API is Unicode only. It requires the use of the UNICODE | 176 | #if 1 /* The NET API is Unicode only. It requires the use of the UNICODE |
175 | * macro. When UNICODE is defined LPTSTR becomes LPWSTR. LMSTR was | 177 | * macro. When UNICODE is defined LPTSTR becomes LPWSTR. LMSTR was |
176 | * was added to the Platform SDK to allow the NET API to be used in | 178 | * was added to the Platform SDK to allow the NET API to be used in |
@@ -209,20 +211,32 @@ int RAND_poll(void) | |||
209 | osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ; | 211 | osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ; |
210 | GetVersionEx( &osverinfo ) ; | 212 | GetVersionEx( &osverinfo ) ; |
211 | 213 | ||
214 | #if defined(OPENSSL_SYS_WINCE) && WCEPLATFORM!=MS_HPC_PRO | ||
215 | /* poll the CryptoAPI PRNG */ | ||
216 | /* The CryptoAPI returns sizeof(buf) bytes of randomness */ | ||
217 | if (CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) | ||
218 | { | ||
219 | if (CryptGenRandom(hProvider, sizeof(buf), buf)) | ||
220 | RAND_add(buf, sizeof(buf), sizeof(buf)); | ||
221 | CryptReleaseContext(hProvider, 0); | ||
222 | } | ||
223 | #endif | ||
224 | |||
212 | /* load functions dynamically - not available on all systems */ | 225 | /* load functions dynamically - not available on all systems */ |
213 | advapi = LoadLibrary("ADVAPI32.DLL"); | 226 | advapi = LoadLibrary(TEXT("ADVAPI32.DLL")); |
214 | kernel = LoadLibrary("KERNEL32.DLL"); | 227 | kernel = LoadLibrary(TEXT("KERNEL32.DLL")); |
215 | user = LoadLibrary("USER32.DLL"); | 228 | user = LoadLibrary(TEXT("USER32.DLL")); |
216 | netapi = LoadLibrary("NETAPI32.DLL"); | 229 | netapi = LoadLibrary(TEXT("NETAPI32.DLL")); |
217 | 230 | ||
231 | #ifndef OPENSSL_SYS_WINCE | ||
218 | #if 1 /* There was previously a problem with NETSTATGET. Currently, this | 232 | #if 1 /* There was previously a problem with NETSTATGET. Currently, this |
219 | * section is still experimental, but if all goes well, this conditional | 233 | * section is still experimental, but if all goes well, this conditional |
220 | * will be removed | 234 | * will be removed |
221 | */ | 235 | */ |
222 | if (netapi) | 236 | if (netapi) |
223 | { | 237 | { |
224 | netstatget = (NETSTATGET) GetProcAddress(netapi,"NetStatisticsGet"); | 238 | netstatget = (NETSTATGET) GetProcAddress(netapi,TEXT("NetStatisticsGet")); |
225 | netfree = (NETFREE) GetProcAddress(netapi,"NetApiBufferFree"); | 239 | netfree = (NETFREE) GetProcAddress(netapi,TEXT("NetApiBufferFree")); |
226 | } | 240 | } |
227 | 241 | ||
228 | if (netstatget && netfree) | 242 | if (netstatget && netfree) |
@@ -249,7 +263,9 @@ int RAND_poll(void) | |||
249 | if (netapi) | 263 | if (netapi) |
250 | FreeLibrary(netapi); | 264 | FreeLibrary(netapi); |
251 | #endif /* 1 */ | 265 | #endif /* 1 */ |
266 | #endif /* !OPENSSL_SYS_WINCE */ | ||
252 | 267 | ||
268 | #ifndef OPENSSL_SYS_WINCE | ||
253 | /* It appears like this can cause an exception deep within ADVAPI32.DLL | 269 | /* It appears like this can cause an exception deep within ADVAPI32.DLL |
254 | * at random times on Windows 2000. Reported by Jeffrey Altman. | 270 | * at random times on Windows 2000. Reported by Jeffrey Altman. |
255 | * Only use it on NT. | 271 | * Only use it on NT. |
@@ -280,30 +296,40 @@ int RAND_poll(void) | |||
280 | bufsz += 8192; | 296 | bufsz += 8192; |
281 | 297 | ||
282 | length = bufsz; | 298 | length = bufsz; |
283 | rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global", | 299 | rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, TEXT("Global"), |
284 | NULL, NULL, buf, &length); | 300 | NULL, NULL, buf, &length); |
285 | } | 301 | } |
286 | if (rc == ERROR_SUCCESS) | 302 | if (rc == ERROR_SUCCESS) |
287 | { | 303 | { |
288 | /* For entropy count assume only least significant | 304 | /* For entropy count assume only least significant |
289 | * byte of each DWORD is random. | 305 | * byte of each DWORD is random. |
290 | */ | 306 | */ |
291 | RAND_add(&length, sizeof(length), 0); | 307 | RAND_add(&length, sizeof(length), 0); |
292 | RAND_add(buf, length, length / 4.0); | 308 | RAND_add(buf, length, length / 4.0); |
309 | |||
310 | /* Close the Registry Key to allow Windows to cleanup/close | ||
311 | * the open handle | ||
312 | * Note: The 'HKEY_PERFORMANCE_DATA' key is implicitly opened | ||
313 | * when the RegQueryValueEx above is done. However, if | ||
314 | * it is not explicitly closed, it can cause disk | ||
315 | * partition manipulation problems. | ||
316 | */ | ||
317 | RegCloseKey(HKEY_PERFORMANCE_DATA); | ||
293 | } | 318 | } |
294 | if (buf) | 319 | if (buf) |
295 | free(buf); | 320 | free(buf); |
296 | } | 321 | } |
297 | #endif | 322 | #endif |
323 | #endif /* !OPENSSL_SYS_WINCE */ | ||
298 | 324 | ||
299 | if (advapi) | 325 | if (advapi) |
300 | { | 326 | { |
301 | acquire = (CRYPTACQUIRECONTEXT) GetProcAddress(advapi, | 327 | acquire = (CRYPTACQUIRECONTEXT) GetProcAddress(advapi, |
302 | "CryptAcquireContextA"); | 328 | TEXT("CryptAcquireContextA")); |
303 | gen = (CRYPTGENRANDOM) GetProcAddress(advapi, | 329 | gen = (CRYPTGENRANDOM) GetProcAddress(advapi, |
304 | "CryptGenRandom"); | 330 | TEXT("CryptGenRandom")); |
305 | release = (CRYPTRELEASECONTEXT) GetProcAddress(advapi, | 331 | release = (CRYPTRELEASECONTEXT) GetProcAddress(advapi, |
306 | "CryptReleaseContext"); | 332 | TEXT("CryptReleaseContext")); |
307 | } | 333 | } |
308 | 334 | ||
309 | if (acquire && gen && release) | 335 | if (acquire && gen && release) |
@@ -357,9 +383,9 @@ int RAND_poll(void) | |||
357 | GETFOREGROUNDWINDOW win; | 383 | GETFOREGROUNDWINDOW win; |
358 | GETQUEUESTATUS queue; | 384 | GETQUEUESTATUS queue; |
359 | 385 | ||
360 | win = (GETFOREGROUNDWINDOW) GetProcAddress(user, "GetForegroundWindow"); | 386 | win = (GETFOREGROUNDWINDOW) GetProcAddress(user, TEXT("GetForegroundWindow")); |
361 | cursor = (GETCURSORINFO) GetProcAddress(user, "GetCursorInfo"); | 387 | cursor = (GETCURSORINFO) GetProcAddress(user, TEXT("GetCursorInfo")); |
362 | queue = (GETQUEUESTATUS) GetProcAddress(user, "GetQueueStatus"); | 388 | queue = (GETQUEUESTATUS) GetProcAddress(user, TEXT("GetQueueStatus")); |
363 | 389 | ||
364 | if (win) | 390 | if (win) |
365 | { | 391 | { |
@@ -430,17 +456,17 @@ int RAND_poll(void) | |||
430 | MODULEENTRY32 m; | 456 | MODULEENTRY32 m; |
431 | 457 | ||
432 | snap = (CREATETOOLHELP32SNAPSHOT) | 458 | snap = (CREATETOOLHELP32SNAPSHOT) |
433 | GetProcAddress(kernel, "CreateToolhelp32Snapshot"); | 459 | GetProcAddress(kernel, TEXT("CreateToolhelp32Snapshot")); |
434 | heap_first = (HEAP32FIRST) GetProcAddress(kernel, "Heap32First"); | 460 | heap_first = (HEAP32FIRST) GetProcAddress(kernel, TEXT("Heap32First")); |
435 | heap_next = (HEAP32NEXT) GetProcAddress(kernel, "Heap32Next"); | 461 | heap_next = (HEAP32NEXT) GetProcAddress(kernel, TEXT("Heap32Next")); |
436 | heaplist_first = (HEAP32LIST) GetProcAddress(kernel, "Heap32ListFirst"); | 462 | heaplist_first = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListFirst")); |
437 | heaplist_next = (HEAP32LIST) GetProcAddress(kernel, "Heap32ListNext"); | 463 | heaplist_next = (HEAP32LIST) GetProcAddress(kernel, TEXT("Heap32ListNext")); |
438 | process_first = (PROCESS32) GetProcAddress(kernel, "Process32First"); | 464 | process_first = (PROCESS32) GetProcAddress(kernel, TEXT("Process32First")); |
439 | process_next = (PROCESS32) GetProcAddress(kernel, "Process32Next"); | 465 | process_next = (PROCESS32) GetProcAddress(kernel, TEXT("Process32Next")); |
440 | thread_first = (THREAD32) GetProcAddress(kernel, "Thread32First"); | 466 | thread_first = (THREAD32) GetProcAddress(kernel, TEXT("Thread32First")); |
441 | thread_next = (THREAD32) GetProcAddress(kernel, "Thread32Next"); | 467 | thread_next = (THREAD32) GetProcAddress(kernel, TEXT("Thread32Next")); |
442 | module_first = (MODULE32) GetProcAddress(kernel, "Module32First"); | 468 | module_first = (MODULE32) GetProcAddress(kernel, TEXT("Module32First")); |
443 | module_next = (MODULE32) GetProcAddress(kernel, "Module32Next"); | 469 | module_next = (MODULE32) GetProcAddress(kernel, TEXT("Module32Next")); |
444 | 470 | ||
445 | if (snap && heap_first && heap_next && heaplist_first && | 471 | if (snap && heap_first && heap_next && heaplist_first && |
446 | heaplist_next && process_first && process_next && | 472 | heaplist_next && process_first && process_next && |
@@ -575,7 +601,7 @@ static void readtimer(void) | |||
575 | DWORD w; | 601 | DWORD w; |
576 | LARGE_INTEGER l; | 602 | LARGE_INTEGER l; |
577 | static int have_perfc = 1; | 603 | static int have_perfc = 1; |
578 | #ifdef _MSC_VER | 604 | #if defined(_MSC_VER) && !defined(OPENSSL_SYS_WINCE) |
579 | static int have_tsc = 1; | 605 | static int have_tsc = 1; |
580 | DWORD cyclecount; | 606 | DWORD cyclecount; |
581 | 607 | ||
@@ -628,6 +654,7 @@ static void readtimer(void) | |||
628 | 654 | ||
629 | static void readscreen(void) | 655 | static void readscreen(void) |
630 | { | 656 | { |
657 | #ifndef OPENSSL_SYS_WINCE | ||
631 | HDC hScrDC; /* screen DC */ | 658 | HDC hScrDC; /* screen DC */ |
632 | HDC hMemDC; /* memory DC */ | 659 | HDC hMemDC; /* memory DC */ |
633 | HBITMAP hBitmap; /* handle for our bitmap */ | 660 | HBITMAP hBitmap; /* handle for our bitmap */ |
@@ -641,7 +668,7 @@ static void readscreen(void) | |||
641 | int n = 16; /* number of screen lines to grab at a time */ | 668 | int n = 16; /* number of screen lines to grab at a time */ |
642 | 669 | ||
643 | /* Create a screen DC and a memory DC compatible to screen DC */ | 670 | /* Create a screen DC and a memory DC compatible to screen DC */ |
644 | hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL); | 671 | hScrDC = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); |
645 | hMemDC = CreateCompatibleDC(hScrDC); | 672 | hMemDC = CreateCompatibleDC(hScrDC); |
646 | 673 | ||
647 | /* Get screen resolution */ | 674 | /* Get screen resolution */ |
@@ -688,6 +715,7 @@ static void readscreen(void) | |||
688 | DeleteObject(hBitmap); | 715 | DeleteObject(hBitmap); |
689 | DeleteDC(hMemDC); | 716 | DeleteDC(hMemDC); |
690 | DeleteDC(hScrDC); | 717 | DeleteDC(hScrDC); |
718 | #endif /* !OPENSSL_SYS_WINCE */ | ||
691 | } | 719 | } |
692 | 720 | ||
693 | #endif | 721 | #endif |
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index 311dd27a7b..cfbec2ac1f 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
@@ -132,7 +132,7 @@ int RAND_load_file(const char *file, long bytes) | |||
132 | } | 132 | } |
133 | } | 133 | } |
134 | fclose(in); | 134 | fclose(in); |
135 | memset(buf,0,BUFSIZE); | 135 | OPENSSL_cleanse(buf,BUFSIZE); |
136 | err: | 136 | err: |
137 | return(ret); | 137 | return(ret); |
138 | } | 138 | } |
@@ -210,7 +210,7 @@ int RAND_write_file(const char *file) | |||
210 | #endif /* OPENSSL_SYS_VMS */ | 210 | #endif /* OPENSSL_SYS_VMS */ |
211 | 211 | ||
212 | fclose(out); | 212 | fclose(out); |
213 | memset(buf,0,BUFSIZE); | 213 | OPENSSL_cleanse(buf,BUFSIZE); |
214 | err: | 214 | err: |
215 | return (rand_err ? -1 : ret); | 215 | return (rand_err ? -1 : ret); |
216 | } | 216 | } |
@@ -225,8 +225,8 @@ const char *RAND_file_name(char *buf, size_t size) | |||
225 | s=getenv("RANDFILE"); | 225 | s=getenv("RANDFILE"); |
226 | if (s != NULL && *s && strlen(s) + 1 < size) | 226 | if (s != NULL && *s && strlen(s) + 1 < size) |
227 | { | 227 | { |
228 | strlcpy(buf,s,size); | 228 | if (strlcpy(buf,s,size) >= size) |
229 | ok = 1; | 229 | return NULL; |
230 | } | 230 | } |
231 | else | 231 | else |
232 | { | 232 | { |
diff --git a/src/lib/libcrypto/rand/randtest.c b/src/lib/libcrypto/rand/randtest.c index b64de616db..701932e6ee 100644 --- a/src/lib/libcrypto/rand/randtest.c +++ b/src/lib/libcrypto/rand/randtest.c | |||
@@ -60,6 +60,8 @@ | |||
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | #include <openssl/rand.h> | 61 | #include <openssl/rand.h> |
62 | 62 | ||
63 | #include "../e_os.h" | ||
64 | |||
63 | /* some FIPS 140-1 random number test */ | 65 | /* some FIPS 140-1 random number test */ |
64 | /* some simple tests */ | 66 | /* some simple tests */ |
65 | 67 | ||
@@ -209,6 +211,6 @@ int main() | |||
209 | printf("test 4 done\n"); | 211 | printf("test 4 done\n"); |
210 | err: | 212 | err: |
211 | err=((err)?1:0); | 213 | err=((err)?1:0); |
212 | exit(err); | 214 | EXIT(err); |
213 | return(err); | 215 | return(err); |
214 | } | 216 | } |