]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/rand.h
Rename OPENSSL_CTX prefix to OSSL_LIB_CTX
[thirdparty/openssl.git] / include / openssl / rand.h
CommitLineData
21dcbebc 1/*
33388b44 2 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
d02b48c6 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
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
ae4186b0
DMSP
10#ifndef OPENSSL_RAND_H
11# define OPENSSL_RAND_H
d86167ec
DMSP
12# pragma once
13
14# include <openssl/macros.h>
936c2b9e 15# ifndef OPENSSL_NO_DEPRECATED_3_0
d86167ec
DMSP
16# define HEADER_RAND_H
17# endif
d02b48c6 18
0f113f3e 19# include <stdlib.h>
50cd4768 20# include <openssl/types.h>
0f113f3e 21# include <openssl/e_os2.h>
52df25cf 22# include <openssl/randerr.h>
7d615e21 23# include <openssl/evp.h>
fb96d9d9 24
d02b48c6
RE
25#ifdef __cplusplus
26extern "C" {
27#endif
28
7d615e21
P
29/*
30 * Default security strength (in the sense of [NIST SP 800-90Ar1])
31 *
32 * NIST SP 800-90Ar1 supports the strength of the DRBG being smaller than that
33 * of the cipher by collecting less entropy. The current DRBG implementation
34 * does not take RAND_DRBG_STRENGTH into account and sets the strength of the
35 * DRBG to that of the cipher.
36 */
37# define RAND_DRBG_STRENGTH 256
38
0f113f3e
MC
39struct rand_meth_st {
40 int (*seed) (const void *buf, int num);
41 int (*bytes) (unsigned char *buf, int num);
42 void (*cleanup) (void);
f367ac2b 43 int (*add) (const void *buf, int num, double randomness);
0f113f3e
MC
44 int (*pseudorand) (unsigned char *buf, int num);
45 int (*status) (void);
46};
47
cb78486d
GT
48int RAND_set_rand_method(const RAND_METHOD *meth);
49const RAND_METHOD *RAND_get_rand_method(void);
0f113f3e 50# ifndef OPENSSL_NO_ENGINE
cb78486d 51int RAND_set_rand_engine(ENGINE *engine);
0f113f3e 52# endif
75e2c877 53
b0700d2c 54RAND_METHOD *RAND_OpenSSL(void);
75e2c877 55
00db8c60 56# ifndef OPENSSL_NO_DEPRECATED_1_1_0
12fb8c3d
RS
57# define RAND_cleanup() while(0) continue
58# endif
0f113f3e 59int RAND_bytes(unsigned char *buf, int num);
ddc6a5c8 60int RAND_priv_bytes(unsigned char *buf, int num);
993ebac9 61
b4250010
DMSP
62/* Equivalent of RAND_priv_bytes() but additionally taking an OSSL_LIB_CTX */
63int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, int num);
993ebac9 64
b4250010
DMSP
65/* Equivalent of RAND_bytes() but additionally taking an OSSL_LIB_CTX */
66int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, int num);
993ebac9 67
98186eb4 68DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))
75e2c877 69
b4250010
DMSP
70EVP_RAND_CTX *RAND_get0_primary(OSSL_LIB_CTX *ctx);
71EVP_RAND_CTX *RAND_get0_public(OSSL_LIB_CTX *ctx);
72EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx);
7d615e21 73
0f113f3e 74void RAND_seed(const void *buf, int num);
c7504aeb 75void RAND_keep_random_devices_open(int keep);
75e2c877 76
12fb8c3d 77# if defined(__ANDROID__) && defined(__NDK_FPABI__)
dd6b2706 78__NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */
12fb8c3d 79# endif
f367ac2b 80void RAND_add(const void *buf, int num, double randomness);
0f113f3e
MC
81int RAND_load_file(const char *file, long max_bytes);
82int RAND_write_file(const char *file);
83const char *RAND_file_name(char *file, size_t num);
4ec2d4d2 84int RAND_status(void);
75e2c877 85
0423f812 86# ifndef OPENSSL_NO_EGD
6343829a 87int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
4ec2d4d2 88int RAND_egd(const char *path);
0f113f3e 89int RAND_egd_bytes(const char *path, int bytes);
0423f812 90# endif
75e2c877 91
c0722725 92int RAND_poll(void);
82271cee 93
12fb8c3d 94# if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
f1f5ee17 95/* application has to include <windows.h> in order to use these */
73241290
JY
96DEPRECATEDIN_1_1_0(void RAND_screen(void))
97DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM))
12fb8c3d 98# endif
73241290 99
12fb8c3d 100#ifdef __cplusplus
65e81670 101}
12fb8c3d
RS
102#endif
103
d02b48c6 104#endif