From 3f567a07ca0cda5c3370105d88cb939ad62b4b7d Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 7 Jul 2015 10:49:50 -0700 Subject: Save a little bit of RAM by getting rid of overkill CMWC4096 non-crypto PRNG and replacing it with a simple non-crypto PRNG that just uses Salsa20. --- node/Node.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'node/Node.hpp') diff --git a/node/Node.hpp b/node/Node.hpp index fe31576c..579d3a57 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -44,6 +44,7 @@ #include "MAC.hpp" #include "Network.hpp" #include "Path.hpp" +#include "Salsa20.hpp" #undef TRACE #ifdef ZT_TRACE @@ -219,6 +220,11 @@ public: void postTrace(const char *module,unsigned int line,const char *fmt,...); #endif + /** + * @return Next 64-bit random number (not for cryptographic use) + */ + uint64_t prng(); + private: inline SharedPtr _network(uint64_t nwid) const { @@ -253,6 +259,10 @@ private: Mutex _backgroundTasksLock; + unsigned int _prngStreamPtr; + Salsa20 _prng; + uint64_t _prngStream[16]; // repeatedly encrypted with _prng to yield a high-quality non-crypto PRNG stream + uint64_t _now; uint64_t _lastPingCheck; uint64_t _lastHousekeepingRun; -- cgit v1.2.3