diff options
Diffstat (limited to 'src/lib/libcrypto/rand/rand_lib.c')
-rw-r--r-- | src/lib/libcrypto/rand/rand_lib.c | 71 |
1 files changed, 1 insertions, 70 deletions
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c index da6b4e0e86..513e338985 100644 --- a/src/lib/libcrypto/rand/rand_lib.c +++ b/src/lib/libcrypto/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 | ||
73 | static const RAND_METHOD *default_RAND_meth = NULL; | ||
74 | |||
75 | #ifdef OPENSSL_FIPS | ||
76 | |||
77 | static int fips_RAND_set_rand_method(const RAND_METHOD *meth, | ||
78 | const RAND_METHOD **pmeth) | ||
79 | { | ||
80 | *pmeth = meth; | ||
81 | return 1; | ||
82 | } | ||
83 | |||
84 | static 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 | |||
104 | static int (*RAND_set_rand_method_func)(const RAND_METHOD *meth, | ||
105 | const RAND_METHOD **pmeth) | ||
106 | = fips_RAND_set_rand_method; | ||
107 | static 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 | ||
112 | void 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 | |||
123 | int RAND_set_rand_method(const RAND_METHOD *meth) | ||
124 | { | ||
125 | return RAND_set_rand_method_func(meth, &default_RAND_meth); | ||
126 | } | ||
127 | |||
128 | const 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 */ |
137 | static ENGINE *funct_ref =NULL; | 69 | static ENGINE *funct_ref =NULL; |
138 | #endif | 70 | #endif |
71 | static const RAND_METHOD *default_RAND_meth = NULL; | ||
139 | 72 | ||
140 | int RAND_set_rand_method(const RAND_METHOD *meth) | 73 | int 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 | |||
201 | void RAND_cleanup(void) | 132 | void RAND_cleanup(void) |
202 | { | 133 | { |
203 | const RAND_METHOD *meth = RAND_get_rand_method(); | 134 | const RAND_METHOD *meth = RAND_get_rand_method(); |