Merge pull request #810 from GrahamForks/cs

PHPDoc Fixes And Others

* GrahamForks/cs:
  Fixed another case
  Minor tweaks
  Fixed error
  More fixes
  PHPDoc fixes
This commit is contained in:
Andreas Fischer 2015-09-14 01:18:09 +02:00
commit 71d7108d9a
19 changed files with 144 additions and 128 deletions

View File

@ -950,7 +950,7 @@ class Crypt_Base
if ($this->continuousBuffer) { if ($this->continuousBuffer) {
$this->encryptIV = $xor; $this->encryptIV = $xor;
if ($start = strlen($plaintext) % $block_size) { if ($start = strlen($plaintext) % $block_size) {
$buffer['xor'] = substr($key, $start) . $buffer['xor']; $buffer['xor'] = substr($key, $start) . $buffer['xor'];
} }
} }
break; break;
@ -1240,7 +1240,7 @@ class Crypt_Base
if ($this->continuousBuffer) { if ($this->continuousBuffer) {
$this->decryptIV = $xor; $this->decryptIV = $xor;
if ($start = strlen($ciphertext) % $block_size) { if ($start = strlen($ciphertext) % $block_size) {
$buffer['xor'] = substr($key, $start) . $buffer['xor']; $buffer['xor'] = substr($key, $start) . $buffer['xor'];
} }
} }
break; break;
@ -1790,7 +1790,6 @@ class Crypt_Base
if ($this->mode == CRYPT_MODE_CFB) { if ($this->mode == CRYPT_MODE_CFB) {
$this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, ''); $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
} }
} // else should mcrypt_generic_deinit be called? } // else should mcrypt_generic_deinit be called?
if ($this->mode == CRYPT_MODE_CFB) { if ($this->mode == CRYPT_MODE_CFB) {

View File

@ -165,7 +165,7 @@ class Crypt_Blowfish extends Crypt_Base
* @access private * @access private
* @var array * @var array
*/ */
var $sbox0 = array ( var $sbox0 = array(
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
@ -544,7 +544,7 @@ class Crypt_Blowfish extends Crypt_Base
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
// (Currently, for Crypt_Blowfish, one generated $lambda_function cost on php5.5@32bit ~100kb unfreeable mem and ~180kb on php5.5@64bit) // (Currently, for Crypt_Blowfish, one generated $lambda_function cost on php5.5@32bit ~100kb unfreeable mem and ~180kb on php5.5@64bit)
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one. // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); $gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
// Generation of a unique hash for our generated code // Generation of a unique hash for our generated code
$code_hash = "Crypt_Blowfish, {$this->mode}"; $code_hash = "Crypt_Blowfish, {$this->mode}";

View File

@ -637,7 +637,7 @@ class Crypt_RC2 extends Crypt_Base
// for the mixing rounds, for better inline crypt performance [~20% faster]. // for the mixing rounds, for better inline crypt performance [~20% faster].
// But for memory reason we have to limit those ultra-optimized $lambda_functions to an amount of 10. // But for memory reason we have to limit those ultra-optimized $lambda_functions to an amount of 10.
// (Currently, for Crypt_RC2, one generated $lambda_function cost on php5.5@32bit ~60kb unfreeable mem and ~100kb on php5.5@64bit) // (Currently, for Crypt_RC2, one generated $lambda_function cost on php5.5@32bit ~60kb unfreeable mem and ~100kb on php5.5@64bit)
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); $gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
// Generation of a uniqe hash for our generated code // Generation of a uniqe hash for our generated code
$code_hash = "Crypt_RC2, {$this->mode}"; $code_hash = "Crypt_RC2, {$this->mode}";

View File

@ -1644,7 +1644,6 @@ class Crypt_RSA
break; break;
} }
} }
} else { } else {
$components = $this->_parseKey($key, $type); $components = $this->_parseKey($key, $type);
} }
@ -1859,7 +1858,6 @@ class Crypt_RSA
default: default:
return false; return false;
} }
} }
/** /**

View File

@ -268,7 +268,7 @@ if (!function_exists('phpseclib_resolve_include_path')) {
* PHP 5.3.2) with fallback implementation for earlier PHP versions. * PHP 5.3.2) with fallback implementation for earlier PHP versions.
* *
* @param string $filename * @param string $filename
* @return mixed Filename (string) on success, false otherwise. * @return string|false
* @access public * @access public
*/ */
function phpseclib_resolve_include_path($filename) function phpseclib_resolve_include_path($filename)

View File

@ -755,7 +755,7 @@ class Crypt_Rijndael extends Crypt_Base
{ {
static $sbox; static $sbox;
if (empty($sbox)) { if (empty($sbox)) {
list(,,,, $sbox) = $this->_getTables(); list(, , , , $sbox) = $this->_getTables();
} }
return $sbox[$word & 0x000000FF] | return $sbox[$word & 0x000000FF] |
@ -954,7 +954,7 @@ class Crypt_Rijndael extends Crypt_Base
// We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function. // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
// (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit) // (Currently, for Crypt_Rijndael/AES, one generated $lambda_function cost on php5.5@32bit ~80kb unfreeable mem and ~130kb on php5.5@64bit)
// After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one. // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); $gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
// Generation of a uniqe hash for our generated code // Generation of a uniqe hash for our generated code
$code_hash = "Crypt_Rijndael, {$this->mode}, {$this->Nr}, {$this->Nb}"; $code_hash = "Crypt_Rijndael, {$this->mode}, {$this->Nr}, {$this->Nb}";

View File

@ -144,7 +144,7 @@ class Crypt_Twofish extends Crypt_Base
* @var array * @var array
* @access private * @access private
*/ */
var $q0 = array ( var $q0 = array(
0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76,
0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38,
0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,
@ -185,7 +185,7 @@ class Crypt_Twofish extends Crypt_Base
* @var array * @var array
* @access private * @access private
*/ */
var $q1 = array ( var $q1 = array(
0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8,
0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B,
0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,
@ -226,7 +226,7 @@ class Crypt_Twofish extends Crypt_Base
* @var array * @var array
* @access private * @access private
*/ */
var $m0 = array ( var $m0 = array(
0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8, 0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8,
0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B,
0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1, 0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1,
@ -267,7 +267,7 @@ class Crypt_Twofish extends Crypt_Base
* @var array * @var array
* @access private * @access private
*/ */
var $m1 = array ( var $m1 = array(
0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4, 0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4,
0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A,
0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141, 0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141,
@ -308,7 +308,7 @@ class Crypt_Twofish extends Crypt_Base
* @var array * @var array
* @access private * @access private
*/ */
var $m2 = array ( var $m2 = array(
0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA, 0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA,
0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7,
0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783, 0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783,
@ -349,7 +349,7 @@ class Crypt_Twofish extends Crypt_Base
* @var array * @var array
* @access private * @access private
*/ */
var $m3 = array ( var $m3 = array(
0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF, 0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF,
0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836,
0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77, 0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77,
@ -492,9 +492,9 @@ class Crypt_Twofish extends Crypt_Base
switch (strlen($this->key)) { switch (strlen($this->key)) {
case 16: case 16:
list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]); list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]);
list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]); list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]);
for ($i = 0, $j = 1; $i < 40; $i+= 2,$j+= 2) { for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
$A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^
$m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^
$m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^
@ -515,9 +515,9 @@ class Crypt_Twofish extends Crypt_Base
} }
break; break;
case 24: case 24:
list ($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]); list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]);
list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]); list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]);
list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]); list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]);
for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
$A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
$m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
@ -539,10 +539,10 @@ class Crypt_Twofish extends Crypt_Base
} }
break; break;
default: // 32 default: // 32
list ($sf, $se, $sd, $sc) = $this->_mdsrem($le_longs[1], $le_longs[2]); list($sf, $se, $sd, $sc) = $this->_mdsrem($le_longs[1], $le_longs[2]);
list ($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]); list($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]);
list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]); list($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]);
list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]); list($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]);
for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
$A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
$m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
@ -743,7 +743,7 @@ class Crypt_Twofish extends Crypt_Base
// Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one. // Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one.
// (Currently, for Crypt_Twofish, one generated $lambda_function cost on php5.5@32bit ~140kb unfreeable mem and ~240kb on php5.5@64bit) // (Currently, for Crypt_Twofish, one generated $lambda_function cost on php5.5@32bit ~140kb unfreeable mem and ~240kb on php5.5@64bit)
$gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); $gen_hi_opt_code = (bool)(count($lambda_functions) < 10);
// Generation of a uniqe hash for our generated code // Generation of a uniqe hash for our generated code
$code_hash = "Crypt_Twofish, {$this->mode}"; $code_hash = "Crypt_Twofish, {$this->mode}";

View File

@ -3758,7 +3758,7 @@ class File_X509
* @param string $path absolute path with / as component separator * @param string $path absolute path with / as component separator
* @param bool $create optional * @param bool $create optional
* @access private * @access private
* @return array item ref or false * @return array|false
*/ */
function &_subArray(&$root, $path, $create = false) function &_subArray(&$root, $path, $create = false)
{ {
@ -3794,7 +3794,7 @@ class File_X509
* @param string $path optional absolute path with / as component separator * @param string $path optional absolute path with / as component separator
* @param bool $create optional * @param bool $create optional
* @access private * @access private
* @return array ref or false * @return array|false
*/ */
function &_extensions(&$root, $path = null, $create = false) function &_extensions(&$root, $path = null, $create = false)
{ {
@ -4381,7 +4381,7 @@ class File_X509
* @param string $serial * @param string $serial
* @param bool $create optional * @param bool $create optional
* @access private * @access private
* @return int or false * @return int|false
*/ */
function _revokedCertificate(&$rclist, $serial, $create = false) function _revokedCertificate(&$rclist, $serial, $create = false)
{ {
@ -4631,7 +4631,7 @@ class File_X509
* getOID('zzz') == 'zzz' * getOID('zzz') == 'zzz'
* *
* @access public * @access public
* @return String * @return string
*/ */
function getOID($name) function getOID($name)
{ {

View File

@ -423,13 +423,13 @@ class Math_BigInteger
$this->is_negative = false; $this->is_negative = false;
break; break;
case MATH_BIGINTEGER_MODE_BCMATH: case MATH_BIGINTEGER_MODE_BCMATH:
$x = ( strlen($x) & 1 ) ? '0' . $x : $x; $x = (strlen($x) & 1) ? '0' . $x : $x;
$temp = new Math_BigInteger(pack('H*', $x), 256); $temp = new Math_BigInteger(pack('H*', $x), 256);
$this->value = $this->is_negative ? '-' . $temp->value : $temp->value; $this->value = $this->is_negative ? '-' . $temp->value : $temp->value;
$this->is_negative = false; $this->is_negative = false;
break; break;
default: default:
$x = ( strlen($x) & 1 ) ? '0' . $x : $x; $x = (strlen($x) & 1) ? '0' . $x : $x;
$temp = new Math_BigInteger(pack('H*', $x), 256); $temp = new Math_BigInteger(pack('H*', $x), 256);
$this->value = $temp->value; $this->value = $temp->value;
} }
@ -558,7 +558,7 @@ class Math_BigInteger
} }
$temp = gmp_strval(gmp_abs($this->value), 16); $temp = gmp_strval(gmp_abs($this->value), 16);
$temp = ( strlen($temp) & 1 ) ? '0' . $temp : $temp; $temp = (strlen($temp) & 1) ? '0' . $temp : $temp;
$temp = pack('H*', $temp); $temp = pack('H*', $temp);
return $this->precision > 0 ? return $this->precision > 0 ?
@ -802,7 +802,6 @@ class Math_BigInteger
$vars[] = 'precision'; $vars[] = 'precision';
} }
return $vars; return $vars;
} }
/** /**
@ -1512,7 +1511,7 @@ class Math_BigInteger
); );
$y_window = array( $y_window = array(
$y_value[$y_max], $y_value[$y_max],
( $y_max > 0 ) ? $y_value[$y_max - 1] : 0 ($y_max > 0) ? $y_value[$y_max - 1] : 0
); );
$q_index = $i - $y_max - 1; $q_index = $i - $y_max - 1;
@ -1706,10 +1705,10 @@ class Math_BigInteger
} }
if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH) { if (MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH) {
$temp = new Math_BigInteger(); $temp = new Math_BigInteger();
$temp->value = bcpowmod($this->value, $e->value, $n->value, 0); $temp->value = bcpowmod($this->value, $e->value, $n->value, 0);
return $this->_normalize($temp); return $this->_normalize($temp);
} }
if (empty($e->value)) { if (empty($e->value)) {
@ -1760,7 +1759,7 @@ class Math_BigInteger
$mod2->value = array(1); $mod2->value = array(1);
$mod2->_lshift($j); $mod2->_lshift($j);
$part1 = ( $mod1->value != array(1) ) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger(); $part1 = ($mod1->value != array(1)) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger();
$part2 = $this->_slidingWindow($e, $mod2, MATH_BIGINTEGER_POWEROF2); $part2 = $this->_slidingWindow($e, $mod2, MATH_BIGINTEGER_POWEROF2);
$y1 = $mod2->modInverse($mod1); $y1 = $mod2->modInverse($mod1);
@ -1855,13 +1854,14 @@ class Math_BigInteger
} }
} }
for ($k = 0; $k <= $j; ++$k) {// eg. the length of substr($e_bits, $i, $j+1) // eg. the length of substr($e_bits, $i, $j + 1)
for ($k = 0; $k <= $j; ++$k) {
$result = $this->_squareReduce($result, $n_value, $mode); $result = $this->_squareReduce($result, $n_value, $mode);
} }
$result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode); $result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode);
$i+=$j + 1; $i += $j + 1;
} }
} }
@ -2430,7 +2430,7 @@ class Math_BigInteger
* </code> * </code>
* *
* @param Math_BigInteger $n * @param Math_BigInteger $n
* @return mixed false, if no modular inverse exists, Math_BigInteger, otherwise. * @return Math_BigInteger|false
* @access public * @access public
* @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information. * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information.
*/ */
@ -2441,7 +2441,7 @@ class Math_BigInteger
$temp = new Math_BigInteger(); $temp = new Math_BigInteger();
$temp->value = gmp_invert($this->value, $n->value); $temp->value = gmp_invert($this->value, $n->value);
return ( $temp->value === false ) ? false : $this->_normalize($temp); return ($temp->value === false) ? false : $this->_normalize($temp);
} }
static $zero, $one; static $zero, $one;
@ -2705,13 +2705,13 @@ class Math_BigInteger
function _compare($x_value, $x_negative, $y_value, $y_negative) function _compare($x_value, $x_negative, $y_value, $y_negative)
{ {
if ($x_negative != $y_negative) { if ($x_negative != $y_negative) {
return ( !$x_negative && $y_negative ) ? 1 : -1; return (!$x_negative && $y_negative) ? 1 : -1;
} }
$result = $x_negative ? -1 : 1; $result = $x_negative ? -1 : 1;
if (count($x_value) != count($y_value)) { if (count($x_value) != count($y_value)) {
return ( count($x_value) > count($y_value) ) ? $result : -$result; return (count($x_value) > count($y_value)) ? $result : -$result;
} }
$size = max(count($x_value), count($y_value)); $size = max(count($x_value), count($y_value));
@ -2720,7 +2720,7 @@ class Math_BigInteger
for ($i = count($x_value) - 1; $i >= 0; --$i) { for ($i = count($x_value) - 1; $i >= 0; --$i) {
if ($x_value[$i] != $y_value[$i]) { if ($x_value[$i] != $y_value[$i]) {
return ( $x_value[$i] > $y_value[$i] ) ? $result : -$result; return ($x_value[$i] > $y_value[$i]) ? $result : -$result;
} }
} }
@ -3190,13 +3190,13 @@ class Math_BigInteger
/** /**
* Generate a random prime number. * Generate a random prime number.
* *
* If there's not a prime within the given range, false will be returned. If more than $timeout seconds have elapsed, * If there's not a prime within the given range, false will be returned.
* give up and return false. * If more than $timeout seconds have elapsed, give up and return false.
* *
* @param Math_BigInteger $arg1 * @param Math_BigInteger $arg1
* @param Math_BigInteger $arg2 * @param Math_BigInteger $arg2
* @param int $timeout * @param int $timeout
* @return mixed * @return Math_BigInteger|false
* @access public * @access public
* @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=15 HAC 4.44}. * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=15 HAC 4.44}.
*/ */

View File

@ -1414,7 +1414,7 @@ class Net_SSH1
* Returns a string if NET_SSH1_LOGGING == NET_SSH1_LOG_COMPLEX, an array if NET_SSH1_LOGGING == NET_SSH1_LOG_SIMPLE and false if !defined('NET_SSH1_LOGGING') * Returns a string if NET_SSH1_LOGGING == NET_SSH1_LOG_COMPLEX, an array if NET_SSH1_LOGGING == NET_SSH1_LOG_SIMPLE and false if !defined('NET_SSH1_LOGGING')
* *
* @access public * @access public
* @return string or Array * @return array|false|string
*/ */
function getLog() function getLog()
{ {

View File

@ -192,7 +192,7 @@ class Net_SSH2
* Server Identifier * Server Identifier
* *
* @see Net_SSH2::getServerIdentification() * @see Net_SSH2::getServerIdentification()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $server_identifier = false; var $server_identifier = false;
@ -201,7 +201,7 @@ class Net_SSH2
* Key Exchange Algorithms * Key Exchange Algorithms
* *
* @see Net_SSH2::getKexAlgorithims() * @see Net_SSH2::getKexAlgorithims()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $kex_algorithms = false; var $kex_algorithms = false;
@ -237,7 +237,7 @@ class Net_SSH2
* Server Host Key Algorithms * Server Host Key Algorithms
* *
* @see Net_SSH2::getServerHostKeyAlgorithms() * @see Net_SSH2::getServerHostKeyAlgorithms()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $server_host_key_algorithms = false; var $server_host_key_algorithms = false;
@ -246,7 +246,7 @@ class Net_SSH2
* Encryption Algorithms: Client to Server * Encryption Algorithms: Client to Server
* *
* @see Net_SSH2::getEncryptionAlgorithmsClient2Server() * @see Net_SSH2::getEncryptionAlgorithmsClient2Server()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $encryption_algorithms_client_to_server = false; var $encryption_algorithms_client_to_server = false;
@ -255,7 +255,7 @@ class Net_SSH2
* Encryption Algorithms: Server to Client * Encryption Algorithms: Server to Client
* *
* @see Net_SSH2::getEncryptionAlgorithmsServer2Client() * @see Net_SSH2::getEncryptionAlgorithmsServer2Client()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $encryption_algorithms_server_to_client = false; var $encryption_algorithms_server_to_client = false;
@ -264,7 +264,7 @@ class Net_SSH2
* MAC Algorithms: Client to Server * MAC Algorithms: Client to Server
* *
* @see Net_SSH2::getMACAlgorithmsClient2Server() * @see Net_SSH2::getMACAlgorithmsClient2Server()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $mac_algorithms_client_to_server = false; var $mac_algorithms_client_to_server = false;
@ -273,7 +273,7 @@ class Net_SSH2
* MAC Algorithms: Server to Client * MAC Algorithms: Server to Client
* *
* @see Net_SSH2::getMACAlgorithmsServer2Client() * @see Net_SSH2::getMACAlgorithmsServer2Client()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $mac_algorithms_server_to_client = false; var $mac_algorithms_server_to_client = false;
@ -282,7 +282,7 @@ class Net_SSH2
* Compression Algorithms: Client to Server * Compression Algorithms: Client to Server
* *
* @see Net_SSH2::getCompressionAlgorithmsClient2Server() * @see Net_SSH2::getCompressionAlgorithmsClient2Server()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $compression_algorithms_client_to_server = false; var $compression_algorithms_client_to_server = false;
@ -291,7 +291,7 @@ class Net_SSH2
* Compression Algorithms: Server to Client * Compression Algorithms: Server to Client
* *
* @see Net_SSH2::getCompressionAlgorithmsServer2Client() * @see Net_SSH2::getCompressionAlgorithmsServer2Client()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $compression_algorithms_server_to_client = false; var $compression_algorithms_server_to_client = false;
@ -300,7 +300,7 @@ class Net_SSH2
* Languages: Server to Client * Languages: Server to Client
* *
* @see Net_SSH2::getLanguagesServer2Client() * @see Net_SSH2::getLanguagesServer2Client()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $languages_server_to_client = false; var $languages_server_to_client = false;
@ -309,7 +309,7 @@ class Net_SSH2
* Languages: Client to Server * Languages: Client to Server
* *
* @see Net_SSH2::getLanguagesClient2Server() * @see Net_SSH2::getLanguagesClient2Server()
* @var mixed false or Array * @var array|false
* @access private * @access private
*/ */
var $languages_client_to_server = false; var $languages_client_to_server = false;
@ -1898,7 +1898,7 @@ class Net_SSH2
* Maps an encryption algorithm name to the number of key bytes. * Maps an encryption algorithm name to the number of key bytes.
* *
* @param string $algorithm Name of the encryption algorithm * @param string $algorithm Name of the encryption algorithm
* @return mixed Number of bytes as an integer or null for unknown * @return int|null Number of bytes as an integer or null for unknown
* @access private * @access private
*/ */
function _encryption_algorithm_to_key_size($algorithm) function _encryption_algorithm_to_key_size($algorithm)
@ -3758,7 +3758,7 @@ class Net_SSH2
* Returns a string if NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX, an array if NET_SSH2_LOGGING == NET_SSH2_LOG_SIMPLE and false if !defined('NET_SSH2_LOGGING') * Returns a string if NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX, an array if NET_SSH2_LOGGING == NET_SSH2_LOG_SIMPLE and false if !defined('NET_SSH2_LOGGING')
* *
* @access public * @access public
* @return string or Array * @return array|false|string
*/ */
function getLog() function getLog()
{ {
@ -4191,7 +4191,7 @@ class Net_SSH2
/** /**
* Returns the exit status of an SSH command or false. * Returns the exit status of an SSH command or false.
* *
* @return int or false * @return false|int
* @access public * @access public
*/ */
function getExitStatus() function getExitStatus()

View File

@ -144,8 +144,8 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
} }
/** /**
* @depends testStatOnDir * @depends testStatOnDir
*/ */
public function testPutSizeGetFileCallback($sftp) public function testPutSizeGetFileCallback($sftp)
{ {
self::$buffer = self::$exampleData; self::$buffer = self::$exampleData;

View File

@ -56,13 +56,15 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
$result = array(); $result = array();
// @codingStandardsIgnoreStart foreach ($modes as $mode) {
foreach ($modes as $mode) foreach ($plaintexts as $plaintext) {
foreach ($plaintexts as $plaintext) foreach ($ivs as $iv) {
foreach ($ivs as $iv) foreach ($keys as $key) {
foreach ($keys as $key) $result[] = array($mode, $plaintext, $iv, $key);
$result[] = array($mode, $plaintext, $iv, $key); }
// @codingStandardsIgnoreEnd }
}
}
return $result; return $result;
} }
@ -122,10 +124,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
} }
/** /**
* Produces all combinations of test values. * Produces all combinations of test values.
* *
* @return array * @return array
*/ */
public function continuousBufferBatteryCombos() public function continuousBufferBatteryCombos()
{ {
$modes = array( $modes = array(
@ -153,19 +155,20 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
$result = array(); $result = array();
// @codingStandardsIgnoreStart foreach ($modes as $mode) {
foreach ($modes as $mode) foreach ($combos as $combo) {
foreach ($combos as $combo) foreach (array('encrypt', 'decrypt') as $op) {
foreach (array('encrypt', 'decrypt') as $op) $result[] = array($op, $mode, $combo);
$result[] = array($op, $mode, $combo); }
// @codingStandardsIgnoreEnd }
}
return $result; return $result;
} }
/** /**
* @dataProvider continuousBufferBatteryCombos * @dataProvider continuousBufferBatteryCombos
*/ */
public function testContinuousBufferBattery($op, $mode, $test) public function testContinuousBufferBattery($op, $mode, $test)
{ {
$iv = str_repeat('x', 16); $iv = str_repeat('x', 16);
@ -209,9 +212,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
} }
/** /**
* @dataProvider continuousBufferBatteryCombos * Pretty much the same as testContinuousBufferBattery with the caveat that continuous mode is not enabled.
*/ *
// pretty much the same as testContinuousBufferBattery with the caveat that continuous mode is not enabled * @dataProvider continuousBufferBatteryCombos
*/
public function testNonContinuousBufferBattery($op, $mode, $test) public function testNonContinuousBufferBattery($op, $mode, $test)
{ {
if (count($test) == 1) { if (count($test) == 1) {

View File

@ -55,18 +55,21 @@ class Unit_Crypt_BlowfishTest extends PhpseclibTestCase
array(pack('H*', '0123456789ABCDEF'), pack('H*', '0000000000000000'), pack('H*', '245946885754369A')), array(pack('H*', '0123456789ABCDEF'), pack('H*', '0000000000000000'), pack('H*', '245946885754369A')),
array(pack('H*', 'FEDCBA9876543210'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '6B5C5A9C5D9E0A5A')) array(pack('H*', 'FEDCBA9876543210'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '6B5C5A9C5D9E0A5A'))
); );
$result = array(); $result = array();
// @codingStandardsIgnoreStart
foreach ($engines as $engine => $engineName) foreach ($engines as $engine => $engineName) {
foreach ($tests as $test) foreach ($tests as $test) {
$result[] = array($engine, $engineName, $test[0], $test[1], $test[2]); $result[] = array($engine, $engineName, $test[0], $test[1], $test[2]);
// @codingStandardsIgnoreEnd }
}
return $result; return $result;
} }
/** /**
* @dataProvider engineVectors * @dataProvider engineVectors
*/ */
public function testVectors($engine, $engineName, $key, $plaintext, $expected) public function testVectors($engine, $engineName, $key, $plaintext, $expected)
{ {
$bf = new Crypt_Blowfish(); $bf = new Crypt_Blowfish();

View File

@ -29,12 +29,15 @@ class Unit_Crypt_RC2Test extends PhpseclibTestCase
array('88bca90e90875a7f0f79c384627bafb2', 128, '0000000000000000', '2269552ab0f85ca6'), array('88bca90e90875a7f0f79c384627bafb2', 128, '0000000000000000', '2269552ab0f85ca6'),
array('88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e', 129, '0000000000000000', '5b78d3a43dfff1f1') array('88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e', 129, '0000000000000000', '5b78d3a43dfff1f1')
); );
$result = array(); $result = array();
// @codingStandardsIgnoreStart
foreach ($this->engines as $engine => $engineName) foreach ($this->engines as $engine => $engineName) {
foreach ($tests as $test) foreach ($tests as $test) {
$result[] = array($engine, $engineName, $test[0], $test[1], $test[2], $test[3]); $result[] = array($engine, $engineName, $test[0], $test[1], $test[2], $test[3]);
// @codingStandardsIgnoreEnd }
}
return $result; return $result;
} }
@ -102,8 +105,8 @@ class Unit_Crypt_RC2Test extends PhpseclibTestCase
} }
/** /**
* @dataProvider engineVectors * @dataProvider engineVectors
*/ */
public function testVectors($engine, $engineName, $key, $keyLen, $plaintext, $ciphertext) public function testVectors($engine, $engineName, $key, $keyLen, $plaintext, $ciphertext)
{ {
$rc2 = new Crypt_RC2(); $rc2 = new Crypt_RC2();

View File

@ -180,19 +180,23 @@ class Unit_Crypt_RC4Test extends PhpseclibTestCase
) )
) )
); );
$result = array(); $result = array();
// @codingStandardsIgnoreStart
foreach ($engines as $engine => $engineName) foreach ($engines as $engine => $engineName) {
foreach ($tests as $test) foreach ($tests as $test) {
foreach ($test['output'] as $output) foreach ($test['output'] as $output) {
$result[] = array($engine, $engineName, $test['key'], $output['offset'], $output['result']); $result[] = array($engine, $engineName, $test['key'], $output['offset'], $output['result']);
// @codingStandardsIgnoreEnd }
}
}
return $result; return $result;
} }
/** /**
* @dataProvider engineVectors * @dataProvider engineVectors
*/ */
public function testVectors($engine, $engineName, $key, $offset, $expected) public function testVectors($engine, $engineName, $key, $offset, $expected)
{ {
$rc4 = new Crypt_RC4(); $rc4 = new Crypt_RC4();

View File

@ -86,18 +86,21 @@ class Unit_Crypt_TripleDESTest extends PhpseclibTestCase
array(str_repeat("\x01", 24), pack('H*', '0000000000000002'), pack('H*', '06E7EA22CE92708F')), array(str_repeat("\x01", 24), pack('H*', '0000000000000002'), pack('H*', '06E7EA22CE92708F')),
array(str_repeat("\x01", 24), pack('H*', '0000000000000001'), pack('H*', '166B40B44ABA4BD6')) array(str_repeat("\x01", 24), pack('H*', '0000000000000001'), pack('H*', '166B40B44ABA4BD6'))
); );
$result = array(); $result = array();
// @codingStandardsIgnoreStart
foreach ($this->engines as $engine => $engineName) foreach ($this->engines as $engine => $engineName) {
foreach ($tests as $test) foreach ($tests as $test) {
$result[] = array($engine, $engineName, $test[0], $test[1], $test[2]); $result[] = array($engine, $engineName, $test[0], $test[1], $test[2]);
// @codingStandardsIgnoreEnd }
}
return $result; return $result;
} }
/** /**
* @dataProvider engineVectors * @dataProvider engineVectors
*/ */
public function testVectors($engine, $engineName, $key, $plaintext, $expected) public function testVectors($engine, $engineName, $key, $plaintext, $expected)
{ {
$des = new Crypt_TripleDES(); $des = new Crypt_TripleDES();
@ -134,18 +137,21 @@ class Unit_Crypt_TripleDESTest extends PhpseclibTestCase
pack('H*', '84401f78fe6c10876d8ea23094ea5309'), pack('H*', '84401f78fe6c10876d8ea23094ea5309'),
pack('H*', '7b1f7c7e3b1c948ebd04a75ffba7d2f5')) pack('H*', '7b1f7c7e3b1c948ebd04a75ffba7d2f5'))
); );
$result = array(); $result = array();
// @codingStandardsIgnoreStart
foreach ($engines as $engine => $engineName) foreach ($engines as $engine => $engineName) {
foreach ($tests as $test) foreach ($tests as $test) {
$result[] = array($engine, $engineName, $test[0], $test[1], $test[2], $test[3]); $result[] = array($engine, $engineName, $test[0], $test[1], $test[2], $test[3]);
// @codingStandardsIgnoreEnd }
}
return $result; return $result;
} }
/** /**
* @dataProvider engineIVVectors * @dataProvider engineIVVectors
*/ */
public function testVectorsWithIV($engine, $engineName, $key, $iv, $plaintext, $expected) public function testVectorsWithIV($engine, $engineName, $key, $iv, $plaintext, $expected)
{ {
$des = new Crypt_TripleDES(); $des = new Crypt_TripleDES();

View File

@ -94,6 +94,5 @@ class Unit_File_X509_SPKACTest extends PhpseclibTestCase
$x509->validateSignature(), $x509->validateSignature(),
'Failed asserting that the signature is invalid' 'Failed asserting that the signature is invalid'
); );
} }
} }

View File

@ -52,7 +52,7 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
public function testToHex() public function testToHex()
{ {
$this->assertSame('41', $this->getInstance('65')->toHex()); $this->assertSame('41', $this->getInstance('65')->toHex());
} }
public function testToBits() public function testToBits()