]> git.ipfire.org Git - thirdparty/openssl.git/blob - doc/crypto/RAND_set_rand_method.pod
Add copyright to manpages
[thirdparty/openssl.git] / doc / crypto / RAND_set_rand_method.pod
1 =pod
2
3 =head1 NAME
4
5 RAND_set_rand_method, RAND_get_rand_method, RAND_OpenSSL - select RAND method
6
7 =head1 SYNOPSIS
8
9 #include <openssl/rand.h>
10
11 void RAND_set_rand_method(const RAND_METHOD *meth);
12
13 const RAND_METHOD *RAND_get_rand_method(void);
14
15 RAND_METHOD *RAND_OpenSSL(void);
16
17 =head1 DESCRIPTION
18
19 A B<RAND_METHOD> specifies the functions that OpenSSL uses for random number
20 generation. By modifying the method, alternative implementations such as
21 hardware RNGs may be used. IMPORTANT: See the NOTES section for important
22 information about how these RAND API functions are affected by the use of
23 B<ENGINE> API calls.
24
25 Initially, the default RAND_METHOD is the OpenSSL internal implementation, as
26 returned by RAND_OpenSSL().
27
28 RAND_set_default_method() makes B<meth> the method for PRNG use. B<NB>: This is
29 true only whilst no ENGINE has been set as a default for RAND, so this function
30 is no longer recommended.
31
32 RAND_get_default_method() returns a pointer to the current RAND_METHOD.
33 However, the meaningfulness of this result is dependent on whether the ENGINE
34 API is being used, so this function is no longer recommended.
35
36 =head1 THE RAND_METHOD STRUCTURE
37
38 typedef struct rand_meth_st
39 {
40 void (*seed)(const void *buf, int num);
41 int (*bytes)(unsigned char *buf, int num);
42 void (*cleanup)(void);
43 void (*add)(const void *buf, int num, int entropy);
44 int (*pseudorand)(unsigned char *buf, int num);
45 int (*status)(void);
46 } RAND_METHOD;
47
48 The components point to method implementations used by (or called by), in order,
49 RAND_seed(), RAND_bytes(), internal RAND cleanup, RAND_add(), RAND_pseudo_rand()
50 and RAND_status().
51 Each component may be NULL if the function is not implemented.
52
53 =head1 RETURN VALUES
54
55 RAND_set_rand_method() returns no value. RAND_get_rand_method() and
56 RAND_OpenSSL() return pointers to the respective methods.
57
58 =head1 NOTES
59
60 RAND_METHOD implementations are grouped together with other
61 algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
62 default ENGINE is specified for RAND functionality using an ENGINE API function,
63 that will override any RAND defaults set using the RAND API (ie.
64 RAND_set_rand_method()). For this reason, the ENGINE API is the recommended way
65 to control default implementations for use in RAND and other cryptographic
66 algorithms.
67
68 =head1 SEE ALSO
69
70 L<rand(3)>, L<engine(3)>
71
72 =cut
73
74 =head1 COPYRIGHT
75
76 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
77
78 Licensed under the OpenSSL license (the "License"). You may not use
79 this file except in compliance with the License. You can obtain a copy
80 in the file LICENSE in the source distribution or at
81 L<https://www.openssl.org/source/license.html>.
82
83 =cut