diff options
| author | djm <> | 2010-10-01 22:54:18 +0000 |
|---|---|---|
| committer | djm <> | 2010-10-01 22:54:18 +0000 |
| commit | 75291ae343a87368ad49c13ac02f85a88159417f (patch) | |
| tree | a55c90bd6ea9329d2afb5540220340cadd107178 /src/lib/libcrypto/rand | |
| parent | 40d5d67842948fbf904eb73da8f09a2ebcd2e243 (diff) | |
| download | openbsd-75291ae343a87368ad49c13ac02f85a88159417f.tar.gz openbsd-75291ae343a87368ad49c13ac02f85a88159417f.tar.bz2 openbsd-75291ae343a87368ad49c13ac02f85a88159417f.zip | |
import OpenSSL-1.0.0a
Diffstat (limited to 'src/lib/libcrypto/rand')
| -rw-r--r-- | src/lib/libcrypto/rand/Makefile | 71 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/md_rand.c | 46 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_egd.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_lcl.h | 11 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_os2.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_unix.c | 71 | ||||
| -rw-r--r-- | src/lib/libcrypto/rand/rand_win.c | 71 |
7 files changed, 183 insertions, 95 deletions
diff --git a/src/lib/libcrypto/rand/Makefile b/src/lib/libcrypto/rand/Makefile index 30794305cb..27694aa664 100644 --- a/src/lib/libcrypto/rand/Makefile +++ b/src/lib/libcrypto/rand/Makefile | |||
| @@ -17,9 +17,9 @@ TEST= randtest.c | |||
| 17 | APPS= | 17 | APPS= |
| 18 | 18 | ||
| 19 | LIB=$(TOP)/libcrypto.a | 19 | LIB=$(TOP)/libcrypto.a |
| 20 | LIBSRC=md_rand.c randfile.c rand_lib.c rand_eng.c rand_err.c rand_egd.c \ | 20 | LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c \ |
| 21 | rand_win.c rand_unix.c rand_os2.c rand_nw.c | 21 | rand_win.c rand_unix.c rand_os2.c rand_nw.c |
| 22 | LIBOBJ=md_rand.o randfile.o rand_lib.o rand_eng.o rand_err.o rand_egd.o \ | 22 | LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o \ |
| 23 | rand_win.o rand_unix.o rand_os2.o rand_nw.o | 23 | rand_win.o rand_unix.o rand_os2.o rand_nw.o |
| 24 | 24 | ||
| 25 | SRC= $(LIBSRC) | 25 | SRC= $(LIBSRC) |
| @@ -35,7 +35,7 @@ top: | |||
| 35 | all: lib | 35 | all: lib |
| 36 | 36 | ||
| 37 | lib: $(LIBOBJ) | 37 | lib: $(LIBOBJ) |
| 38 | $(ARX) $(LIB) $(LIBOBJ) | 38 | $(AR) $(LIB) $(LIBOBJ) |
| 39 | $(RANLIB) $(LIB) || echo Never mind. | 39 | $(RANLIB) $(LIB) || echo Never mind. |
| 40 | @touch lib | 40 | @touch lib |
| 41 | 41 | ||
| @@ -79,34 +79,17 @@ clean: | |||
| 79 | md_rand.o: ../../e_os.h ../../include/openssl/asn1.h | 79 | md_rand.o: ../../e_os.h ../../include/openssl/asn1.h |
| 80 | md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 80 | md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
| 81 | md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 81 | md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 82 | md_rand.o: ../../include/openssl/evp.h ../../include/openssl/fips.h | 82 | md_rand.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h |
| 83 | md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 83 | md_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
| 84 | md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 84 | md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
| 85 | md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 85 | md_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h |
| 86 | md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 86 | md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 87 | md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 87 | md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 88 | md_rand.o: ../../include/openssl/symhacks.h md_rand.c rand_lcl.h | 88 | md_rand.o: md_rand.c rand_lcl.h |
| 89 | rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h | 89 | rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h |
| 90 | rand_egd.o: ../../include/openssl/opensslconf.h | 90 | rand_egd.o: ../../include/openssl/opensslconf.h |
| 91 | rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | 91 | rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h |
| 92 | rand_egd.o: rand_egd.c | 92 | rand_egd.o: rand_egd.c |
| 93 | rand_eng.o: ../../e_os.h ../../include/openssl/asn1.h | ||
| 94 | rand_eng.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 95 | rand_eng.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 96 | rand_eng.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h | ||
| 97 | rand_eng.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | ||
| 98 | rand_eng.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | ||
| 99 | rand_eng.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 100 | rand_eng.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h | ||
| 101 | rand_eng.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | ||
| 102 | rand_eng.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 103 | rand_eng.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | ||
| 104 | rand_eng.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | ||
| 105 | rand_eng.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 106 | rand_eng.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 107 | rand_eng.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 108 | rand_eng.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | ||
| 109 | rand_eng.o: ../cryptlib.h rand_eng.c rand_lcl.h | ||
| 110 | rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 93 | rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
| 111 | rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 94 | rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
| 112 | rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 95 | rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h |
| @@ -116,39 +99,34 @@ rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | |||
| 116 | rand_err.o: rand_err.c | 99 | rand_err.o: rand_err.c |
| 117 | rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h | 100 | rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h |
| 118 | rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 101 | rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 119 | rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | 102 | rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 120 | rand_lib.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h | ||
| 121 | rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h | 103 | rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h |
| 122 | rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | 104 | rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h |
| 123 | rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 105 | rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 124 | rand_lib.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h | ||
| 125 | rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 106 | rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 126 | rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 107 | rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 127 | rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 108 | rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 128 | rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h | 109 | rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h |
| 129 | rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 110 | rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
| 130 | rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 111 | rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
| 131 | rand_lib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h | ||
| 132 | rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h | 112 | rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h |
| 133 | rand_lib.o: ../cryptlib.h rand_lcl.h rand_lib.c | 113 | rand_lib.o: ../cryptlib.h rand_lib.c |
| 134 | rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h | 114 | rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h |
| 135 | rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 115 | rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 136 | rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 116 | rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 137 | rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 117 | rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 138 | rand_nw.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | 118 | rand_nw.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 139 | rand_nw.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 119 | rand_nw.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 140 | rand_nw.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 120 | rand_nw.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 141 | rand_nw.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | 121 | rand_nw.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 142 | rand_nw.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 122 | rand_nw.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| 143 | rand_nw.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 123 | rand_nw.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h rand_nw.c |
| 144 | rand_nw.o: ../cryptlib.h rand_lcl.h rand_nw.c | ||
| 145 | rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h | 124 | rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h |
| 146 | rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 125 | rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 147 | rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 126 | rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 148 | rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 127 | rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 149 | rand_os2.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | 128 | rand_os2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 150 | rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 129 | rand_os2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 151 | rand_os2.o: ../../include/openssl/opensslconf.h | ||
| 152 | rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 130 | rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 153 | rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 131 | rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 154 | rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 132 | rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
| @@ -158,8 +136,8 @@ rand_unix.o: ../../e_os.h ../../include/openssl/asn1.h | |||
| 158 | rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 136 | rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 159 | rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 137 | rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 160 | rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 138 | rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 161 | rand_unix.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | 139 | rand_unix.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 162 | rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 140 | rand_unix.o: ../../include/openssl/objects.h |
| 163 | rand_unix.o: ../../include/openssl/opensslconf.h | 141 | rand_unix.o: ../../include/openssl/opensslconf.h |
| 164 | rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 142 | rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 165 | rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 143 | rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| @@ -170,9 +148,8 @@ rand_win.o: ../../e_os.h ../../include/openssl/asn1.h | |||
| 170 | rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 148 | rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
| 171 | rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 149 | rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
| 172 | rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 150 | rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
| 173 | rand_win.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h | 151 | rand_win.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
| 174 | rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 152 | rand_win.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
| 175 | rand_win.o: ../../include/openssl/opensslconf.h | ||
| 176 | rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 153 | rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
| 177 | rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 154 | rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
| 178 | rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 155 | rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
diff --git a/src/lib/libcrypto/rand/md_rand.c b/src/lib/libcrypto/rand/md_rand.c index 0f8dd3e00f..88088ce73c 100644 --- a/src/lib/libcrypto/rand/md_rand.c +++ b/src/lib/libcrypto/rand/md_rand.c | |||
| @@ -126,10 +126,6 @@ | |||
| 126 | 126 | ||
| 127 | #include <openssl/crypto.h> | 127 | #include <openssl/crypto.h> |
| 128 | #include <openssl/err.h> | 128 | #include <openssl/err.h> |
| 129 | #ifdef OPENSSL_FIPS | ||
| 130 | #include <openssl/fips.h> | ||
| 131 | #endif | ||
| 132 | |||
| 133 | 129 | ||
| 134 | #ifdef BN_DEBUG | 130 | #ifdef BN_DEBUG |
| 135 | # define PREDICT | 131 | # define PREDICT |
| @@ -149,7 +145,7 @@ static unsigned int crypto_lock_rand = 0; /* may be set only when a thread | |||
| 149 | * holds CRYPTO_LOCK_RAND | 145 | * holds CRYPTO_LOCK_RAND |
| 150 | * (to prevent double locking) */ | 146 | * (to prevent double locking) */ |
| 151 | /* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */ | 147 | /* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */ |
| 152 | static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */ | 148 | static CRYPTO_THREADID locking_threadid; /* valid iff crypto_lock_rand is set */ |
| 153 | 149 | ||
| 154 | 150 | ||
| 155 | #ifdef PREDICT | 151 | #ifdef PREDICT |
| @@ -217,8 +213,10 @@ static void ssleay_rand_add(const void *buf, int num, double add) | |||
| 217 | /* check if we already have the lock */ | 213 | /* check if we already have the lock */ |
| 218 | if (crypto_lock_rand) | 214 | if (crypto_lock_rand) |
| 219 | { | 215 | { |
| 216 | CRYPTO_THREADID cur; | ||
| 217 | CRYPTO_THREADID_current(&cur); | ||
| 220 | CRYPTO_r_lock(CRYPTO_LOCK_RAND2); | 218 | CRYPTO_r_lock(CRYPTO_LOCK_RAND2); |
| 221 | do_not_lock = (locking_thread == CRYPTO_thread_id()); | 219 | do_not_lock = !CRYPTO_THREADID_cmp(&locking_threadid, &cur); |
| 222 | CRYPTO_r_unlock(CRYPTO_LOCK_RAND2); | 220 | CRYPTO_r_unlock(CRYPTO_LOCK_RAND2); |
| 223 | } | 221 | } |
| 224 | else | 222 | else |
| @@ -274,8 +272,16 @@ static void ssleay_rand_add(const void *buf, int num, double add) | |||
| 274 | } | 272 | } |
| 275 | else | 273 | else |
| 276 | MD_Update(&m,&(state[st_idx]),j); | 274 | MD_Update(&m,&(state[st_idx]),j); |
| 277 | 275 | ||
| 276 | /* DO NOT REMOVE THE FOLLOWING CALL TO MD_Update()! */ | ||
| 278 | MD_Update(&m,buf,j); | 277 | MD_Update(&m,buf,j); |
| 278 | /* We know that line may cause programs such as | ||
| 279 | purify and valgrind to complain about use of | ||
| 280 | uninitialized data. The problem is not, it's | ||
| 281 | with the caller. Removing that line will make | ||
| 282 | sure you get really bad randomness and thereby | ||
| 283 | other problems such as very insecure keys. */ | ||
| 284 | |||
| 279 | MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); | 285 | MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); |
| 280 | MD_Final(&m,local_md); | 286 | MD_Final(&m,local_md); |
| 281 | md_c[1]++; | 287 | md_c[1]++; |
| @@ -336,14 +342,6 @@ static int ssleay_rand_bytes(unsigned char *buf, int num) | |||
| 336 | #endif | 342 | #endif |
| 337 | int do_stir_pool = 0; | 343 | int do_stir_pool = 0; |
| 338 | 344 | ||
| 339 | #ifdef OPENSSL_FIPS | ||
| 340 | if(FIPS_mode()) | ||
| 341 | { | ||
| 342 | FIPSerr(FIPS_F_SSLEAY_RAND_BYTES,FIPS_R_NON_FIPS_METHOD); | ||
| 343 | return 0; | ||
| 344 | } | ||
| 345 | #endif | ||
| 346 | |||
| 347 | #ifdef PREDICT | 345 | #ifdef PREDICT |
| 348 | if (rand_predictable) | 346 | if (rand_predictable) |
| 349 | { | 347 | { |
| @@ -384,7 +382,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num) | |||
| 384 | 382 | ||
| 385 | /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ | 383 | /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ |
| 386 | CRYPTO_w_lock(CRYPTO_LOCK_RAND2); | 384 | CRYPTO_w_lock(CRYPTO_LOCK_RAND2); |
| 387 | locking_thread = CRYPTO_thread_id(); | 385 | CRYPTO_THREADID_current(&locking_threadid); |
| 388 | CRYPTO_w_unlock(CRYPTO_LOCK_RAND2); | 386 | CRYPTO_w_unlock(CRYPTO_LOCK_RAND2); |
| 389 | crypto_lock_rand = 1; | 387 | crypto_lock_rand = 1; |
| 390 | 388 | ||
| @@ -476,9 +474,15 @@ static int ssleay_rand_bytes(unsigned char *buf, int num) | |||
| 476 | #endif | 474 | #endif |
| 477 | MD_Update(&m,local_md,MD_DIGEST_LENGTH); | 475 | MD_Update(&m,local_md,MD_DIGEST_LENGTH); |
| 478 | MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); | 476 | MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); |
| 479 | #ifndef PURIFY | 477 | |
| 480 | MD_Update(&m,buf,j); /* purify complains */ | 478 | #ifndef PURIFY /* purify complains */ |
| 479 | /* DO NOT REMOVE THE FOLLOWING CALL TO MD_Update()! */ | ||
| 480 | MD_Update(&m,buf,j); | ||
| 481 | /* We know that line may cause programs such as | ||
| 482 | purify and valgrind to complain about use of | ||
| 483 | uninitialized data. */ | ||
| 481 | #endif | 484 | #endif |
| 485 | |||
| 482 | k=(st_idx+MD_DIGEST_LENGTH/2)-st_num; | 486 | k=(st_idx+MD_DIGEST_LENGTH/2)-st_num; |
| 483 | if (k > 0) | 487 | if (k > 0) |
| 484 | { | 488 | { |
| @@ -539,15 +543,17 @@ static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num) | |||
| 539 | 543 | ||
| 540 | static int ssleay_rand_status(void) | 544 | static int ssleay_rand_status(void) |
| 541 | { | 545 | { |
| 546 | CRYPTO_THREADID cur; | ||
| 542 | int ret; | 547 | int ret; |
| 543 | int do_not_lock; | 548 | int do_not_lock; |
| 544 | 549 | ||
| 550 | CRYPTO_THREADID_current(&cur); | ||
| 545 | /* check if we already have the lock | 551 | /* check if we already have the lock |
| 546 | * (could happen if a RAND_poll() implementation calls RAND_status()) */ | 552 | * (could happen if a RAND_poll() implementation calls RAND_status()) */ |
| 547 | if (crypto_lock_rand) | 553 | if (crypto_lock_rand) |
| 548 | { | 554 | { |
| 549 | CRYPTO_r_lock(CRYPTO_LOCK_RAND2); | 555 | CRYPTO_r_lock(CRYPTO_LOCK_RAND2); |
| 550 | do_not_lock = (locking_thread == CRYPTO_thread_id()); | 556 | do_not_lock = !CRYPTO_THREADID_cmp(&locking_threadid, &cur); |
| 551 | CRYPTO_r_unlock(CRYPTO_LOCK_RAND2); | 557 | CRYPTO_r_unlock(CRYPTO_LOCK_RAND2); |
| 552 | } | 558 | } |
| 553 | else | 559 | else |
| @@ -559,7 +565,7 @@ static int ssleay_rand_status(void) | |||
| 559 | 565 | ||
| 560 | /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ | 566 | /* prevent ssleay_rand_bytes() from trying to obtain the lock again */ |
| 561 | CRYPTO_w_lock(CRYPTO_LOCK_RAND2); | 567 | CRYPTO_w_lock(CRYPTO_LOCK_RAND2); |
| 562 | locking_thread = CRYPTO_thread_id(); | 568 | CRYPTO_THREADID_cpy(&locking_threadid, &cur); |
| 563 | CRYPTO_w_unlock(CRYPTO_LOCK_RAND2); | 569 | CRYPTO_w_unlock(CRYPTO_LOCK_RAND2); |
| 564 | crypto_lock_rand = 1; | 570 | crypto_lock_rand = 1; |
| 565 | } | 571 | } |
diff --git a/src/lib/libcrypto/rand/rand_egd.c b/src/lib/libcrypto/rand/rand_egd.c index 50bce6caba..d53b916ebe 100644 --- a/src/lib/libcrypto/rand/rand_egd.c +++ b/src/lib/libcrypto/rand/rand_egd.c | |||
| @@ -95,7 +95,7 @@ | |||
| 95 | * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. | 95 | * RAND_egd() is a wrapper for RAND_egd_bytes() with numbytes=255. |
| 96 | */ | 96 | */ |
| 97 | 97 | ||
| 98 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) | 98 | #if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_VOS) || defined(OPENSSL_SYS_BEOS) |
| 99 | int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) | 99 | int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) |
| 100 | { | 100 | { |
| 101 | return(-1); | 101 | return(-1); |
diff --git a/src/lib/libcrypto/rand/rand_lcl.h b/src/lib/libcrypto/rand/rand_lcl.h index 18cc9b1e4a..618a8ec899 100644 --- a/src/lib/libcrypto/rand/rand_lcl.h +++ b/src/lib/libcrypto/rand/rand_lcl.h | |||
| @@ -154,16 +154,5 @@ | |||
| 154 | #define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL) | 154 | #define MD(a,b,c) EVP_Digest(a,b,c,NULL,EVP_md2(), NULL) |
| 155 | #endif | 155 | #endif |
| 156 | 156 | ||
| 157 | #ifndef OPENSSL_NO_ENGINE | ||
| 158 | void int_RAND_set_callbacks( | ||
| 159 | int (*set_rand_func)(const RAND_METHOD *meth, | ||
| 160 | const RAND_METHOD **pmeth), | ||
| 161 | const RAND_METHOD *(*get_rand_func) | ||
| 162 | (const RAND_METHOD **pmeth)); | ||
| 163 | int eng_RAND_set_rand_method(const RAND_METHOD *meth, | ||
| 164 | const RAND_METHOD **pmeth); | ||
| 165 | const RAND_METHOD *eng_RAND_get_rand_method(const RAND_METHOD **pmeth); | ||
| 166 | #endif | ||
| 167 | |||
| 168 | 157 | ||
| 169 | #endif | 158 | #endif |
diff --git a/src/lib/libcrypto/rand/rand_os2.c b/src/lib/libcrypto/rand/rand_os2.c index c3e36d4e5e..fc1e78b179 100644 --- a/src/lib/libcrypto/rand/rand_os2.c +++ b/src/lib/libcrypto/rand/rand_os2.c | |||
| @@ -78,8 +78,10 @@ typedef struct _CPUUTIL { | |||
| 78 | ULONG ulIntrHigh; /* High 32 bits of interrupt time */ | 78 | ULONG ulIntrHigh; /* High 32 bits of interrupt time */ |
| 79 | } CPUUTIL; | 79 | } CPUUTIL; |
| 80 | 80 | ||
| 81 | #ifndef __KLIBC__ | ||
| 81 | APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL; | 82 | APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL; |
| 82 | APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL; | 83 | APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL; |
| 84 | #endif | ||
| 83 | HMODULE hDoscalls = 0; | 85 | HMODULE hDoscalls = 0; |
| 84 | 86 | ||
| 85 | int RAND_poll(void) | 87 | int RAND_poll(void) |
| @@ -91,6 +93,7 @@ int RAND_poll(void) | |||
| 91 | if (hDoscalls == 0) { | 93 | if (hDoscalls == 0) { |
| 92 | ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", &hDoscalls); | 94 | ULONG rc = DosLoadModule(failed_module, sizeof(failed_module), "DOSCALLS", &hDoscalls); |
| 93 | 95 | ||
| 96 | #ifndef __KLIBC__ | ||
| 94 | if (rc == 0) { | 97 | if (rc == 0) { |
| 95 | rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall); | 98 | rc = DosQueryProcAddr(hDoscalls, 976, NULL, (PFN *)&DosPerfSysCall); |
| 96 | 99 | ||
| @@ -102,6 +105,7 @@ int RAND_poll(void) | |||
| 102 | if (rc) | 105 | if (rc) |
| 103 | DosQuerySysState = NULL; | 106 | DosQuerySysState = NULL; |
| 104 | } | 107 | } |
| 108 | #endif | ||
| 105 | } | 109 | } |
| 106 | 110 | ||
| 107 | /* Sample the hi-res timer, runs at around 1.1 MHz */ | 111 | /* Sample the hi-res timer, runs at around 1.1 MHz */ |
| @@ -122,7 +126,9 @@ int RAND_poll(void) | |||
| 122 | RAND_add(&util, sizeof(util), 10); | 126 | RAND_add(&util, sizeof(util), 10); |
| 123 | } | 127 | } |
| 124 | else { | 128 | else { |
| 129 | #ifndef __KLIBC__ | ||
| 125 | DosPerfSysCall = NULL; | 130 | DosPerfSysCall = NULL; |
| 131 | #endif | ||
| 126 | } | 132 | } |
| 127 | } | 133 | } |
| 128 | 134 | ||
diff --git a/src/lib/libcrypto/rand/rand_unix.c b/src/lib/libcrypto/rand/rand_unix.c index 71b98ec212..e9ead3a529 100644 --- a/src/lib/libcrypto/rand/rand_unix.c +++ b/src/lib/libcrypto/rand/rand_unix.c | |||
| @@ -133,7 +133,50 @@ | |||
| 133 | # define FD_SETSIZE (8*sizeof(fd_set)) | 133 | # define FD_SETSIZE (8*sizeof(fd_set)) |
| 134 | #endif | 134 | #endif |
| 135 | 135 | ||
| 136 | #ifdef __OpenBSD__ | 136 | #ifdef __VOS__ |
| 137 | int RAND_poll(void) | ||
| 138 | { | ||
| 139 | unsigned char buf[ENTROPY_NEEDED]; | ||
| 140 | pid_t curr_pid; | ||
| 141 | uid_t curr_uid; | ||
| 142 | static int first=1; | ||
| 143 | int i; | ||
| 144 | long rnd = 0; | ||
| 145 | struct timespec ts; | ||
| 146 | unsigned seed; | ||
| 147 | |||
| 148 | /* The VOS random() function starts from a static seed so its | ||
| 149 | initial value is predictable. If random() returns the | ||
| 150 | initial value, reseed it with dynamic data. The VOS | ||
| 151 | real-time clock has a granularity of 1 nsec so it should be | ||
| 152 | reasonably difficult to predict its exact value. Do not | ||
| 153 | gratuitously reseed the PRNG because other code in this | ||
| 154 | process or thread may be using it. */ | ||
| 155 | |||
| 156 | if (first) { | ||
| 157 | first = 0; | ||
| 158 | rnd = random (); | ||
| 159 | if (rnd == 1804289383) { | ||
| 160 | clock_gettime (CLOCK_REALTIME, &ts); | ||
| 161 | curr_pid = getpid(); | ||
| 162 | curr_uid = getuid(); | ||
| 163 | seed = ts.tv_sec ^ ts.tv_nsec ^ curr_pid ^ curr_uid; | ||
| 164 | srandom (seed); | ||
| 165 | } | ||
| 166 | } | ||
| 167 | |||
| 168 | for (i = 0; i < sizeof(buf); i++) { | ||
| 169 | if (i % 4 == 0) | ||
| 170 | rnd = random(); | ||
| 171 | buf[i] = rnd; | ||
| 172 | rnd >>= 8; | ||
| 173 | } | ||
| 174 | RAND_add(buf, sizeof(buf), ENTROPY_NEEDED); | ||
| 175 | memset(buf, 0, sizeof(buf)); | ||
| 176 | |||
| 177 | return 1; | ||
| 178 | } | ||
| 179 | #elif defined __OpenBSD__ | ||
| 137 | int RAND_poll(void) | 180 | int RAND_poll(void) |
| 138 | { | 181 | { |
| 139 | u_int32_t rnd = 0, i; | 182 | u_int32_t rnd = 0, i; |
| @@ -163,7 +206,7 @@ int RAND_poll(void) | |||
| 163 | static const char *randomfiles[] = { DEVRANDOM }; | 206 | static const char *randomfiles[] = { DEVRANDOM }; |
| 164 | struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])]; | 207 | struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])]; |
| 165 | int fd; | 208 | int fd; |
| 166 | size_t i; | 209 | unsigned int i; |
| 167 | #endif | 210 | #endif |
| 168 | #ifdef DEVRANDOM_EGD | 211 | #ifdef DEVRANDOM_EGD |
| 169 | static const char *egdsockets[] = { DEVRANDOM_EGD, NULL }; | 212 | static const char *egdsockets[] = { DEVRANDOM_EGD, NULL }; |
| @@ -176,7 +219,8 @@ int RAND_poll(void) | |||
| 176 | * have this. Use /dev/urandom if you can as /dev/random may block | 219 | * have this. Use /dev/urandom if you can as /dev/random may block |
| 177 | * if it runs out of random entries. */ | 220 | * if it runs out of random entries. */ |
| 178 | 221 | ||
| 179 | for (i=0; i<sizeof(randomfiles)/sizeof(randomfiles[0]) && n < ENTROPY_NEEDED; i++) | 222 | for (i = 0; (i < sizeof(randomfiles)/sizeof(randomfiles[0])) && |
| 223 | (n < ENTROPY_NEEDED); i++) | ||
| 180 | { | 224 | { |
| 181 | if ((fd = open(randomfiles[i], O_RDONLY | 225 | if ((fd = open(randomfiles[i], O_RDONLY |
| 182 | #ifdef O_NONBLOCK | 226 | #ifdef O_NONBLOCK |
| @@ -193,7 +237,7 @@ int RAND_poll(void) | |||
| 193 | { | 237 | { |
| 194 | int usec = 10*1000; /* spend 10ms on each file */ | 238 | int usec = 10*1000; /* spend 10ms on each file */ |
| 195 | int r; | 239 | int r; |
| 196 | size_t j; | 240 | unsigned int j; |
| 197 | struct stat *st=&randomstats[i]; | 241 | struct stat *st=&randomstats[i]; |
| 198 | 242 | ||
| 199 | /* Avoid using same input... Used to be O_NOFOLLOW | 243 | /* Avoid using same input... Used to be O_NOFOLLOW |
| @@ -211,7 +255,12 @@ int RAND_poll(void) | |||
| 211 | { | 255 | { |
| 212 | int try_read = 0; | 256 | int try_read = 0; |
| 213 | 257 | ||
| 214 | #if defined(OPENSSL_SYS_LINUX) | 258 | #if defined(OPENSSL_SYS_BEOS_R5) |
| 259 | /* select() is broken in BeOS R5, so we simply | ||
| 260 | * try to read something and snooze if we couldn't */ | ||
| 261 | try_read = 1; | ||
| 262 | |||
| 263 | #elif defined(OPENSSL_SYS_LINUX) | ||
| 215 | /* use poll() */ | 264 | /* use poll() */ |
| 216 | struct pollfd pset; | 265 | struct pollfd pset; |
| 217 | 266 | ||
| @@ -258,6 +307,10 @@ int RAND_poll(void) | |||
| 258 | r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n); | 307 | r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n); |
| 259 | if (r > 0) | 308 | if (r > 0) |
| 260 | n += r; | 309 | n += r; |
| 310 | #if defined(OPENSSL_SYS_BEOS_R5) | ||
| 311 | if (r == 0) | ||
| 312 | snooze(t.tv_usec); | ||
| 313 | #endif | ||
| 261 | } | 314 | } |
| 262 | else | 315 | else |
| 263 | r = -1; | 316 | r = -1; |
| @@ -311,6 +364,14 @@ int RAND_poll(void) | |||
| 311 | l=time(NULL); | 364 | l=time(NULL); |
| 312 | RAND_add(&l,sizeof(l),0.0); | 365 | RAND_add(&l,sizeof(l),0.0); |
| 313 | 366 | ||
| 367 | #if defined(OPENSSL_SYS_BEOS) | ||
| 368 | { | ||
| 369 | system_info sysInfo; | ||
| 370 | get_system_info(&sysInfo); | ||
| 371 | RAND_add(&sysInfo,sizeof(sysInfo),0); | ||
| 372 | } | ||
| 373 | #endif | ||
| 374 | |||
| 314 | #if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) | 375 | #if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) |
| 315 | return 1; | 376 | return 1; |
| 316 | #else | 377 | #else |
diff --git a/src/lib/libcrypto/rand/rand_win.c b/src/lib/libcrypto/rand/rand_win.c index 00dbe4232c..5d134e186b 100644 --- a/src/lib/libcrypto/rand/rand_win.c +++ b/src/lib/libcrypto/rand/rand_win.c | |||
| @@ -463,7 +463,7 @@ int RAND_poll(void) | |||
| 463 | PROCESSENTRY32 p; | 463 | PROCESSENTRY32 p; |
| 464 | THREADENTRY32 t; | 464 | THREADENTRY32 t; |
| 465 | MODULEENTRY32 m; | 465 | MODULEENTRY32 m; |
| 466 | DWORD stoptime = 0; | 466 | DWORD starttime = 0; |
| 467 | 467 | ||
| 468 | snap = (CREATETOOLHELP32SNAPSHOT) | 468 | snap = (CREATETOOLHELP32SNAPSHOT) |
| 469 | GetProcAddress(kernel, "CreateToolhelp32Snapshot"); | 469 | GetProcAddress(kernel, "CreateToolhelp32Snapshot"); |
| @@ -494,12 +494,29 @@ int RAND_poll(void) | |||
| 494 | * each entry. Consider each field a source of 1 byte | 494 | * each entry. Consider each field a source of 1 byte |
| 495 | * of entropy. | 495 | * of entropy. |
| 496 | */ | 496 | */ |
| 497 | ZeroMemory(&hlist, sizeof(HEAPLIST32)); | ||
| 497 | hlist.dwSize = sizeof(HEAPLIST32); | 498 | hlist.dwSize = sizeof(HEAPLIST32); |
| 498 | if (good) stoptime = GetTickCount() + MAXDELAY; | 499 | if (good) starttime = GetTickCount(); |
| 500 | #ifdef _MSC_VER | ||
| 499 | if (heaplist_first(handle, &hlist)) | 501 | if (heaplist_first(handle, &hlist)) |
| 502 | { | ||
| 503 | /* | ||
| 504 | following discussion on dev ML, exception on WinCE (or other Win | ||
| 505 | platform) is theoretically of unknown origin; prevent infinite | ||
| 506 | loop here when this theoretical case occurs; otherwise cope with | ||
| 507 | the expected (MSDN documented) exception-throwing behaviour of | ||
| 508 | Heap32Next() on WinCE. | ||
| 509 | |||
| 510 | based on patch in original message by Tanguy Fautré (2009/03/02) | ||
| 511 | Subject: RAND_poll() and CreateToolhelp32Snapshot() stability | ||
| 512 | */ | ||
| 513 | int ex_cnt_limit = 42; | ||
| 500 | do | 514 | do |
| 501 | { | 515 | { |
| 502 | RAND_add(&hlist, hlist.dwSize, 3); | 516 | RAND_add(&hlist, hlist.dwSize, 3); |
| 517 | __try | ||
| 518 | { | ||
| 519 | ZeroMemory(&hentry, sizeof(HEAPENTRY32)); | ||
| 503 | hentry.dwSize = sizeof(HEAPENTRY32); | 520 | hentry.dwSize = sizeof(HEAPENTRY32); |
| 504 | if (heap_first(&hentry, | 521 | if (heap_first(&hentry, |
| 505 | hlist.th32ProcessID, | 522 | hlist.th32ProcessID, |
| @@ -510,10 +527,42 @@ int RAND_poll(void) | |||
| 510 | RAND_add(&hentry, | 527 | RAND_add(&hentry, |
| 511 | hentry.dwSize, 5); | 528 | hentry.dwSize, 5); |
| 512 | while (heap_next(&hentry) | 529 | while (heap_next(&hentry) |
| 530 | && (!good || (GetTickCount()-starttime)<MAXDELAY) | ||
| 513 | && --entrycnt > 0); | 531 | && --entrycnt > 0); |
| 514 | } | 532 | } |
| 515 | } while (heaplist_next(handle, | 533 | } |
| 516 | &hlist) && GetTickCount() < stoptime); | 534 | __except (EXCEPTION_EXECUTE_HANDLER) |
| 535 | { | ||
| 536 | /* ignore access violations when walking the heap list */ | ||
| 537 | ex_cnt_limit--; | ||
| 538 | } | ||
| 539 | } while (heaplist_next(handle, &hlist) | ||
| 540 | && (!good || (GetTickCount()-starttime)<MAXDELAY) | ||
| 541 | && ex_cnt_limit > 0); | ||
| 542 | } | ||
| 543 | |||
| 544 | #else | ||
| 545 | if (heaplist_first(handle, &hlist)) | ||
| 546 | { | ||
| 547 | do | ||
| 548 | { | ||
| 549 | RAND_add(&hlist, hlist.dwSize, 3); | ||
| 550 | hentry.dwSize = sizeof(HEAPENTRY32); | ||
| 551 | if (heap_first(&hentry, | ||
| 552 | hlist.th32ProcessID, | ||
| 553 | hlist.th32HeapID)) | ||
| 554 | { | ||
| 555 | int entrycnt = 80; | ||
| 556 | do | ||
| 557 | RAND_add(&hentry, | ||
| 558 | hentry.dwSize, 5); | ||
| 559 | while (heap_next(&hentry) | ||
| 560 | && --entrycnt > 0); | ||
| 561 | } | ||
| 562 | } while (heaplist_next(handle, &hlist) | ||
| 563 | && (!good || (GetTickCount()-starttime)<MAXDELAY)); | ||
| 564 | } | ||
| 565 | #endif | ||
| 517 | 566 | ||
| 518 | /* process walking */ | 567 | /* process walking */ |
| 519 | /* PROCESSENTRY32 contains 9 fields that will change | 568 | /* PROCESSENTRY32 contains 9 fields that will change |
| @@ -522,11 +571,11 @@ int RAND_poll(void) | |||
| 522 | */ | 571 | */ |
| 523 | p.dwSize = sizeof(PROCESSENTRY32); | 572 | p.dwSize = sizeof(PROCESSENTRY32); |
| 524 | 573 | ||
| 525 | if (good) stoptime = GetTickCount() + MAXDELAY; | 574 | if (good) starttime = GetTickCount(); |
| 526 | if (process_first(handle, &p)) | 575 | if (process_first(handle, &p)) |
| 527 | do | 576 | do |
| 528 | RAND_add(&p, p.dwSize, 9); | 577 | RAND_add(&p, p.dwSize, 9); |
| 529 | while (process_next(handle, &p) && GetTickCount() < stoptime); | 578 | while (process_next(handle, &p) && (!good || (GetTickCount()-starttime)<MAXDELAY)); |
| 530 | 579 | ||
| 531 | /* thread walking */ | 580 | /* thread walking */ |
| 532 | /* THREADENTRY32 contains 6 fields that will change | 581 | /* THREADENTRY32 contains 6 fields that will change |
| @@ -534,11 +583,11 @@ int RAND_poll(void) | |||
| 534 | * 1 byte of entropy. | 583 | * 1 byte of entropy. |
| 535 | */ | 584 | */ |
| 536 | t.dwSize = sizeof(THREADENTRY32); | 585 | t.dwSize = sizeof(THREADENTRY32); |
| 537 | if (good) stoptime = GetTickCount() + MAXDELAY; | 586 | if (good) starttime = GetTickCount(); |
| 538 | if (thread_first(handle, &t)) | 587 | if (thread_first(handle, &t)) |
| 539 | do | 588 | do |
| 540 | RAND_add(&t, t.dwSize, 6); | 589 | RAND_add(&t, t.dwSize, 6); |
| 541 | while (thread_next(handle, &t) && GetTickCount() < stoptime); | 590 | while (thread_next(handle, &t) && (!good || (GetTickCount()-starttime)<MAXDELAY)); |
| 542 | 591 | ||
| 543 | /* module walking */ | 592 | /* module walking */ |
| 544 | /* MODULEENTRY32 contains 9 fields that will change | 593 | /* MODULEENTRY32 contains 9 fields that will change |
| @@ -546,12 +595,12 @@ int RAND_poll(void) | |||
| 546 | * 1 byte of entropy. | 595 | * 1 byte of entropy. |
| 547 | */ | 596 | */ |
| 548 | m.dwSize = sizeof(MODULEENTRY32); | 597 | m.dwSize = sizeof(MODULEENTRY32); |
| 549 | if (good) stoptime = GetTickCount() + MAXDELAY; | 598 | if (good) starttime = GetTickCount(); |
| 550 | if (module_first(handle, &m)) | 599 | if (module_first(handle, &m)) |
| 551 | do | 600 | do |
| 552 | RAND_add(&m, m.dwSize, 9); | 601 | RAND_add(&m, m.dwSize, 9); |
| 553 | while (module_next(handle, &m) | 602 | while (module_next(handle, &m) |
| 554 | && (GetTickCount() < stoptime)); | 603 | && (!good || (GetTickCount()-starttime)<MAXDELAY)); |
| 555 | if (close_snap) | 604 | if (close_snap) |
| 556 | close_snap(handle); | 605 | close_snap(handle); |
| 557 | else | 606 | else |
| @@ -701,7 +750,7 @@ static void readscreen(void) | |||
| 701 | int y; /* y-coordinate of screen lines to grab */ | 750 | int y; /* y-coordinate of screen lines to grab */ |
| 702 | int n = 16; /* number of screen lines to grab at a time */ | 751 | int n = 16; /* number of screen lines to grab at a time */ |
| 703 | 752 | ||
| 704 | if (GetVersion() >= 0x80000000 || !OPENSSL_isservice()) | 753 | if (GetVersion() < 0x80000000 && OPENSSL_isservice()>0) |
| 705 | return; | 754 | return; |
| 706 | 755 | ||
| 707 | /* Create a screen DC and a memory DC compatible to screen DC */ | 756 | /* Create a screen DC and a memory DC compatible to screen DC */ |
