OpenVPN 3 Core Library
Loading...
Searching...
No Matches
randistrib.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12#pragma once
13
14#include <cstdint>
15
16namespace openvpn {
17
18// Return a uniformly distributed random number in the range [0, end)
19// using seed as a random seed. This version is strictly 32-bit only
20// and optimizes by avoiding integer division.
21inline std::uint32_t rand32_distribute(const std::uint32_t seed,
22 const std::uint32_t end)
23{
24 return static_cast<uint32_t>((std::uint64_t(seed) * end) >> 32);
25}
26
27} // namespace openvpn
Support deferred server-side state creation when client connects.
Definition ovpncli.cpp:95
std::uint32_t rand32_distribute(const std::uint32_t seed, const std::uint32_t end)