xref: /freebsd/crypto/openssl/doc/man3/RAND_set_rand_method.pod (revision a90b9d0159070121c221b966469c3e36d912bf82)
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
11The following functions have been deprecated since OpenSSL 3.0, and can be
12hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
13see L<openssl_user_macros(7)>:
14
15 RAND_METHOD *RAND_OpenSSL(void);
16
17 int RAND_set_rand_method(const RAND_METHOD *meth);
18
19 const RAND_METHOD *RAND_get_rand_method(void);
20
21=head1 DESCRIPTION
22
23All of the functions described on this page are deprecated.
24Applications should instead use L<RAND_set_DRBG_type(3)>,
25L<EVP_RAND(3)> and L<EVP_RAND(7)>.
26
27A B<RAND_METHOD> specifies the functions that OpenSSL uses for random number
28generation.
29
30RAND_OpenSSL() returns the default B<RAND_METHOD> implementation by OpenSSL.
31This implementation ensures that the PRNG state is unique for each thread.
32
33If an B<ENGINE> is loaded that provides the RAND API, however, it will
34be used instead of the method returned by RAND_OpenSSL().  This is deprecated
35in OpenSSL 3.0.
36
37RAND_set_rand_method() makes B<meth> the method for PRNG use.  If an
38ENGINE was providing the method, it will be released first.
39
40RAND_get_rand_method() returns a pointer to the current B<RAND_METHOD>.
41
42=head1 THE RAND_METHOD STRUCTURE
43
44 typedef struct rand_meth_st {
45     int (*seed)(const void *buf, int num);
46     int (*bytes)(unsigned char *buf, int num);
47     void (*cleanup)(void);
48     int (*add)(const void *buf, int num, double entropy);
49     int (*pseudorand)(unsigned char *buf, int num);
50     int (*status)(void);
51 } RAND_METHOD;
52
53The fields point to functions that are used by, in order,
54RAND_seed(), RAND_bytes(), internal RAND cleanup, RAND_add(), RAND_pseudo_rand()
55and RAND_status().
56Each pointer may be NULL if the function is not implemented.
57
58=head1 RETURN VALUES
59
60RAND_set_rand_method() returns 1 on success and 0 on failure.
61RAND_get_rand_method() and RAND_OpenSSL() return pointers to the respective
62methods.
63
64=head1 SEE ALSO
65
66L<EVP_RAND(3)>,
67L<RAND_set_DRBG_type(3)>,
68L<RAND_bytes(3)>,
69L<ENGINE_by_id(3)>,
70L<EVP_RAND(7)>,
71L<RAND(7)>
72
73=head1 HISTORY
74
75All of these functions were deprecated in OpenSSL 3.0.
76
77=head1 COPYRIGHT
78
79Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
80
81Licensed under the Apache License 2.0 (the "License").  You may not use
82this file except in compliance with the License.  You can obtain a copy
83in the file LICENSE in the source distribution or at
84L<https://www.openssl.org/source/license.html>.
85
86=cut
87