Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:48

0001 /*
0002  * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
0003  *
0004  * Licensed under the Apache License 2.0 (the "License").  You may not use
0005  * this file except in compliance with the License.  You can obtain a copy
0006  * in the file LICENSE in the source distribution or at
0007  * https://www.openssl.org/source/license.html
0008  */
0009 
0010 #ifndef OPENSSL_RAND_H
0011 # define OPENSSL_RAND_H
0012 # pragma once
0013 
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 #  define HEADER_RAND_H
0017 # endif
0018 
0019 # include <stdlib.h>
0020 # include <openssl/types.h>
0021 # include <openssl/e_os2.h>
0022 # include <openssl/randerr.h>
0023 # include <openssl/evp.h>
0024 
0025 #ifdef  __cplusplus
0026 extern "C" {
0027 #endif
0028 
0029 /*
0030  * Default security strength (in the sense of [NIST SP 800-90Ar1])
0031  *
0032  * NIST SP 800-90Ar1 supports the strength of the DRBG being smaller than that
0033  * of the cipher by collecting less entropy. The current DRBG implementation
0034  * does not take RAND_DRBG_STRENGTH into account and sets the strength of the
0035  * DRBG to that of the cipher.
0036  */
0037 # define RAND_DRBG_STRENGTH             256
0038 
0039 # ifndef OPENSSL_NO_DEPRECATED_3_0
0040 struct rand_meth_st {
0041     int (*seed) (const void *buf, int num);
0042     int (*bytes) (unsigned char *buf, int num);
0043     void (*cleanup) (void);
0044     int (*add) (const void *buf, int num, double randomness);
0045     int (*pseudorand) (unsigned char *buf, int num);
0046     int (*status) (void);
0047 };
0048 
0049 OSSL_DEPRECATEDIN_3_0 int RAND_set_rand_method(const RAND_METHOD *meth);
0050 OSSL_DEPRECATEDIN_3_0 const RAND_METHOD *RAND_get_rand_method(void);
0051 #  ifndef OPENSSL_NO_ENGINE
0052 OSSL_DEPRECATEDIN_3_0 int RAND_set_rand_engine(ENGINE *engine);
0053 #  endif
0054 
0055 OSSL_DEPRECATEDIN_3_0 RAND_METHOD *RAND_OpenSSL(void);
0056 # endif /* OPENSSL_NO_DEPRECATED_3_0 */
0057 
0058 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0059 #   define RAND_cleanup() while(0) continue
0060 # endif
0061 int RAND_bytes(unsigned char *buf, int num);
0062 int RAND_priv_bytes(unsigned char *buf, int num);
0063 
0064 /*
0065  * Equivalent of RAND_priv_bytes() but additionally taking an OSSL_LIB_CTX and
0066  * a strength.
0067  */
0068 int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num,
0069                        unsigned int strength);
0070 
0071 /*
0072  * Equivalent of RAND_bytes() but additionally taking an OSSL_LIB_CTX and
0073  * a strength.
0074  */
0075 int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num,
0076                   unsigned int strength);
0077 
0078 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0079 OSSL_DEPRECATEDIN_1_1_0 int RAND_pseudo_bytes(unsigned char *buf, int num);
0080 # endif
0081 
0082 EVP_RAND_CTX *RAND_get0_primary(OSSL_LIB_CTX *ctx);
0083 EVP_RAND_CTX *RAND_get0_public(OSSL_LIB_CTX *ctx);
0084 EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx);
0085 int RAND_set0_public(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand);
0086 int RAND_set0_private(OSSL_LIB_CTX *ctx, EVP_RAND_CTX *rand);
0087 
0088 int RAND_set_DRBG_type(OSSL_LIB_CTX *ctx, const char *drbg, const char *propq,
0089                        const char *cipher, const char *digest);
0090 int RAND_set_seed_source_type(OSSL_LIB_CTX *ctx, const char *seed,
0091                               const char *propq);
0092 
0093 void RAND_seed(const void *buf, int num);
0094 void RAND_keep_random_devices_open(int keep);
0095 
0096 # if defined(__ANDROID__) && defined(__NDK_FPABI__)
0097 __NDK_FPABI__   /* __attribute__((pcs("aapcs"))) on ARM */
0098 # endif
0099 void RAND_add(const void *buf, int num, double randomness);
0100 int RAND_load_file(const char *file, long max_bytes);
0101 int RAND_write_file(const char *file);
0102 const char *RAND_file_name(char *file, size_t num);
0103 int RAND_status(void);
0104 
0105 # ifndef OPENSSL_NO_EGD
0106 int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes);
0107 int RAND_egd(const char *path);
0108 int RAND_egd_bytes(const char *path, int bytes);
0109 # endif
0110 
0111 int RAND_poll(void);
0112 
0113 # if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
0114 /* application has to include <windows.h> in order to use these */
0115 #  ifndef OPENSSL_NO_DEPRECATED_1_1_0
0116 OSSL_DEPRECATEDIN_1_1_0 void RAND_screen(void);
0117 OSSL_DEPRECATEDIN_1_1_0 int RAND_event(UINT, WPARAM, LPARAM);
0118 #  endif
0119 # endif
0120 
0121 #ifdef  __cplusplus
0122 }
0123 #endif
0124 
0125 #endif