xref: /freebsd/crypto/openssl/doc/man3/RAND_set_rand_method.pod (revision f6a3b357e9be4c6423c85eff9a847163a0d307c8)
1=pod
2
3=head1 NAME
4
5RAND_set_rand_method, RAND_get_rand_method, RAND_OpenSSL - select RAND method
6
7=head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 RAND_METHOD *RAND_OpenSSL(void);
12
13 void RAND_set_rand_method(const RAND_METHOD *meth);
14
15 const RAND_METHOD *RAND_get_rand_method(void);
16
17=head1 DESCRIPTION
18
19A B<RAND_METHOD> specifies the functions that OpenSSL uses for random number
20generation.
21
22RAND_OpenSSL() returns the default B<RAND_METHOD> implementation by OpenSSL.
23This implementation ensures that the PRNG state is unique for each thread.
24
25If an B<ENGINE> is loaded that provides the RAND API, however, it will
26be used instead of the method returned by RAND_OpenSSL().
27
28RAND_set_rand_method() makes B<meth> the method for PRNG use.  If an
29ENGINE was providing the method, it will be released first.
30
31RAND_get_rand_method() returns a pointer to the current B<RAND_METHOD>.
32
33=head1 THE RAND_METHOD STRUCTURE
34
35 typedef struct rand_meth_st {
36     void (*seed)(const void *buf, int num);
37     int (*bytes)(unsigned char *buf, int num);
38     void (*cleanup)(void);
39     void (*add)(const void *buf, int num, int randomness);
40     int (*pseudorand)(unsigned char *buf, int num);
41     int (*status)(void);
42 } RAND_METHOD;
43
44The fields point to functions that are used by, in order,
45RAND_seed(), RAND_bytes(), internal RAND cleanup, RAND_add(), RAND_pseudo_rand()
46and RAND_status().
47Each pointer may be NULL if the function is not implemented.
48
49=head1 RETURN VALUES
50
51RAND_set_rand_method() returns no value. RAND_get_rand_method() and
52RAND_OpenSSL() return pointers to the respective methods.
53
54=head1 SEE ALSO
55
56L<RAND_bytes(3)>,
57L<ENGINE_by_id(3)>,
58L<RAND(7)>
59
60=head1 COPYRIGHT
61
62Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
63
64Licensed under the OpenSSL license (the "License").  You may not use
65this file except in compliance with the License.  You can obtain a copy
66in the file LICENSE in the source distribution or at
67L<https://www.openssl.org/source/license.html>.
68
69=cut
70