mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-11 08:10:58 +00:00
Renamed Random::crypt_random_string to Random::string
This commit is contained in:
parent
82de57a65f
commit
f5ed86e385
@ -795,7 +795,7 @@ class Crypt_RSA
|
||||
$source.= pack('Na*', strlen($private), $private);
|
||||
$hashkey = 'putty-private-key-file-mac-key';
|
||||
} else {
|
||||
$private.= Random::crypt_random_string(16 - (strlen($private) & 15));
|
||||
$private.= Random::string(16 - (strlen($private) & 15));
|
||||
$source.= pack('Na*', strlen($private), $private);
|
||||
if (!class_exists('Crypt_AES')) {
|
||||
include_once 'Crypt/AES.php';
|
||||
@ -861,7 +861,7 @@ class Crypt_RSA
|
||||
);
|
||||
$RSAPrivateKey = pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey);
|
||||
if (!empty($this->password) || is_string($this->password)) {
|
||||
$salt = Random::crypt_random_string(8);
|
||||
$salt = Random::string(8);
|
||||
$iterationCount = 2048;
|
||||
|
||||
if (!class_exists('Crypt_DES')) {
|
||||
@ -901,7 +901,7 @@ class Crypt_RSA
|
||||
}
|
||||
|
||||
if (!empty($this->password) || is_string($this->password)) {
|
||||
$iv = Random::crypt_random_string(8);
|
||||
$iv = Random::string(8);
|
||||
$symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key
|
||||
$symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8);
|
||||
if (!class_exists('Crypt_TripleDES')) {
|
||||
@ -2303,7 +2303,7 @@ class Crypt_RSA
|
||||
$lHash = $this->hash->hash($l);
|
||||
$ps = str_repeat(chr(0), $this->k - $mLen - 2 * $this->hLen - 2);
|
||||
$db = $lHash . $ps . chr(1) . $m;
|
||||
$seed = Random::crypt_random_string($this->hLen);
|
||||
$seed = Random::string($this->hLen);
|
||||
$dbMask = $this->_mgf1($seed, $this->k - $this->hLen - 1);
|
||||
$maskedDB = $db ^ $dbMask;
|
||||
$seedMask = $this->_mgf1($maskedDB, $this->hLen);
|
||||
@ -2421,7 +2421,7 @@ class Crypt_RSA
|
||||
$psLen = $this->k - $mLen - 3;
|
||||
$ps = '';
|
||||
while (strlen($ps) != $psLen) {
|
||||
$temp = Random::crypt_random_string($psLen - strlen($ps));
|
||||
$temp = Random::string($psLen - strlen($ps));
|
||||
$temp = str_replace("\x00", '', $temp);
|
||||
$ps.= $temp;
|
||||
}
|
||||
@ -2527,7 +2527,7 @@ class Crypt_RSA
|
||||
return false;
|
||||
}
|
||||
|
||||
$salt = Random::crypt_random_string($sLen);
|
||||
$salt = Random::string($sLen);
|
||||
$m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt;
|
||||
$h = $this->hash->hash($m2);
|
||||
$ps = str_repeat(chr(0), $emLen - $sLen - $this->hLen - 2);
|
||||
|
@ -3,9 +3,6 @@
|
||||
/**
|
||||
* Random Number Generator
|
||||
*
|
||||
* The idea behind this function is that it can be easily replaced with your own crypt_random_string()
|
||||
* function. eg. maybe you have a better source of entropy for creating the initial states or whatever.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* Here's a short example of how to use this library:
|
||||
@ -13,7 +10,7 @@
|
||||
* <?php
|
||||
* include 'Crypt/Random.php';
|
||||
*
|
||||
* echo bin2hex(crypt_random_string(8));
|
||||
* echo bin2hex(Random::string(8));
|
||||
* ?>
|
||||
* </code>
|
||||
*
|
||||
@ -65,7 +62,7 @@ class Random
|
||||
* @return String
|
||||
* @access public
|
||||
*/
|
||||
static function crypt_random_string($length)
|
||||
static function string($length)
|
||||
{
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
// method 1. prior to PHP 5.3 this would call rand() on windows hence the function_exists('class_alias') call.
|
||||
@ -231,7 +228,7 @@ class Random
|
||||
$crypto = new Crypt_RC4();
|
||||
break;
|
||||
default:
|
||||
user_error('crypt_random_string requires at least one symmetric cipher be loaded');
|
||||
user_error('string requires at least one symmetric cipher be loaded');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3475,7 +3475,7 @@ class File_X509
|
||||
// "A challenge string that is submitted along with the public key. Defaults to an empty string if not specified."
|
||||
// both Firefox and OpenSSL ("openssl spkac -key private.key") behave this way
|
||||
// we could alternatively do this instead if we ignored the specs:
|
||||
// Random::crypt_random_string(8) & str_repeat("\x7F", 8)
|
||||
// Random::string(8) & str_repeat("\x7F", 8)
|
||||
'challenge' => !empty($this->challenge) ? $this->challenge : ''
|
||||
),
|
||||
'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm),
|
||||
|
@ -3032,7 +3032,7 @@ class BigInteger
|
||||
function _random_number_helper($size)
|
||||
{
|
||||
if (class_exists('phpseclib\Crypt\Random')) {
|
||||
$random = Random::crypt_random_string($size);
|
||||
$random = Random::string($size);
|
||||
} else {
|
||||
$random = '';
|
||||
|
||||
|
@ -632,7 +632,7 @@ class Net_SSH1
|
||||
|
||||
$session_id = pack('H*', md5($host_key_public_modulus->toBytes() . $server_key_public_modulus->toBytes() . $anti_spoofing_cookie));
|
||||
|
||||
$session_key = Random::crypt_random_string(32);
|
||||
$session_key = Random::string(32);
|
||||
$double_encrypted_session_key = $session_key ^ str_pad($session_id, 32, chr(0));
|
||||
|
||||
if ($server_key_public_modulus->compare($host_key_public_modulus) < 0) {
|
||||
@ -1180,7 +1180,7 @@ class Net_SSH1
|
||||
|
||||
$length = strlen($data) + 4;
|
||||
|
||||
$padding = Random::crypt_random_string(8 - ($length & 7));
|
||||
$padding = Random::string(8 - ($length & 7));
|
||||
|
||||
$orig = $data;
|
||||
$data = $padding . $data;
|
||||
@ -1366,7 +1366,7 @@ class Net_SSH1
|
||||
$length = strlen($modulus) - strlen($m) - 3;
|
||||
$random = '';
|
||||
while (strlen($random) != $length) {
|
||||
$block = Random::crypt_random_string($length - strlen($random));
|
||||
$block = Random::string($length - strlen($random));
|
||||
$block = str_replace("\x00", '', $block);
|
||||
$random.= $block;
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ class Net_SSH2
|
||||
$compression_algorithms_server_to_client = $compression_algorithms_client_to_server = implode(',', $compression_algorithms);
|
||||
}
|
||||
|
||||
$client_cookie = Random::crypt_random_string(16);
|
||||
$client_cookie = Random::string(16);
|
||||
|
||||
$response = $kexinit_payload_server;
|
||||
$this->_string_shift($response, 1); // skip past the message number (it should be SSH_MSG_KEXINIT)
|
||||
@ -3155,7 +3155,7 @@ class Net_SSH2
|
||||
$packet_length+= (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size;
|
||||
// subtracting strlen($data) is obvious - subtracting 5 is necessary because of packet_length and padding_length
|
||||
$padding_length = $packet_length - strlen($data) - 5;
|
||||
$padding = Random::crypt_random_string($padding_length);
|
||||
$padding = Random::string($padding_length);
|
||||
|
||||
// we subtract 4 from packet_length because the packet_length field isn't supposed to include itself
|
||||
$packet = pack('NCa*', $packet_length - 4, $padding_length, $data . $padding);
|
||||
|
Loading…
Reference in New Issue
Block a user