]> git.ipfire.org Git - thirdparty/openssl.git/blob - include/openssl/rand.h
Copyright consolidation 03/10
[thirdparty/openssl.git] / include / openssl / rand.h
1 /*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10 #ifndef HEADER_RAND_H
11 # define HEADER_RAND_H
12
13 # include <stdlib.h>
14 # include <openssl/ossl_typ.h>
15 # include <openssl/e_os2.h>
16
17 # if defined(OPENSSL_SYS_WINDOWS)
18 # include <windows.h>
19 # endif
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /* Already defined in ossl_typ.h */
26 /* typedef struct rand_meth_st RAND_METHOD; */
27
28 struct rand_meth_st {
29 int (*seed) (const void *buf, int num);
30 int (*bytes) (unsigned char *buf, int num);
31 void (*cleanup) (void);
32 int (*add) (const void *buf, int num, double entropy);
33 int (*pseudorand) (unsigned char *buf, int num);
34 int (*status) (void);
35 };
36
37 # ifdef BN_DEBUG
38 extern int rand_predictable;
39 # endif
40
41 int RAND_set_rand_method(const RAND_METHOD *meth);
42 const RAND_METHOD *RAND_get_rand_method(void);
43 # ifndef OPENSSL_NO_ENGINE
44 int RAND_set_rand_engine(ENGINE *engine);
45 # endif
46 RAND_METHOD *RAND_OpenSSL(void);
47 #if OPENSSL_API_COMPAT < 0x10100000L
48 # define RAND_cleanup() while(0) continue
49 #endif
50 int RAND_bytes(unsigned char *buf, int num);
51 DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
52 void RAND_seed(const void *buf, int num);
53 #if defined(__ANDROID__) && defined(__NDK_FPABI__)
54 __NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
55 #endif
56 void RAND_add(const void *buf, int num, double entropy);
57 int RAND_load_file(const char *file, long max_bytes);
58 int RAND_write_file(const char *file);
59 const char *RAND_file_name(char *file, size_t num);
60 int RAND_status(void);
61 # ifndef OPENSSL_NO_EGD
62 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
63 int RAND_egd(const char *path);
64 int RAND_egd_bytes(const char *path, int bytes);
65 # endif
66 int RAND_poll(void);
67
68 # if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
69
70 void RAND_screen(void);
71 int RAND_event(UINT, WPARAM, LPARAM);
72
73 # endif
74
75 /* BEGIN ERROR CODES */
76 /*
77 * The following lines are auto generated by the script mkerr.pl. Any changes
78 * made after this point may be overwritten when the script is next run.
79 */
80 void ERR_load_RAND_strings(void);
81
82 /* Error codes for the RAND functions. */
83
84 /* Function codes. */
85 # define RAND_F_FIPS_RAND 102
86 # define RAND_F_FIPS_RAND_SET_DT 103
87 # define RAND_F_FIPS_SET_PRNG_SEED 104
88 # define RAND_F_FIPS_SET_TEST_MODE 105
89 # define RAND_F_FIPS_X931_SET_DT 106
90 # define RAND_F_RAND_BYTES 100
91 # define RAND_F_RAND_GET_RAND_METHOD 101
92
93 /* Reason codes. */
94 # define RAND_R_NOT_IN_TEST_MODE 101
95 # define RAND_R_NO_KEY_SET 102
96 # define RAND_R_PRNG_ERROR 103
97 # define RAND_R_PRNG_KEYED 104
98 # define RAND_R_PRNG_NOT_SEEDED 100
99 # define RAND_R_PRNG_SEED_MUST_NOT_MATCH_KEY 105
100 # define RAND_R_PRNG_STUCK 106
101
102 #ifdef __cplusplus
103 }
104 #endif
105 #endif