Skip to content

Commit 270f95b

Browse files
authored
Merge pull request #184 from robrwo/rrwo/randomness-guide-update
Randomness guide update
2 parents d8d7702 + 5e93338 commit 270f95b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docs/guides/random-data-for-security.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ the [Win32::API](https://metacpan.org/pod/Win32::API) random function call.
6969

7070
To obtain 256-bits (32 bytes) of data:
7171

72-
use Crypt::SysRandom qw( random_bytes );
72+
use Crypt::SysRandom 0.006 qw( random_bytes );
7373

7474
my $bytes = random_bytes(32);
7575

@@ -163,6 +163,20 @@ One caveat of this module is that it needs to be manually seeded by 256 long int
163163

164164
my $rng = Math::Random::ISAAC->new( unpack( "N*", urandom(1024) ) ); # 8192 bits
165165

166+
### Crypt::OpenSSL::Random
167+
168+
[Crypt::OpenSSL::Random](https://metacpan.org/pod/Crypt::OpenSSL::Random) will return bytes from OpenSSL or LibreSSL libraries' pseudo-random number generators.
169+
170+
use Crypt::OpenSSL::Random qw( random_bytes );
171+
172+
my $bytes = random_bytes(32)
173+
or die "not enough randomness";
174+
175+
This module requires the OpenSSL or LibreSSL libraries to be installed, which may make it non-portable.
176+
177+
Note that on systems without `/dev/random` device, the random seed may need to be initialised.
178+
(There is a `random_status` function that indicates whether there is sufficient seeding.)
179+
166180
## Generating IDs, Tokens and Passwords
167181

168182
When generating raw random data for encryption keys or initialisation vectors, a common need is to generate a
@@ -273,7 +287,7 @@ December 2024.
273287

274288
## License and use of this document
275289

276-
* Version: 0.3.0
290+
* Version: 0.3.1
277291
* License: [CC-BY-SA-4.0](https://creativecommons.org/licenses/by-sa/4.0/deed)
278292
* Copyright: © Robert Rothenberg <rrwo@cpan.org>, Some rights reserved.
279293

0 commit comments

Comments
 (0)