blob: 5a84a898f90ee19aea0a15f664b1072e02c261b8 [file] [log] [blame]
Adam Langley95c29f32014-06-20 12:00:00 -07001/* 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/* RAND_bytes writes |len| bytes of random data to |buf|. It returns one on
26 * success and zero on otherwise. */
Adam Langleyeb7d2ed2014-07-30 16:02:14 -070027OPENSSL_EXPORT int RAND_bytes(uint8_t *buf, size_t len);
Adam Langley95c29f32014-06-20 12:00:00 -070028
29/* RAND_cleanup frees any resources used by the RNG. This is not safe if other
30 * threads might still be calling |RAND_bytes|. */
David Benjaminc44d2f42014-08-20 16:24:00 -040031OPENSSL_EXPORT void RAND_cleanup(void);
Adam Langley95c29f32014-06-20 12:00:00 -070032
33
34/* Deprecated functions */
35
36/* RAND_pseudo_bytes is a wrapper around |RAND_bytes|. */
Adam Langleyeb7d2ed2014-07-30 16:02:14 -070037OPENSSL_EXPORT int RAND_pseudo_bytes(uint8_t *buf, size_t len);
Adam Langley95c29f32014-06-20 12:00:00 -070038
39/* RAND_seed does nothing. */
Adam Langleyeb7d2ed2014-07-30 16:02:14 -070040OPENSSL_EXPORT void RAND_seed(const void *buf, int num);
Adam Langley95c29f32014-06-20 12:00:00 -070041
42/* RAND_add does nothing. */
Adam Langleyeb7d2ed2014-07-30 16:02:14 -070043OPENSSL_EXPORT void RAND_add(const void *buf, int num, double entropy);
Adam Langley95c29f32014-06-20 12:00:00 -070044
45/* RAND_poll returns one. */
Adam Langleyeb7d2ed2014-07-30 16:02:14 -070046OPENSSL_EXPORT int RAND_poll(void);
Adam Langley95c29f32014-06-20 12:00:00 -070047
48
49#if defined(__cplusplus)
50} /* extern C */
51#endif
52
53#endif /* OPENSSL_HEADER_RAND_H */