summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/crypto/rand
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/crypto/rand')
-rw-r--r--src/lib/libssl/src/crypto/rand/Makefile71
-rw-r--r--src/lib/libssl/src/crypto/rand/Makefile.ssl196
-rw-r--r--src/lib/libssl/src/crypto/rand/md_rand.c46
-rw-r--r--src/lib/libssl/src/crypto/rand/rand.h29
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_egd.c2
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_eng.c152
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_err.c20
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_lcl.h11
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_lib.c71
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_os2.c6
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_unix.c71
-rw-r--r--src/lib/libssl/src/crypto/rand/rand_win.c71
-rw-r--r--src/lib/libssl/src/crypto/rand/randfile.c33
13 files changed, 209 insertions, 570 deletions
diff --git a/src/lib/libssl/src/crypto/rand/Makefile b/src/lib/libssl/src/crypto/rand/Makefile
index 30794305cb..27694aa664 100644
--- a/src/lib/libssl/src/crypto/rand/Makefile
+++ b/src/lib/libssl/src/crypto/rand/Makefile
@@ -17,9 +17,9 @@ TEST= randtest.c
17APPS= 17APPS=
18 18
19LIB=$(TOP)/libcrypto.a 19LIB=$(TOP)/libcrypto.a
20LIBSRC=md_rand.c randfile.c rand_lib.c rand_eng.c rand_err.c rand_egd.c \ 20LIBSRC=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
22LIBOBJ=md_rand.o randfile.o rand_lib.o rand_eng.o rand_err.o rand_egd.o \ 22LIBOBJ=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
25SRC= $(LIBSRC) 25SRC= $(LIBSRC)
@@ -35,7 +35,7 @@ top:
35all: lib 35all: lib
36 36
37lib: $(LIBOBJ) 37lib: $(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:
79md_rand.o: ../../e_os.h ../../include/openssl/asn1.h 79md_rand.o: ../../e_os.h ../../include/openssl/asn1.h
80md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 80md_rand.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
81md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 81md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
82md_rand.o: ../../include/openssl/evp.h ../../include/openssl/fips.h 82md_rand.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
83md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 83md_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
84md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 84md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
85md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 85md_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
86md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 86md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
87md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 87md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88md_rand.o: ../../include/openssl/symhacks.h md_rand.c rand_lcl.h 88md_rand.o: md_rand.c rand_lcl.h
89rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h 89rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
90rand_egd.o: ../../include/openssl/opensslconf.h 90rand_egd.o: ../../include/openssl/opensslconf.h
91rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 91rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
92rand_egd.o: rand_egd.c 92rand_egd.o: rand_egd.c
93rand_eng.o: ../../e_os.h ../../include/openssl/asn1.h
94rand_eng.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
95rand_eng.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
96rand_eng.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
97rand_eng.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
98rand_eng.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
99rand_eng.o: ../../include/openssl/err.h ../../include/openssl/evp.h
100rand_eng.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h
101rand_eng.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
102rand_eng.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
103rand_eng.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
104rand_eng.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
105rand_eng.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
106rand_eng.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
107rand_eng.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
108rand_eng.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
109rand_eng.o: ../cryptlib.h rand_eng.c rand_lcl.h
110rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h 93rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
111rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 94rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
112rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 95rand_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
116rand_err.o: rand_err.c 99rand_err.o: rand_err.c
117rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h 100rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
118rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 101rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
119rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h 102rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
120rand_lib.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
121rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h 103rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
122rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h 104rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
123rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h 105rand_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
124rand_lib.o: ../../include/openssl/fips.h ../../include/openssl/fips_rand.h
125rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h 106rand_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
126rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h 107rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
127rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 108rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
128rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h 109rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
129rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 110rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
130rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 111rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
131rand_lib.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
132rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h 112rand_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
133rand_lib.o: ../cryptlib.h rand_lcl.h rand_lib.c 113rand_lib.o: ../cryptlib.h rand_lib.c
134rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h 114rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h
135rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 115rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
136rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 116rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
137rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h 117rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h
138rand_nw.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 118rand_nw.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
139rand_nw.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 119rand_nw.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
140rand_nw.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 120rand_nw.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
141rand_nw.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h 121rand_nw.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
142rand_nw.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h 122rand_nw.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
143rand_nw.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 123rand_nw.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h rand_nw.c
144rand_nw.o: ../cryptlib.h rand_lcl.h rand_nw.c
145rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h 124rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h
146rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 125rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
147rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 126rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
148rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h 127rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
149rand_os2.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 128rand_os2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
150rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 129rand_os2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
151rand_os2.o: ../../include/openssl/opensslconf.h
152rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 130rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
153rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 131rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
154rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 132rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
@@ -158,8 +136,8 @@ rand_unix.o: ../../e_os.h ../../include/openssl/asn1.h
158rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 136rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
159rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 137rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
160rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h 138rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h
161rand_unix.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 139rand_unix.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
162rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 140rand_unix.o: ../../include/openssl/objects.h
163rand_unix.o: ../../include/openssl/opensslconf.h 141rand_unix.o: ../../include/openssl/opensslconf.h
164rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 142rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
165rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 143rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
@@ -170,9 +148,8 @@ rand_win.o: ../../e_os.h ../../include/openssl/asn1.h
170rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h 148rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
171rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 149rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
172rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h 150rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h
173rand_win.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h 151rand_win.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
174rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h 152rand_win.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
175rand_win.o: ../../include/openssl/opensslconf.h
176rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h 153rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
177rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h 154rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
178rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h 155rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
diff --git a/src/lib/libssl/src/crypto/rand/Makefile.ssl b/src/lib/libssl/src/crypto/rand/Makefile.ssl
deleted file mode 100644
index e5cbe5319c..0000000000
--- a/src/lib/libssl/src/crypto/rand/Makefile.ssl
+++ /dev/null
@@ -1,196 +0,0 @@
1#
2# SSLeay/crypto/rand/Makefile
3#
4
5DIR= rand
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKE= make -f Makefile.ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile.ssl
17AR= ar r
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST= randtest.c
23APPS=
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=md_rand.c randfile.c rand_lib.c rand_err.c rand_egd.c \
27 rand_win.c rand_unix.c rand_os2.c
28LIBOBJ=md_rand.o randfile.o rand_lib.o rand_err.o rand_egd.o \
29 rand_win.o rand_unix.o rand_os2.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rand.h
34HEADER= $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 $(RANLIB) $(LIB) || echo Never mind.
46 @touch lib
47
48files:
49 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
50
51links:
52 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
53 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
54 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
55 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
61 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
74
75dclean:
76 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82# DO NOT DELETE THIS LINE -- make depend depends on it.
83
84md_rand.o: ../../e_os.h ../../include/openssl/aes.h
85md_rand.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
86md_rand.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
87md_rand.o: ../../include/openssl/cast.h ../../include/openssl/crypto.h
88md_rand.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
89md_rand.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
90md_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
91md_rand.o: ../../include/openssl/evp.h ../../include/openssl/idea.h
92md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/md2.h
93md_rand.o: ../../include/openssl/md4.h ../../include/openssl/md5.h
94md_rand.o: ../../include/openssl/mdc2.h ../../include/openssl/obj_mac.h
95md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
96md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
97md_rand.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
98md_rand.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
99md_rand.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
100md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
101md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
102md_rand.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
103md_rand.o: md_rand.c rand_lcl.h
104rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
105rand_egd.o: ../../include/openssl/opensslconf.h
106rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
107rand_egd.o: rand_egd.c
108rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
109rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
110rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
111rand_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
112rand_err.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
113rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
114rand_err.o: rand_err.c
115rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h
116rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
117rand_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
118rand_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
119rand_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h
120rand_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
121rand_lib.o: ../../include/openssl/opensslconf.h
122rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
123rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/rsa.h
124rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
125rand_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
126rand_lib.o: ../cryptlib.h rand_lib.c
127rand_os2.o: ../../e_os.h ../../include/openssl/aes.h
128rand_os2.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
129rand_os2.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
130rand_os2.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
131rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
132rand_os2.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
133rand_os2.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
134rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h
135rand_os2.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
136rand_os2.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
137rand_os2.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
138rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
139rand_os2.o: ../../include/openssl/opensslconf.h
140rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
141rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
142rand_os2.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
143rand_os2.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
144rand_os2.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
145rand_os2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
146rand_os2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
147rand_os2.o: ../cryptlib.h rand_lcl.h rand_os2.c
148rand_unix.o: ../../e_os.h ../../include/openssl/aes.h
149rand_unix.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
150rand_unix.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
151rand_unix.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
152rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
153rand_unix.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
154rand_unix.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
155rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h
156rand_unix.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
157rand_unix.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
158rand_unix.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
159rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
160rand_unix.o: ../../include/openssl/opensslconf.h
161rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
162rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
163rand_unix.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
164rand_unix.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
165rand_unix.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
166rand_unix.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
167rand_unix.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
168rand_unix.o: ../cryptlib.h rand_lcl.h rand_unix.c
169rand_win.o: ../../e_os.h ../../include/openssl/aes.h
170rand_win.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
171rand_win.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h
172rand_win.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h
173rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
174rand_win.o: ../../include/openssl/des_old.h ../../include/openssl/dh.h
175rand_win.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
176rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h
177rand_win.o: ../../include/openssl/idea.h ../../include/openssl/lhash.h
178rand_win.o: ../../include/openssl/md2.h ../../include/openssl/md4.h
179rand_win.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h
180rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
181rand_win.o: ../../include/openssl/opensslconf.h
182rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
183rand_win.o: ../../include/openssl/rand.h ../../include/openssl/rc2.h
184rand_win.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h
185rand_win.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h
186rand_win.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
187rand_win.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
188rand_win.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
189rand_win.o: ../cryptlib.h rand_lcl.h rand_win.c
190randfile.o: ../../e_os.h ../../include/openssl/buffer.h
191randfile.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
192randfile.o: ../../include/openssl/opensslconf.h
193randfile.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
194randfile.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
195randfile.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
196randfile.o: randfile.c
diff --git a/src/lib/libssl/src/crypto/rand/md_rand.c b/src/lib/libssl/src/crypto/rand/md_rand.c
index 0f8dd3e00f..88088ce73c 100644
--- a/src/lib/libssl/src/crypto/rand/md_rand.c
+++ b/src/lib/libssl/src/crypto/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 */
152static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */ 148static 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
540static int ssleay_rand_status(void) 544static 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/libssl/src/crypto/rand/rand.h b/src/lib/libssl/src/crypto/rand/rand.h
index ea89153cba..ac6c021763 100644
--- a/src/lib/libssl/src/crypto/rand/rand.h
+++ b/src/lib/libssl/src/crypto/rand/rand.h
@@ -72,7 +72,7 @@ extern "C" {
72#endif 72#endif
73 73
74#if defined(OPENSSL_FIPS) 74#if defined(OPENSSL_FIPS)
75#define FIPS_RAND_SIZE_T int 75#define FIPS_RAND_SIZE_T size_t
76#endif 76#endif
77 77
78/* Already defined in ossl_typ.h */ 78/* Already defined in ossl_typ.h */
@@ -111,15 +111,6 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
111int RAND_egd(const char *path); 111int RAND_egd(const char *path);
112int RAND_egd_bytes(const char *path,int bytes); 112int RAND_egd_bytes(const char *path,int bytes);
113int RAND_poll(void); 113int RAND_poll(void);
114#ifndef OPENSSL_NO_ENGINE
115#ifdef OPENSSL_FIPS
116void int_RAND_init_engine_callbacks(void);
117void int_RAND_set_callbacks(
118 int (*set_rand_func)(const RAND_METHOD *meth,
119 const RAND_METHOD **pmeth),
120 const RAND_METHOD *(*get_rand_func)(const RAND_METHOD **pmeth));
121#endif
122#endif
123 114
124#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) 115#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
125 116
@@ -137,29 +128,11 @@ void ERR_load_RAND_strings(void);
137/* Error codes for the RAND functions. */ 128/* Error codes for the RAND functions. */
138 129
139/* Function codes. */ 130/* Function codes. */
140#define RAND_F_ENG_RAND_GET_RAND_METHOD 108
141#define RAND_F_FIPS_RAND 103
142#define RAND_F_FIPS_RAND_BYTES 102
143#define RAND_F_FIPS_RAND_GET_RAND_METHOD 109
144#define RAND_F_FIPS_RAND_SET_DT 106
145#define RAND_F_FIPS_SET_DT 104
146#define RAND_F_FIPS_SET_PRNG_SEED 107
147#define RAND_F_FIPS_SET_TEST_MODE 105
148#define RAND_F_RAND_GET_RAND_METHOD 101 131#define RAND_F_RAND_GET_RAND_METHOD 101
149#define RAND_F_SSLEAY_RAND_BYTES 100 132#define RAND_F_SSLEAY_RAND_BYTES 100
150 133
151/* Reason codes. */ 134/* Reason codes. */
152#define RAND_R_NON_FIPS_METHOD 105
153#define RAND_R_NOT_IN_TEST_MODE 106
154#define RAND_R_NO_KEY_SET 107
155#define RAND_R_PRNG_ASKING_FOR_TOO_MUCH 101
156#define RAND_R_PRNG_ERROR 108
157#define RAND_R_PRNG_KEYED 109
158#define RAND_R_PRNG_NOT_REKEYED 102
159#define RAND_R_PRNG_NOT_RESEEDED 103
160#define RAND_R_PRNG_NOT_SEEDED 100 135#define RAND_R_PRNG_NOT_SEEDED 100
161#define RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY 110
162#define RAND_R_PRNG_STUCK 104
163 136
164#ifdef __cplusplus 137#ifdef __cplusplus
165} 138}
diff --git a/src/lib/libssl/src/crypto/rand/rand_egd.c b/src/lib/libssl/src/crypto/rand/rand_egd.c
index 50bce6caba..d53b916ebe 100644
--- a/src/lib/libssl/src/crypto/rand/rand_egd.c
+++ b/src/lib/libssl/src/crypto/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)
99int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) 99int 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/libssl/src/crypto/rand/rand_eng.c b/src/lib/libssl/src/crypto/rand/rand_eng.c
deleted file mode 100644
index 1669cef43c..0000000000
--- a/src/lib/libssl/src/crypto/rand/rand_eng.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/* crypto/rand/rand_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <time.h>
61#include "cryptlib.h"
62#include "rand_lcl.h"
63#include <openssl/rand.h>
64#ifdef OPENSSL_FIPS
65#include <openssl/fips.h>
66#include <openssl/fips_rand.h>
67#endif
68
69#ifndef OPENSSL_NO_ENGINE
70#include <openssl/engine.h>
71#endif
72
73#if defined(OPENSSL_FIPS) && !defined(OPENSSL_NO_ENGINE)
74
75/* non-NULL if default_RAND_meth is ENGINE-provided */
76static ENGINE *funct_ref =NULL;
77
78int eng_RAND_set_rand_method(const RAND_METHOD *meth, const RAND_METHOD **pmeth)
79 {
80 if(funct_ref)
81 {
82 ENGINE_finish(funct_ref);
83 funct_ref = NULL;
84 }
85 *pmeth = meth;
86 return 1;
87 }
88
89const RAND_METHOD *eng_RAND_get_rand_method(const RAND_METHOD **pmeth)
90 {
91 if (!*pmeth)
92 {
93 ENGINE *e = ENGINE_get_default_RAND();
94 if(e)
95 {
96 *pmeth = ENGINE_get_RAND(e);
97 if(!*pmeth)
98 {
99 ENGINE_finish(e);
100 e = NULL;
101 }
102 }
103 if(e)
104 funct_ref = e;
105 else
106 if(FIPS_mode())
107 *pmeth=FIPS_rand_method();
108 else
109 *pmeth = RAND_SSLeay();
110 }
111
112 if(FIPS_mode()
113 && *pmeth != FIPS_rand_check())
114 {
115 RANDerr(RAND_F_ENG_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD);
116 return 0;
117 }
118
119 return *pmeth;
120 }
121
122int RAND_set_rand_engine(ENGINE *engine)
123 {
124 const RAND_METHOD *tmp_meth = NULL;
125 if(engine)
126 {
127 if(!ENGINE_init(engine))
128 return 0;
129 tmp_meth = ENGINE_get_RAND(engine);
130 if(!tmp_meth)
131 {
132 ENGINE_finish(engine);
133 return 0;
134 }
135 }
136 /* This function releases any prior ENGINE so call it first */
137 RAND_set_rand_method(tmp_meth);
138 funct_ref = engine;
139 return 1;
140 }
141
142void int_RAND_init_engine_callbacks(void)
143 {
144 static int done = 0;
145 if (done)
146 return;
147 int_RAND_set_callbacks(eng_RAND_set_rand_method,
148 eng_RAND_get_rand_method);
149 done = 1;
150 }
151
152#endif
diff --git a/src/lib/libssl/src/crypto/rand/rand_err.c b/src/lib/libssl/src/crypto/rand/rand_err.c
index 829fb44d77..03cda4dd92 100644
--- a/src/lib/libssl/src/crypto/rand/rand_err.c
+++ b/src/lib/libssl/src/crypto/rand/rand_err.c
@@ -1,6 +1,6 @@
1/* crypto/rand/rand_err.c */ 1/* crypto/rand/rand_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -70,14 +70,6 @@
70 70
71static ERR_STRING_DATA RAND_str_functs[]= 71static ERR_STRING_DATA RAND_str_functs[]=
72 { 72 {
73{ERR_FUNC(RAND_F_ENG_RAND_GET_RAND_METHOD), "ENG_RAND_GET_RAND_METHOD"},
74{ERR_FUNC(RAND_F_FIPS_RAND), "FIPS_RAND"},
75{ERR_FUNC(RAND_F_FIPS_RAND_BYTES), "FIPS_RAND_BYTES"},
76{ERR_FUNC(RAND_F_FIPS_RAND_GET_RAND_METHOD), "FIPS_RAND_GET_RAND_METHOD"},
77{ERR_FUNC(RAND_F_FIPS_RAND_SET_DT), "FIPS_RAND_SET_DT"},
78{ERR_FUNC(RAND_F_FIPS_SET_DT), "FIPS_SET_DT"},
79{ERR_FUNC(RAND_F_FIPS_SET_PRNG_SEED), "FIPS_SET_PRNG_SEED"},
80{ERR_FUNC(RAND_F_FIPS_SET_TEST_MODE), "FIPS_SET_TEST_MODE"},
81{ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"}, 73{ERR_FUNC(RAND_F_RAND_GET_RAND_METHOD), "RAND_get_rand_method"},
82{ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"}, 74{ERR_FUNC(RAND_F_SSLEAY_RAND_BYTES), "SSLEAY_RAND_BYTES"},
83{0,NULL} 75{0,NULL}
@@ -85,17 +77,7 @@ static ERR_STRING_DATA RAND_str_functs[]=
85 77
86static ERR_STRING_DATA RAND_str_reasons[]= 78static ERR_STRING_DATA RAND_str_reasons[]=
87 { 79 {
88{ERR_REASON(RAND_R_NON_FIPS_METHOD) ,"non fips method"},
89{ERR_REASON(RAND_R_NOT_IN_TEST_MODE) ,"not in test mode"},
90{ERR_REASON(RAND_R_NO_KEY_SET) ,"no key set"},
91{ERR_REASON(RAND_R_PRNG_ASKING_FOR_TOO_MUCH),"prng asking for too much"},
92{ERR_REASON(RAND_R_PRNG_ERROR) ,"prng error"},
93{ERR_REASON(RAND_R_PRNG_KEYED) ,"prng keyed"},
94{ERR_REASON(RAND_R_PRNG_NOT_REKEYED) ,"prng not rekeyed"},
95{ERR_REASON(RAND_R_PRNG_NOT_RESEEDED) ,"prng not reseeded"},
96{ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"}, 80{ERR_REASON(RAND_R_PRNG_NOT_SEEDED) ,"PRNG not seeded"},
97{ERR_REASON(RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY),"prng seed must not match key"},
98{ERR_REASON(RAND_R_PRNG_STUCK) ,"prng stuck"},
99{0,NULL} 81{0,NULL}
100 }; 82 };
101 83
diff --git a/src/lib/libssl/src/crypto/rand/rand_lcl.h b/src/lib/libssl/src/crypto/rand/rand_lcl.h
index 18cc9b1e4a..618a8ec899 100644
--- a/src/lib/libssl/src/crypto/rand/rand_lcl.h
+++ b/src/lib/libssl/src/crypto/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
158void 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));
163int eng_RAND_set_rand_method(const RAND_METHOD *meth,
164 const RAND_METHOD **pmeth);
165const 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/libssl/src/crypto/rand/rand_lib.c b/src/lib/libssl/src/crypto/rand/rand_lib.c
index da6b4e0e86..513e338985 100644
--- a/src/lib/libssl/src/crypto/rand/rand_lib.c
+++ b/src/lib/libssl/src/crypto/rand/rand_lib.c
@@ -60,82 +60,15 @@
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#include "rand_lcl.h"
64#ifdef OPENSSL_FIPS
65#include <openssl/fips.h>
66#include <openssl/fips_rand.h>
67#endif
68
69#ifndef OPENSSL_NO_ENGINE 63#ifndef OPENSSL_NO_ENGINE
70#include <openssl/engine.h> 64#include <openssl/engine.h>
71#endif 65#endif
72 66
73static const RAND_METHOD *default_RAND_meth = NULL;
74
75#ifdef OPENSSL_FIPS
76
77static int fips_RAND_set_rand_method(const RAND_METHOD *meth,
78 const RAND_METHOD **pmeth)
79 {
80 *pmeth = meth;
81 return 1;
82 }
83
84static const RAND_METHOD *fips_RAND_get_rand_method(const RAND_METHOD **pmeth)
85 {
86 if (!*pmeth)
87 {
88 if(FIPS_mode())
89 *pmeth=FIPS_rand_method();
90 else
91 *pmeth = RAND_SSLeay();
92 }
93
94 if(FIPS_mode()
95 && *pmeth != FIPS_rand_check())
96 {
97 RANDerr(RAND_F_FIPS_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD);
98 return 0;
99 }
100
101 return *pmeth;
102 }
103
104static int (*RAND_set_rand_method_func)(const RAND_METHOD *meth,
105 const RAND_METHOD **pmeth)
106 = fips_RAND_set_rand_method;
107static const RAND_METHOD *(*RAND_get_rand_method_func)
108 (const RAND_METHOD **pmeth)
109 = fips_RAND_get_rand_method;
110
111#ifndef OPENSSL_NO_ENGINE
112void int_RAND_set_callbacks(
113 int (*set_rand_func)(const RAND_METHOD *meth,
114 const RAND_METHOD **pmeth),
115 const RAND_METHOD *(*get_rand_func)
116 (const RAND_METHOD **pmeth))
117 {
118 RAND_set_rand_method_func = set_rand_func;
119 RAND_get_rand_method_func = get_rand_func;
120 }
121#endif
122
123int RAND_set_rand_method(const RAND_METHOD *meth)
124 {
125 return RAND_set_rand_method_func(meth, &default_RAND_meth);
126 }
127
128const RAND_METHOD *RAND_get_rand_method(void)
129 {
130 return RAND_get_rand_method_func(&default_RAND_meth);
131 }
132
133#else
134
135#ifndef OPENSSL_NO_ENGINE 67#ifndef OPENSSL_NO_ENGINE
136/* non-NULL if default_RAND_meth is ENGINE-provided */ 68/* non-NULL if default_RAND_meth is ENGINE-provided */
137static ENGINE *funct_ref =NULL; 69static ENGINE *funct_ref =NULL;
138#endif 70#endif
71static const RAND_METHOD *default_RAND_meth = NULL;
139 72
140int RAND_set_rand_method(const RAND_METHOD *meth) 73int RAND_set_rand_method(const RAND_METHOD *meth)
141 { 74 {
@@ -196,8 +129,6 @@ int RAND_set_rand_engine(ENGINE *engine)
196 } 129 }
197#endif 130#endif
198 131
199#endif
200
201void RAND_cleanup(void) 132void RAND_cleanup(void)
202 { 133 {
203 const RAND_METHOD *meth = RAND_get_rand_method(); 134 const RAND_METHOD *meth = RAND_get_rand_method();
diff --git a/src/lib/libssl/src/crypto/rand/rand_os2.c b/src/lib/libssl/src/crypto/rand/rand_os2.c
index c3e36d4e5e..fc1e78b179 100644
--- a/src/lib/libssl/src/crypto/rand/rand_os2.c
+++ b/src/lib/libssl/src/crypto/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__
81APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL; 82APIRET APIENTRY(*DosPerfSysCall) (ULONG ulCommand, ULONG ulParm1, ULONG ulParm2, ULONG ulParm3) = NULL;
82APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL; 83APIRET APIENTRY(*DosQuerySysState) (ULONG func, ULONG arg1, ULONG pid, ULONG _res_, PVOID buf, ULONG bufsz) = NULL;
84#endif
83HMODULE hDoscalls = 0; 85HMODULE hDoscalls = 0;
84 86
85int RAND_poll(void) 87int 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/libssl/src/crypto/rand/rand_unix.c b/src/lib/libssl/src/crypto/rand/rand_unix.c
index 58c6173094..4bb9666e49 100644
--- a/src/lib/libssl/src/crypto/rand/rand_unix.c
+++ b/src/lib/libssl/src/crypto/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__
137int 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__
137int RAND_poll(void) 180int RAND_poll(void)
138{ 181{
139 unsigned char buf[ENTROPY_NEEDED]; 182 unsigned char buf[ENTROPY_NEEDED];
@@ -157,7 +200,7 @@ int RAND_poll(void)
157 static const char *randomfiles[] = { DEVRANDOM }; 200 static const char *randomfiles[] = { DEVRANDOM };
158 struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])]; 201 struct stat randomstats[sizeof(randomfiles)/sizeof(randomfiles[0])];
159 int fd; 202 int fd;
160 size_t i; 203 unsigned int i;
161#endif 204#endif
162#ifdef DEVRANDOM_EGD 205#ifdef DEVRANDOM_EGD
163 static const char *egdsockets[] = { DEVRANDOM_EGD, NULL }; 206 static const char *egdsockets[] = { DEVRANDOM_EGD, NULL };
@@ -170,7 +213,8 @@ int RAND_poll(void)
170 * have this. Use /dev/urandom if you can as /dev/random may block 213 * have this. Use /dev/urandom if you can as /dev/random may block
171 * if it runs out of random entries. */ 214 * if it runs out of random entries. */
172 215
173 for (i=0; i<sizeof(randomfiles)/sizeof(randomfiles[0]) && n < ENTROPY_NEEDED; i++) 216 for (i = 0; (i < sizeof(randomfiles)/sizeof(randomfiles[0])) &&
217 (n < ENTROPY_NEEDED); i++)
174 { 218 {
175 if ((fd = open(randomfiles[i], O_RDONLY 219 if ((fd = open(randomfiles[i], O_RDONLY
176#ifdef O_NONBLOCK 220#ifdef O_NONBLOCK
@@ -187,7 +231,7 @@ int RAND_poll(void)
187 { 231 {
188 int usec = 10*1000; /* spend 10ms on each file */ 232 int usec = 10*1000; /* spend 10ms on each file */
189 int r; 233 int r;
190 size_t j; 234 unsigned int j;
191 struct stat *st=&randomstats[i]; 235 struct stat *st=&randomstats[i];
192 236
193 /* Avoid using same input... Used to be O_NOFOLLOW 237 /* Avoid using same input... Used to be O_NOFOLLOW
@@ -205,7 +249,12 @@ int RAND_poll(void)
205 { 249 {
206 int try_read = 0; 250 int try_read = 0;
207 251
208#if defined(OPENSSL_SYS_LINUX) 252#if defined(OPENSSL_SYS_BEOS_R5)
253 /* select() is broken in BeOS R5, so we simply
254 * try to read something and snooze if we couldn't */
255 try_read = 1;
256
257#elif defined(OPENSSL_SYS_LINUX)
209 /* use poll() */ 258 /* use poll() */
210 struct pollfd pset; 259 struct pollfd pset;
211 260
@@ -252,6 +301,10 @@ int RAND_poll(void)
252 r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n); 301 r = read(fd,(unsigned char *)tmpbuf+n, ENTROPY_NEEDED-n);
253 if (r > 0) 302 if (r > 0)
254 n += r; 303 n += r;
304#if defined(OPENSSL_SYS_BEOS_R5)
305 if (r == 0)
306 snooze(t.tv_usec);
307#endif
255 } 308 }
256 else 309 else
257 r = -1; 310 r = -1;
@@ -305,6 +358,14 @@ int RAND_poll(void)
305 l=time(NULL); 358 l=time(NULL);
306 RAND_add(&l,sizeof(l),0.0); 359 RAND_add(&l,sizeof(l),0.0);
307 360
361#if defined(OPENSSL_SYS_BEOS)
362 {
363 system_info sysInfo;
364 get_system_info(&sysInfo);
365 RAND_add(&sysInfo,sizeof(sysInfo),0);
366 }
367#endif
368
308#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD) 369#if defined(DEVRANDOM) || defined(DEVRANDOM_EGD)
309 return 1; 370 return 1;
310#else 371#else
diff --git a/src/lib/libssl/src/crypto/rand/rand_win.c b/src/lib/libssl/src/crypto/rand/rand_win.c
index 00dbe4232c..5d134e186b 100644
--- a/src/lib/libssl/src/crypto/rand/rand_win.c
+++ b/src/lib/libssl/src/crypto/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 */
diff --git a/src/lib/libssl/src/crypto/rand/randfile.c b/src/lib/libssl/src/crypto/rand/randfile.c
index d108353bbc..4ed40b7b70 100644
--- a/src/lib/libssl/src/crypto/rand/randfile.c
+++ b/src/lib/libssl/src/crypto/rand/randfile.c
@@ -75,9 +75,7 @@
75#ifndef NO_SYS_TYPES_H 75#ifndef NO_SYS_TYPES_H
76# include <sys/types.h> 76# include <sys/types.h>
77#endif 77#endif
78#ifdef MAC_OS_pre_X 78#ifndef OPENSSL_NO_POSIX_IO
79# include <stat.h>
80#else
81# include <sys/stat.h> 79# include <sys/stat.h>
82#endif 80#endif
83 81
@@ -111,14 +109,26 @@ int RAND_load_file(const char *file, long bytes)
111 * if bytes == -1, read complete file. */ 109 * if bytes == -1, read complete file. */
112 110
113 MS_STATIC unsigned char buf[BUFSIZE]; 111 MS_STATIC unsigned char buf[BUFSIZE];
112#ifndef OPENSSL_NO_POSIX_IO
114 struct stat sb; 113 struct stat sb;
114#endif
115 int i,ret=0,n; 115 int i,ret=0,n;
116 FILE *in; 116 FILE *in;
117 117
118 if (file == NULL) return(0); 118 if (file == NULL) return(0);
119 119
120#ifndef OPENSSL_NO_POSIX_IO
121#ifdef PURIFY
122 /* struct stat can have padding and unused fields that may not be
123 * initialized in the call to stat(). We need to clear the entire
124 * structure before calling RAND_add() to avoid complaints from
125 * applications such as Valgrind.
126 */
127 memset(&sb, 0, sizeof(sb));
128#endif
120 if (stat(file,&sb) < 0) return(0); 129 if (stat(file,&sb) < 0) return(0);
121 RAND_add(&sb,sizeof(sb),0.0); 130 RAND_add(&sb,sizeof(sb),0.0);
131#endif
122 if (bytes == 0) return(ret); 132 if (bytes == 0) return(ret);
123 133
124#ifdef OPENSSL_SYS_VMS 134#ifdef OPENSSL_SYS_VMS
@@ -127,7 +137,7 @@ int RAND_load_file(const char *file, long bytes)
127 in=fopen(file,"rb"); 137 in=fopen(file,"rb");
128#endif 138#endif
129 if (in == NULL) goto err; 139 if (in == NULL) goto err;
130#if defined(S_IFBLK) && defined(S_IFCHR) 140#if defined(S_IFBLK) && defined(S_IFCHR) && !defined(OPNESSL_NO_POSIX_IO)
131 if (sb.st_mode & (S_IFBLK | S_IFCHR)) { 141 if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
132 /* this file is a device. we don't want read an infinite number 142 /* this file is a device. we don't want read an infinite number
133 * of bytes from a random device, nor do we want to use buffered 143 * of bytes from a random device, nor do we want to use buffered
@@ -170,12 +180,13 @@ int RAND_write_file(const char *file)
170 int i,ret=0,rand_err=0; 180 int i,ret=0,rand_err=0;
171 FILE *out = NULL; 181 FILE *out = NULL;
172 int n; 182 int n;
183#ifndef OPENSSL_NO_POSIX_IO
173 struct stat sb; 184 struct stat sb;
174 185
175 i=stat(file,&sb); 186 i=stat(file,&sb);
176 if (i != -1) { 187 if (i != -1) {
177#if defined(S_IFBLK) && defined(S_IFCHR) 188#if defined(S_ISBLK) && defined(S_ISCHR)
178 if (sb.st_mode & (S_IFBLK | S_IFCHR)) { 189 if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
179 /* this file is a device. we don't write back to it. 190 /* this file is a device. we don't write back to it.
180 * we "succeed" on the assumption this is some sort 191 * we "succeed" on the assumption this is some sort
181 * of random device. Otherwise attempting to write to 192 * of random device. Otherwise attempting to write to
@@ -185,14 +196,16 @@ int RAND_write_file(const char *file)
185 } 196 }
186#endif 197#endif
187 } 198 }
199#endif
188 200
189#if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) 201#if defined(O_CREAT) && !defined(OPENSSL_NO_POSIX_IO) && !defined(OPENSSL_SYS_VMS)
190 { 202 {
191 /* For some reason Win32 can't write to files created this way */ 203#ifndef O_BINARY
192 204#define O_BINARY 0
205#endif
193 /* chmod(..., 0600) is too late to protect the file, 206 /* chmod(..., 0600) is too late to protect the file,
194 * permissions should be restrictive from the start */ 207 * permissions should be restrictive from the start */
195 int fd = open(file, O_CREAT, 0600); 208 int fd = open(file, O_WRONLY|O_CREAT|O_BINARY, 0600);
196 if (fd != -1) 209 if (fd != -1)
197 out = fdopen(fd, "wb"); 210 out = fdopen(fd, "wb");
198 } 211 }