Removes Dependency on Laminas\Math
Closes
MODIFY
composer.json
composer.json
"laminas/laminas-filter": "^2.14.0",
"laminas/laminas-http": "^2.14.2",
"laminas/laminas-i18n": "^2.15.0",
- "laminas/laminas-math": "^2.7.1",
"laminas/laminas-session": "^2.12.1",
"laminas/laminas-uri": "^2.9.1",
"phpspec/prophecy-phpunit": "^2.0",
"laminas/laminas-filter": "Laminas\\Filter component, required by the Digits validator",
"laminas/laminas-i18n": "Laminas\\I18n component to allow translation of validation error messages",
"laminas/laminas-i18n-resources": "Translations of validator messages",
- "laminas/laminas-math": "Laminas\\Math component, required by the Csrf validator",
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component to allow using the ValidatorPluginManager and validator chains",
"laminas/laminas-session": "Laminas\\Session component, ^2.8; required by the Csrf validator",
"laminas/laminas-uri": "Laminas\\Uri component, required by the Uri and Sitemap\\Loc validators",

MODIFY
composer.lock
composer.lock
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "0eb1f1c3bae821da3c13e1e504414c93",
+ "content-hash": "f8bcfbe52ea67b5c0a12788e142c00bf",
"packages": [
{
"name": "laminas/laminas-servicemanager",
],
"time": "2021-09-02T18:30:53+00:00"
},
- {
- "name": "laminas/laminas-math",
- "version": "2.7.1",
- "source": {
- "type": "git",
- "url": "https://github.com/laminas/laminas-math.git",
- "reference": "8027b37e00accc43f28605c7d8fd081baed1f475"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-math/zipball/8027b37e00accc43f28605c7d8fd081baed1f475",
- "reference": "8027b37e00accc43f28605c7d8fd081baed1f475",
- "shasum": ""
- },
- "require": {
- "laminas/laminas-zendframework-bridge": "^1.0",
- "php": "^5.5 || ^7.0"
- },
- "replace": {
- "zendframework/zend-math": "self.version"
- },
- "require-dev": {
- "fabpot/php-cs-fixer": "1.7.*",
- "ircmaxell/random-lib": "~1.1",
- "phpunit/phpunit": "~4.0"
- },
- "suggest": {
- "ext-bcmath": "If using the bcmath functionality",
- "ext-gmp": "If using the gmp functionality",
- "ircmaxell/random-lib": "Fallback random byte generator for Laminas\\Math\\Rand if Mcrypt extensions is unavailable"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.7-dev",
- "dev-develop": "2.8-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Laminas\\Math\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "homepage": "https://laminas.dev",
- "keywords": [
- "laminas",
- "math"
- ],
- "support": {
- "chat": "https://laminas.dev/chat",
- "docs": "https://docs.laminas.dev/laminas-math/",
- "forum": "https://discourse.laminas.dev",
- "issues": "https://github.com/laminas/laminas-math/issues",
- "rss": "https://github.com/laminas/laminas-math/releases.atom",
- "source": "https://github.com/laminas/laminas-math"
- },
- "time": "2019-12-31T17:24:15+00:00"
- },
{
"name": "laminas/laminas-session",
"version": "2.12.1",

MODIFY
src/Csrf.php
src/Csrf.php
namespace Laminas\Validator;
-use Laminas\Math\Rand;
use Laminas\Session\Container as SessionContainer;
use Laminas\Stdlib\ArrayUtils;
use Traversable;
@@ -11,6 +10,7 @@ use function explode;
use function is_array;
use function is_string;
use function md5;
+use function random_bytes;
use function sprintf;
use function str_replace;
use function strtolower;
@@ -301,7 +301,7 @@ class Csrf extends AbstractValidator
*/
protected function generateHash()
{
- $token = md5($this->getSalt() . Rand::getBytes(32) . $this->getName());
+ $token = md5($this->getSalt() . random_bytes(32) . $this->getName());
$this->hash = $this->formatHash($token, $this->generateTokenId());
@@ -314,7 +314,7 @@ class Csrf extends AbstractValidator
*/
protected function generateTokenId()
{
- return md5(Rand::getBytes(32));
+ return md5(random_bytes(32));
}
/**

Removes Dependency on Laminas\Math

Closes #132

Signed-off-by: George Steel <george@net-glue.co.uk>