aboutsummaryrefslogtreecommitdiff
path: root/lib/std/crypto.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/crypto.zig')
-rw-r--r--lib/std/crypto.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig
index 6eb934473f..e3581cde96 100644
--- a/lib/std/crypto.zig
+++ b/lib/std/crypto.zig
@@ -134,8 +134,10 @@ pub const nacl = struct {
pub const utils = @import("crypto/utils.zig");
+/// This is a thread-local, cryptographically secure pseudo random number generator.
+pub const random = &@import("crypto/tlcsprng.zig").interface;
+
const std = @import("std.zig");
-pub const randomBytes = std.os.getrandom;
test "crypto" {
inline for (std.meta.declarations(@This())) |decl| {
@@ -178,6 +180,13 @@ test "crypto" {
_ = @import("crypto/25519/ristretto255.zig");
}
+test "CSPRNG" {
+ const a = random.int(u64);
+ const b = random.int(u64);
+ const c = random.int(u64);
+ std.testing.expect(a ^ b ^ c != 0);
+}
+
test "issue #4532: no index out of bounds" {
const types = [_]type{
hash.Md5,