| 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 | |
| 10 | #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_PRNG_HPP |
| 11 | #define BOOST_BEAST_WEBSOCKET_DETAIL_PRNG_HPP |
| 12 | |
| 13 | #include <boost/beast/core/detail/config.hpp> |
| 14 | #include <boost/config.hpp> |
| 15 | #include <cstdint> |
| 16 | #include <random> |
| 17 | |
| 18 | namespace boost { |
| 19 | namespace beast { |
| 20 | namespace websocket { |
| 21 | namespace detail { |
| 22 | |
| 23 | using generator = std::uint32_t(*)(); |
| 24 | |
| 25 | //------------------------------------------------------------------------------ |
| 26 | |
| 27 | // Manually seed the prngs, must be called |
| 28 | // before acquiring a prng for the first time. |
| 29 | // |
| 30 | BOOST_BEAST_DECL |
| 31 | std::uint32_t const* |
| 32 | prng_seed(std::seed_seq* ss = nullptr); |
| 33 | |
| 34 | // Acquire a PRNG using the TLS implementation if it |
| 35 | // is available, otherwise using the no-TLS implementation. |
| 36 | // |
| 37 | BOOST_BEAST_DECL |
| 38 | generator |
| 39 | make_prng(bool secure); |
| 40 | |
| 41 | } // detail |
| 42 | } // websocket |
| 43 | } // beast |
| 44 | } // boost |
| 45 | |
| 46 | #ifdef BOOST_BEAST_HEADER_ONLY |
| 47 | #include <boost/beast/websocket/detail/prng.ipp> |
| 48 | #endif |
| 49 | |
| 50 | #endif |
| 51 |
