Bug 1468696 [wpt PR 11497] - Update wpt metadata, a=testonly
[gecko.git] / mfbt / RandomNum.h
blob5af510d621a6e89c16070010fe83dad78585f2be
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 /* Routines for generating random numbers */
9 #ifndef mozilla_RandomNum_h_
10 #define mozilla_RandomNum_h_
12 #include "mozilla/Maybe.h"
13 #include "mozilla/Types.h"
15 namespace mozilla {
17 /**
18 * Generate a cryptographically secure random 64-bit unsigned number using the
19 * best facilities available on the current OS.
21 * Useful whenever a secure random number is needed and NSS isn't available.
22 * (Perhaps because it hasn't been initialized yet)
24 * Current mechanisms:
25 * Windows: RtlGenRandom()
26 * Android, Darwin, DragonFly, FreeBSD, OpenBSD, NetBSD: arc4random()
27 * Linux: getrandom() if available, "/dev/urandom" otherwise
28 * Other Unix: "/dev/urandom"
31 MFBT_API Maybe<uint64_t> RandomUint64();
33 } // namespace mozilla
35 #endif // mozilla_RandomNum_h_