rand.h revision e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5
1/* Copyright (c) 2014, Google Inc.
2 *
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15#ifndef OPENSSL_HEADER_RAND_H
16#define OPENSSL_HEADER_RAND_H
17
18#include <openssl/base.h>
19
20#if defined(__cplusplus)
21extern "C" {
22#endif
23
24
25/* Random number generation. */
26
27
28/* RAND_bytes writes |len| bytes of random data to |buf| and returns one. */
29OPENSSL_EXPORT int RAND_bytes(uint8_t *buf, size_t len);
30
31/* RAND_cleanup frees any resources used by the RNG. This is not safe if other
32 * threads might still be calling |RAND_bytes|. */
33OPENSSL_EXPORT void RAND_cleanup(void);
34
35
36/* Deprecated functions */
37
38/* RAND_pseudo_bytes is a wrapper around |RAND_bytes|. */
39OPENSSL_EXPORT int RAND_pseudo_bytes(uint8_t *buf, size_t len);
40
41/* RAND_seed does nothing. */
42OPENSSL_EXPORT void RAND_seed(const void *buf, int num);
43
44/* RAND_add does nothing. */
45OPENSSL_EXPORT void RAND_add(const void *buf, int num, double entropy);
46
47/* RAND_poll returns one. */
48OPENSSL_EXPORT int RAND_poll(void);
49
50/* RAND_status returns one. */
51OPENSSL_EXPORT int RAND_status(void);
52
53
54#if defined(__cplusplus)
55}  /* extern C */
56#endif
57
58#endif  /* OPENSSL_HEADER_RAND_H */
59