You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
croak "unable to open /dev/urandom ($err1) or /dev/arandom ($err2)";
98
+
}
99
+
100
+
sysread($fh, $seed, 1024) == 1024 || croak "unable to read from random device: $!";
101
+
}
102
+
103
+
return$seed;
94
104
}
95
105
96
106
@@ -144,9 +154,9 @@ When a Session::Token object is created, 1024 bytes are read from C</dev/urandom
144
154
145
155
Once a generator is created, you can repeatedly call the C<get> method on the generator object and it will return a new token each time.
146
156
147
-
B<IMPORTANT>: If your application calls C<fork>, make sure that any generators are re-created in one of the processes after the fork since forking will duplicate the generator state and both parent and child processes will go on to produce identical tokens (just like perl's L<rand> after it is seeded).
157
+
If your application calls C<fork>, generators will detect this and re-seed themselves from the kernel before producing another token, so parent and child processes will not go on to produce identical tokens (as happens with perl's L<rand> after it is seeded).
148
158
149
-
After the generator context is created, no system calls are used to generate tokens. This is one way that Session::Token helps with efficiency. However, this is only important for certain use cases (generally not web sessions).
159
+
After the generator context is created, no system calls are used to generate tokens (except to re-seed after a fork). This is one way that Session::Token helps with efficiency. However, this is only important for certain use cases (generally not web sessions).
150
160
151
161
ISAAC is a cryptographically secure PRNG that improves on the well-known RC4 algorithm in some important areas. For instance, it doesn't have short cycles or initial bias like RC4 does. A theoretical shortest possible cycle in ISAAC is C<2**40>, although no cycles this short have ever been found (and probably don't exist at all). On average, ISAAC cycles are C<2**8295>.
152
162
@@ -376,6 +386,8 @@ This is done in the test-suite to compare against Jenkins' reference ISAAC outpu
376
386
377
387
One valid reason for manually seeding is if you have some reason to believe that there isn't enough entropy in your kernel's randomness pool and therefore you don't trust C</dev/urandom>. In this case you should acquire your own seed data from somewhere trustworthy (maybe C</dev/random> or a previously stored trusted seed).
378
388
389
+
Generators created with a custom seed are not re-seeded after a C<fork>.
390
+
379
391
380
392
381
393
@@ -416,8 +428,6 @@ It supports all the options of this module via command line parameters, and mult
416
428
417
429
Should check for biased alphabets and print warnings.
418
430
419
-
Would be cool if it could detect forks and warn or re-seed in the child process (without incurring C<getpid> overhead).
420
-
421
431
There is currently no way to extract the seed from a Session::Token object. Note when implementing this: The saved seed must either store the current state of the ISAAC round as well as the 1024 byte C<randsl> array or else do some kind of minimum fast forwarding in order to protect against a partially duplicated output-stream bug.
422
432
423
433
Doesn't work on perl 5.6 and below due to the use of C<:raw> (thanks CPAN testers). It could probably use C<binmode> instead, but meh.
0 commit comments