diff options
Diffstat (limited to 'src/lib/libcrypto/rand')
-rw-r--r-- | src/lib/libcrypto/rand/Makefile | 86 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/md_rand.c | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand_eng.c | 152 | ||||
-rw-r--r-- | src/lib/libcrypto/rand/rand_lcl.h | 11 |
4 files changed, 232 insertions, 29 deletions
diff --git a/src/lib/libcrypto/rand/Makefile b/src/lib/libcrypto/rand/Makefile index 3c1ab5bbae..30794305cb 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_err.c rand_egd.c \ | 20 | LIBSRC=md_rand.c randfile.c rand_lib.c rand_eng.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_err.o rand_egd.o \ | 22 | LIBOBJ=md_rand.o randfile.o rand_lib.o rand_eng.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 | $(AR) $(LIB) $(LIBOBJ) | 38 | $(ARX) $(LIB) $(LIBOBJ) |
39 | $(RANLIB) $(LIB) || echo Never mind. | 39 | $(RANLIB) $(LIB) || echo Never mind. |
40 | @touch lib | 40 | @touch lib |
41 | 41 | ||
@@ -79,17 +79,34 @@ 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/lhash.h | 82 | md_rand.o: ../../include/openssl/evp.h ../../include/openssl/fips.h |
83 | md_rand.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | 83 | md_rand.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h |
84 | md_rand.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | 84 | md_rand.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h |
85 | md_rand.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | 85 | md_rand.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
86 | md_rand.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | 86 | md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
87 | md_rand.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 87 | md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
88 | md_rand.o: md_rand.c rand_lcl.h | 88 | md_rand.o: ../../include/openssl/symhacks.h 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 | ||
93 | rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | 110 | rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h |
94 | rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | 111 | rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h |
95 | rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h | 112 | rand_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h |
@@ -97,31 +114,41 @@ rand_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | |||
97 | rand_err.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 114 | rand_err.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
98 | rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 115 | rand_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
99 | rand_err.o: rand_err.c | 116 | rand_err.o: rand_err.c |
100 | rand_lib.o: ../../e_os.h ../../include/openssl/bio.h | 117 | rand_lib.o: ../../e_os.h ../../include/openssl/asn1.h |
101 | rand_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | 118 | rand_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
102 | rand_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/engine.h | 119 | rand_lib.o: ../../include/openssl/crypto.h ../../include/openssl/des.h |
103 | rand_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | 120 | rand_lib.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h |
104 | rand_lib.o: ../../include/openssl/opensslconf.h | 121 | rand_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h |
122 | rand_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h | ||
123 | 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 | ||
126 | rand_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
105 | rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 127 | rand_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
106 | rand_lib.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 128 | rand_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h |
129 | rand_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
107 | rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | 130 | rand_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
108 | rand_lib.o: ../cryptlib.h rand_lib.c | 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 | ||
133 | rand_lib.o: ../cryptlib.h rand_lcl.h rand_lib.c | ||
109 | rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h | 134 | rand_nw.o: ../../e_os.h ../../include/openssl/asn1.h |
110 | rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 135 | rand_nw.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
111 | rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 136 | rand_nw.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
112 | rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 137 | rand_nw.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
113 | rand_nw.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 138 | rand_nw.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
114 | rand_nw.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 139 | rand_nw.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
115 | rand_nw.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 140 | rand_nw.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h |
116 | rand_nw.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 141 | rand_nw.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h |
117 | rand_nw.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 142 | rand_nw.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h |
118 | rand_nw.o: ../../include/openssl/symhacks.h ../cryptlib.h rand_lcl.h rand_nw.c | 143 | rand_nw.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h |
144 | rand_nw.o: ../cryptlib.h rand_lcl.h rand_nw.c | ||
119 | rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h | 145 | rand_os2.o: ../../e_os.h ../../include/openssl/asn1.h |
120 | rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 146 | rand_os2.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
121 | rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 147 | rand_os2.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
122 | rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 148 | rand_os2.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
123 | rand_os2.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 149 | rand_os2.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
124 | rand_os2.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 150 | rand_os2.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
151 | rand_os2.o: ../../include/openssl/opensslconf.h | ||
125 | rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 152 | rand_os2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
126 | rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 153 | rand_os2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
127 | rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 154 | rand_os2.o: ../../include/openssl/sha.h ../../include/openssl/stack.h |
@@ -131,8 +158,8 @@ rand_unix.o: ../../e_os.h ../../include/openssl/asn1.h | |||
131 | rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 158 | rand_unix.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
132 | rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 159 | rand_unix.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
133 | rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 160 | rand_unix.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
134 | rand_unix.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 161 | rand_unix.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
135 | rand_unix.o: ../../include/openssl/objects.h | 162 | rand_unix.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
136 | rand_unix.o: ../../include/openssl/opensslconf.h | 163 | rand_unix.o: ../../include/openssl/opensslconf.h |
137 | rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 164 | rand_unix.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
138 | rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 165 | rand_unix.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
@@ -143,8 +170,9 @@ rand_win.o: ../../e_os.h ../../include/openssl/asn1.h | |||
143 | rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | 170 | rand_win.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h |
144 | rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h | 171 | rand_win.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h |
145 | rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h | 172 | rand_win.o: ../../include/openssl/err.h ../../include/openssl/evp.h |
146 | rand_win.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h | 173 | rand_win.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h |
147 | rand_win.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | 174 | rand_win.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h |
175 | rand_win.o: ../../include/openssl/opensslconf.h | ||
148 | rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h | 176 | rand_win.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h |
149 | rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h | 177 | rand_win.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h |
150 | rand_win.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | 178 | 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 9783d0c23e..0f8dd3e00f 100644 --- a/src/lib/libcrypto/rand/md_rand.c +++ b/src/lib/libcrypto/rand/md_rand.c | |||
@@ -126,6 +126,10 @@ | |||
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 | |||
129 | 133 | ||
130 | #ifdef BN_DEBUG | 134 | #ifdef BN_DEBUG |
131 | # define PREDICT | 135 | # define PREDICT |
@@ -332,6 +336,14 @@ static int ssleay_rand_bytes(unsigned char *buf, int num) | |||
332 | #endif | 336 | #endif |
333 | int do_stir_pool = 0; | 337 | int do_stir_pool = 0; |
334 | 338 | ||
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 | |||
335 | #ifdef PREDICT | 347 | #ifdef PREDICT |
336 | if (rand_predictable) | 348 | if (rand_predictable) |
337 | { | 349 | { |
diff --git a/src/lib/libcrypto/rand/rand_eng.c b/src/lib/libcrypto/rand/rand_eng.c new file mode 100644 index 0000000000..1669cef43c --- /dev/null +++ b/src/lib/libcrypto/rand/rand_eng.c | |||
@@ -0,0 +1,152 @@ | |||
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 */ | ||
76 | static ENGINE *funct_ref =NULL; | ||
77 | |||
78 | int 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 | |||
89 | const 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 | |||
122 | int 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 | |||
142 | void 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/libcrypto/rand/rand_lcl.h b/src/lib/libcrypto/rand/rand_lcl.h index 618a8ec899..18cc9b1e4a 100644 --- a/src/lib/libcrypto/rand/rand_lcl.h +++ b/src/lib/libcrypto/rand/rand_lcl.h | |||
@@ -154,5 +154,16 @@ | |||
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 | |||
157 | 168 | ||
158 | #endif | 169 | #endif |