1b077aed3SPierre Pronchery=pod 2b077aed3SPierre Pronchery 3b077aed3SPierre Pronchery=head1 NAME 4b077aed3SPierre Pronchery 5b077aed3SPierre ProncheryEVP_RAND, EVP_RAND_fetch, EVP_RAND_free, EVP_RAND_up_ref, EVP_RAND_CTX, 6b077aed3SPierre ProncheryEVP_RAND_CTX_new, EVP_RAND_CTX_free, EVP_RAND_instantiate, 7b077aed3SPierre ProncheryEVP_RAND_uninstantiate, EVP_RAND_generate, EVP_RAND_reseed, EVP_RAND_nonce, 8b077aed3SPierre ProncheryEVP_RAND_enable_locking, EVP_RAND_verify_zeroization, EVP_RAND_get_strength, 9b077aed3SPierre ProncheryEVP_RAND_get_state, 10b077aed3SPierre ProncheryEVP_RAND_get0_provider, EVP_RAND_CTX_get0_rand, EVP_RAND_is_a, 11b077aed3SPierre ProncheryEVP_RAND_get0_name, EVP_RAND_names_do_all, 12b077aed3SPierre ProncheryEVP_RAND_get0_description, 13b077aed3SPierre ProncheryEVP_RAND_CTX_get_params, 14b077aed3SPierre ProncheryEVP_RAND_CTX_set_params, EVP_RAND_do_all_provided, EVP_RAND_get_params, 15b077aed3SPierre ProncheryEVP_RAND_gettable_ctx_params, EVP_RAND_settable_ctx_params, 16b077aed3SPierre ProncheryEVP_RAND_CTX_gettable_params, EVP_RAND_CTX_settable_params, 17b077aed3SPierre ProncheryEVP_RAND_gettable_params, EVP_RAND_STATE_UNINITIALISED, EVP_RAND_STATE_READY, 18b077aed3SPierre ProncheryEVP_RAND_STATE_ERROR - EVP RAND routines 19b077aed3SPierre Pronchery 20b077aed3SPierre Pronchery=head1 SYNOPSIS 21b077aed3SPierre Pronchery 22b077aed3SPierre Pronchery #include <openssl/evp.h> 23b077aed3SPierre Pronchery 24b077aed3SPierre Pronchery typedef struct evp_rand_st EVP_RAND; 25b077aed3SPierre Pronchery typedef struct evp_rand_ctx_st EVP_RAND_CTX; 26b077aed3SPierre Pronchery 27b077aed3SPierre Pronchery EVP_RAND *EVP_RAND_fetch(OSSL_LIB_CTX *libctx, const char *algorithm, 28b077aed3SPierre Pronchery const char *properties); 29b077aed3SPierre Pronchery int EVP_RAND_up_ref(EVP_RAND *rand); 30b077aed3SPierre Pronchery void EVP_RAND_free(EVP_RAND *rand); 31b077aed3SPierre Pronchery EVP_RAND_CTX *EVP_RAND_CTX_new(EVP_RAND *rand, EVP_RAND_CTX *parent); 32b077aed3SPierre Pronchery void EVP_RAND_CTX_free(EVP_RAND_CTX *ctx); 33b077aed3SPierre Pronchery EVP_RAND *EVP_RAND_CTX_get0_rand(EVP_RAND_CTX *ctx); 34b077aed3SPierre Pronchery int EVP_RAND_get_params(EVP_RAND *rand, OSSL_PARAM params[]); 35b077aed3SPierre Pronchery int EVP_RAND_CTX_get_params(EVP_RAND_CTX *ctx, OSSL_PARAM params[]); 36b077aed3SPierre Pronchery int EVP_RAND_CTX_set_params(EVP_RAND_CTX *ctx, const OSSL_PARAM params[]); 37b077aed3SPierre Pronchery const OSSL_PARAM *EVP_RAND_gettable_params(const EVP_RAND *rand); 38b077aed3SPierre Pronchery const OSSL_PARAM *EVP_RAND_gettable_ctx_params(const EVP_RAND *rand); 39b077aed3SPierre Pronchery const OSSL_PARAM *EVP_RAND_settable_ctx_params(const EVP_RAND *rand); 40b077aed3SPierre Pronchery const OSSL_PARAM *EVP_RAND_CTX_gettable_params(EVP_RAND_CTX *ctx); 41b077aed3SPierre Pronchery const OSSL_PARAM *EVP_RAND_CTX_settable_params(EVP_RAND_CTX *ctx); 42b077aed3SPierre Pronchery const char *EVP_RAND_get0_name(const EVP_RAND *rand); 43b077aed3SPierre Pronchery const char *EVP_RAND_get0_description(const EVP_RAND *rand); 44b077aed3SPierre Pronchery int EVP_RAND_is_a(const EVP_RAND *rand, const char *name); 45b077aed3SPierre Pronchery const OSSL_PROVIDER *EVP_RAND_get0_provider(const EVP_RAND *rand); 46b077aed3SPierre Pronchery void EVP_RAND_do_all_provided(OSSL_LIB_CTX *libctx, 47b077aed3SPierre Pronchery void (*fn)(EVP_RAND *rand, void *arg), 48b077aed3SPierre Pronchery void *arg); 49b077aed3SPierre Pronchery int EVP_RAND_names_do_all(const EVP_RAND *rand, 50b077aed3SPierre Pronchery void (*fn)(const char *name, void *data), 51b077aed3SPierre Pronchery void *data); 52b077aed3SPierre Pronchery 53b077aed3SPierre Pronchery int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength, 54b077aed3SPierre Pronchery int prediction_resistance, 55b077aed3SPierre Pronchery const unsigned char *pstr, size_t pstr_len, 56b077aed3SPierre Pronchery const OSSL_PARAM params[]); 57b077aed3SPierre Pronchery int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx); 58b077aed3SPierre Pronchery int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen, 59b077aed3SPierre Pronchery unsigned int strength, int prediction_resistance, 60b077aed3SPierre Pronchery const unsigned char *addin, size_t addin_len); 61b077aed3SPierre Pronchery int EVP_RAND_reseed(EVP_RAND_CTX *ctx, int prediction_resistance, 62b077aed3SPierre Pronchery const unsigned char *ent, size_t ent_len, 63b077aed3SPierre Pronchery const unsigned char *addin, size_t addin_len); 64b077aed3SPierre Pronchery int EVP_RAND_nonce(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen); 65b077aed3SPierre Pronchery int EVP_RAND_enable_locking(EVP_RAND_CTX *ctx); 66b077aed3SPierre Pronchery int EVP_RAND_verify_zeroization(EVP_RAND_CTX *ctx); 67b077aed3SPierre Pronchery unsigned int EVP_RAND_get_strength(EVP_RAND_CTX *ctx); 68b077aed3SPierre Pronchery int EVP_RAND_get_state(EVP_RAND_CTX *ctx); 69b077aed3SPierre Pronchery 70b077aed3SPierre Pronchery #define EVP_RAND_STATE_UNINITIALISED 0 71b077aed3SPierre Pronchery #define EVP_RAND_STATE_READY 1 72b077aed3SPierre Pronchery #define EVP_RAND_STATE_ERROR 2 73b077aed3SPierre Pronchery 74b077aed3SPierre Pronchery=head1 DESCRIPTION 75b077aed3SPierre Pronchery 76b077aed3SPierre ProncheryThe EVP RAND routines are a high-level interface to random number generators 77b077aed3SPierre Proncheryboth deterministic and not. 78b077aed3SPierre ProncheryIf you just want to generate random bytes then you don't need to use 79b077aed3SPierre Proncherythese functions: just call RAND_bytes() or RAND_priv_bytes(). 80b077aed3SPierre ProncheryIf you want to do more, these calls should be used instead of the older 81b077aed3SPierre ProncheryRAND and RAND_DRBG functions. 82b077aed3SPierre Pronchery 83b077aed3SPierre ProncheryAfter creating a B<EVP_RAND_CTX> for the required algorithm using 84b077aed3SPierre ProncheryEVP_RAND_CTX_new(), inputs to the algorithm are supplied either by 85b077aed3SPierre Proncherypassing them as part of the EVP_RAND_instantiate() call or using calls to 86b077aed3SPierre ProncheryEVP_RAND_CTX_set_params() before calling EVP_RAND_instantiate(). Finally, 87b077aed3SPierre Proncherycall EVP_RAND_generate() to produce cryptographically secure random bytes. 88b077aed3SPierre Pronchery 89b077aed3SPierre Pronchery=head2 Types 90b077aed3SPierre Pronchery 91b077aed3SPierre ProncheryB<EVP_RAND> is a type that holds the implementation of a RAND. 92b077aed3SPierre Pronchery 93b077aed3SPierre ProncheryB<EVP_RAND_CTX> is a context type that holds the algorithm inputs. 94b077aed3SPierre ProncheryB<EVP_RAND_CTX> structures are reference counted. 95b077aed3SPierre Pronchery 96b077aed3SPierre Pronchery=head2 Algorithm implementation fetching 97b077aed3SPierre Pronchery 98b077aed3SPierre ProncheryEVP_RAND_fetch() fetches an implementation of a RAND I<algorithm>, given 99b077aed3SPierre Proncherya library context I<libctx> and a set of I<properties>. 100b077aed3SPierre ProncherySee L<crypto(7)/ALGORITHM FETCHING> for further information. 101b077aed3SPierre Pronchery 102b077aed3SPierre ProncheryThe returned value must eventually be freed with 103b077aed3SPierre ProncheryL<EVP_RAND_free(3)>. 104b077aed3SPierre Pronchery 105b077aed3SPierre ProncheryEVP_RAND_up_ref() increments the reference count of an already fetched 106b077aed3SPierre ProncheryRAND. 107b077aed3SPierre Pronchery 108b077aed3SPierre ProncheryEVP_RAND_free() frees a fetched algorithm. 109b077aed3SPierre ProncheryNULL is a valid parameter, for which this function is a no-op. 110b077aed3SPierre Pronchery 111b077aed3SPierre Pronchery=head2 Context manipulation functions 112b077aed3SPierre Pronchery 113b077aed3SPierre ProncheryEVP_RAND_CTX_new() creates a new context for the RAND implementation I<rand>. 114b077aed3SPierre ProncheryIf not NULL, I<parent> specifies the seed source for this implementation. 115b077aed3SPierre ProncheryNot all random number generators need to have a seed source specified. 116b077aed3SPierre ProncheryIf a parent is required, a NULL I<parent> will utilise the operating 117b077aed3SPierre Proncherysystem entropy sources. 118b077aed3SPierre ProncheryIt is recommended to minimise the number of random number generators that 119b077aed3SPierre Proncheryrely on the operating system for their randomness because this is often scarce. 120b077aed3SPierre Pronchery 121b077aed3SPierre ProncheryEVP_RAND_CTX_free() frees up the context I<ctx>. If I<ctx> is NULL, nothing 122b077aed3SPierre Proncheryis done. 123b077aed3SPierre Pronchery 124b077aed3SPierre ProncheryEVP_RAND_CTX_get0_rand() returns the B<EVP_RAND> associated with the context 125b077aed3SPierre ProncheryI<ctx>. 126b077aed3SPierre Pronchery 127b077aed3SPierre Pronchery=head2 Random Number Generator Functions 128b077aed3SPierre Pronchery 129b077aed3SPierre ProncheryEVP_RAND_instantiate() processes any parameters in I<params> and 130b077aed3SPierre Proncherythen instantiates the RAND I<ctx> with a minimum security strength 131b077aed3SPierre Proncheryof <strength> and personalisation string I<pstr> of length <pstr_len>. 132b077aed3SPierre ProncheryIf I<prediction_resistance> is specified, fresh entropy from a live source 133b077aed3SPierre Proncherywill be sought. This call operates as per NIST SP 800-90A and SP 800-90C. 134b077aed3SPierre Pronchery 135b077aed3SPierre ProncheryEVP_RAND_uninstantiate() uninstantiates the RAND I<ctx> as per 136b077aed3SPierre ProncheryNIST SP 800-90A and SP 800-90C. Subsequent to this call, the RAND cannot 137b077aed3SPierre Proncherybe used to generate bytes. It can only be freed or instantiated again. 138b077aed3SPierre Pronchery 139b077aed3SPierre ProncheryEVP_RAND_generate() produces random bytes from the RAND I<ctx> with the 140b077aed3SPierre Proncheryadditional input I<addin> of length I<addin_len>. The bytes 141b077aed3SPierre Proncheryproduced will meet the security I<strength>. 142b077aed3SPierre ProncheryIf I<prediction_resistance> is specified, fresh entropy from a live source 143b077aed3SPierre Proncherywill be sought. This call operates as per NIST SP 800-90A and SP 800-90C. 144b077aed3SPierre Pronchery 145b077aed3SPierre ProncheryEVP_RAND_reseed() reseeds the RAND with new entropy. 146b077aed3SPierre ProncheryEntropy I<ent> of length I<ent_len> bytes can be supplied as can additional 147b077aed3SPierre Proncheryinput I<addin> of length I<addin_len> bytes. In the FIPS provider, both are 148b077aed3SPierre Proncherytreated as additional input as per NIST SP-800-90Ar1, Sections 9.1 and 9.2. 149b077aed3SPierre ProncheryAdditional seed material is also drawn from the RAND's parent or the 150b077aed3SPierre Proncheryoperating system. If I<prediction_resistance> is specified, fresh entropy 151b077aed3SPierre Proncheryfrom a live source will be sought. This call operates as per NIST SP 800-90A 152b077aed3SPierre Proncheryand SP 800-90C. 153b077aed3SPierre Pronchery 154b077aed3SPierre ProncheryEVP_RAND_nonce() creates a nonce in I<out> of maximum length I<outlen> 155b077aed3SPierre Proncherybytes from the RAND I<ctx>. The function returns the length of the generated 156b077aed3SPierre Proncherynonce. If I<out> is NULL, the length is still returned but no generation 157b077aed3SPierre Proncherytakes place. This allows a caller to dynamically allocate a buffer of the 158b077aed3SPierre Proncheryappropriate size. 159b077aed3SPierre Pronchery 160b077aed3SPierre ProncheryEVP_RAND_enable_locking() enables locking for the RAND I<ctx> and all of 161b077aed3SPierre Proncheryits parents. After this I<ctx> will operate in a thread safe manner, albeit 162b077aed3SPierre Proncherymore slowly. This function is not itself thread safe if called with the same 163b077aed3SPierre ProncheryI<ctx> from multiple threads. Typically locking should be enabled before a 164b077aed3SPierre ProncheryI<ctx> is shared across multiple threads. 165b077aed3SPierre Pronchery 166b077aed3SPierre ProncheryEVP_RAND_get_params() retrieves details about the implementation 167b077aed3SPierre ProncheryI<rand>. 168b077aed3SPierre ProncheryThe set of parameters given with I<params> determine exactly what 169b077aed3SPierre Proncheryparameters should be retrieved. 170b077aed3SPierre ProncheryNote that a parameter that is unknown in the underlying context is 171b077aed3SPierre Proncherysimply ignored. 172b077aed3SPierre Pronchery 173b077aed3SPierre ProncheryEVP_RAND_CTX_get_params() retrieves chosen parameters, given the 174b077aed3SPierre Proncherycontext I<ctx> and its underlying context. 175b077aed3SPierre ProncheryThe set of parameters given with I<params> determine exactly what 176b077aed3SPierre Proncheryparameters should be retrieved. 177b077aed3SPierre ProncheryNote that a parameter that is unknown in the underlying context is 178b077aed3SPierre Proncherysimply ignored. 179b077aed3SPierre Pronchery 180b077aed3SPierre ProncheryEVP_RAND_CTX_set_params() passes chosen parameters to the underlying 181b077aed3SPierre Proncherycontext, given a context I<ctx>. 182b077aed3SPierre ProncheryThe set of parameters given with I<params> determine exactly what 183b077aed3SPierre Proncheryparameters are passed down. 184b077aed3SPierre ProncheryNote that a parameter that is unknown in the underlying context is 185b077aed3SPierre Proncherysimply ignored. 186b077aed3SPierre ProncheryAlso, what happens when a needed parameter isn't passed down is 187b077aed3SPierre Proncherydefined by the implementation. 188b077aed3SPierre Pronchery 189b077aed3SPierre ProncheryEVP_RAND_gettable_params() returns an L<OSSL_PARAM(3)> array that describes 190b077aed3SPierre Proncherythe retrievable and settable parameters. EVP_RAND_gettable_params() returns 191b077aed3SPierre Proncheryparameters that can be used with EVP_RAND_get_params(). 192b077aed3SPierre Pronchery 193b077aed3SPierre ProncheryEVP_RAND_gettable_ctx_params() and EVP_RAND_CTX_gettable_params() return 194b077aed3SPierre Proncheryconstant L<OSSL_PARAM(3)> arrays that describe the retrievable parameters that 195b077aed3SPierre Proncherycan be used with EVP_RAND_CTX_get_params(). EVP_RAND_gettable_ctx_params() 196b077aed3SPierre Proncheryreturns the parameters that can be retrieved from the algorithm, whereas 197b077aed3SPierre ProncheryEVP_RAND_CTX_gettable_params() returns the parameters that can be retrieved 198b077aed3SPierre Proncheryin the context's current state. 199b077aed3SPierre Pronchery 200b077aed3SPierre ProncheryEVP_RAND_settable_ctx_params() and EVP_RAND_CTX_settable_params() return 201b077aed3SPierre Proncheryconstant L<OSSL_PARAM(3)> arrays that describe the settable parameters that 202b077aed3SPierre Proncherycan be used with EVP_RAND_CTX_set_params(). EVP_RAND_settable_ctx_params() 203b077aed3SPierre Proncheryreturns the parameters that can be retrieved from the algorithm, whereas 204b077aed3SPierre ProncheryEVP_RAND_CTX_settable_params() returns the parameters that can be retrieved 205b077aed3SPierre Proncheryin the context's current state. 206b077aed3SPierre Pronchery 207b077aed3SPierre Pronchery=head2 Information functions 208b077aed3SPierre Pronchery 209b077aed3SPierre ProncheryEVP_RAND_get_strength() returns the security strength of the RAND I<ctx>. 210b077aed3SPierre Pronchery 211b077aed3SPierre ProncheryEVP_RAND_get_state() returns the current state of the RAND I<ctx>. 212b077aed3SPierre ProncheryStates defined by the OpenSSL RNGs are: 213b077aed3SPierre Pronchery 214b077aed3SPierre Pronchery=over 4 215b077aed3SPierre Pronchery 216b077aed3SPierre Pronchery=item * 217b077aed3SPierre Pronchery 218b077aed3SPierre ProncheryEVP_RAND_STATE_UNINITIALISED: this RNG is currently uninitialised. 219b077aed3SPierre ProncheryThe instantiate call will change this to the ready state. 220b077aed3SPierre Pronchery 221b077aed3SPierre Pronchery=item * 222b077aed3SPierre Pronchery 223b077aed3SPierre ProncheryEVP_RAND_STATE_READY: this RNG is currently ready to generate output. 224b077aed3SPierre Pronchery 225b077aed3SPierre Pronchery=item * 226b077aed3SPierre Pronchery 227b077aed3SPierre ProncheryEVP_RAND_STATE_ERROR: this RNG is in an error state. 228b077aed3SPierre Pronchery 229b077aed3SPierre Pronchery=back 230b077aed3SPierre Pronchery 231b077aed3SPierre ProncheryEVP_RAND_is_a() returns 1 if I<rand> is an implementation of an 232b077aed3SPierre Proncheryalgorithm that's identifiable with I<name>, otherwise 0. 233b077aed3SPierre Pronchery 234b077aed3SPierre ProncheryEVP_RAND_get0_provider() returns the provider that holds the implementation 235b077aed3SPierre Proncheryof the given I<rand>. 236b077aed3SPierre Pronchery 237b077aed3SPierre ProncheryEVP_RAND_do_all_provided() traverses all RAND implemented by all activated 238b077aed3SPierre Proncheryproviders in the given library context I<libctx>, and for each of the 239b077aed3SPierre Proncheryimplementations, calls the given function I<fn> with the implementation method 240b077aed3SPierre Proncheryand the given I<arg> as argument. 241b077aed3SPierre Pronchery 242b077aed3SPierre ProncheryEVP_RAND_get0_name() returns the canonical name of I<rand>. 243b077aed3SPierre Pronchery 244b077aed3SPierre ProncheryEVP_RAND_names_do_all() traverses all names for I<rand>, and calls 245b077aed3SPierre ProncheryI<fn> with each name and I<data>. 246b077aed3SPierre Pronchery 247b077aed3SPierre ProncheryEVP_RAND_get0_description() returns a description of the rand, meant for 248b077aed3SPierre Proncherydisplay and human consumption. The description is at the discretion of 249b077aed3SPierre Proncherythe rand implementation. 250b077aed3SPierre Pronchery 251b077aed3SPierre ProncheryEVP_RAND_verify_zeroization() confirms if the internal DRBG state is 252b077aed3SPierre Proncherycurrently zeroed. This is used by the FIPS provider to support the mandatory 253b077aed3SPierre Proncheryself tests. 254b077aed3SPierre Pronchery 255b077aed3SPierre Pronchery=head1 PARAMETERS 256b077aed3SPierre Pronchery 257b077aed3SPierre ProncheryThe standard parameter names are: 258b077aed3SPierre Pronchery 259b077aed3SPierre Pronchery=over 4 260b077aed3SPierre Pronchery 261b077aed3SPierre Pronchery=item "state" (B<OSSL_RAND_PARAM_STATE>) <integer> 262b077aed3SPierre Pronchery 263b077aed3SPierre ProncheryReturns the state of the random number generator. 264b077aed3SPierre Pronchery 265b077aed3SPierre Pronchery=item "strength" (B<OSSL_RAND_PARAM_STRENGTH>) <unsigned integer> 266b077aed3SPierre Pronchery 267b077aed3SPierre ProncheryReturns the bit strength of the random number generator. 268b077aed3SPierre Pronchery 269b077aed3SPierre Pronchery=back 270b077aed3SPierre Pronchery 271b077aed3SPierre ProncheryFor rands that are also deterministic random bit generators (DRBGs), these 272b077aed3SPierre Proncheryadditional parameters are recognised. Not all 273b077aed3SPierre Proncheryparameters are relevant to, or are understood by all DRBG rands: 274b077aed3SPierre Pronchery 275b077aed3SPierre Pronchery=over 4 276b077aed3SPierre Pronchery 277b077aed3SPierre Pronchery=item "reseed_requests" (B<OSSL_DRBG_PARAM_RESEED_REQUESTS>) <unsigned integer> 278b077aed3SPierre Pronchery 279b077aed3SPierre ProncheryReads or set the number of generate requests before reseeding the 280b077aed3SPierre Proncheryassociated RAND ctx. 281b077aed3SPierre Pronchery 282b077aed3SPierre Pronchery=item "reseed_time_interval" (B<OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL>) <integer> 283b077aed3SPierre Pronchery 284b077aed3SPierre ProncheryReads or set the number of elapsed seconds before reseeding the 285b077aed3SPierre Proncheryassociated RAND ctx. 286b077aed3SPierre Pronchery 287*a7148ab3SEnji Cooper=item "max_request" (B<OSSL_RAND_PARAM_MAX_REQUEST>) <unsigned integer> 288b077aed3SPierre Pronchery 289b077aed3SPierre ProncherySpecifies the maximum number of bytes that can be generated in a single 290b077aed3SPierre Proncherycall to OSSL_FUNC_rand_generate. 291b077aed3SPierre Pronchery 292b077aed3SPierre Pronchery=item "min_entropylen" (B<OSSL_DRBG_PARAM_MIN_ENTROPYLEN>) <unsigned integer> 293b077aed3SPierre Pronchery 294b077aed3SPierre Pronchery=item "max_entropylen" (B<OSSL_DRBG_PARAM_MAX_ENTROPYLEN>) <unsigned integer> 295b077aed3SPierre Pronchery 296b077aed3SPierre ProncherySpecify the minimum and maximum number of bytes of random material that 297b077aed3SPierre Proncherycan be used to seed the DRBG. 298b077aed3SPierre Pronchery 299b077aed3SPierre Pronchery=item "min_noncelen" (B<OSSL_DRBG_PARAM_MIN_NONCELEN>) <unsigned integer> 300b077aed3SPierre Pronchery 301b077aed3SPierre Pronchery=item "max_noncelen" (B<OSSL_DRBG_PARAM_MAX_NONCELEN>) <unsigned integer> 302b077aed3SPierre Pronchery 303b077aed3SPierre ProncherySpecify the minimum and maximum number of bytes of nonce that can be used to 304b077aed3SPierre Proncheryseed the DRBG. 305b077aed3SPierre Pronchery 306b077aed3SPierre Pronchery=item "max_perslen" (B<OSSL_DRBG_PARAM_MAX_PERSLEN>) <unsigned integer> 307b077aed3SPierre Pronchery 308b077aed3SPierre Pronchery=item "max_adinlen" (B<OSSL_DRBG_PARAM_MAX_ADINLEN>) <unsigned integer> 309b077aed3SPierre Pronchery 310b077aed3SPierre ProncherySpecify the minimum and maximum number of bytes of personalisation string 311b077aed3SPierre Proncherythat can be used with the DRBG. 312b077aed3SPierre Pronchery 313b077aed3SPierre Pronchery=item "reseed_counter" (B<OSSL_DRBG_PARAM_RESEED_COUNTER>) <unsigned integer> 314b077aed3SPierre Pronchery 315b077aed3SPierre ProncherySpecifies the number of times the DRBG has been seeded or reseeded. 316b077aed3SPierre Pronchery 317b077aed3SPierre Pronchery=item "properties" (B<OSSL_RAND_PARAM_PROPERTIES>) <UTF8 string> 318b077aed3SPierre Pronchery 319b077aed3SPierre Pronchery=item "mac" (B<OSSL_RAND_PARAM_MAC>) <UTF8 string> 320b077aed3SPierre Pronchery 321b077aed3SPierre Pronchery=item "digest" (B<OSSL_RAND_PARAM_DIGEST>) <UTF8 string> 322b077aed3SPierre Pronchery 323b077aed3SPierre Pronchery=item "cipher" (B<OSSL_RAND_PARAM_CIPHER>) <UTF8 string> 324b077aed3SPierre Pronchery 325b077aed3SPierre ProncheryFor RAND implementations that use an underlying computation MAC, digest or 326b077aed3SPierre Proncherycipher, these parameters set what the algorithm should be. 327b077aed3SPierre Pronchery 328b077aed3SPierre ProncheryThe value is always the name of the intended algorithm, 329b077aed3SPierre Proncheryor the properties in the case of B<OSSL_RAND_PARAM_PROPERTIES>. 330b077aed3SPierre Pronchery 331b077aed3SPierre Pronchery=back 332b077aed3SPierre Pronchery 333b077aed3SPierre Pronchery=head1 NOTES 334b077aed3SPierre Pronchery 335b077aed3SPierre ProncheryThe use of a nonzero value for the I<prediction_resistance> argument to 336b077aed3SPierre ProncheryEVP_RAND_instantiate(), EVP_RAND_generate() or EVP_RAND_reseed() should 337b077aed3SPierre Proncherybe used sparingly. In the default setup, this will cause all public and 338b077aed3SPierre Proncheryprivate DRBGs to be reseeded on next use. Since, by default, public and 339b077aed3SPierre Proncheryprivate DRBGs are allocated on a per thread basis, this can result in 340b077aed3SPierre Proncherysignificant overhead for highly multi-threaded applications. For normal 341b077aed3SPierre Proncheryuse-cases, the default "reseed_requests" and "reseed_time_interval" 342b077aed3SPierre Proncherythresholds ensure sufficient prediction resistance over time and you 343b077aed3SPierre Proncherycan reduce those values if you think they are too high. Explicitly 344b077aed3SPierre Proncheryrequesting prediction resistance is intended for more special use-cases 345b077aed3SPierre Proncherylike generating long-term secrets. 346b077aed3SPierre Pronchery 347b077aed3SPierre ProncheryAn B<EVP_RAND_CTX> needs to have locking enabled if it acts as the parent of 348b077aed3SPierre Proncherymore than one child and the children can be accessed concurrently. This must 349b077aed3SPierre Proncherybe done by explicitly calling EVP_RAND_enable_locking(). 350b077aed3SPierre Pronchery 351b077aed3SPierre ProncheryThe RAND life-cycle is described in L<life_cycle-rand(7)>. In the future, 352b077aed3SPierre Proncherythe transitions described there will be enforced. When this is done, it will 353b077aed3SPierre Proncherynot be considered a breaking change to the API. 354b077aed3SPierre Pronchery 355b077aed3SPierre Pronchery=head1 RETURN VALUES 356b077aed3SPierre Pronchery 357b077aed3SPierre ProncheryEVP_RAND_fetch() returns a pointer to a newly fetched B<EVP_RAND>, or 358b077aed3SPierre ProncheryNULL if allocation failed. 359b077aed3SPierre Pronchery 360b077aed3SPierre ProncheryEVP_RAND_get0_provider() returns a pointer to the provider for the RAND, or 361b077aed3SPierre ProncheryNULL on error. 362b077aed3SPierre Pronchery 363b077aed3SPierre ProncheryEVP_RAND_CTX_get0_rand() returns a pointer to the B<EVP_RAND> associated 364b077aed3SPierre Proncherywith the context. 365b077aed3SPierre Pronchery 366b077aed3SPierre ProncheryEVP_RAND_get0_name() returns the name of the random number generation 367b077aed3SPierre Proncheryalgorithm. 368b077aed3SPierre Pronchery 369b077aed3SPierre ProncheryEVP_RAND_up_ref() returns 1 on success, 0 on error. 370b077aed3SPierre Pronchery 371b077aed3SPierre ProncheryEVP_RAND_names_do_all() returns 1 if the callback was called for all names. A 372b077aed3SPierre Proncheryreturn value of 0 means that the callback was not called for any names. 373b077aed3SPierre Pronchery 374b077aed3SPierre ProncheryEVP_RAND_CTX_new() returns either the newly allocated 375b077aed3SPierre ProncheryB<EVP_RAND_CTX> structure or NULL if an error occurred. 376b077aed3SPierre Pronchery 377b077aed3SPierre ProncheryEVP_RAND_CTX_free() does not return a value. 378b077aed3SPierre Pronchery 379b077aed3SPierre ProncheryEVP_RAND_nonce() returns the length of the nonce. 380b077aed3SPierre Pronchery 381b077aed3SPierre ProncheryEVP_RAND_get_strength() returns the strength of the random number generator 382b077aed3SPierre Proncheryin bits. 383b077aed3SPierre Pronchery 384b077aed3SPierre ProncheryEVP_RAND_gettable_params(), EVP_RAND_gettable_ctx_params() and 385b077aed3SPierre ProncheryEVP_RAND_settable_ctx_params() return an array of OSSL_PARAMs. 386b077aed3SPierre Pronchery 387b077aed3SPierre ProncheryEVP_RAND_verify_zeroization() returns 1 if the internal DRBG state is 388b077aed3SPierre Proncherycurrently zeroed, and 0 if not. 389b077aed3SPierre Pronchery 390b077aed3SPierre ProncheryThe remaining functions return 1 for success and 0 or a negative value for 391b077aed3SPierre Proncheryfailure. 392b077aed3SPierre Pronchery 393b077aed3SPierre Pronchery=head1 SEE ALSO 394b077aed3SPierre Pronchery 395b077aed3SPierre ProncheryL<RAND_bytes(3)>, 396b077aed3SPierre ProncheryL<EVP_RAND-CTR-DRBG(7)>, 397b077aed3SPierre ProncheryL<EVP_RAND-HASH-DRBG(7)>, 398b077aed3SPierre ProncheryL<EVP_RAND-HMAC-DRBG(7)>, 399b077aed3SPierre ProncheryL<EVP_RAND-TEST-RAND(7)>, 400b077aed3SPierre ProncheryL<provider-rand(7)>, 401b077aed3SPierre ProncheryL<life_cycle-rand(7)> 402b077aed3SPierre Pronchery 403b077aed3SPierre Pronchery=head1 HISTORY 404b077aed3SPierre Pronchery 405b077aed3SPierre ProncheryThis functionality was added to OpenSSL 3.0. 406b077aed3SPierre Pronchery 407b077aed3SPierre Pronchery=head1 COPYRIGHT 408b077aed3SPierre Pronchery 409*a7148ab3SEnji CooperCopyright 2020-2024 The OpenSSL Project Authors. All Rights Reserved. 410b077aed3SPierre Pronchery 411b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 412b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 413b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 414b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 415b077aed3SPierre Pronchery 416b077aed3SPierre Pronchery=cut 417