2 // Copyright (c) 2017 James E. King III
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // https://www.boost.org/LICENSE_1_0.txt)
8 // getentropy() capable platforms
11 #include <boost/config.hpp>
12 #include <boost/throw_exception.hpp>
21 class random_provider_base
24 //! Obtain entropy and place it into a memory location
25 //! \param[in] buf the location to write entropy
26 //! \param[in] siz the number of bytes to acquire
27 void get_random_bytes(void *buf, std::size_t siz)
29 int res = getentropy(buf, siz);
30 if (BOOST_UNLIKELY(-1 == res))
33 BOOST_THROW_EXCEPTION(entropy_error(err, "getentropy"));