prng.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_PRNG_HPP
  10. #define BOOST_BEAST_WEBSOCKET_DETAIL_PRNG_HPP
  11. #include <boost/beast/core/detail/config.hpp>
  12. #include <boost/config.hpp>
  13. #include <cstdint>
  14. #include <random>
  15. namespace boost {
  16. namespace beast {
  17. namespace websocket {
  18. namespace detail {
  19. using generator = std::uint32_t(*)();
  20. //------------------------------------------------------------------------------
  21. // Manually seed the prngs, must be called
  22. // before acquiring a prng for the first time.
  23. //
  24. BOOST_BEAST_DECL
  25. std::uint32_t const*
  26. prng_seed(std::seed_seq* ss = nullptr);
  27. // Acquire a PRNG using the TLS implementation if it
  28. // is available, otherwise using the no-TLS implementation.
  29. //
  30. BOOST_BEAST_DECL
  31. generator
  32. make_prng(bool secure);
  33. } // detail
  34. } // websocket
  35. } // beast
  36. } // boost
  37. #ifdef BOOST_BEAST_HEADER_ONLY
  38. #include <boost/beast/websocket/detail/prng.ipp>
  39. #endif
  40. #endif