random_provider_arc4random.ipp 730 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // Copyright (c) 2017 James E. King III
  3. //
  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)
  7. //
  8. // "A Replacement Call for Random"
  9. // https://man.openbsd.org/arc4random.3
  10. //
  11. #include <cstddef>
  12. #include <stdlib.h>
  13. namespace boost {
  14. namespace uuids {
  15. namespace detail {
  16. class random_provider_base
  17. {
  18. public:
  19. //! Obtain entropy and place it into a memory location
  20. //! \param[in] buf the location to write entropy
  21. //! \param[in] siz the number of bytes to acquire
  22. void get_random_bytes(void *buf, std::size_t siz)
  23. {
  24. arc4random_buf(buf, siz);
  25. }
  26. };
  27. } // detail
  28. } // uuids
  29. } // boost