Debian Codegraph @

README

raw
1 NAME
2 Crypt::OpenSSL::Random - OpenSSL/LibreSSL pseudo-random number generator
3 access
4
5 SYNOPSIS
6 use Crypt::OpenSSL::Random;
7
8 Crypt::OpenSSL::Random::random_seed($good_random_data);
9 Crypt::OpenSSL::Random::random_egd("/tmp/entropy");
10 Crypt::OpenSSL::Random::random_status() or
11 die "Unable to sufficiently seed the random number generator".
12
13 my $ten_good_random_bytes = Crypt::OpenSSL::Random::random_bytes(10);
14 my $ten_ok_random_bytes = Crypt::OpenSSL::Random::random_pseudo_bytes(10);
15
16 DESCRIPTION
17 "Crypt::OpenSSL::Random" provides the ability to seed and query the
18 OpenSSL and LibreSSL library's pseudo-random number generators.
19
20 Note: On LibreSSL random_egd() is not defined.
21
22 EXPORT
23 None by default.
24
25 Static Methods
26 random_bytes (IV num_bytes)
27 This function, returns a specified number of cryptographically
28 strong pseudo-random bytes from the PRNG. If the PRNG has not been
29 seeded with enough randomness to ensure an unpredictable byte
30 sequence, then a false value is returned.
31
32 random_pseudo_bytes (IV num_bytes)
33 This function, is similar to "random_bytes", but the resulting
34 sequence of bytes are not necessarily unpredictable. They can be
35 used for non-cryptographic purposes and for certain purposes in
36 cryptographic protocols, but usually not for key generation etc.
37
38 random_seed (PV random_bytes_string)
39 This function seeds the PRNG with a supplied string of bytes. It
40 returns true if the PRNG has sufficient seeding. Note: calling this
41 function with non-random bytes is of limited value at best!
42
43 random_egd (PV egd_string)
44 This function seeds the PRNG with data from the specified entropy
45 gathering daemon. Returns the number of bytes read from the daemon
46 on success, or -1 if not enough bytes were read, or if the
47 connection to the daemon failed.
48
49 "libressl" considers this function insecure, so with libressl or an
50 openssl with no-egd this function does not exist.
51
52 random_status ()
53 This function returns 1 if the PRNG has sufficient seeding. or 0 if
54 not.
55
56 BUGS
57 Because of the internal workings of OpenSSL's random library, the
58 pseudo-random number generator (PRNG) accessed by Crypt::OpenSSL::Random
59 will be different than the one accessed by any other perl module. Hence,
60 to use a module such as Crypt::OpenSSL::Random, you will need to seed
61 the PRNG used there from one used here. This class is still
62 advantageous, however, as it centralizes other methods, such as
63 "random_egd", in one place.
64
65 AUTHOR
66 Ian Robertson, "[email protected]"
67
68 Now maintained by Reini Urban, "[email protected]"
69
70 LICENSE
71 This module is available under the same licences as perl, the Artistic
72 license and the GPL.
73
74 SEE ALSO
75 perl(1), rand(3), RAND_add(3), RAND_egd(3), RAND_bytes(3).
76