aboutsummaryrefslogtreecommitdiff
path: root/core/crypto/rand_darwin.odin
blob: df474bc4c765f4b2149debf8286f45575e307e15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package crypto

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 {
		msg := CF.StringCopyToOdinString(Sec.CopyErrorMessageString(err))
		fmt.panicf("crypto/rand_bytes: SecRandomCopyBytes returned non-zero result: %v %s", err, msg)
	}
}