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) (unidiff)
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 @@
9#include <openssl/md5.h> 9#include <openssl/md5.h>
10#include "eyetil.h" 10#include "eyetil.h"
11 11
12#include "config.h"
13#ifdef HAVE_LIBUUID
14# include <uuid/uuid.h>
15#endif
16
12binary_t& binary_t::from_hex(const std::string& h) { 17binary_t& binary_t::from_hex(const std::string& h) {
13 std::string::size_type hs = h.length(); 18 std::string::size_type hs = h.length();
14 if(hs&1) 19 if(hs&1)
@@ -32,6 +37,18 @@ binary_t& binary_t::from_data(const void *d,size_t s) {
32 return *this; 37 return *this;
33} 38}
34 39
40binary_t& binary_t::make_nonce() {
41#ifdef HAVE_LIBUUID
42 uuid_t uuid;
43 uuid_generate(uuid);
44 from_data((unsigned char*)uuid,sizeof(uuid));
45#else
46 resize(16);
47 std::generate_n(begin(),16,rand);
48#endif /* HAVE_LIBUUID */
49 return *this;
50}
51
35std::string binary_t::hex() const { 52std::string binary_t::hex() const {
36 std::string rv; 53 std::string rv;
37 rv.reserve((size()<<1)+1); 54 rv.reserve((size()<<1)+1);