1BN_rand(3)                          OpenSSL                         BN_rand(3)
2
3
4

NAME

6       BN_rand, BN_pseudo_rand - generate pseudo-random number
7

SYNOPSIS

9        #include <openssl/bn.h>
10
11        int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
12
13        int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
14
15        int BN_rand_range(BIGNUM *rnd, BIGNUM *range);
16
17        int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range);
18

DESCRIPTION

20       BN_rand() generates a cryptographically strong pseudo-random number of
21       bits bits in length and stores it in rnd. If top is -1, the most
22       significant bit of the random number can be zero. If top is 0, it is
23       set to 1, and if top is 1, the two most significant bits of the number
24       will be set to 1, so that the product of two such random numbers will
25       always have 2*bits length.  If bottom is true, the number will be odd.
26
27       BN_pseudo_rand() does the same, but pseudo-random numbers generated by
28       this function are not necessarily unpredictable. They can be used for
29       non-cryptographic purposes and for certain purposes in cryptographic
30       protocols, but usually not for key generation etc.
31
32       BN_rand_range() generates a cryptographically strong pseudo-random
33       number rnd in the range 0 <lt>= rnd < range.  BN_pseudo_rand_range()
34       does the same, but is based on BN_pseudo_rand(), and hence numbers
35       generated by it are not necessarily unpredictable.
36
37       The PRNG must be seeded prior to calling BN_rand() or BN_rand_range().
38

RETURN VALUES

40       The functions return 1 on success, 0 on error.  The error codes can be
41       obtained by ERR_get_error(3).
42

SEE ALSO

44       bn(3), ERR_get_error(3), rand(3), RAND_add(3), RAND_bytes(3)
45

HISTORY

47       BN_rand() is available in all versions of SSLeay and OpenSSL.
48       BN_pseudo_rand() was added in OpenSSL 0.9.5. The top == -1 case and the
49       function BN_rand_range() were added in OpenSSL 0.9.6a.
50       BN_pseudo_rand_range() was added in OpenSSL 0.9.6c.
51
52
53
541.0.0e                            2002-09-25                        BN_rand(3)
Impressum