0f692684d20032f4b7cf23ea58fc363aadc0c7ac
[openssl.git] / doc / crypto / BN_rand.pod
1 =pod
2
3 =head1 NAME
4
5 BN_rand - Generate pseudo-random number
6
7 =head1 SYNOPSIS
8
9  #include <openssl/bn.h>
10
11  int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
12
13 =head1 DESCRIPTION
14
15 BN_rand() generates a cryptographically strong pseudo-random number of
16 B<bits> bits in length and stores it in B<rnd>. If B<top> is true, the
17 two most significant bits of the number will be set to 1, so that the
18 product of two such random numbers will always have 2*B<bits> length.
19 If B<bottom> is true, the number will be odd.
20
21 The PRNG must be seeded prior to calling BN_rand().
22
23 =head1 RETURN VALUES
24
25 BN_rand() returns 1 on success, 0 on error.
26 The error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
27
28 =head1 SEE ALSO
29
30 L<bn(3)|bn(3)>, L<err(3)|err(3)>, L<rand(3)|rand(3)>,
31 L<RAND_add(3)|RAND_add(3)>, L<RAND_bytes(3)|RAND_bytes(3)>
32
33 =head1 HISTORY
34
35 BN_rand() is available in all versions of SSLeay and OpenSSL.
36
37 =cut