summaryrefslogtreecommitdiffabout
path: root/src/eyetil.cc
authorMichael Krelin <hacker@klever.net>2009-04-06 20:27:39 (UTC)
committer Michael Krelin <hacker@klever.net>2009-04-06 20:27:39 (UTC)
commit51d8a8a4ac6ef6096c393fd602df34c6bf8f6366 (patch) (side-by-side diff)
tree8126f60fac6562b14c965e41d19983d81312638a /src/eyetil.cc
parentde964540e5a58b3a9195c642ef7a0745ee3b2344 (diff)
downloadiii-51d8a8a4ac6ef6096c393fd602df34c6bf8f6366.zip
iii-51d8a8a4ac6ef6096c393fd602df34c6bf8f6366.tar.gz
iii-51d8a8a4ac6ef6096c393fd602df34c6bf8f6366.tar.bz2
better nonce generation and session credentials verification
based on the patch from Chris Davies Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'src/eyetil.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyetil.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/eyetil.cc b/src/eyetil.cc
index fe816a6..7669cb6 100644
--- a/src/eyetil.cc
+++ b/src/eyetil.cc
@@ -9,6 +9,11 @@
#include <openssl/md5.h>
#include "eyetil.h"
+#include "config.h"
+#ifdef HAVE_LIBUUID
+# include <uuid/uuid.h>
+#endif
+
binary_t& binary_t::from_hex(const std::string& h) {
std::string::size_type hs = h.length();
if(hs&1)
@@ -32,6 +37,18 @@ binary_t& binary_t::from_data(const void *d,size_t s) {
return *this;
}
+binary_t& binary_t::make_nonce() {
+#ifdef HAVE_LIBUUID
+ uuid_t uuid;
+ uuid_generate(uuid);
+ from_data((unsigned char*)uuid,sizeof(uuid));
+#else
+ resize(16);
+ std::generate_n(begin(),16,rand);
+#endif /* HAVE_LIBUUID */
+ return *this;
+}
+
std::string binary_t::hex() const {
std::string rv;
rv.reserve((size()<<1)+1);