Bug 1652557: don't skip test_bug767684.html when xorigin iframes and fission are...
[gecko.git] / mfbt / RandomNum.h
blob5d392c9a68197901cc25d94acaa3a29ddd851ca8
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 /**
34 * Like RandomUint64, but always returns a uint64_t or crashes with an assert
35 * if the underlying RandomUint64 call failed.
37 MFBT_API uint64_t RandomUint64OrDie();
39 } // namespace mozilla
41 #endif // mozilla_RandomNum_h_