File: //usr/local/openssl/man/man3/RAND_bytes.3
.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "RAND_bytes 3"
.TH RAND_bytes 3 2019-12-20 1.0.2u OpenSSL
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
RAND_bytes, RAND_pseudo_bytes \- generate random data
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\& #include <openssl/rand.h>
\&
\& int RAND_bytes(unsigned char *buf, int num);
\&
\& int RAND_pseudo_bytes(unsigned char *buf, int num);
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
\&\fBRAND_bytes()\fR puts \fBnum\fR cryptographically strong pseudo-random bytes
into \fBbuf\fR. An error occurs if the PRNG has not been seeded with
enough randomness to ensure an unpredictable byte sequence.
.PP
\&\fBRAND_pseudo_bytes()\fR puts \fBnum\fR pseudo-random bytes into \fBbuf\fR.
Pseudo-random byte sequences generated by \fBRAND_pseudo_bytes()\fR will be
unique if they are of sufficient length, but are not necessarily
unpredictable. They can be used for non-cryptographic purposes and for
certain purposes in cryptographic protocols, but usually not for key
generation etc.
.PP
The contents of \fBbuf\fR is mixed into the entropy pool before retrieving
the new pseudo-random bytes unless disabled at compile time (see FAQ).
.SH "RETURN VALUES"
.IX Header "RETURN VALUES"
\&\fBRAND_bytes()\fR returns 1 on success, 0 otherwise. The error code can be
obtained by \fBERR_get_error\fR\|(3). \fBRAND_pseudo_bytes()\fR returns 1 if the
bytes generated are cryptographically strong, 0 otherwise. Both
functions return \-1 if they are not supported by the current RAND
method.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBrand\fR\|(3), \fBERR_get_error\fR\|(3),
\&\fBRAND_add\fR\|(3)
.SH HISTORY
.IX Header "HISTORY"
\&\fBRAND_bytes()\fR is available in all versions of SSLeay and OpenSSL. It
has a return value since OpenSSL 0.9.5. \fBRAND_pseudo_bytes()\fR was added
in OpenSSL 0.9.5.