BN_rand(3) OpenSSL BN_rand(3) NNAAMMEE BN_rand, BN_pseudo_rand - generate pseudo-random number SSYYNNOOPPSSIISS #include int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); int BN_rand_range(BIGNUM *rnd, BIGNUM *range); int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); DDEESSCCRRIIPPTTIIOONN _B_N___r_a_n_d_(_) generates a cryptographically strong pseudo-random number of bbiittss in length and stores it in rrnndd. If ttoopp is -1, the most significant bit of the random number can be zero. If ttoopp is 0, it is set to 1, and if ttoopp is 1, the two most significant bits of the number will be set to 1, so that the product of two such random numbers will always have 2*bbiittss length. If bboottttoomm is true, the number will be odd. The value of bbiittss must be zero or greater. If bbiittss is 1 then ttoopp cannot also be 1. _B_N___p_s_e_u_d_o___r_a_n_d_(_) does the same, but pseudo-random numbers generated by this function are not necessarily unpredictable. They can be used for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc. _B_N___r_a_n_d___r_a_n_g_e_(_) generates a cryptographically strong pseudo-random num- ber rrnndd in the range 0 <= rrnndd < rraannggee. _B_N___p_s_e_u_d_o___r_a_n_d___r_a_n_g_e_(_) does the same, but is based on _B_N___p_s_e_u_d_o___r_a_n_d_(_), and hence numbers generated by it are not necessarily unpredictable. The PRNG must be seeded prior to calling _B_N___r_a_n_d_(_) or _B_N___r_a_n_d___r_a_n_g_e_(_). RREETTUURRNN VVAALLUUEESS The functions return 1 on success, 0 on error. The error codes can be obtained by _E_R_R___g_e_t___e_r_r_o_r(3). SSEEEE AALLSSOO _b_n(3), _E_R_R___g_e_t___e_r_r_o_r(3), _r_a_n_d(3), _R_A_N_D___a_d_d(3), _R_A_N_D___b_y_t_e_s(3) HHIISSTTOORRYY _B_N___r_a_n_d_(_) is available in all versions of SSLeay and OpenSSL. _B_N___p_s_e_u_d_o___r_a_n_d_(_) was added in OpenSSL 0.9.5. The ttoopp == -1 case and the function _B_N___r_a_n_d___r_a_n_g_e_(_) were added in OpenSSL 0.9.6a. _B_N___p_s_e_u_d_o___r_a_n_d___r_a_n_g_e_(_) was added in OpenSSL 0.9.6c. 1.0.1u 2016-09-22 BN_rand(3)