diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-07 10:49:50 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-07 10:49:50 -0700 |
| commit | 3f567a07ca0cda5c3370105d88cb939ad62b4b7d (patch) | |
| tree | d84ea22fc19d74f9a7bb7441ff399e2a702caee7 /node/Node.hpp | |
| parent | 41fc08b3308be6ac57d737b225a58d41854bd695 (diff) | |
| download | infinitytier-3f567a07ca0cda5c3370105d88cb939ad62b4b7d.tar.gz infinitytier-3f567a07ca0cda5c3370105d88cb939ad62b4b7d.zip | |
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.
Diffstat (limited to 'node/Node.hpp')
| -rw-r--r-- | node/Node.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
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> _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; |
