#include <libkern/crypto/rand.h>
libkern/crypto/rand.h
typedefcrypto_random_ctx_t
A handle to a random generator suitable for use with
crypto_random_generate.
typedef void *crypto_random_ctx_t
macroCRYPTO_RANDOM_MAX_CTX_SIZE
The maximum size (in bytes) of a random generator.
#define CRYPTO_RANDOM_MAX_CTX_SIZE ((size_t)256)
typedefcrypto_random_generate_fn_t
typedef void (*)(crypto_random_ctx_t, void *, size_t) crypto_random_generate_fn_t;
typedefcrypto_random_uniform_fn_t
typedef void (*)(crypto_random_ctx_t, uint64_t, uint64_t *) crypto_random_uniform_fn_t;
typedefcrypto_random_kmem_ctx_size_fn_t
typedef size_t (*crypto_random_kmem_ctx_size_fn_t)(void)
typedefcrypto_random_kmem_init_fn_t
typedef void (*)(crypto_random_ctx_t) crypto_random_kmem_init_fn_t;
functionrandom_buf
int random_buf(void *buf, size_t buflen)
▾
claude-fable-5, 2026-08-24 · not from Apple sources · verified against xnu libkern/crypto/corecrypto_rand.c
Fills buf with buflen bytes from the kernel's cryptographic random number generator (corecrypto cc_rand_generate). Returns 0 on success or a nonzero corecrypto error status. Suitable for keys and other security-sensitive material; see also read_random.