aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_rng.cpp
diff options
context:
space:
mode:
authorTom <[email protected]>2021-01-17 16:20:22 +0000
committerTom <[email protected]>2021-01-18 18:26:53 +0000
commit5be8105c117a662cab66d4a1c0136b4a67bf5244 (patch)
tree909b84ed13e4efbd3190f937ca9a2e6af955cb81 /src/tests/test_rng.cpp
parent4a4f2abcb82222f919f8d439b2f97727ed95dadc (diff)
Fix System_RNG only filling the first 4GB of the buffer for len >4GB
Diffstat (limited to 'src/tests/test_rng.cpp')
-rw-r--r--src/tests/test_rng.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tests/test_rng.cpp b/src/tests/test_rng.cpp
index 96a4de4f9..cd2541921 100644
--- a/src/tests/test_rng.cpp
+++ b/src/tests/test_rng.cpp
@@ -771,6 +771,21 @@ class System_RNG_Tests final : public Test
rng.add_entropy(out_buf.data(), out_buf.size());
}
+ if constexpr(sizeof(size_t) > 4)
+ {
+ // Pass buffer with a size greater than 32bit
+ const size_t size32BitsMax = std::numeric_limits<uint32_t>::max();
+ const size_t checkSize = 1024;
+ std::vector<uint8_t> large_buf(size32BitsMax + checkSize);
+ std::memset(large_buf.data() + size32BitsMax, 0xFE, checkSize);
+
+ rng.randomize(large_buf.data(), large_buf.size());
+
+ std::vector<uint8_t> check_buf(checkSize, 0xFE);
+
+ result.confirm("System RNG failed to write after 4GB boundry", std::memcmp(large_buf.data() + size32BitsMax, check_buf.data(), checkSize) != 0);
+ }
+
return std::vector<Test::Result>{result};
}
};