From 51d8a8a4ac6ef6096c393fd602df34c6bf8f6366 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Mon, 06 Apr 2009 20:27:39 +0000 Subject: better nonce generation and session credentials verification based on the patch from Chris Davies Signed-off-by: Michael Krelin --- (limited to 'src/eyetil.cc') 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 #include "eyetil.h" +#include "config.h" +#ifdef HAVE_LIBUUID +# include +#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); -- cgit v0.9.0.2