summaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2022-02-07 19:38:32 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2022-02-08 09:59:03 -0500
commitff21940200b22552138858dd0f455a5cb25f5ed7 (patch)
tree919e1b75ef55764a62384eaef77610f1dec181d6 /src/CMakeLists.txt
parenta60c1846d619f57e3aadae05f90640f63c56d321 (diff)
downloadlibgit2-ff21940200b22552138858dd0f455a5cb25f5ed7.tar.gz
rand: introduce git_rand PRNG
Introduce `git_rand`, a PRNG based on xoroshiro256**, a fast, all-purpose pseudo-random number generator: https://prng.di.unimi.it The PRNG will be seeded by the system's entropy store when possible, falling back to current time and system data (pid, uptime, etc). Inspiration for this was taken from libressl, but since our PRNG is not used for cryptographic purposes (and indeed currently only generates a unique temp file name that is written in a protected directory), this should be more than sufficient. Our implementation of xoroshiro256** was taken almost strictly from the original author's sources, but was tested against PractRand to ensure that there were no foolish mistranslations: ``` RNG_test using PractRand version 0.94 RNG = RNG_stdin64, seed = unknown test set = core, folding = standard (64 bit) rng=RNG_stdin64, seed=unknown length= 256 megabytes (2^28 bytes), time= 2.9 seconds no anomalies in 210 test result(s) rng=RNG_stdin64, seed=unknown length= 512 megabytes (2^29 bytes), time= 6.2 seconds no anomalies in 226 test result(s) rng=RNG_stdin64, seed=unknown length= 1 gigabyte (2^30 bytes), time= 12.7 seconds no anomalies in 243 test result(s) rng=RNG_stdin64, seed=unknown length= 2 gigabytes (2^31 bytes), time= 25.4 seconds no anomalies in 261 test result(s) rng=RNG_stdin64, seed=unknown length= 4 gigabytes (2^32 bytes), time= 50.6 seconds no anomalies in 277 test result(s) rng=RNG_stdin64, seed=unknown length= 8 gigabytes (2^33 bytes), time= 104 seconds no anomalies in 294 test result(s) ```
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e2da4bc90..4b2173745 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -55,6 +55,11 @@ check_prototype_definition(qsort_r
check_function_exists(qsort_s GIT_QSORT_S)
+check_function_exists(getrandom GIT_RAND_GETRANDOM)
+if(NOT GIT_RAND_GETENTROPY)
+ check_function_exists(getentropy GIT_RAND_GETENTROPY)
+endif()
+
# Find required dependencies
if(WIN32)