summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rand/rand_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rand/rand_lib.c')
-rw-r--r--src/lib/libcrypto/rand/rand_lib.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/libcrypto/rand/rand_lib.c b/src/lib/libcrypto/rand/rand_lib.c
index 5cf5dc1188..513e338985 100644
--- a/src/lib/libcrypto/rand/rand_lib.c
+++ b/src/lib/libcrypto/rand/rand_lib.c
@@ -60,19 +60,25 @@
60#include <time.h> 60#include <time.h>
61#include "cryptlib.h" 61#include "cryptlib.h"
62#include <openssl/rand.h> 62#include <openssl/rand.h>
63#ifndef OPENSSL_NO_ENGINE
63#include <openssl/engine.h> 64#include <openssl/engine.h>
65#endif
64 66
67#ifndef OPENSSL_NO_ENGINE
65/* non-NULL if default_RAND_meth is ENGINE-provided */ 68/* non-NULL if default_RAND_meth is ENGINE-provided */
66static ENGINE *funct_ref =NULL; 69static ENGINE *funct_ref =NULL;
70#endif
67static const RAND_METHOD *default_RAND_meth = NULL; 71static const RAND_METHOD *default_RAND_meth = NULL;
68 72
69int RAND_set_rand_method(const RAND_METHOD *meth) 73int RAND_set_rand_method(const RAND_METHOD *meth)
70 { 74 {
75#ifndef OPENSSL_NO_ENGINE
71 if(funct_ref) 76 if(funct_ref)
72 { 77 {
73 ENGINE_finish(funct_ref); 78 ENGINE_finish(funct_ref);
74 funct_ref = NULL; 79 funct_ref = NULL;
75 } 80 }
81#endif
76 default_RAND_meth = meth; 82 default_RAND_meth = meth;
77 return 1; 83 return 1;
78 } 84 }
@@ -81,6 +87,7 @@ const RAND_METHOD *RAND_get_rand_method(void)
81 { 87 {
82 if (!default_RAND_meth) 88 if (!default_RAND_meth)
83 { 89 {
90#ifndef OPENSSL_NO_ENGINE
84 ENGINE *e = ENGINE_get_default_RAND(); 91 ENGINE *e = ENGINE_get_default_RAND();
85 if(e) 92 if(e)
86 { 93 {
@@ -94,11 +101,13 @@ const RAND_METHOD *RAND_get_rand_method(void)
94 if(e) 101 if(e)
95 funct_ref = e; 102 funct_ref = e;
96 else 103 else
104#endif
97 default_RAND_meth = RAND_SSLeay(); 105 default_RAND_meth = RAND_SSLeay();
98 } 106 }
99 return default_RAND_meth; 107 return default_RAND_meth;
100 } 108 }
101 109
110#ifndef OPENSSL_NO_ENGINE
102int RAND_set_rand_engine(ENGINE *engine) 111int RAND_set_rand_engine(ENGINE *engine)
103 { 112 {
104 const RAND_METHOD *tmp_meth = NULL; 113 const RAND_METHOD *tmp_meth = NULL;
@@ -118,6 +127,7 @@ int RAND_set_rand_engine(ENGINE *engine)
118 funct_ref = engine; 127 funct_ref = engine;
119 return 1; 128 return 1;
120 } 129 }
130#endif
121 131
122void RAND_cleanup(void) 132void RAND_cleanup(void)
123 { 133 {