Document RAND library.
[openssl.git] / doc / crypto / RAND_bytes.pod
1 =pod
2
3 =head1 NAME
4
5 RAND_bytes, RAND_pseudo_bytes - Generate random data
6
7 =head1 SYNOPSIS
8
9  #include <openssl/rand.h>
10
11  int RAND_bytes(unsigned char *buf, int num);
12
13  int RAND_pseudo_bytes(unsigned char *buf, int num);
14
15 =head1 DESCRIPTION
16
17 RAND_bytes() puts B<num> random bytes into B<buf>. An error occurs if
18 the PRNG has not been seeded with enough randomness.
19
20 RAND_pseudo_bytes() puts B<num> pseudo-random bytes into B<buf>. These
21 bytes are guaranteed to be unique, but not unpredictable. They can be
22 used for non-cryptographic purposes and for certain purposes in
23 cryptographic protocols, but not for key generation etc.
24
25 =head1 RETURN VALUES
26
27 RAND_bytes() returns 1 on success, 0 otherwise. The error code can be
28 obtained by ERR_get_error(3). RAND_pseudo_bytes() returns 1 if the
29 bytes generated are cryptographically strong, 0 otherwise. Both
30 functions return -1 if they are not supported by the current RAND
31 method.
32
33 =head1 SEE ALSO
34
35 rand(3), err(3), RAND_add(3)
36
37 =head1 HISTORY
38
39 RAND_bytes() is available in all versions of SSLeay and OpenSSL.  It
40 has a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added
41 in OpenSSL 0.9.5.
42
43 =cut