diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2019-07-03 11:05:01 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2019-08-15 16:33:15 +0200 |
commit | 7b9a420787c71624ff0e9c6bcfe1e72c74feb677 (patch) | |
tree | 587dcbf07b08a78775b1f517067c49d816f0ef50 /tests/unit_tests/ringct.cpp | |
parent | Merge pull request #5779 (diff) | |
download | monero-7b9a420787c71624ff0e9c6bcfe1e72c74feb677.tar.xz |
Replace std::random_shuffle with std::shuffle
According to [1], std::random_shuffle is deprecated in C++14 and removed
in C++17. Since std::shuffle is available since C++11 as a replacement
and monero already requires C++11, this is a good replacement.
A cryptographically secure random number generator is used in all cases
to prevent people from perhaps copying an insecure std::shuffle call
over to a place where a secure one would be warranted. A form of
defense-in-depth.
[1]: https://en.cppreference.com/w/cpp/algorithm/random_shuffle
Diffstat (limited to 'tests/unit_tests/ringct.cpp')
-rw-r--r-- | tests/unit_tests/ringct.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/unit_tests/ringct.cpp b/tests/unit_tests/ringct.cpp index 4d51ec434..d2b2c3109 100644 --- a/tests/unit_tests/ringct.cpp +++ b/tests/unit_tests/ringct.cpp @@ -779,8 +779,8 @@ TEST(ringct, range_proofs_accept_very_long_simple) inputs[n] = n; outputs[n] = n; } - std::random_shuffle(inputs, inputs + N); - std::random_shuffle(outputs, outputs + N); + std::shuffle(inputs, inputs + N, crypto::random_device{}); + std::shuffle(outputs, outputs + N, crypto::random_device{}); EXPECT_TRUE(range_proof_test(true, NELTS(inputs), inputs, NELTS(outputs), outputs, false, true)); } |