librandombytes

NAME

randombytes - fill a buffer with random data

SYNOPSIS

#include <randombytes.h>

unsigned char x[xbytes];

randombytes(x,xbytes);

Link with -lrandombytes.

DESCRIPTION

randombytes sets x[0], x[1], ..., x[xbytes-1] to random bytes of data.

Randomness APIs vary in three major ways. randombytes is designed in each way to simplify callers:

There are some programs that try to close all file descriptors. These programs must limit their library use to libraries that promise not to keep file descriptors open. In particular, these programs must not use randombytes (which keeps a file descriptor open on some systems) or other libraries calling randombytes. `

LINK DETAILS

Currently -lrandombytes is a frontend symbolic link to either -lrandombytes-kernel or -lrandombytes-openssl as a backend library. To simplify system-wide replacement of the backend library, typical applications should dynamically link to -lrandombytes rather than to -lrandombytes-kernel or -lrandombytes-openssl.

Applications that link statically to -lrandombytes also need -lcrypto if -lrandombytes is -lrandombytes-openssl.

Currently randombytes is a macro, where the function actually linked is randombytes_internal_void_voidstar_longlong.

HISTORY

The randombytes API was introduced in 2008 as part of the SUPERCOP benchmarking framework for cryptographic software.

Similar previous APIs include RAND_bytes and arc4random_buf, but RAND_bytes was allowed to return failures and arc4random_buf was using the broken RC4 stream cipher.

SEE ALSO

getrandom(2), getentropy(2), rand(3), random(3), arc4random(3), urandom(4)


Version: This is version 2023.01.16 of the "API" web page.