Skip to content

Commit

Permalink
Drop srand hack in Zend_Filter_Encrypt_Mcrypt for php < 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Feb 5, 2021
1 parent 0e79ddb commit e046c04
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions packages/zend-filter/library/Zend/Filter/Encrypt/Mcrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public function setVector($vector = null)
$cipher = $this->_openCipher();
$size = mcrypt_enc_get_iv_size($cipher);
if (empty($vector)) {
$this->_srand();
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && version_compare(PHP_VERSION, '5.3.0', '<')) {
$method = MCRYPT_RAND;
} else {
Expand Down Expand Up @@ -331,7 +330,6 @@ protected function _initCipher($cipher)

$keysizes = mcrypt_enc_get_supported_key_sizes($cipher);
if (empty($keysizes) || ($this->_encryption['salt'] == true)) {
$this->_srand();
$keysize = mcrypt_enc_get_key_size($cipher);
$key = substr(md5($key), 0, $keysize);
} else if (!in_array(strlen($key), $keysizes)) {
Expand All @@ -347,20 +345,4 @@ protected function _initCipher($cipher)

return $this;
}

/**
* _srand() interception
*
* @see ZF-8742
*/
protected function _srand()
{
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
return;
}
if (!self::$_srandCalled) {
srand(Zend_Crypt_Math::randInteger(0, PHP_INT_MAX));
self::$_srandCalled = true;
}
}
}

0 comments on commit e046c04

Please sign in to comment.