core/crypto: Add a HAS_RAND_BYTES constant

This commit is contained in:
Yawning Angel
2024-04-23 11:47:43 +09:00
parent 902e877467
commit a6eb64df6c
8 changed files with 24 additions and 31 deletions
+3 -4
View File
@@ -5,6 +5,9 @@ import "core:fmt"
import CF "core:sys/darwin/CoreFoundation"
import Sec "core:sys/darwin/Security"
HAS_RAND_BYTES :: true
@(private)
_rand_bytes :: proc(dst: []byte) {
err := Sec.RandomCopyBytes(count=len(dst), bytes=raw_data(dst))
if err != .Success {
@@ -12,7 +15,3 @@ _rand_bytes :: proc(dst: []byte) {
panic(fmt.tprintf("crypto/rand_bytes: SecRandomCopyBytes returned non-zero result: %v %s", err, msg))
}
}
_has_rand_bytes :: proc() -> bool {
return true
}