Crate fast_rands

Crate fast_rands 

Source
Expand description

The fast random number generators of LibAFL

§Fast_Rands: Get (non-cryptographically secure!) Random Numbers Faster.

LibAFL logo

The faster_rands crate is a collection of a range of fast RNGs, such as RomuRand and others. It can be used together with LibAFL or any place that needs random numbers, as long as you don’t rely on the randomness for security.

§Usage

use fast_rands::{Rand, StdRand};
use core::num::NonZeroUsize;

// Create a new random number generator with a random seed
let mut rand = StdRand::new();

// Get a random u64
let n = rand.next();

// Get a random number below 100
let below_100 = rand.below(NonZeroUsize::new(100).unwrap());

// Get a random number between 50 and 100 (inclusive)
let between_50_and_100 = rand.between(50, 100);

§The LibAFL Project

The LibAFL project is part of AFLplusplus and maintained by

§Contributing

For bugs, feel free to open issues or contact us directly. Thank you for your support. <3

Even though we will gladly assist you in finishing up your PR, try to

  • keep all the crates compiling with stable rust (hide the eventual non-stable code under cfgs.)
  • run cargo nightly fmt on your code before pushing
  • check the output of cargo clippy --all or ./clippy.sh
  • run cargo build --no-default-features to check for no_std compatibility (and possibly add #[cfg(feature = "std")]) to hide parts of your code.

Some parts in this list may sound hard, but don’t be afraid to open a PR if you cannot fix them by yourself. We will gladly assist.

§License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies under more restrictive licenses, such as GPL or AGPL, can be enabled using the respective feature in each crate when it is present, such as the 'agpl' feature of the libafl crate.

§Feature Flags

§General Features

  • std (enabled by default) — Enables features that need rust’s std lib to work, like print, env, … support
  • alloc (enabled by default) — Enables all features that allocate in no_std
  • rand_trait — If set, libafl_rand’s rand implementations will implement rand_core::CoreRng and, inversely, all seedable rand_core::RngCore types can be used as Rng for LibAFL.
  • python — Enable python support for Rand

Modules§

loaded_dice
Loaded Dice
pybind
Rand Python bindings

Macros§

unwrap_me_mut_body
Unwrap the mutable body of this wrapper

Structs§

Lehmer64Rand
Lehmer64 PRNG
RomuDuoJrRand
see https://arxiv.org/pdf/2002.11331.pdf
RomuTrioRand
Extremely quick rand implementation see https://arxiv.org/pdf/2002.11331.pdf
Sfc64Rand
SFC64 algorithm by Chris Doty-Humphrey.
XkcdRand
fake rand, for testing purposes
XorShift64Rand
Xorshift64 PRNG
Xoshiro256PlusPlusRand
xoshiro256++ PRNG: https://prng.di.unimi.it/

Traits§

Rand
Ways to get random around here. Please note that these are not cryptographically secure. Or, even if some might be by accident, at least they are not seeded in a cryptographically secure fashion.

Functions§

choose
Choose an item at random from the given iterator, sampling uniformly.
fast_bound
Faster and almost unbiased alternative to rand % n.
random_seed
Return a pseudo-random seed. For no_std environments, a single deterministic sequence is used.

Type Aliases§

StdRand
The standard Rand implementation for LibAFL.