File: //usr/local/openssl/man/man3/RAND_get_rand_method.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_set_rand_method 3"
.TH RAND_set_rand_method 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_set_rand_method, RAND_get_rand_method, RAND_SSLeay \- select RAND method
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\& #include <openssl/rand.h>
\&
\& void RAND_set_rand_method(const RAND_METHOD *meth);
\&
\& const RAND_METHOD *RAND_get_rand_method(void);
\&
\& RAND_METHOD *RAND_SSLeay(void);
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
A \fBRAND_METHOD\fR specifies the functions that OpenSSL uses for random number
generation. By modifying the method, alternative implementations such as
hardware RNGs may be used. IMPORTANT: See the NOTES section for important
information about how these RAND API functions are affected by the use of
\&\fBENGINE\fR API calls.
.PP
Initially, the default RAND_METHOD is the OpenSSL internal implementation, as
returned by \fBRAND_SSLeay()\fR.
.PP
\&\fBRAND_set_default_method()\fR makes \fBmeth\fR the method for PRNG use. \fBNB\fR: This is
true only whilst no ENGINE has been set as a default for RAND, so this function
is no longer recommended.
.PP
\&\fBRAND_get_default_method()\fR returns a pointer to the current RAND_METHOD.
However, the meaningfulness of this result is dependent on whether the ENGINE
API is being used, so this function is no longer recommended.
.SH "THE RAND_METHOD STRUCTURE"
.IX Header "THE RAND_METHOD STRUCTURE"
.Vb 9
\& typedef struct rand_meth_st
\& {
\& void (*seed)(const void *buf, int num);
\& int (*bytes)(unsigned char *buf, int num);
\& void (*cleanup)(void);
\& void (*add)(const void *buf, int num, int entropy);
\& int (*pseudorand)(unsigned char *buf, int num);
\& int (*status)(void);
\& } RAND_METHOD;
.Ve
.PP
The components point to the implementation of \fBRAND_seed()\fR,
\&\fBRAND_bytes()\fR, \fBRAND_cleanup()\fR, \fBRAND_add()\fR, \fBRAND_pseudo_rand()\fR
and \fBRAND_status()\fR.
Each component may be NULL if the function is not implemented.
.SH "RETURN VALUES"
.IX Header "RETURN VALUES"
\&\fBRAND_set_rand_method()\fR returns no value. \fBRAND_get_rand_method()\fR and
\&\fBRAND_SSLeay()\fR return pointers to the respective methods.
.SH NOTES
.IX Header "NOTES"
As of version 0.9.7, RAND_METHOD implementations are grouped together with other
algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in \fBENGINE\fR modules. If a
default ENGINE is specified for RAND functionality using an ENGINE API function,
that will override any RAND defaults set using the RAND API (ie.
\&\fBRAND_set_rand_method()\fR). For this reason, the ENGINE API is the recommended way
to control default implementations for use in RAND and other cryptographic
algorithms.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBrand\fR\|(3), \fBengine\fR\|(3)
.SH HISTORY
.IX Header "HISTORY"
\&\fBRAND_set_rand_method()\fR, \fBRAND_get_rand_method()\fR and \fBRAND_SSLeay()\fR are
available in all versions of OpenSSL.
.PP
In the engine version of version 0.9.6, \fBRAND_set_rand_method()\fR was altered to
take an ENGINE pointer as its argument. As of version 0.9.7, that has been
reverted as the ENGINE API transparently overrides RAND defaults if used,
otherwise RAND API functions work as before. \fBRAND_set_rand_engine()\fR was also
introduced in version 0.9.7.