use Security.framework with SecRandomCopyBytes for rand_bytes on darwin
This commit is contained in:
1 parent
3bc172c70b
commit
91cf0826c1
3 files changed
+36
-1
No files matched your search
@@ -0,0 +1,11 @@
|
||||
package crypto
|
||||
|
||||
import "core:fmt"
|
||||
import "core:sys/darwin"
|
||||
|
||||
_rand_bytes :: proc(dst: []byte) {
|
||||
res := darwin.SecRandomCopyBytes(count=len(dst), bytes=raw_data(dst))
|
||||
if res != .Success {
|
||||
panic(fmt.tprintf("crypto/rand_bytes: SecRandomCopyBytes returned non-zero result: %v", res))
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//+build freebsd, openbsd, darwin
|
||||
//+build freebsd, openbsd
|
||||
package crypto
|
||||
|
||||
foreign import libc "system:c"
|
||||
|
||||
Reference in new issue
Block a user