1*b077aed3SPierre Pronchery=pod 2*b077aed3SPierre Pronchery 3*b077aed3SPierre Pronchery=head1 NAME 4*b077aed3SPierre Pronchery 5*b077aed3SPierre ProncheryEVP_RAND-CTR-DRBG - The CTR DRBG EVP_RAND implementation 6*b077aed3SPierre Pronchery 7*b077aed3SPierre Pronchery=head1 DESCRIPTION 8*b077aed3SPierre Pronchery 9*b077aed3SPierre ProncherySupport for the counter deterministic random bit generator through the 10*b077aed3SPierre ProncheryB<EVP_RAND> API. 11*b077aed3SPierre Pronchery 12*b077aed3SPierre Pronchery=head2 Identity 13*b077aed3SPierre Pronchery 14*b077aed3SPierre Pronchery"CTR-DRBG" is the name for this implementation; it can be used with the 15*b077aed3SPierre ProncheryEVP_RAND_fetch() function. 16*b077aed3SPierre Pronchery 17*b077aed3SPierre Pronchery=head2 Supported parameters 18*b077aed3SPierre Pronchery 19*b077aed3SPierre ProncheryThe supported parameters are: 20*b077aed3SPierre Pronchery 21*b077aed3SPierre Pronchery=over 4 22*b077aed3SPierre Pronchery 23*b077aed3SPierre Pronchery=item "state" (B<OSSL_RAND_PARAM_STATE>) <integer> 24*b077aed3SPierre Pronchery 25*b077aed3SPierre Pronchery=item "strength" (B<OSSL_RAND_PARAM_STRENGTH>) <unsigned integer> 26*b077aed3SPierre Pronchery 27*b077aed3SPierre Pronchery=item "max_request" (B<OSSL_RAND_PARAM_MAX_REQUEST>) <unsigned integer> 28*b077aed3SPierre Pronchery 29*b077aed3SPierre Pronchery=item "reseed_requests" (B<OSSL_DRBG_PARAM_RESEED_REQUESTS>) <unsigned integer> 30*b077aed3SPierre Pronchery 31*b077aed3SPierre Pronchery=item "reseed_time_interval" (B<OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL>) <integer> 32*b077aed3SPierre Pronchery 33*b077aed3SPierre Pronchery=item "min_entropylen" (B<OSSL_DRBG_PARAM_MIN_ENTROPYLEN>) <unsigned integer> 34*b077aed3SPierre Pronchery 35*b077aed3SPierre Pronchery=item "max_entropylen" (B<OSSL_DRBG_PARAM_MAX_ENTROPYLEN>) <unsigned integer> 36*b077aed3SPierre Pronchery 37*b077aed3SPierre Pronchery=item "min_noncelen" (B<OSSL_DRBG_PARAM_MIN_NONCELEN>) <unsigned integer> 38*b077aed3SPierre Pronchery 39*b077aed3SPierre Pronchery=item "max_noncelen" (B<OSSL_DRBG_PARAM_MAX_NONCELEN>) <unsigned integer> 40*b077aed3SPierre Pronchery 41*b077aed3SPierre Pronchery=item "max_perslen" (B<OSSL_DRBG_PARAM_MAX_PERSLEN>) <unsigned integer> 42*b077aed3SPierre Pronchery 43*b077aed3SPierre Pronchery=item "max_adinlen" (B<OSSL_DRBG_PARAM_MAX_ADINLEN>) <unsigned integer> 44*b077aed3SPierre Pronchery 45*b077aed3SPierre Pronchery=item "reseed_counter" (B<OSSL_DRBG_PARAM_RESEED_COUNTER>) <unsigned integer> 46*b077aed3SPierre Pronchery 47*b077aed3SPierre Pronchery=item "properties" (B<OSSL_DRBG_PARAM_PROPERTIES>) <UTF8 string> 48*b077aed3SPierre Pronchery 49*b077aed3SPierre Pronchery=item "cipher" (B<OSSL_DRBG_PARAM_CIPHER>) <UTF8 string> 50*b077aed3SPierre Pronchery 51*b077aed3SPierre ProncheryThese parameters work as described in L<EVP_RAND(3)/PARAMETERS>. 52*b077aed3SPierre Pronchery 53*b077aed3SPierre Pronchery=item "use_derivation_function" (B<OSSL_DRBG_PARAM_USE_DF>) <integer> 54*b077aed3SPierre Pronchery 55*b077aed3SPierre ProncheryThis Boolean indicates if a derivation function should be used or not. 56*b077aed3SPierre ProncheryA nonzero value (the default) uses the derivation function. A zero value 57*b077aed3SPierre Proncherydoes not. 58*b077aed3SPierre Pronchery 59*b077aed3SPierre Pronchery=back 60*b077aed3SPierre Pronchery 61*b077aed3SPierre Pronchery=head1 NOTES 62*b077aed3SPierre Pronchery 63*b077aed3SPierre ProncheryA context for CTR DRBG can be obtained by calling: 64*b077aed3SPierre Pronchery 65*b077aed3SPierre Pronchery EVP_RAND *rand = EVP_RAND_fetch(NULL, "CTR-DRBG", NULL); 66*b077aed3SPierre Pronchery EVP_RAND_CTX *rctx = EVP_RAND_CTX_new(rand); 67*b077aed3SPierre Pronchery 68*b077aed3SPierre Pronchery=head1 EXAMPLES 69*b077aed3SPierre Pronchery 70*b077aed3SPierre Pronchery EVP_RAND *rand; 71*b077aed3SPierre Pronchery EVP_RAND_CTX *rctx; 72*b077aed3SPierre Pronchery unsigned char bytes[100]; 73*b077aed3SPierre Pronchery OSSL_PARAM params[2], *p = params; 74*b077aed3SPierre Pronchery unsigned int strength = 128; 75*b077aed3SPierre Pronchery 76*b077aed3SPierre Pronchery rand = EVP_RAND_fetch(NULL, "CTR-DRBG", NULL); 77*b077aed3SPierre Pronchery rctx = EVP_RAND_CTX_new(rand, NULL); 78*b077aed3SPierre Pronchery EVP_RAND_free(rand); 79*b077aed3SPierre Pronchery 80*b077aed3SPierre Pronchery *p++ = OSSL_PARAM_construct_utf8_string(OSSL_DRBG_PARAM_CIPHER, 81*b077aed3SPierre Pronchery SN_aes_256_ctr, 0); 82*b077aed3SPierre Pronchery *p = OSSL_PARAM_construct_end(); 83*b077aed3SPierre Pronchery EVP_RAND_instantiate(rctx, strength, 0, NULL, 0, params); 84*b077aed3SPierre Pronchery 85*b077aed3SPierre Pronchery EVP_RAND_generate(rctx, bytes, sizeof(bytes), strength, 0, NULL, 0); 86*b077aed3SPierre Pronchery 87*b077aed3SPierre Pronchery EVP_RAND_CTX_free(rctx); 88*b077aed3SPierre Pronchery 89*b077aed3SPierre Pronchery=head1 CONFORMING TO 90*b077aed3SPierre Pronchery 91*b077aed3SPierre ProncheryNIST SP 800-90A and SP 800-90B 92*b077aed3SPierre Pronchery 93*b077aed3SPierre Pronchery=head1 SEE ALSO 94*b077aed3SPierre Pronchery 95*b077aed3SPierre ProncheryL<EVP_RAND(3)>, 96*b077aed3SPierre ProncheryL<EVP_RAND(3)/PARAMETERS> 97*b077aed3SPierre Pronchery 98*b077aed3SPierre Pronchery=head1 COPYRIGHT 99*b077aed3SPierre Pronchery 100*b077aed3SPierre ProncheryCopyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. 101*b077aed3SPierre Pronchery 102*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 103*b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 104*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 105*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 106*b077aed3SPierre Pronchery 107*b077aed3SPierre Pronchery=cut 108