]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/rand.h
Fix reseeding issues of the public RAND_DRBG
[thirdparty/openssl.git] / include / openssl / rand.h
CommitLineData
21dcbebc
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
d02b48c6 3 *
21dcbebc
RS
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
d02b48c6
RE
8 */
9
10#ifndef HEADER_RAND_H
0f113f3e 11# define HEADER_RAND_H
d02b48c6 12
0f113f3e
MC
13# include <stdlib.h>
14# include <openssl/ossl_typ.h>
15# include <openssl/e_os2.h>
52df25cf 16# include <openssl/randerr.h>
fb96d9d9 17
d02b48c6
RE
18#ifdef __cplusplus
19extern "C" {
20#endif
21
0f113f3e
MC
22struct rand_meth_st {
23 int (*seed) (const void *buf, int num);
24 int (*bytes) (unsigned char *buf, int num);
25 void (*cleanup) (void);
f367ac2b 26 int (*add) (const void *buf, int num, double randomness);
0f113f3e
MC
27 int (*pseudorand) (unsigned char *buf, int num);
28 int (*status) (void);
29};
30
cb78486d
GT
31int RAND_set_rand_method(const RAND_METHOD *meth);
32const RAND_METHOD *RAND_get_rand_method(void);
0f113f3e 33# ifndef OPENSSL_NO_ENGINE
cb78486d 34int RAND_set_rand_engine(ENGINE *engine);
0f113f3e 35# endif
75e2c877 36
b0700d2c 37RAND_METHOD *RAND_OpenSSL(void);
75e2c877 38
12fb8c3d
RS
39# if OPENSSL_API_COMPAT < 0x10100000L
40# define RAND_cleanup() while(0) continue
41# endif
0f113f3e 42int RAND_bytes(unsigned char *buf, int num);
ddc6a5c8 43int RAND_priv_bytes(unsigned char *buf, int num);
98186eb4 44DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
75e2c877 45
0f113f3e 46void RAND_seed(const void *buf, int num);
75e2c877 47
12fb8c3d 48# if defined(__ANDROID__) && defined(__NDK_FPABI__)
449e3f26 49__NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
12fb8c3d 50# endif
75e2c877 51
f367ac2b 52void RAND_add(const void *buf, int num, double randomness);
0f113f3e
MC
53int RAND_load_file(const char *file, long max_bytes);
54int RAND_write_file(const char *file);
55const char *RAND_file_name(char *file, size_t num);
4ec2d4d2 56int RAND_status(void);
75e2c877 57
0423f812 58# ifndef OPENSSL_NO_EGD
6343829a 59int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
4ec2d4d2 60int RAND_egd(const char *path);
0f113f3e 61int RAND_egd_bytes(const char *path, int bytes);
0423f812 62# endif
75e2c877 63
4871fa49 64typedef void (*RAND_poll_cb)(void *arg,
75e2c877 65 const void *buf, int num, double randomness);
c0722725 66int RAND_poll(void);
82271cee 67
12fb8c3d 68# if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
f1f5ee17 69/* application has to include <windows.h> in order to use these */
73241290
JY
70DEPRECATEDIN_1_1_0(void RAND_screen(void))
71DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))
12fb8c3d 72# endif
73241290 73
69588edb 74int ERR_load_RAND_strings(void);
eb952088 75
12fb8c3d 76#ifdef __cplusplus
65e81670 77}
12fb8c3d
RS
78#endif
79
d02b48c6 80#endif