#include "reference_drivers/random.h"
#include <cstddef>
#include <cstdint>
#include "build/build_config.h"
#include "third_party/abseil-cpp/absl/base/macros.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#elif BUILDFLAG(IS_FUCHSIA)
#include <zircon/syscalls.h>
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
#include <asm/unistd.h>
#include <sys/syscall.h>
#include <unistd.h>
#elif BUILDFLAG(IS_MAC)
#include <sys/random.h>
#include <unistd.h>
#elif BUILDFLAG(IS_NACL)
#include <nacl/nacl_random.h>
#endif
#if BUILDFLAG(IS_POSIX)
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#endif
#if BUILDFLAG(IS_WIN)
extern "C" {
BOOL WINAPI ProcessPrng(PBYTE pbData, SIZE_T cbData);
}
#endif
namespace ipcz::reference_drivers {
namespace {
#if BUILDFLAG(IS_WIN)
decltype(&ProcessPrng) GetProcessPrng() {
HMODULE hmod = LoadLibraryW(L"bcryptprimitives.dll");
ABSL_ASSERT(hmod);
decltype(&ProcessPrng) process_prng_fn =
reinterpret_cast<decltype(&ProcessPrng)>(
GetProcAddress(hmod, "ProcessPrng"));
ABSL_ASSERT(process_prng_fn);
return process_prng_fn;
}
#endif
#if defined(OS_POSIX) && !BUILDFLAG(IS_MAC)
void RandomBytesFromDevUrandom(absl::Span<uint8_t> destination) { … }
#endif
}
void RandomBytes(absl::Span<uint8_t> destination) { … }
}