mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-22 21:54:59 -07:00
b155fdf8c9
This allows runtime detection as to if `rand_bytes` is supported or not, and lets us enable the test-case on all of the supported targets.
17 lines
430 B
Odin
17 lines
430 B
Odin
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 {
|
|
msg := darwin.CFStringCopyToOdinString(darwin.SecCopyErrorMessageString(res))
|
|
panic(fmt.tprintf("crypto/rand_bytes: SecRandomCopyBytes returned non-zero result: %v %s", res, msg))
|
|
}
|
|
}
|
|
|
|
_has_rand_bytes :: proc () -> bool {
|
|
return true
|
|
}
|