2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_MASK_IPP
11 #define BOOST_BEAST_WEBSOCKET_DETAIL_MASK_IPP
13 #include <boost/beast/websocket/detail/mask.hpp>
21 prepare_key(prepared_key& prepared, std::uint32_t key)
23 prepared[0] = (key >> 0) & 0xff;
24 prepared[1] = (key >> 8) & 0xff;
25 prepared[2] = (key >> 16) & 0xff;
26 prepared[3] = (key >> 24) & 0xff;
31 rol(prepared_key& v, std::size_t n)
34 for(std::size_t i = 0; i < v.size(); ++i )
35 v[i] = v0[(i + n) % v.size()];
38 // Apply mask in place
41 mask_inplace(net::mutable_buffer const& b, prepared_key& key)
44 auto const mask = key; // avoid aliasing
45 auto p = static_cast<unsigned char*>(b.data());
48 for(int i = 0; i < 4; ++i)
55 for(std::size_t i = 0; i < n; ++i)