summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index a0804ddf9..c2dc4c878 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -14,6 +14,7 @@
#include "inspircd.h"
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include <gcrypt.h>
#include "ssl.h"
#include "m_cap.h"
@@ -69,6 +70,16 @@ static ssize_t gnutls_push_wrapper(gnutls_transport_ptr_t user_wrap, const void*
return rv;
}
+class RandGen : public HandlerBase2<void, char*, size_t>
+{
+ public:
+ RandGen() {}
+ void Call(char* buffer, size_t len)
+ {
+ gcry_randomize(buffer, len, GCRY_STRONG_RANDOM);
+ }
+};
+
/** Represents an SSL user's extra data
*/
class issl_session
@@ -136,6 +147,7 @@ class ModuleSSLGnuTLS : public Module
bool cred_alloc;
+ RandGen randhandler;
CommandStartTLS starttls;
GenericCap capHandler;
@@ -159,6 +171,8 @@ class ModuleSSLGnuTLS : public Module
// Needs the flag as it ignores a plain /rehash
OnModuleRehash(NULL,"ssl");
+ ServerInstance->GenRandom = &randhandler;
+
// Void return, guess we assume success
gnutls_certificate_set_dh_params(x509_cred, dh_params);
Implementation eventlist[] = { I_On005Numeric, I_OnRehash, I_OnModuleRehash, I_OnUserConnect,
@@ -294,6 +308,7 @@ class ModuleSSLGnuTLS : public Module
}
gnutls_global_deinit();
delete[] sessions;
+ ServerInstance->GenRandom = &ServerInstance->HandleGenRandom;
}
void OnCleanup(int target_type, void* item)