diff options
Diffstat (limited to 'src/lib/libcrypto/man/BN_rand.3')
| -rw-r--r-- | src/lib/libcrypto/man/BN_rand.3 | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/BN_rand.3 b/src/lib/libcrypto/man/BN_rand.3 new file mode 100644 index 0000000000..5ae9e9d791 --- /dev/null +++ b/src/lib/libcrypto/man/BN_rand.3 | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | .Dd $Mdocdate: February 23 2015 $ | ||
| 2 | .Dt BN_RAND 3 | ||
| 3 | .Os | ||
| 4 | .Sh NAME | ||
| 5 | .Nm BN_rand , | ||
| 6 | .Nm BN_pseudo_rand , | ||
| 7 | .Nm BN_rand_range , | ||
| 8 | .Nm BN_pseudo_rand_range | ||
| 9 | .Nd generate pseudo-random number | ||
| 10 | .Sh SYNOPSIS | ||
| 11 | .In openssl/bn.h | ||
| 12 | .Ft int | ||
| 13 | .Fo BN_rand | ||
| 14 | .Fa "BIGNUM *rnd" | ||
| 15 | .Fa "int bits" | ||
| 16 | .Fa "int top" | ||
| 17 | .Fa "int bottom" | ||
| 18 | .Fc | ||
| 19 | .Ft int | ||
| 20 | .Fo BN_pseudo_rand | ||
| 21 | .Fa "BIGNUM *rnd" | ||
| 22 | .Fa "int bits" | ||
| 23 | .Fa "int top" | ||
| 24 | .Fa "int bottom" | ||
| 25 | .Fc | ||
| 26 | .Ft int | ||
| 27 | .Fo BN_rand_range | ||
| 28 | .Fa "BIGNUM *rnd" | ||
| 29 | .Fa "BIGNUM *range" | ||
| 30 | .Fc | ||
| 31 | .Ft int | ||
| 32 | .Fo BN_pseudo_rand_range | ||
| 33 | .Fa "BIGNUM *rnd" | ||
| 34 | .Fa "BIGNUM *range" | ||
| 35 | .Fc | ||
| 36 | .Sh DESCRIPTION | ||
| 37 | .Fn BN_rand | ||
| 38 | generates a cryptographically strong pseudo-random number of | ||
| 39 | .Fa bits | ||
| 40 | bits in length and stores it in | ||
| 41 | .Fa rnd . | ||
| 42 | If | ||
| 43 | .Fa top | ||
| 44 | is -1, the most significant bit of the random number can be zero. | ||
| 45 | If | ||
| 46 | .Fa top | ||
| 47 | is 0, it is set to 1, and if | ||
| 48 | .Fa top | ||
| 49 | is 1, the two most significant bits of the number will be set to 1, so | ||
| 50 | that the product of two such random numbers will always have | ||
| 51 | .Pf 2* Fa bits | ||
| 52 | length. | ||
| 53 | If | ||
| 54 | .Fa bottom | ||
| 55 | is true, the number will be odd. | ||
| 56 | .Pp | ||
| 57 | .Fn BN_pseudo_rand | ||
| 58 | does the same, but pseudo-random numbers generated by this function are | ||
| 59 | not necessarily unpredictable. | ||
| 60 | They can be used for non-cryptographic purposes and for certain purposes | ||
| 61 | in cryptographic protocols, but usually not for key generation etc. | ||
| 62 | .Pp | ||
| 63 | .Fn BN_rand_range | ||
| 64 | generates a cryptographically strong pseudo-random number | ||
| 65 | .Fa rnd | ||
| 66 | in the range 0 <= | ||
| 67 | .Fa rnd No < Fa range . | ||
| 68 | .Fn BN_pseudo_rand_range | ||
| 69 | does the same, but is based on | ||
| 70 | .Fn BN_pseudo_rand , | ||
| 71 | and hence numbers generated by it are not necessarily unpredictable. | ||
| 72 | .Sh RETURN VALUES | ||
| 73 | The functions return 1 on success, 0 on error. | ||
| 74 | The error codes can be obtained by | ||
| 75 | .Xr ERR_get_error 3 . | ||
| 76 | .Sh SEE ALSO | ||
| 77 | .Xr bn 3 , | ||
| 78 | .Xr ERR_get_error 3 , | ||
| 79 | .Xr rand 3 , | ||
| 80 | .Xr RAND_add 3 , | ||
| 81 | .Xr RAND_bytes 3 | ||
| 82 | .Sh HISTORY | ||
| 83 | .Fn BN_rand | ||
| 84 | is available in all versions of SSLeay and OpenSSL. | ||
| 85 | .Fn BN_pseudo_rand | ||
| 86 | was added in OpenSSL 0.9.5. | ||
| 87 | The | ||
| 88 | .Fa top | ||
| 89 | == -1 case and the function | ||
| 90 | .Fn BN_rand_range | ||
| 91 | were added in OpenSSL 0.9.6a. | ||
| 92 | .Fn BN_pseudo_rand_range | ||
| 93 | was added in OpenSSL 0.9.6c. | ||
