X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Frand%2Fdrbg_lib.c;h=5e6bdceb1ed77c45fad3f7c6e4171c74650655aa;hp=5d3d0f2fd718fe92ae6e7ae9a8f8afd43ae1ea27;hb=20928ff635772182fe8696d618a19f9101a5370f;hpb=1af66bb7241268f96554136387126d280efab75d diff --git a/crypto/rand/drbg_lib.c b/crypto/rand/drbg_lib.c index 5d3d0f2fd7..5e6bdceb1e 100644 --- a/crypto/rand/drbg_lib.c +++ b/crypto/rand/drbg_lib.c @@ -534,6 +534,28 @@ int RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen, return 1; } +/* + * Generates |outlen| random bytes and stores them in |out|. It will + * using the given |drbg| to generate the bytes. + * + * Requires that drbg->lock is already locked for write, if non-null. + * + * Returns 1 on success 0 on failure. + */ +int RAND_DRBG_bytes(RAND_DRBG *drbg, unsigned char *out, size_t outlen) +{ + unsigned char *additional = NULL; + size_t additional_len; + size_t ret; + + additional_len = rand_drbg_get_additional_data(&additional, drbg->max_adinlen); + ret = RAND_DRBG_generate(drbg, out, outlen, 0, additional, additional_len); + if (additional_len != 0) + OPENSSL_secure_clear_free(additional, additional_len); + + return ret; +} + /* * Set the RAND_DRBG callbacks for obtaining entropy and nonce. *