Page MenuHomeDevCentral

Use cryptographically secure pseudo-random integers
ClosedPublic

Authored by dereckson on Apr 9 2022, 12:04.
Tags
None
Referenced Files
F7770553: D2656.id6715.diff
Fri, May 2, 13:57
F7746413: D2656.id6715.diff
Fri, May 2, 03:30
F7740285: D2656.diff
Fri, May 2, 01:02
F7735479: D2656.id6716.diff
Thu, May 1, 23:09
Unknown Object (File)
Mon, Apr 28, 14:22
Unknown Object (File)
Sun, Apr 27, 20:42
Unknown Object (File)
Sat, Apr 26, 03:58
Unknown Object (File)
Fri, Apr 25, 21:45
Subscribers
None

Details

Summary

Methods from Identifiers\Random were currently implemented using
the Mersenne Twister general-purpose pseudorandom number generator.

As randomness is often used as a source to generate credentials,
and to also offer unbiaised results for games, this changes switch
to the CSPRNG method random_int. The random_bytes method was already used.

According PHP manual, the "cryptographically secure pseudo-random number
generator (CSPRNG) API provides an easy and reliable way to generate
crypto-strong random integers and bytes for use within cryptographic contexts."

As our library is PHP 7+ (actually PHP 8.1+), the CSPRNG methods are always
available.

Test Plan

Run unit tests, no regression detected.

Diff Detail

Repository
rKERUALD Keruald libraries development repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable