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