replace random_bytes
This commit is contained in:
parent
482c6efdd9
commit
7c241620c0
@ -46,7 +46,7 @@ class Swift_Mime_IdGenerator implements Swift_IdGenerator
|
|||||||
*/
|
*/
|
||||||
public function generateId()
|
public function generateId()
|
||||||
{
|
{
|
||||||
$idLeft = bin2hex(random_bytes(16)); // set 32 hex values
|
$idLeft = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true));
|
||||||
|
|
||||||
return $idLeft.'@'.$this->idRight;
|
return $idLeft.'@'.$this->idRight;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,7 +92,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
|||||||
*/
|
*/
|
||||||
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator)
|
public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator)
|
||||||
{
|
{
|
||||||
$this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values
|
$this->cacheKey = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true));
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
$this->headers = $headers;
|
$this->headers = $headers;
|
||||||
$this->idGenerator = $idGenerator;
|
$this->idGenerator = $idGenerator;
|
||||||
@ -420,7 +420,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
|||||||
public function getBoundary()
|
public function getBoundary()
|
||||||
{
|
{
|
||||||
if (!isset($this->boundary)) {
|
if (!isset($this->boundary)) {
|
||||||
$this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_';
|
$this->boundary = '_=_swift_'.time().'_'.md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)).'_=_';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->boundary;
|
return $this->boundary;
|
||||||
@ -813,7 +813,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M
|
|||||||
{
|
{
|
||||||
$this->headers = clone $this->headers;
|
$this->headers = clone $this->headers;
|
||||||
$this->encoder = clone $this->encoder;
|
$this->encoder = clone $this->encoder;
|
||||||
$this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values
|
$this->cacheKey = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true));
|
||||||
$children = array();
|
$children = array();
|
||||||
foreach ($this->children as $pos => $child) {
|
foreach ($this->children as $pos => $child) {
|
||||||
$children[$pos] = clone $child;
|
$children[$pos] = clone $child;
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
|||||||
|
|
||||||
// extra parameters for our unit cases
|
// extra parameters for our unit cases
|
||||||
$timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000'));
|
$timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000'));
|
||||||
$client = func_num_args() > 4 ? func_get_arg(4) : random_bytes(8);
|
$client = func_num_args() > 4 ? func_get_arg(4) : $this->getRandomBytes(8);
|
||||||
|
|
||||||
// Message 3 response
|
// Message 3 response
|
||||||
$this->sendMessage3($response, $username, $password, $timestamp, $client, $agent);
|
$this->sendMessage3($response, $username, $password, $timestamp, $client, $agent);
|
||||||
@ -548,6 +548,22 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es
|
|||||||
return $byte;
|
return $byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create random bytes.
|
||||||
|
*
|
||||||
|
* @param $length
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getRandomBytes($length) : string
|
||||||
|
{
|
||||||
|
$bytes = openssl_random_pseudo_bytes($length, $strong);
|
||||||
|
if (false !== $bytes && true === $strong) {
|
||||||
|
return $bytes;
|
||||||
|
}
|
||||||
|
throw new RuntimeException('OpenSSL did not produce a secure random number.');
|
||||||
|
}
|
||||||
|
|
||||||
/** ENCRYPTION ALGORITHMS */
|
/** ENCRYPTION ALGORITHMS */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user