summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-13 13:26:27 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-13 13:26:27 -0400
commit3e49337d9a773a5d805a908bc093b5d72985d8d9 (patch)
treedd8bf524287442c1c3a30f9390d712b77c0e53d0 /node/Node.cpp
parentc6dd5b239ff30a192c5bc6e784fd5d4b3085646d (diff)
downloadinfinitytier-3e49337d9a773a5d805a908bc093b5d72985d8d9.tar.gz
infinitytier-3e49337d9a773a5d805a908bc093b5d72985d8d9.zip
Add a fast non-cryptographic PRNG.
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index 976de742..265b77e4 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -193,8 +193,11 @@ Node::ReasonForTermination Node::run()
std::string ovsPath(_r->homePath + ZT_PATH_SEPARATOR_S + "thisdeviceismine");
if (((Utils::now() - Utils::getLastModified(ovsPath.c_str())) >= ZT_OVS_GENERATE_NEW_IF_OLDER_THAN)||(!Utils::readFile(ovsPath.c_str(),_r->ownershipVerificationSecret))) {
_r->ownershipVerificationSecret = "";
- for(unsigned int i=0;i<24;++i)
- _r->ownershipVerificationSecret.push_back("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Utils::randomInt<unsigned int>() % 62]);
+ unsigned int securern = 0;
+ for(unsigned int i=0;i<24;++i) {
+ Utils::getSecureRandom(&securern,sizeof(securern));
+ _r->ownershipVerificationSecret.push_back("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[securern % 62]);
+ }
_r->ownershipVerificationSecret.append(ZT_EOL_S);
if (!Utils::writeFile(ovsPath.c_str(),_r->ownershipVerificationSecret))
return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"could not write 'thisdeviceismine' (home path not writable?)");