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.

This commit is contained in:
Adam Ierymenko 2015-07-07 10:49:50 -07:00
parent 41fc08b330
commit 3f567a07ca
6 changed files with 32 additions and 104 deletions

View file

@ -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;