1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimRAND_bytes, RAND_priv_bytes, RAND_pseudo_bytes - generate random data 6e71b7053SJung-uk Kim 7e71b7053SJung-uk Kim=head1 SYNOPSIS 8e71b7053SJung-uk Kim 9e71b7053SJung-uk Kim #include <openssl/rand.h> 10e71b7053SJung-uk Kim 11e71b7053SJung-uk Kim int RAND_bytes(unsigned char *buf, int num); 12e71b7053SJung-uk Kim int RAND_priv_bytes(unsigned char *buf, int num); 13e71b7053SJung-uk Kim 14e71b7053SJung-uk KimDeprecated: 15e71b7053SJung-uk Kim 16e71b7053SJung-uk Kim #if OPENSSL_API_COMPAT < 0x10100000L 17e71b7053SJung-uk Kim int RAND_pseudo_bytes(unsigned char *buf, int num); 18e71b7053SJung-uk Kim #endif 19e71b7053SJung-uk Kim 20e71b7053SJung-uk Kim=head1 DESCRIPTION 21e71b7053SJung-uk Kim 22e71b7053SJung-uk KimRAND_bytes() puts B<num> cryptographically strong pseudo-random bytes 23e71b7053SJung-uk Kiminto B<buf>. 24e71b7053SJung-uk Kim 25e71b7053SJung-uk KimRAND_priv_bytes() has the same semantics as RAND_bytes(). It is intended to 26e71b7053SJung-uk Kimbe used for generating values that should remain private. If using the 27e71b7053SJung-uk Kimdefault RAND_METHOD, this function uses a separate "private" PRNG 28e71b7053SJung-uk Kiminstance so that a compromise of the "public" PRNG instance will not 29e71b7053SJung-uk Kimaffect the secrecy of these private values, as described in L<RAND(7)> 30e71b7053SJung-uk Kimand L<RAND_DRBG(7)>. 31e71b7053SJung-uk Kim 32e71b7053SJung-uk Kim=head1 NOTES 33e71b7053SJung-uk Kim 34e71b7053SJung-uk KimAlways check the error return value of RAND_bytes() and 35e71b7053SJung-uk KimRAND_priv_bytes() and do not take randomness for granted: an error occurs 36e71b7053SJung-uk Kimif the CSPRNG has not been seeded with enough randomness to ensure an 37e71b7053SJung-uk Kimunpredictable byte sequence. 38e71b7053SJung-uk Kim 39e71b7053SJung-uk Kim=head1 RETURN VALUES 40e71b7053SJung-uk Kim 41e71b7053SJung-uk KimRAND_bytes() and RAND_priv_bytes() 42e71b7053SJung-uk Kimreturn 1 on success, -1 if not supported by the current 43e71b7053SJung-uk KimRAND method, or 0 on other failure. The error code can be 44e71b7053SJung-uk Kimobtained by L<ERR_get_error(3)>. 45e71b7053SJung-uk Kim 46*610a21fdSJung-uk Kim=head1 SEE ALSO 47*610a21fdSJung-uk Kim 48*610a21fdSJung-uk KimL<RAND_add(3)>, 49*610a21fdSJung-uk KimL<RAND_bytes(3)>, 50*610a21fdSJung-uk KimL<RAND_priv_bytes(3)>, 51*610a21fdSJung-uk KimL<ERR_get_error(3)>, 52*610a21fdSJung-uk KimL<RAND(7)>, 53*610a21fdSJung-uk KimL<RAND_DRBG(7)> 54*610a21fdSJung-uk Kim 55e71b7053SJung-uk Kim=head1 HISTORY 56e71b7053SJung-uk Kim 57e71b7053SJung-uk Kim=over 2 58e71b7053SJung-uk Kim 59e71b7053SJung-uk Kim=item * 60e71b7053SJung-uk Kim 61e71b7053SJung-uk KimRAND_pseudo_bytes() was deprecated in OpenSSL 1.1.0; use RAND_bytes() instead. 62e71b7053SJung-uk Kim 63e71b7053SJung-uk Kim=item * 64e71b7053SJung-uk Kim 656935a639SJung-uk KimThe RAND_priv_bytes() function was added in OpenSSL 1.1.1. 66e71b7053SJung-uk Kim 67e71b7053SJung-uk Kim=back 68e71b7053SJung-uk Kim 69e71b7053SJung-uk Kim=head1 COPYRIGHT 70e71b7053SJung-uk Kim 71*610a21fdSJung-uk KimCopyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. 72e71b7053SJung-uk Kim 73e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License"). You may not use 74e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 75e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 76e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 77e71b7053SJung-uk Kim 78e71b7053SJung-uk Kim=cut 79