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_MASK_HPP 11 #define BOOST_BEAST_WEBSOCKET_DETAIL_MASK_HPP 12 13 #include <boost/beast/core/detail/config.hpp> 14 #include <boost/beast/core/buffers_range.hpp> 15 #include <boost/asio/buffer.hpp> 16 #include <array> 17 #include <climits> 18 #include <cstdint> 19 #include <random> 20 #include <type_traits> 21 22 namespace boost { 23 namespace beast { 24 namespace websocket { 25 namespace detail { 26 27 using prepared_key = std::array<unsigned char, 4>; 28 29 BOOST_BEAST_DECL 30 void 31 prepare_key(prepared_key& prepared, std::uint32_t key); 32 33 // Apply mask in place 34 // 35 BOOST_BEAST_DECL 36 void 37 mask_inplace(net::mutable_buffer const& b, prepared_key& key); 38 39 // Apply mask in place 40 // 41 template<class MutableBufferSequence> 42 void mask_inplace(MutableBufferSequence const & buffers,prepared_key & key)43mask_inplace( 44 MutableBufferSequence const& buffers, 45 prepared_key& key) 46 { 47 for(net::mutable_buffer b : 48 beast::buffers_range_ref(buffers)) 49 detail::mask_inplace(b, key); 50 } 51 52 } // detail 53 } // websocket 54 } // beast 55 } // boost 56 57 58 #if BOOST_BEAST_HEADER_ONLY 59 #include <boost/beast/websocket/detail/mask.ipp> 60 #endif 61 62 63 #endif 64