https://github.com/CryptDB/cryptdb
Tip revision: 7678bc98d3054f1418371779c6d1050cd1a88b2e authored by Raluca Ada Popa on 04 January 2014, 01:31:06 UTC
small changes to readme
small changes to readme
Tip revision: 7678bc9
urandom.cc
#include <string.h>
#include <sys/fcntl.h>
#include <crypto/prng.hh>
#include <util/errstream.hh>
using namespace std;
urandom::urandom()
: f("/dev/urandom")
{
throw_c(false == f.fail(),
"cannot open /dev/urandom: " + std::string(strerror(errno)));
}
void
urandom::rand_bytes(size_t nbytes, uint8_t *buf)
{
f.read((char *) buf, nbytes);
}
void
urandom::seed_bytes(size_t nbytes, uint8_t *buf)
{
f.write((char *) buf, nbytes);
}