Long array() to short [] syntax

This commit is contained in:
Sokolovskyy Roman 2017-11-27 09:30:14 +01:00
parent 2314b638c7
commit 966ee7f170
26 changed files with 560 additions and 560 deletions

View File

@ -64,7 +64,7 @@ abstract class Objects
* @return mixed * @return mixed
* @access public * @access public
*/ */
public static function callFunc($obj, $func, $params = array()) public static function callFunc($obj, $func, $params = [])
{ {
$reflection = new \ReflectionClass(get_class($obj)); $reflection = new \ReflectionClass(get_class($obj));
$method = $reflection->getMethod($func); $method = $reflection->getMethod($func);

View File

@ -2384,10 +2384,10 @@ class X509
$this->currentCert = [ $this->currentCert = [
'tbsCertificate' => 'tbsCertificate' =>
array( [
'version' => 'v3', 'version' => 'v3',
'serialNumber' => $serialNumber, // $this->setserialNumber() 'serialNumber' => $serialNumber, // $this->setserialNumber()
'signature' => array('algorithm' => $signatureAlgorithm), 'signature' => ['algorithm' => $signatureAlgorithm],
'issuer' => false, // this is going to be overwritten later 'issuer' => false, // this is going to be overwritten later
'validity' => [ 'validity' => [
'notBefore' => $this->timeField($startDate), // $this->setStartDate() 'notBefore' => $this->timeField($startDate), // $this->setStartDate()
@ -2395,7 +2395,7 @@ class X509
], ],
'subject' => $subject->dn, 'subject' => $subject->dn,
'subjectPublicKeyInfo' => $subjectPublicKey 'subjectPublicKeyInfo' => $subjectPublicKey
), ],
'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm], 'signatureAlgorithm' => ['algorithm' => $signatureAlgorithm],
'signature' => false // this is going to be overwritten later 'signature' => false // this is going to be overwritten later
]; ];
@ -3467,7 +3467,7 @@ class X509
// the former is a good example of how to do fuzzing on the public key // the former is a good example of how to do fuzzing on the public key
//return new Element(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey())); //return new Element(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey()));
return [ return [
'algorithm' => array('algorithm' => 'rsaEncryption'), 'algorithm' => ['algorithm' => 'rsaEncryption'],
'subjectPublicKey' => $this->publicKey->getPublicKey('PKCS1') 'subjectPublicKey' => $this->publicKey->getPublicKey('PKCS1')
]; ];
} }

View File

@ -243,7 +243,7 @@ abstract class PHP extends Engine
if ($x_negative != $y_negative) { if ($x_negative != $y_negative) {
if ($x_value == $y_value) { if ($x_value == $y_value) {
return [ return [
self::VALUE => array(), self::VALUE => [],
self::SIGN => false self::SIGN => false
]; ];
} }

View File

@ -3645,7 +3645,7 @@ class SSH2
return $data; return $data;
} }
if (!isset($this->channel_buffers[$channel])) { if (!isset($this->channel_buffers[$channel])) {
$this->channel_buffers[$channel] = array(); $this->channel_buffers[$channel] = [];
} }
$this->channel_buffers[$channel][] = $data; $this->channel_buffers[$channel][] = $data;

View File

@ -63,12 +63,12 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase
// TODO: Address https://github.com/phpseclib/phpseclib/issues/146 // TODO: Address https://github.com/phpseclib/phpseclib/issues/146
$this->assertContains( $this->assertContains(
strlen($content), strlen($content),
array(self::$exampleDataLength, self::$exampleDataLength + 1), [self::$exampleDataLength, self::$exampleDataLength + 1],
'Failed asserting that string length matches expected length.' 'Failed asserting that string length matches expected length.'
); );
$this->assertContains( $this->assertContains(
$content, $content,
array(self::$exampleData, self::$exampleData . "\0"), [self::$exampleData, self::$exampleData . "\0"],
'Failed asserting that string content matches expected content.' 'Failed asserting that string content matches expected content.'
); );
return $scp; return $scp;
@ -88,12 +88,12 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase
// TODO: Address https://github.com/phpseclib/phpseclib/issues/146 // TODO: Address https://github.com/phpseclib/phpseclib/issues/146
$this->assertContains( $this->assertContains(
filesize($localFilename), filesize($localFilename),
array(self::$exampleDataLength, self::$exampleDataLength + 1), [self::$exampleDataLength, self::$exampleDataLength + 1],
'Failed asserting that filesize matches expected data size.' 'Failed asserting that filesize matches expected data size.'
); );
$this->assertContains( $this->assertContains(
file_get_contents($localFilename), file_get_contents($localFilename),
array(self::$exampleData, self::$exampleData . "\0"), [self::$exampleData, self::$exampleData . "\0"],
'Failed asserting that file content matches expected content.' 'Failed asserting that file content matches expected content.'
); );
} }

View File

@ -18,9 +18,9 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
public function testFopenFcloseCreatesFile() public function testFopenFcloseCreatesFile()
{ {
$context = stream_context_create(array( $context = stream_context_create([
'sftp' => array('session' => $this->sftp), 'sftp' => ['session' => $this->sftp],
)); ]);
$fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context); $fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context);
$this->assertTrue(is_resource($fp)); $this->assertTrue(is_resource($fp));
fclose($fp); fclose($fp);
@ -32,9 +32,9 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
*/ */
public function testFilenameWithHash() public function testFilenameWithHash()
{ {
$context = stream_context_create(array( $context = stream_context_create([
'sftp' => array('session' => $this->sftp), 'sftp' => ['session' => $this->sftp],
)); ]);
$fp = fopen($this->buildUrl('te#st.txt'), 'wb', false, $context); $fp = fopen($this->buildUrl('te#st.txt'), 'wb', false, $context);
fputs($fp, 'zzzz'); fputs($fp, 'zzzz');
fclose($fp); fclose($fp);
@ -52,7 +52,7 @@ class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
$session = $this->sftp; $session = $this->sftp;
$dirs = scandir("sftp://$session/"); $dirs = scandir("sftp://$session/");
$this->assertCount($originalConnectionsCount, \phpseclib\Net\SSH2::getConnections()); $this->assertCount($originalConnectionsCount, \phpseclib\Net\SSH2::getConnections());
$this->assertEquals(array('.', '..'), array_slice($dirs, 0, 2)); $this->assertEquals(['.', '..'], array_slice($dirs, 0, 2));
} }
protected function buildUrl($suffix) protected function buildUrl($suffix)

View File

@ -127,7 +127,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
public function testStatOnDir($sftp) public function testStatOnDir($sftp)
{ {
$this->assertNotSame( $this->assertNotSame(
array(), [],
$sftp->stat('.'), $sftp->stat('.'),
'Failed asserting that the cwd has a non-empty stat.' 'Failed asserting that the cwd has a non-empty stat.'
); );
@ -177,7 +177,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
{ {
self::$buffer = self::$exampleData; self::$buffer = self::$exampleData;
$this->assertTrue( $this->assertTrue(
$sftp->put('file1.txt', array(__CLASS__, 'callback'), $sftp::SOURCE_CALLBACK), $sftp->put('file1.txt', [__CLASS__, 'callback'], $sftp::SOURCE_CALLBACK),
'Failed asserting that example data could be successfully put().' 'Failed asserting that example data could be successfully put().'
); );
@ -325,7 +325,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$sftp->setListOrder('filename', SORT_DESC); $sftp->setListOrder('filename', SORT_DESC);
$list = $sftp->nlist(); $list = $sftp->nlist();
$expected = array('.', '..', 'temp', 'file3.txt', 'file2.txt', 'file1.txt'); $expected = ['.', '..', 'temp', 'file3.txt', 'file2.txt', 'file1.txt'];
$this->assertSame( $this->assertSame(
$list, $list,
@ -336,7 +336,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
$sftp->setListOrder('filename', SORT_ASC); $sftp->setListOrder('filename', SORT_ASC);
$list = $sftp->nlist(); $list = $sftp->nlist();
$expected = array('.', '..', 'temp', 'file1.txt', 'file2.txt', 'file3.txt'); $expected = ['.', '..', 'temp', 'file1.txt', 'file2.txt', 'file3.txt'];
$this->assertSame( $this->assertSame(
$list, $list,

View File

@ -31,7 +31,7 @@ class Functional_Net_SSH2AgentTest extends PhpseclibFunctionalTestCase
'SSH2 login using Agent failed.' 'SSH2 login using Agent failed.'
); );
return array('ssh' => $ssh, 'ssh-agent' => $agent); return ['ssh' => $ssh, 'ssh-agent' => $agent];
} }
/** /**

View File

@ -108,12 +108,12 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
*/ */
public function testExecWithMethodCallback($ssh) public function testExecWithMethodCallback($ssh)
{ {
$callbackObject = $this->getMock('stdClass', array('callbackMethod')); $callbackObject = $this->getMock('stdClass', ['callbackMethod']);
$callbackObject $callbackObject
->expects($this->atLeastOnce()) ->expects($this->atLeastOnce())
->method('callbackMethod') ->method('callbackMethod')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$ssh->exec('pwd', array($callbackObject, 'callbackMethod')); $ssh->exec('pwd', [$callbackObject, 'callbackMethod']);
return $ssh; return $ssh;
} }

View File

@ -7,7 +7,7 @@
abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
{ {
protected $tempFilesToUnlinkOnTearDown = array(); protected $tempFilesToUnlinkOnTearDown = [];
public function tearDown() public function tearDown()
{ {
@ -110,7 +110,7 @@ abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase
return $prop->getValue($obj); return $prop->getValue($obj);
} }
public static function callFunc($obj, $func, $params = array()) public static function callFunc($obj, $func, $params = [])
{ {
$reflection = new ReflectionClass(get_class($obj)); $reflection = new ReflectionClass(get_class($obj));
$method = $reflection->getMethod($func); $method = $reflection->getMethod($func);

View File

@ -27,35 +27,35 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
*/ */
public function continuousBufferCombos() public function continuousBufferCombos()
{ {
$modes = array( $modes = [
'ctr', 'ctr',
'ofb', 'ofb',
'cfb', 'cfb',
'cfb8' 'cfb8'
); ];
$plaintexts = array( $plaintexts = [
'', '',
'12345678901234567', // https://github.com/phpseclib/phpseclib/issues/39 '12345678901234567', // https://github.com/phpseclib/phpseclib/issues/39
"\xDE\xAD\xBE\xAF", "\xDE\xAD\xBE\xAF",
':-):-):-):-):-):-)', // https://github.com/phpseclib/phpseclib/pull/43 ':-):-):-):-):-):-)', // https://github.com/phpseclib/phpseclib/pull/43
); ];
$ivs = array( $ivs = [
str_repeat("\0", 16), str_repeat("\0", 16),
str_pad('test123', 16, "\0"), str_pad('test123', 16, "\0"),
); ];
$keys = array( $keys = [
str_repeat("\0", 16), str_repeat("\0", 16),
str_pad(':-8', 16, "\0"), // https://github.com/phpseclib/phpseclib/pull/43 str_pad(':-8', 16, "\0"), // https://github.com/phpseclib/phpseclib/pull/43
str_pad('FOOBARZ', 16, "\0"), str_pad('FOOBARZ', 16, "\0"),
); ];
$result = array(); $result = [];
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[] = [$mode, $plaintext, $iv, $key];
} }
} }
} }
@ -128,36 +128,36 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
*/ */
public function continuousBufferBatteryCombos() public function continuousBufferBatteryCombos()
{ {
$modes = array( $modes = [
'ctr', 'ctr',
'ofb', 'ofb',
'cfb', 'cfb',
'cfb8', 'cfb8',
); ];
$combos = array( $combos = [
array(16), [16],
array(17), [17],
array(1, 16), [1, 16],
array(3, 6, 7), // (3 to test the openssl_encrypt call and the buffer creation, 6 to test the exclusive use of the buffer and 7 to test the buffer's exhaustion and recreation) [3, 6, 7], // (3 to test the openssl_encrypt call and the buffer creation, 6 to test the exclusive use of the buffer and 7 to test the buffer's exhaustion and recreation)
array(15, 4), // (15 to test openssl_encrypt call and buffer creation and 4 to test something that spans multpile bloc [15, 4], // (15 to test openssl_encrypt call and buffer creation and 4 to test something that spans multpile bloc
array(3, 6, 10, 16), // this is why the strlen check in the buffer-only code was needed [3, 6, 10, 16], // this is why the strlen check in the buffer-only code was needed
array(16, 16), // two full size blocks [16, 16], // two full size blocks
array(3, 6, 7, 16), // partial block + full size block [3, 6, 7, 16], // partial block + full size block
array(16, 3, 6, 7), [16, 3, 6, 7],
// a few others just for fun // a few others just for fun
array(32,32), [32,32],
array(31,31), [31,31],
array(17,17), [17,17],
array(99, 99) [99, 99]
); ];
$result = array(); $result = [];
foreach ($modes as $mode) { foreach ($modes as $mode) {
foreach ($combos as $combo) { foreach ($combos as $combo) {
foreach (array('encrypt', 'decrypt') as $op) { foreach (['encrypt', 'decrypt'] as $op) {
$result[] = array($op, $mode, $combo); $result[] = [$op, $mode, $combo];
} }
} }
} }

View File

@ -12,57 +12,57 @@ class Unit_Crypt_BlowfishTest extends PhpseclibTestCase
{ {
public function engineVectors() public function engineVectors()
{ {
$engines = array( $engines = [
'PHP', 'PHP',
'Eval', 'Eval',
'mcrypt', 'mcrypt',
'OpenSSL', 'OpenSSL',
); ];
// tests from https://www.schneier.com/code/vectors.txt // tests from https://www.schneier.com/code/vectors.txt
$tests = array( $tests = [
// key, plaintext, ciphertext // key, plaintext, ciphertext
array(pack('H*', '0000000000000000'), pack('H*', '0000000000000000'), pack('H*', '4EF997456198DD78')), [pack('H*', '0000000000000000'), pack('H*', '0000000000000000'), pack('H*', '4EF997456198DD78')],
array(pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '51866FD5B85ECB8A')), [pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '51866FD5B85ECB8A')],
array(pack('H*', '3000000000000000'), pack('H*', '1000000000000001'), pack('H*', '7D856F9A613063F2')), [pack('H*', '3000000000000000'), pack('H*', '1000000000000001'), pack('H*', '7D856F9A613063F2')],
array(pack('H*', '1111111111111111'), pack('H*', '1111111111111111'), pack('H*', '2466DD878B963C9D')), [pack('H*', '1111111111111111'), pack('H*', '1111111111111111'), pack('H*', '2466DD878B963C9D')],
array(pack('H*', '0123456789ABCDEF'), pack('H*', '1111111111111111'), pack('H*', '61F9C3802281B096')), [pack('H*', '0123456789ABCDEF'), pack('H*', '1111111111111111'), pack('H*', '61F9C3802281B096')],
array(pack('H*', '1111111111111111'), pack('H*', '0123456789ABCDEF'), pack('H*', '7D0CC630AFDA1EC7')), [pack('H*', '1111111111111111'), pack('H*', '0123456789ABCDEF'), pack('H*', '7D0CC630AFDA1EC7')],
array(pack('H*', '0000000000000000'), pack('H*', '0000000000000000'), pack('H*', '4EF997456198DD78')), [pack('H*', '0000000000000000'), pack('H*', '0000000000000000'), pack('H*', '4EF997456198DD78')],
array(pack('H*', 'FEDCBA9876543210'), pack('H*', '0123456789ABCDEF'), pack('H*', '0ACEAB0FC6A0A28D')), [pack('H*', 'FEDCBA9876543210'), pack('H*', '0123456789ABCDEF'), pack('H*', '0ACEAB0FC6A0A28D')],
array(pack('H*', '7CA110454A1A6E57'), pack('H*', '01A1D6D039776742'), pack('H*', '59C68245EB05282B')), [pack('H*', '7CA110454A1A6E57'), pack('H*', '01A1D6D039776742'), pack('H*', '59C68245EB05282B')],
array(pack('H*', '0131D9619DC1376E'), pack('H*', '5CD54CA83DEF57DA'), pack('H*', 'B1B8CC0B250F09A0')), [pack('H*', '0131D9619DC1376E'), pack('H*', '5CD54CA83DEF57DA'), pack('H*', 'B1B8CC0B250F09A0')],
array(pack('H*', '07A1133E4A0B2686'), pack('H*', '0248D43806F67172'), pack('H*', '1730E5778BEA1DA4')), [pack('H*', '07A1133E4A0B2686'), pack('H*', '0248D43806F67172'), pack('H*', '1730E5778BEA1DA4')],
array(pack('H*', '3849674C2602319E'), pack('H*', '51454B582DDF440A'), pack('H*', 'A25E7856CF2651EB')), [pack('H*', '3849674C2602319E'), pack('H*', '51454B582DDF440A'), pack('H*', 'A25E7856CF2651EB')],
array(pack('H*', '04B915BA43FEB5B6'), pack('H*', '42FD443059577FA2'), pack('H*', '353882B109CE8F1A')), [pack('H*', '04B915BA43FEB5B6'), pack('H*', '42FD443059577FA2'), pack('H*', '353882B109CE8F1A')],
array(pack('H*', '0113B970FD34F2CE'), pack('H*', '059B5E0851CF143A'), pack('H*', '48F4D0884C379918')), [pack('H*', '0113B970FD34F2CE'), pack('H*', '059B5E0851CF143A'), pack('H*', '48F4D0884C379918')],
array(pack('H*', '0170F175468FB5E6'), pack('H*', '0756D8E0774761D2'), pack('H*', '432193B78951FC98')), [pack('H*', '0170F175468FB5E6'), pack('H*', '0756D8E0774761D2'), pack('H*', '432193B78951FC98')],
array(pack('H*', '43297FAD38E373FE'), pack('H*', '762514B829BF486A'), pack('H*', '13F04154D69D1AE5')), [pack('H*', '43297FAD38E373FE'), pack('H*', '762514B829BF486A'), pack('H*', '13F04154D69D1AE5')],
array(pack('H*', '07A7137045DA2A16'), pack('H*', '3BDD119049372802'), pack('H*', '2EEDDA93FFD39C79')), [pack('H*', '07A7137045DA2A16'), pack('H*', '3BDD119049372802'), pack('H*', '2EEDDA93FFD39C79')],
array(pack('H*', '04689104C2FD3B2F'), pack('H*', '26955F6835AF609A'), pack('H*', 'D887E0393C2DA6E3')), [pack('H*', '04689104C2FD3B2F'), pack('H*', '26955F6835AF609A'), pack('H*', 'D887E0393C2DA6E3')],
array(pack('H*', '37D06BB516CB7546'), pack('H*', '164D5E404F275232'), pack('H*', '5F99D04F5B163969')), [pack('H*', '37D06BB516CB7546'), pack('H*', '164D5E404F275232'), pack('H*', '5F99D04F5B163969')],
array(pack('H*', '1F08260D1AC2465E'), pack('H*', '6B056E18759F5CCA'), pack('H*', '4A057A3B24D3977B')), [pack('H*', '1F08260D1AC2465E'), pack('H*', '6B056E18759F5CCA'), pack('H*', '4A057A3B24D3977B')],
array(pack('H*', '584023641ABA6176'), pack('H*', '004BD6EF09176062'), pack('H*', '452031C1E4FADA8E')), [pack('H*', '584023641ABA6176'), pack('H*', '004BD6EF09176062'), pack('H*', '452031C1E4FADA8E')],
array(pack('H*', '025816164629B007'), pack('H*', '480D39006EE762F2'), pack('H*', '7555AE39F59B87BD')), [pack('H*', '025816164629B007'), pack('H*', '480D39006EE762F2'), pack('H*', '7555AE39F59B87BD')],
array(pack('H*', '49793EBC79B3258F'), pack('H*', '437540C8698F3CFA'), pack('H*', '53C55F9CB49FC019')), [pack('H*', '49793EBC79B3258F'), pack('H*', '437540C8698F3CFA'), pack('H*', '53C55F9CB49FC019')],
array(pack('H*', '4FB05E1515AB73A7'), pack('H*', '072D43A077075292'), pack('H*', '7A8E7BFA937E89A3')), [pack('H*', '4FB05E1515AB73A7'), pack('H*', '072D43A077075292'), pack('H*', '7A8E7BFA937E89A3')],
array(pack('H*', '49E95D6D4CA229BF'), pack('H*', '02FE55778117F12A'), pack('H*', 'CF9C5D7A4986ADB5')), [pack('H*', '49E95D6D4CA229BF'), pack('H*', '02FE55778117F12A'), pack('H*', 'CF9C5D7A4986ADB5')],
array(pack('H*', '018310DC409B26D6'), pack('H*', '1D9D5C5018F728C2'), pack('H*', 'D1ABB290658BC778')), [pack('H*', '018310DC409B26D6'), pack('H*', '1D9D5C5018F728C2'), pack('H*', 'D1ABB290658BC778')],
array(pack('H*', '1C587F1C13924FEF'), pack('H*', '305532286D6F295A'), pack('H*', '55CB3774D13EF201')), [pack('H*', '1C587F1C13924FEF'), pack('H*', '305532286D6F295A'), pack('H*', '55CB3774D13EF201')],
array(pack('H*', '0101010101010101'), pack('H*', '0123456789ABCDEF'), pack('H*', 'FA34EC4847B268B2')), [pack('H*', '0101010101010101'), pack('H*', '0123456789ABCDEF'), pack('H*', 'FA34EC4847B268B2')],
array(pack('H*', '1F1F1F1F0E0E0E0E'), pack('H*', '0123456789ABCDEF'), pack('H*', 'A790795108EA3CAE')), [pack('H*', '1F1F1F1F0E0E0E0E'), pack('H*', '0123456789ABCDEF'), pack('H*', 'A790795108EA3CAE')],
array(pack('H*', 'E0FEE0FEF1FEF1FE'), pack('H*', '0123456789ABCDEF'), pack('H*', 'C39E072D9FAC631D')), [pack('H*', 'E0FEE0FEF1FEF1FE'), pack('H*', '0123456789ABCDEF'), pack('H*', 'C39E072D9FAC631D')],
array(pack('H*', '0000000000000000'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '014933E0CDAFF6E4')), [pack('H*', '0000000000000000'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '014933E0CDAFF6E4')],
array(pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '0000000000000000'), pack('H*', 'F21E9A77B71C49BC')), [pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '0000000000000000'), pack('H*', 'F21E9A77B71C49BC')],
array(pack('H*', '0123456789ABCDEF'), pack('H*', '0000000000000000'), pack('H*', '245946885754369A')), [pack('H*', '0123456789ABCDEF'), pack('H*', '0000000000000000'), pack('H*', '245946885754369A')],
array(pack('H*', 'FEDCBA9876543210'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '6B5C5A9C5D9E0A5A')) [pack('H*', 'FEDCBA9876543210'), pack('H*', 'FFFFFFFFFFFFFFFF'), pack('H*', '6B5C5A9C5D9E0A5A')]
); ];
$result = array(); $result = [];
foreach ($engines as $engine) { foreach ($engines as $engine) {
foreach ($tests as $test) { foreach ($tests as $test) {
$result[] = array($engine, $test[0], $test[1], $test[2]); $result[] = [$engine, $test[0], $test[1], $test[2]];
} }
} }
@ -90,7 +90,7 @@ class Unit_Crypt_BlowfishTest extends PhpseclibTestCase
public function testKeySizes() public function testKeySizes()
{ {
$objects = $engines = array(); $objects = $engines = [];
$temp = new Blowfish('ctr'); $temp = new Blowfish('ctr');
$temp->setPreferredEngine('PHP'); $temp->setPreferredEngine('PHP');
$objects[] = $temp; $objects[] = $temp;

View File

@ -39,86 +39,86 @@ class Unit_Crypt_HashTest extends PhpseclibTestCase
public static function hashData() public static function hashData()
{ {
return array( return [
array('md5', '', 'd41d8cd98f00b204e9800998ecf8427e'), ['md5', '', 'd41d8cd98f00b204e9800998ecf8427e'],
array('md5', 'The quick brown fox jumps over the lazy dog', '9e107d9d372bb6826bd81d3542a419d6'), ['md5', 'The quick brown fox jumps over the lazy dog', '9e107d9d372bb6826bd81d3542a419d6'],
array('md5', 'The quick brown fox jumps over the lazy dog.', 'e4d909c290d0fb1ca068ffaddf22cbd0'), ['md5', 'The quick brown fox jumps over the lazy dog.', 'e4d909c290d0fb1ca068ffaddf22cbd0'],
array('sha1', 'The quick brown fox jumps over the lazy dog', '2fd4e1c67a2d28fced849ee1bb76e7391b93eb12'), ['sha1', 'The quick brown fox jumps over the lazy dog', '2fd4e1c67a2d28fced849ee1bb76e7391b93eb12'],
array('sha1', 'The quick brown fox jumps over the lazy dog.', '408d94384216f890ff7a0c3528e8bed1e0b01621'), ['sha1', 'The quick brown fox jumps over the lazy dog.', '408d94384216f890ff7a0c3528e8bed1e0b01621'],
array( [
'sha256', 'sha256',
'', '',
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
), ],
array( [
'sha256', 'sha256',
'The quick brown fox jumps over the lazy dog', 'The quick brown fox jumps over the lazy dog',
'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592', 'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592',
), ],
array( [
'sha256', 'sha256',
'The quick brown fox jumps over the lazy dog.', 'The quick brown fox jumps over the lazy dog.',
'ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c', 'ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c',
), ],
array( [
'sha384', 'sha384',
'', '',
'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b' '38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b'
), ],
array( [
'sha384', 'sha384',
'The quick brown fox jumps over the lazy dog', 'The quick brown fox jumps over the lazy dog',
'ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1', 'ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1',
), ],
array( [
'sha512', 'sha512',
'', '',
'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e' 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
), ],
array( [
'sha512', 'sha512',
'The quick brown fox jumps over the lazy dog', 'The quick brown fox jumps over the lazy dog',
'07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6', '07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6',
), ],
array( [
'sha512', 'sha512',
'The quick brown fox jumps over the lazy dog.', 'The quick brown fox jumps over the lazy dog.',
'91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed', '91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed',
), ],
// from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512_224.pdf // from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512_224.pdf
array( [
'sha512/224', 'sha512/224',
'abc', 'abc',
'4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa' '4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa'
), ],
array( [
'sha512/224', 'sha512/224',
'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu', 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu',
'23fec5bb94d60b23308192640b0c453335d664734fe40e7268674af9' '23fec5bb94d60b23308192640b0c453335d664734fe40e7268674af9'
), ],
// from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512_256.pdf // from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA512_256.pdf
array( [
'sha512/256', 'sha512/256',
'abc', 'abc',
'53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23' '53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23'
), ],
array( [
'sha512/256', 'sha512/256',
'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu', 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu',
'3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a' '3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a'
), ],
// from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA224.pdf // from http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA224.pdf
array( [
'sha224', 'sha224',
'abc', 'abc',
'23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7' '23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7'
), ],
array( [
'sha224', 'sha224',
'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq', 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq',
'75388B16512776CC5DBA5DA1FD890150B0C6455CB4F58B1952522525' '75388B16512776CC5DBA5DA1FD890150B0C6455CB4F58B1952522525'
), ],
); ];
} }
/** /**
@ -139,187 +139,187 @@ class Unit_Crypt_HashTest extends PhpseclibTestCase
public static function hmacData() public static function hmacData()
{ {
return array( return [
array('md5', '', '', '74e6f7298a9c2d168935f58c001bad88'), ['md5', '', '', '74e6f7298a9c2d168935f58c001bad88'],
array('md5', 'key', 'The quick brown fox jumps over the lazy dog', '80070713463e7749b90c2dc24911e275'), ['md5', 'key', 'The quick brown fox jumps over the lazy dog', '80070713463e7749b90c2dc24911e275'],
// from https://tools.ietf.org/rfc/rfc4231.txt // from https://tools.ietf.org/rfc/rfc4231.txt
// test case 1 // test case 1
array( [
'sha224', 'sha224',
str_repeat("\x0b", 20), str_repeat("\x0b", 20),
'Hi There', 'Hi There',
'896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22', '896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22',
), ],
// test case 2 // test case 2
array( [
'sha224', 'sha224',
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44', 'a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44',
), ],
// test case 3 // test case 3
array( [
'sha224', 'sha224',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'),
'7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea', '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea',
), ],
// test case 4 // test case 4
array( [
'sha224', 'sha224',
pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'), pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'),
pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'), pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'),
'6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a', '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a',
), ],
// skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested // skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested
// test case 6 // test case 6
array( [
'sha224', 'sha224',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
'95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e', '95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870e',
), ],
// test case 7 // test case 7
array( [
'sha224', 'sha224',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.', 'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.',
'3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1' '3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1'
), ],
// test case 1 // test case 1
array( [
'sha256', 'sha256',
str_repeat("\x0b", 20), str_repeat("\x0b", 20),
'Hi There', 'Hi There',
'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7', 'b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7',
), ],
// test case 2 // test case 2
array( [
'sha256', 'sha256',
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843', '5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843',
), ],
// test case 3 // test case 3
array( [
'sha256', 'sha256',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'),
'773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe', '773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe',
), ],
// test case 4 // test case 4
array( [
'sha256', 'sha256',
pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'), pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'),
pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'), pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'),
'82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b', '82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b',
), ],
// skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested // skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested
// test case 6 // test case 6
array( [
'sha256', 'sha256',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
'60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54', '60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54',
), ],
// test case 7 // test case 7
array( [
'sha256', 'sha256',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.', 'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.',
'9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2' '9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2'
), ],
// test case 1 // test case 1
array( [
'sha384', 'sha384',
str_repeat("\x0b", 20), str_repeat("\x0b", 20),
'Hi There', 'Hi There',
'afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6', 'afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6',
), ],
// test case 2 // test case 2
array( [
'sha384', 'sha384',
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649', 'af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649',
), ],
// test case 3 // test case 3
array( [
'sha384', 'sha384',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'),
'88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27', '88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27',
), ],
// test case 4 // test case 4
array( [
'sha384', 'sha384',
pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'), pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'),
pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'), pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'),
'3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb', '3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffb',
), ],
// skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested // skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested
// test case 6 // test case 6
array( [
'sha384', 'sha384',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
'4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952', '4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952',
), ],
// test case 7 // test case 7
array( [
'sha384', 'sha384',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.', 'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.',
'6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e' '6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523e'
), ],
// test case 1 // test case 1
array( [
'sha512', 'sha512',
str_repeat("\x0b", 20), str_repeat("\x0b", 20),
'Hi There', 'Hi There',
'87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854', '87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854',
), ],
// test case 2 // test case 2
array( [
'sha512', 'sha512',
'Jefe', 'Jefe',
'what do ya want for nothing?', 'what do ya want for nothing?',
'164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737', '164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737',
), ],
// test case 3 // test case 3
array( [
'sha512', 'sha512',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), pack('H*', 'dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'),
'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb', 'fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb',
), ],
// test case 4 // test case 4
array( [
'sha512', 'sha512',
pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'), pack('H*', '0102030405060708090a0b0c0d0e0f10111213141516171819'),
pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'), pack('H*', 'cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd'),
'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd', 'b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd',
), ],
// skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested // skip test case 5; truncation is only supported to 96 bits (eg. sha1-96) and that's already unit tested
// test case 6 // test case 6
array( [
'sha512', 'sha512',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'Test Using Larger Than Block-Size Key - Hash Key First', 'Test Using Larger Than Block-Size Key - Hash Key First',
'80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598', '80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598',
), ],
// test case 7 // test case 7
array( [
'sha512', 'sha512',
pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'), pack('H*', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'),
'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.', 'This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.',
'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58' 'e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58'
), ],
); ];
} }
/** /**
@ -380,14 +380,14 @@ class Unit_Crypt_HashTest extends PhpseclibTestCase
public function lengths() public function lengths()
{ {
return array( return [
// known // known
array('md5-96', 12), ['md5-96', 12],
array('md5', 16), ['md5', 16],
array('sha1', 20), ['sha1', 20],
array('sha256', 32), ['sha256', 32],
array('sha384', 48), ['sha384', 48],
array('sha512', 64), ['sha512', 64],
); ];
} }
} }

View File

@ -9,33 +9,33 @@ use phpseclib\Crypt\RC2;
class Unit_Crypt_RC2Test extends PhpseclibTestCase class Unit_Crypt_RC2Test extends PhpseclibTestCase
{ {
var $engines = array( var $engines = [
'PHP', 'PHP',
'Eval', 'Eval',
'mcrypt', 'mcrypt',
'OpenSSL', 'OpenSSL',
); ];
public function engineVectors() public function engineVectors()
{ {
// tests from https://tools.ietf.org/html/rfc2268#page-8 // tests from https://tools.ietf.org/html/rfc2268#page-8
$tests = array( $tests = [
// key, effective key length, plaintext, ciphertext // key, effective key length, plaintext, ciphertext
array('0000000000000000', 63, '0000000000000000', 'ebb773f993278eff'), ['0000000000000000', 63, '0000000000000000', 'ebb773f993278eff'],
array('ffffffffffffffff', 64, 'ffffffffffffffff', '278b27e42e2f0d49'), ['ffffffffffffffff', 64, 'ffffffffffffffff', '278b27e42e2f0d49'],
array('3000000000000000', 64, '1000000000000001', '30649edf9be7d2c2'), ['3000000000000000', 64, '1000000000000001', '30649edf9be7d2c2'],
array('88', 64, '0000000000000000', '61a8a244adacccf0'), ['88', 64, '0000000000000000', '61a8a244adacccf0'],
array('88bca90e90875a', 64, '0000000000000000', '6ccf4308974c267f'), ['88bca90e90875a', 64, '0000000000000000', '6ccf4308974c267f'],
array('88bca90e90875a7f0f79c384627bafb2', 64, '0000000000000000', '1a807d272bbe5db1'), ['88bca90e90875a7f0f79c384627bafb2', 64, '0000000000000000', '1a807d272bbe5db1'],
array('88bca90e90875a7f0f79c384627bafb2', 128, '0000000000000000', '2269552ab0f85ca6'), ['88bca90e90875a7f0f79c384627bafb2', 128, '0000000000000000', '2269552ab0f85ca6'],
array('88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e', 129, '0000000000000000', '5b78d3a43dfff1f1') ['88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e', 129, '0000000000000000', '5b78d3a43dfff1f1']
); ];
$result = array(); $result = [];
foreach ($this->engines as $engine) { foreach ($this->engines as $engine) {
foreach ($tests as $test) { foreach ($tests as $test) {
$result[] = array($engine, $test[0], $test[1], $test[2], $test[3]); $result[] = [$engine, $test[0], $test[1], $test[2], $test[3]];
} }
} }

View File

@ -12,183 +12,183 @@ class Unit_Crypt_RC4Test extends PhpseclibTestCase
{ {
public function engineVectors() public function engineVectors()
{ {
$engines = array( $engines = [
'PHP', 'PHP',
'Eval', 'Eval',
'mcrypt', 'mcrypt',
'OpenSSL', 'OpenSSL',
); ];
// tests from https://tools.ietf.org/html/rfc6229 // tests from https://tools.ietf.org/html/rfc6229
$tests = array( $tests = [
array( [
'key' => pack('H*', '0102030405'), // 40-bit key 'key' => pack('H*', '0102030405'), // 40-bit key
'output' => array( 'output' => [
array('offset' => 0, 'result' => 'b2396305f03dc027ccc3524a0a1118a8'), ['offset' => 0, 'result' => 'b2396305f03dc027ccc3524a0a1118a8'],
array('offset' => 16, 'result' => '6982944f18fc82d589c403a47a0d0919'), ['offset' => 16, 'result' => '6982944f18fc82d589c403a47a0d0919'],
array('offset' => 240, 'result' => '28cb1132c96ce286421dcaadb8b69eae'), ['offset' => 240, 'result' => '28cb1132c96ce286421dcaadb8b69eae'],
array('offset' => 256, 'result' => '1cfcf62b03eddb641d77dfcf7f8d8c93'), ['offset' => 256, 'result' => '1cfcf62b03eddb641d77dfcf7f8d8c93'],
array('offset' => 496, 'result' => '42b7d0cdd918a8a33dd51781c81f4041'), ['offset' => 496, 'result' => '42b7d0cdd918a8a33dd51781c81f4041'],
array('offset' => 512, 'result' => '6459844432a7da923cfb3eb4980661f6'), ['offset' => 512, 'result' => '6459844432a7da923cfb3eb4980661f6'],
array('offset' => 752, 'result' => 'ec10327bde2beefd18f9277680457e22'), ['offset' => 752, 'result' => 'ec10327bde2beefd18f9277680457e22'],
array('offset' => 768, 'result' => 'eb62638d4f0ba1fe9fca20e05bf8ff2b'), ['offset' => 768, 'result' => 'eb62638d4f0ba1fe9fca20e05bf8ff2b'],
array('offset' => 1008, 'result' => '45129048e6a0ed0b56b490338f078da5'), ['offset' => 1008, 'result' => '45129048e6a0ed0b56b490338f078da5'],
array('offset' => 1024, 'result' => '30abbcc7c20b01609f23ee2d5f6bb7df'), ['offset' => 1024, 'result' => '30abbcc7c20b01609f23ee2d5f6bb7df'],
array('offset' => 1520, 'result' => '3294f744d8f9790507e70f62e5bbceea'), ['offset' => 1520, 'result' => '3294f744d8f9790507e70f62e5bbceea'],
array('offset' => 1536, 'result' => 'd8729db41882259bee4f825325f5a130'), ['offset' => 1536, 'result' => 'd8729db41882259bee4f825325f5a130'],
array('offset' => 2032, 'result' => '1eb14a0c13b3bf47fa2a0ba93ad45b8b'), ['offset' => 2032, 'result' => '1eb14a0c13b3bf47fa2a0ba93ad45b8b'],
array('offset' => 2048, 'result' => 'cc582f8ba9f265e2b1be9112e975d2d7'), ['offset' => 2048, 'result' => 'cc582f8ba9f265e2b1be9112e975d2d7'],
array('offset' => 3056, 'result' => 'f2e30f9bd102ecbf75aaade9bc35c43c'), ['offset' => 3056, 'result' => 'f2e30f9bd102ecbf75aaade9bc35c43c'],
array('offset' => 3072, 'result' => 'ec0e11c479dc329dc8da7968fe965681'), ['offset' => 3072, 'result' => 'ec0e11c479dc329dc8da7968fe965681'],
array('offset' => 4080, 'result' => '068326a2118416d21f9d04b2cd1ca050'), ['offset' => 4080, 'result' => '068326a2118416d21f9d04b2cd1ca050'],
array('offset' => 4096, 'result' => 'ff25b58995996707e51fbdf08b34d875') ['offset' => 4096, 'result' => 'ff25b58995996707e51fbdf08b34d875']
) ]
), ],
array( [
'key' => pack('H*', '01020304050607'), // 56-bit key 'key' => pack('H*', '01020304050607'), // 56-bit key
'output' => array( 'output' => [
array('offset' => 0, 'result' => '293f02d47f37c9b633f2af5285feb46b'), ['offset' => 0, 'result' => '293f02d47f37c9b633f2af5285feb46b'],
array('offset' => 16, 'result' => 'e620f1390d19bd84e2e0fd752031afc1'), ['offset' => 16, 'result' => 'e620f1390d19bd84e2e0fd752031afc1'],
array('offset' => 240, 'result' => '914f02531c9218810df60f67e338154c'), ['offset' => 240, 'result' => '914f02531c9218810df60f67e338154c'],
array('offset' => 256, 'result' => 'd0fdb583073ce85ab83917740ec011d5'), ['offset' => 256, 'result' => 'd0fdb583073ce85ab83917740ec011d5'],
array('offset' => 496, 'result' => '75f81411e871cffa70b90c74c592e454'), ['offset' => 496, 'result' => '75f81411e871cffa70b90c74c592e454'],
array('offset' => 512, 'result' => '0bb87202938dad609e87a5a1b079e5e4'), ['offset' => 512, 'result' => '0bb87202938dad609e87a5a1b079e5e4'],
array('offset' => 752, 'result' => 'c2911246b612e7e7b903dfeda1dad866'), ['offset' => 752, 'result' => 'c2911246b612e7e7b903dfeda1dad866'],
array('offset' => 768, 'result' => '32828f91502b6291368de8081de36fc2'), ['offset' => 768, 'result' => '32828f91502b6291368de8081de36fc2'],
array('offset' => 1008, 'result' => 'f3b9a7e3b297bf9ad804512f9063eff1'), ['offset' => 1008, 'result' => 'f3b9a7e3b297bf9ad804512f9063eff1'],
array('offset' => 1024, 'result' => '8ecb67a9ba1f55a5a067e2b026a3676f'), ['offset' => 1024, 'result' => '8ecb67a9ba1f55a5a067e2b026a3676f'],
array('offset' => 1520, 'result' => 'd2aa902bd42d0d7cfd340cd45810529f'), ['offset' => 1520, 'result' => 'd2aa902bd42d0d7cfd340cd45810529f'],
array('offset' => 1536, 'result' => '78b272c96e42eab4c60bd914e39d06e3'), ['offset' => 1536, 'result' => '78b272c96e42eab4c60bd914e39d06e3'],
array('offset' => 2032, 'result' => 'f4332fd31a079396ee3cee3f2a4ff049'), ['offset' => 2032, 'result' => 'f4332fd31a079396ee3cee3f2a4ff049'],
array('offset' => 2048, 'result' => '05459781d41fda7f30c1be7e1246c623'), ['offset' => 2048, 'result' => '05459781d41fda7f30c1be7e1246c623'],
array('offset' => 3056, 'result' => 'adfd3868b8e51485d5e610017e3dd609'), ['offset' => 3056, 'result' => 'adfd3868b8e51485d5e610017e3dd609'],
array('offset' => 3072, 'result' => 'ad26581c0c5be45f4cea01db2f3805d5'), ['offset' => 3072, 'result' => 'ad26581c0c5be45f4cea01db2f3805d5'],
array('offset' => 4080, 'result' => 'f3172ceffc3b3d997c85ccd5af1a950c'), ['offset' => 4080, 'result' => 'f3172ceffc3b3d997c85ccd5af1a950c'],
array('offset' => 4096, 'result' => 'e74b0b9731227fd37c0ec08a47ddd8b8') ['offset' => 4096, 'result' => 'e74b0b9731227fd37c0ec08a47ddd8b8']
) ]
), ],
array( [
'key' => pack('H*', '0102030405060708'), // 64-bit key 'key' => pack('H*', '0102030405060708'), // 64-bit key
'output' => array( 'output' => [
array('offset' => 0, 'result' => '97ab8a1bf0afb96132f2f67258da15a8'), ['offset' => 0, 'result' => '97ab8a1bf0afb96132f2f67258da15a8'],
array('offset' => 16, 'result' => '8263efdb45c4a18684ef87e6b19e5b09'), ['offset' => 16, 'result' => '8263efdb45c4a18684ef87e6b19e5b09'],
array('offset' => 240, 'result' => '9636ebc9841926f4f7d1f362bddf6e18'), ['offset' => 240, 'result' => '9636ebc9841926f4f7d1f362bddf6e18'],
array('offset' => 256, 'result' => 'd0a990ff2c05fef5b90373c9ff4b870a'), ['offset' => 256, 'result' => 'd0a990ff2c05fef5b90373c9ff4b870a'],
array('offset' => 496, 'result' => '73239f1db7f41d80b643c0c52518ec63'), ['offset' => 496, 'result' => '73239f1db7f41d80b643c0c52518ec63'],
array('offset' => 512, 'result' => '163b319923a6bdb4527c626126703c0f'), ['offset' => 512, 'result' => '163b319923a6bdb4527c626126703c0f'],
array('offset' => 752, 'result' => '49d6c8af0f97144a87df21d91472f966'), ['offset' => 752, 'result' => '49d6c8af0f97144a87df21d91472f966'],
array('offset' => 768, 'result' => '44173a103b6616c5d5ad1cee40c863d0'), ['offset' => 768, 'result' => '44173a103b6616c5d5ad1cee40c863d0'],
array('offset' => 1008, 'result' => '273c9c4b27f322e4e716ef53a47de7a4'), ['offset' => 1008, 'result' => '273c9c4b27f322e4e716ef53a47de7a4'],
array('offset' => 1024, 'result' => 'c6d0e7b226259fa9023490b26167ad1d'), ['offset' => 1024, 'result' => 'c6d0e7b226259fa9023490b26167ad1d'],
array('offset' => 1520, 'result' => '1fe8986713f07c3d9ae1c163ff8cf9d3'), ['offset' => 1520, 'result' => '1fe8986713f07c3d9ae1c163ff8cf9d3'],
array('offset' => 1536, 'result' => '8369e1a965610be887fbd0c79162aafb'), ['offset' => 1536, 'result' => '8369e1a965610be887fbd0c79162aafb'],
array('offset' => 2032, 'result' => '0a0127abb44484b9fbef5abcae1b579f'), ['offset' => 2032, 'result' => '0a0127abb44484b9fbef5abcae1b579f'],
array('offset' => 2048, 'result' => 'c2cdadc6402e8ee866e1f37bdb47e42c'), ['offset' => 2048, 'result' => 'c2cdadc6402e8ee866e1f37bdb47e42c'],
array('offset' => 3056, 'result' => '26b51ea37df8e1d6f76fc3b66a7429b3'), ['offset' => 3056, 'result' => '26b51ea37df8e1d6f76fc3b66a7429b3'],
array('offset' => 3072, 'result' => 'bc7683205d4f443dc1f29dda3315c87b'), ['offset' => 3072, 'result' => 'bc7683205d4f443dc1f29dda3315c87b'],
array('offset' => 4080, 'result' => 'd5fa5a3469d29aaaf83d23589db8c85b'), ['offset' => 4080, 'result' => 'd5fa5a3469d29aaaf83d23589db8c85b'],
array('offset' => 4096, 'result' => '3fb46e2c8f0f068edce8cdcd7dfc5862') ['offset' => 4096, 'result' => '3fb46e2c8f0f068edce8cdcd7dfc5862']
) ]
), ],
array( [
'key' => pack('H*', '0102030405060708090a'), // 80-bit key 'key' => pack('H*', '0102030405060708090a'), // 80-bit key
'output' => array( 'output' => [
array('offset' => 0, 'result' => 'ede3b04643e586cc907dc21851709902'), ['offset' => 0, 'result' => 'ede3b04643e586cc907dc21851709902'],
array('offset' => 16, 'result' => '03516ba78f413beb223aa5d4d2df6711'), ['offset' => 16, 'result' => '03516ba78f413beb223aa5d4d2df6711'],
array('offset' => 240, 'result' => '3cfd6cb58ee0fdde640176ad0000044d'), ['offset' => 240, 'result' => '3cfd6cb58ee0fdde640176ad0000044d'],
array('offset' => 256, 'result' => '48532b21fb6079c9114c0ffd9c04a1ad'), ['offset' => 256, 'result' => '48532b21fb6079c9114c0ffd9c04a1ad'],
array('offset' => 496, 'result' => '3e8cea98017109979084b1ef92f99d86'), ['offset' => 496, 'result' => '3e8cea98017109979084b1ef92f99d86'],
array('offset' => 512, 'result' => 'e20fb49bdb337ee48b8d8dc0f4afeffe'), ['offset' => 512, 'result' => 'e20fb49bdb337ee48b8d8dc0f4afeffe'],
array('offset' => 752, 'result' => '5c2521eacd7966f15e056544bea0d315'), ['offset' => 752, 'result' => '5c2521eacd7966f15e056544bea0d315'],
array('offset' => 768, 'result' => 'e067a7031931a246a6c3875d2f678acb'), ['offset' => 768, 'result' => 'e067a7031931a246a6c3875d2f678acb'],
array('offset' => 1008, 'result' => 'a64f70af88ae56b6f87581c0e23e6b08'), ['offset' => 1008, 'result' => 'a64f70af88ae56b6f87581c0e23e6b08'],
array('offset' => 1024, 'result' => 'f449031de312814ec6f319291f4a0516'), ['offset' => 1024, 'result' => 'f449031de312814ec6f319291f4a0516'],
array('offset' => 1520, 'result' => 'bdae85924b3cb1d0a2e33a30c6d79599'), ['offset' => 1520, 'result' => 'bdae85924b3cb1d0a2e33a30c6d79599'],
array('offset' => 1536, 'result' => '8a0feddbac865a09bcd127fb562ed60a'), ['offset' => 1536, 'result' => '8a0feddbac865a09bcd127fb562ed60a'],
array('offset' => 2032, 'result' => 'b55a0a5b51a12a8be34899c3e047511a'), ['offset' => 2032, 'result' => 'b55a0a5b51a12a8be34899c3e047511a'],
array('offset' => 2048, 'result' => 'd9a09cea3ce75fe39698070317a71339'), ['offset' => 2048, 'result' => 'd9a09cea3ce75fe39698070317a71339'],
array('offset' => 3056, 'result' => '552225ed1177f44584ac8cfa6c4eb5fc'), ['offset' => 3056, 'result' => '552225ed1177f44584ac8cfa6c4eb5fc'],
array('offset' => 3072, 'result' => '7e82cbabfc95381b080998442129c2f8'), ['offset' => 3072, 'result' => '7e82cbabfc95381b080998442129c2f8'],
array('offset' => 4080, 'result' => '1f135ed14ce60a91369d2322bef25e3c'), ['offset' => 4080, 'result' => '1f135ed14ce60a91369d2322bef25e3c'],
array('offset' => 4096, 'result' => '08b6be45124a43e2eb77953f84dc8553') ['offset' => 4096, 'result' => '08b6be45124a43e2eb77953f84dc8553']
) ]
), ],
array( [
'key' => pack('H*', '0102030405060708090a0b0c0d0e0f10'), // 128-bit key 'key' => pack('H*', '0102030405060708090a0b0c0d0e0f10'), // 128-bit key
'output' => array( 'output' => [
array('offset' => 0, 'result' => '9ac7cc9a609d1ef7b2932899cde41b97'), ['offset' => 0, 'result' => '9ac7cc9a609d1ef7b2932899cde41b97'],
array('offset' => 16, 'result' => '5248c4959014126a6e8a84f11d1a9e1c'), ['offset' => 16, 'result' => '5248c4959014126a6e8a84f11d1a9e1c'],
array('offset' => 240, 'result' => '065902e4b620f6cc36c8589f66432f2b'), ['offset' => 240, 'result' => '065902e4b620f6cc36c8589f66432f2b'],
array('offset' => 256, 'result' => 'd39d566bc6bce3010768151549f3873f'), ['offset' => 256, 'result' => 'd39d566bc6bce3010768151549f3873f'],
array('offset' => 496, 'result' => 'b6d1e6c4a5e4771cad79538df295fb11'), ['offset' => 496, 'result' => 'b6d1e6c4a5e4771cad79538df295fb11'],
array('offset' => 512, 'result' => 'c68c1d5c559a974123df1dbc52a43b89'), ['offset' => 512, 'result' => 'c68c1d5c559a974123df1dbc52a43b89'],
array('offset' => 752, 'result' => 'c5ecf88de897fd57fed301701b82a259'), ['offset' => 752, 'result' => 'c5ecf88de897fd57fed301701b82a259'],
array('offset' => 768, 'result' => 'eccbe13de1fcc91c11a0b26c0bc8fa4d'), ['offset' => 768, 'result' => 'eccbe13de1fcc91c11a0b26c0bc8fa4d'],
array('offset' => 1008, 'result' => 'e7a72574f8782ae26aabcf9ebcd66065'), ['offset' => 1008, 'result' => 'e7a72574f8782ae26aabcf9ebcd66065'],
array('offset' => 1024, 'result' => 'bdf0324e6083dcc6d3cedd3ca8c53c16'), ['offset' => 1024, 'result' => 'bdf0324e6083dcc6d3cedd3ca8c53c16'],
array('offset' => 1520, 'result' => 'b40110c4190b5622a96116b0017ed297'), ['offset' => 1520, 'result' => 'b40110c4190b5622a96116b0017ed297'],
array('offset' => 1536, 'result' => 'ffa0b514647ec04f6306b892ae661181'), ['offset' => 1536, 'result' => 'ffa0b514647ec04f6306b892ae661181'],
array('offset' => 2032, 'result' => 'd03d1bc03cd33d70dff9fa5d71963ebd'), ['offset' => 2032, 'result' => 'd03d1bc03cd33d70dff9fa5d71963ebd'],
array('offset' => 2048, 'result' => '8a44126411eaa78bd51e8d87a8879bf5'), ['offset' => 2048, 'result' => '8a44126411eaa78bd51e8d87a8879bf5'],
array('offset' => 3056, 'result' => 'fabeb76028ade2d0e48722e46c4615a3'), ['offset' => 3056, 'result' => 'fabeb76028ade2d0e48722e46c4615a3'],
array('offset' => 3072, 'result' => 'c05d88abd50357f935a63c59ee537623'), ['offset' => 3072, 'result' => 'c05d88abd50357f935a63c59ee537623'],
array('offset' => 4080, 'result' => 'ff38265c1642c1abe8d3c2fe5e572bf8'), ['offset' => 4080, 'result' => 'ff38265c1642c1abe8d3c2fe5e572bf8'],
array('offset' => 4096, 'result' => 'a36a4c301ae8ac13610ccbc12256cacc') ['offset' => 4096, 'result' => 'a36a4c301ae8ac13610ccbc12256cacc']
) ]
), ],
array( [
'key' => pack('H*', '0102030405060708090a0b0c0d0e0f101112131415161718'), // 192-bit key 'key' => pack('H*', '0102030405060708090a0b0c0d0e0f101112131415161718'), // 192-bit key
'output' => array( 'output' => [
array('offset' => 0, 'result' => '0595e57fe5f0bb3c706edac8a4b2db11'), ['offset' => 0, 'result' => '0595e57fe5f0bb3c706edac8a4b2db11'],
array('offset' => 16, 'result' => 'dfde31344a1af769c74f070aee9e2326'), ['offset' => 16, 'result' => 'dfde31344a1af769c74f070aee9e2326'],
array('offset' => 240, 'result' => 'b06b9b1e195d13d8f4a7995c4553ac05'), ['offset' => 240, 'result' => 'b06b9b1e195d13d8f4a7995c4553ac05'],
array('offset' => 256, 'result' => '6bd2378ec341c9a42f37ba79f88a32ff'), ['offset' => 256, 'result' => '6bd2378ec341c9a42f37ba79f88a32ff'],
array('offset' => 496, 'result' => 'e70bce1df7645adb5d2c4130215c3522'), ['offset' => 496, 'result' => 'e70bce1df7645adb5d2c4130215c3522'],
array('offset' => 512, 'result' => '9a5730c7fcb4c9af51ffda89c7f1ad22'), ['offset' => 512, 'result' => '9a5730c7fcb4c9af51ffda89c7f1ad22'],
array('offset' => 752, 'result' => '0485055fd4f6f0d963ef5ab9a5476982'), ['offset' => 752, 'result' => '0485055fd4f6f0d963ef5ab9a5476982'],
array('offset' => 768, 'result' => '591fc66bcda10e452b03d4551f6b62ac'), ['offset' => 768, 'result' => '591fc66bcda10e452b03d4551f6b62ac'],
array('offset' => 1008, 'result' => '2753cc83988afa3e1688a1d3b42c9a02'), ['offset' => 1008, 'result' => '2753cc83988afa3e1688a1d3b42c9a02'],
array('offset' => 1024, 'result' => '93610d523d1d3f0062b3c2a3bbc7c7f0'), ['offset' => 1024, 'result' => '93610d523d1d3f0062b3c2a3bbc7c7f0'],
array('offset' => 1520, 'result' => '96c248610aadedfeaf8978c03de8205a'), ['offset' => 1520, 'result' => '96c248610aadedfeaf8978c03de8205a'],
array('offset' => 1536, 'result' => '0e317b3d1c73b9e9a4688f296d133a19'), ['offset' => 1536, 'result' => '0e317b3d1c73b9e9a4688f296d133a19'],
array('offset' => 2032, 'result' => 'bdf0e6c3cca5b5b9d533b69c56ada120'), ['offset' => 2032, 'result' => 'bdf0e6c3cca5b5b9d533b69c56ada120'],
array('offset' => 2048, 'result' => '88a218b6e2ece1e6246d44c759d19b10'), ['offset' => 2048, 'result' => '88a218b6e2ece1e6246d44c759d19b10'],
array('offset' => 3056, 'result' => '6866397e95c140534f94263421006e40'), ['offset' => 3056, 'result' => '6866397e95c140534f94263421006e40'],
array('offset' => 3072, 'result' => '32cb0a1e9542c6b3b8b398abc3b0f1d5'), ['offset' => 3072, 'result' => '32cb0a1e9542c6b3b8b398abc3b0f1d5'],
array('offset' => 4080, 'result' => '29a0b8aed54a132324c62e423f54b4c8'), ['offset' => 4080, 'result' => '29a0b8aed54a132324c62e423f54b4c8'],
array('offset' => 4096, 'result' => '3cb0f3b5020a98b82af9fe154484a168') ['offset' => 4096, 'result' => '3cb0f3b5020a98b82af9fe154484a168']
) ]
), ],
array( [
'key' => pack('H*', '0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20'), // 256-bit key 'key' => pack('H*', '0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20'), // 256-bit key
'output' => array( 'output' => [
array('offset' => 0, 'result' => 'eaa6bd25880bf93d3f5d1e4ca2611d91'), ['offset' => 0, 'result' => 'eaa6bd25880bf93d3f5d1e4ca2611d91'],
array('offset' => 16, 'result' => 'cfa45c9f7e714b54bdfa80027cb14380'), ['offset' => 16, 'result' => 'cfa45c9f7e714b54bdfa80027cb14380'],
array('offset' => 240, 'result' => '114ae344ded71b35f2e60febad727fd8'), ['offset' => 240, 'result' => '114ae344ded71b35f2e60febad727fd8'],
array('offset' => 256, 'result' => '02e1e7056b0f623900496422943e97b6'), ['offset' => 256, 'result' => '02e1e7056b0f623900496422943e97b6'],
array('offset' => 496, 'result' => '91cb93c787964e10d9527d999c6f936b'), ['offset' => 496, 'result' => '91cb93c787964e10d9527d999c6f936b'],
array('offset' => 512, 'result' => '49b18b42f8e8367cbeb5ef104ba1c7cd'), ['offset' => 512, 'result' => '49b18b42f8e8367cbeb5ef104ba1c7cd'],
array('offset' => 752, 'result' => '87084b3ba700bade955610672745b374'), ['offset' => 752, 'result' => '87084b3ba700bade955610672745b374'],
array('offset' => 768, 'result' => 'e7a7b9e9ec540d5ff43bdb12792d1b35'), ['offset' => 768, 'result' => 'e7a7b9e9ec540d5ff43bdb12792d1b35'],
array('offset' => 1008, 'result' => 'c799b596738f6b018c76c74b1759bd90'), ['offset' => 1008, 'result' => 'c799b596738f6b018c76c74b1759bd90'],
array('offset' => 1024, 'result' => '7fec5bfd9f9b89ce6548309092d7e958'), ['offset' => 1024, 'result' => '7fec5bfd9f9b89ce6548309092d7e958'],
array('offset' => 1520, 'result' => '40f250b26d1f096a4afd4c340a588815'), ['offset' => 1520, 'result' => '40f250b26d1f096a4afd4c340a588815'],
array('offset' => 1536, 'result' => '3e34135c79db010200767651cf263073'), ['offset' => 1536, 'result' => '3e34135c79db010200767651cf263073'],
array('offset' => 2032, 'result' => 'f656abccf88dd827027b2ce917d464ec'), ['offset' => 2032, 'result' => 'f656abccf88dd827027b2ce917d464ec'],
array('offset' => 2048, 'result' => '18b62503bfbc077fbabb98f20d98ab34'), ['offset' => 2048, 'result' => '18b62503bfbc077fbabb98f20d98ab34'],
array('offset' => 3056, 'result' => '8aed95ee5b0dcbfbef4eb21d3a3f52f9'), ['offset' => 3056, 'result' => '8aed95ee5b0dcbfbef4eb21d3a3f52f9'],
array('offset' => 3072, 'result' => '625a1ab00ee39a5327346bddb01a9c18'), ['offset' => 3072, 'result' => '625a1ab00ee39a5327346bddb01a9c18'],
array('offset' => 4080, 'result' => 'a13a7c79c7e119b5ab0296ab28c300b9'), ['offset' => 4080, 'result' => 'a13a7c79c7e119b5ab0296ab28c300b9'],
array('offset' => 4096, 'result' => 'f3e4c0a2e02d1d01f7f0a74618af2b48') ['offset' => 4096, 'result' => 'f3e4c0a2e02d1d01f7f0a74618af2b48']
) ]
) ]
); ];
$result = array(); $result = [];
foreach ($engines as $engine) { foreach ($engines as $engine) {
foreach ($tests as $test) { foreach ($tests as $test) {
foreach ($test['output'] as $output) { foreach ($test['output'] as $output) {
$result[] = array($engine, $test['key'], $output['offset'], $output['result']); $result[] = [$engine, $test['key'], $output['offset'], $output['result']];
} }
} }
} }
@ -213,7 +213,7 @@ class Unit_Crypt_RC4Test extends PhpseclibTestCase
public function testKeySizes() public function testKeySizes()
{ {
$objects = $engines = array(); $objects = $engines = [];
$temp = new RC4(RC4::MODE_CTR); $temp = new RC4(RC4::MODE_CTR);
$temp->setPreferredEngine('internal'); $temp->setPreferredEngine('internal');
$objects[] = $temp; $objects[] = $temp;

View File

@ -21,7 +21,7 @@ class Unit_Crypt_RSA_CreateKeyTest extends PhpseclibTestCase
$this->assertSame($privatekey->getLength(), 768); $this->assertSame($privatekey->getLength(), 768);
$this->assertSame($publickey->getLength(), 768); $this->assertSame($publickey->getLength(), 768);
return array($publickey, $privatekey); return [$publickey, $privatekey];
} }
/** /**

View File

@ -61,7 +61,7 @@ X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl
U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0= 37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
-----END RSA PRIVATE KEY-----'; -----END RSA PRIVATE KEY-----';
$key = str_replace(array("\r", "\n", "\r\n"), ' ', $key); $key = str_replace(["\r", "\n", "\r\n"], ' ', $key);
$this->assertTrue($rsa->load($key)); $this->assertTrue($rsa->load($key));
$this->assertInternalType('string', $rsa->getPrivateKey()); $this->assertInternalType('string', $rsa->getPrivateKey());
@ -400,13 +400,13 @@ Private-MAC: 03e2cb74e1d67652fbad063d2ed0478f31bdf256
{ {
$rsa = new RSA(); $rsa = new RSA();
$key = array( $key = [
'e' => new BigInteger('10001', 16), 'e' => new BigInteger('10001', 16),
'n' => new BigInteger('aa18aba43b50deef38598faf87d2ab634e4571c130a9bca7b878267414faab8b471bd8965f5c9fc3' . 'n' => new BigInteger('aa18aba43b50deef38598faf87d2ab634e4571c130a9bca7b878267414faab8b471bd8965f5c9fc3' .
'818485eaf529c26246f3055064a8de19c8c338be5496cbaeb059dc0b358143b44a35449eb2641131' . '818485eaf529c26246f3055064a8de19c8c338be5496cbaeb059dc0b358143b44a35449eb2641131' .
'21a455bd7fde3fac919e94b56fb9bb4f651cdb23ead439d6cd523eb08191e75b35fd13a7419b3090' . '21a455bd7fde3fac919e94b56fb9bb4f651cdb23ead439d6cd523eb08191e75b35fd13a7419b3090' .
'f24787bd4f4e1967', 16) 'f24787bd4f4e1967', 16)
); ];
$this->assertTrue($rsa->load($key)); $this->assertTrue($rsa->load($key));
$rsa->setPublicKeyFormat('raw'); $rsa->setPublicKeyFormat('raw');
$this->assertEmpty("$rsa"); $this->assertEmpty("$rsa");

View File

@ -76,7 +76,7 @@ p0GbMJDyR4e9T04ZZwIDAQAB
$e = new BigInteger(base64_decode('158753FF2AF4D1E5BBAB574D5AE6B54D'), 256); $e = new BigInteger(base64_decode('158753FF2AF4D1E5BBAB574D5AE6B54D'), 256);
$rsa = new RSA(); $rsa = new RSA();
$rsa->load(array('n' => $n, 'e' => $e)); $rsa->load(['n' => $n, 'e' => $e]);
$rsa->encrypt($plaintext); $rsa->encrypt($plaintext);
} }

View File

@ -11,11 +11,11 @@ class Unit_Crypt_RandomTest extends PhpseclibTestCase
{ {
public function stringLengthData() public function stringLengthData()
{ {
return array_map(array($this, 'wrap'), array( return array_map([$this, 'wrap'], [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 20, 23, 29, 31, 37, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 17, 19, 20, 23, 29, 31, 37,
41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 111, 128, 1000, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 111, 128, 1000,
1024, 10000, 12345, 100000, 123456 1024, 10000, 12345, 100000, 123456
)); ]);
} }
/** @dataProvider stringLengthData */ /** @dataProvider stringLengthData */
@ -34,7 +34,7 @@ class Unit_Crypt_RandomTest extends PhpseclibTestCase
*/ */
public function testStringUniqueness() public function testStringUniqueness()
{ {
$values = array(); $values = [];
for ($i = 0; $i < 10000; ++$i) { for ($i = 0; $i < 10000; ++$i) {
$rand = Random::string(16); $rand = Random::string(16);
$this->assertSame(16, strlen($rand)); $this->assertSame(16, strlen($rand));
@ -50,6 +50,6 @@ class Unit_Crypt_RandomTest extends PhpseclibTestCase
protected function wrap($x) protected function wrap($x)
{ {
// array() is not a function, but $this->wrap() is. // array() is not a function, but $this->wrap() is.
return array($x); return [$x];
} }
} }

View File

@ -9,90 +9,90 @@ use phpseclib\Crypt\TripleDES;
class Unit_Crypt_TripleDESTest extends PhpseclibTestCase class Unit_Crypt_TripleDESTest extends PhpseclibTestCase
{ {
var $engines = array( var $engines = [
'PHP', 'PHP',
'Eval', 'Eval',
'mcrypt', 'mcrypt',
'OpenSSL', 'OpenSSL',
); ];
public function engineVectors() public function engineVectors()
{ {
// tests from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf#page=273 // tests from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf#page=273
$tests = array( $tests = [
// Table A.1 // Table A.1
// key, plaintext, ciphertext // key, plaintext, ciphertext
array(str_repeat("\x01", 24), pack('H*', '8000000000000000'), pack('H*', '95F8A5E5DD31D900')), [str_repeat("\x01", 24), pack('H*', '8000000000000000'), pack('H*', '95F8A5E5DD31D900')],
array(str_repeat("\x01", 24), pack('H*', '4000000000000000'), pack('H*', 'DD7F121CA5015619')), [str_repeat("\x01", 24), pack('H*', '4000000000000000'), pack('H*', 'DD7F121CA5015619')],
array(str_repeat("\x01", 24), pack('H*', '2000000000000000'), pack('H*', '2E8653104F3834EA')), [str_repeat("\x01", 24), pack('H*', '2000000000000000'), pack('H*', '2E8653104F3834EA')],
array(str_repeat("\x01", 24), pack('H*', '1000000000000000'), pack('H*', '4BD388FF6CD81D4F')), [str_repeat("\x01", 24), pack('H*', '1000000000000000'), pack('H*', '4BD388FF6CD81D4F')],
array(str_repeat("\x01", 24), pack('H*', '0800000000000000'), pack('H*', '20B9E767B2FB1456')), [str_repeat("\x01", 24), pack('H*', '0800000000000000'), pack('H*', '20B9E767B2FB1456')],
array(str_repeat("\x01", 24), pack('H*', '0400000000000000'), pack('H*', '55579380D77138EF')), [str_repeat("\x01", 24), pack('H*', '0400000000000000'), pack('H*', '55579380D77138EF')],
array(str_repeat("\x01", 24), pack('H*', '0200000000000000'), pack('H*', '6CC5DEFAAF04512F')), [str_repeat("\x01", 24), pack('H*', '0200000000000000'), pack('H*', '6CC5DEFAAF04512F')],
array(str_repeat("\x01", 24), pack('H*', '0100000000000000'), pack('H*', '0D9F279BA5D87260')), [str_repeat("\x01", 24), pack('H*', '0100000000000000'), pack('H*', '0D9F279BA5D87260')],
array(str_repeat("\x01", 24), pack('H*', '0080000000000000'), pack('H*', 'D9031B0271BD5A0A')), [str_repeat("\x01", 24), pack('H*', '0080000000000000'), pack('H*', 'D9031B0271BD5A0A')],
array(str_repeat("\x01", 24), pack('H*', '0040000000000000'), pack('H*', '424250B37C3DD951')), [str_repeat("\x01", 24), pack('H*', '0040000000000000'), pack('H*', '424250B37C3DD951')],
array(str_repeat("\x01", 24), pack('H*', '0020000000000000'), pack('H*', 'B8061B7ECD9A21E5')), [str_repeat("\x01", 24), pack('H*', '0020000000000000'), pack('H*', 'B8061B7ECD9A21E5')],
array(str_repeat("\x01", 24), pack('H*', '0010000000000000'), pack('H*', 'F15D0F286B65BD28')), [str_repeat("\x01", 24), pack('H*', '0010000000000000'), pack('H*', 'F15D0F286B65BD28')],
array(str_repeat("\x01", 24), pack('H*', '0008000000000000'), pack('H*', 'ADD0CC8D6E5DEBA1')), [str_repeat("\x01", 24), pack('H*', '0008000000000000'), pack('H*', 'ADD0CC8D6E5DEBA1')],
array(str_repeat("\x01", 24), pack('H*', '0004000000000000'), pack('H*', 'E6D5F82752AD63D1')), [str_repeat("\x01", 24), pack('H*', '0004000000000000'), pack('H*', 'E6D5F82752AD63D1')],
array(str_repeat("\x01", 24), pack('H*', '0002000000000000'), pack('H*', 'ECBFE3BD3F591A5E')), [str_repeat("\x01", 24), pack('H*', '0002000000000000'), pack('H*', 'ECBFE3BD3F591A5E')],
array(str_repeat("\x01", 24), pack('H*', '0001000000000000'), pack('H*', 'F356834379D165CD')), [str_repeat("\x01", 24), pack('H*', '0001000000000000'), pack('H*', 'F356834379D165CD')],
array(str_repeat("\x01", 24), pack('H*', '0000800000000000'), pack('H*', '2B9F982F20037FA9')), [str_repeat("\x01", 24), pack('H*', '0000800000000000'), pack('H*', '2B9F982F20037FA9')],
array(str_repeat("\x01", 24), pack('H*', '0000400000000000'), pack('H*', '889DE068A16F0BE6')), [str_repeat("\x01", 24), pack('H*', '0000400000000000'), pack('H*', '889DE068A16F0BE6')],
array(str_repeat("\x01", 24), pack('H*', '0000200000000000'), pack('H*', 'E19E275D846A1298')), [str_repeat("\x01", 24), pack('H*', '0000200000000000'), pack('H*', 'E19E275D846A1298')],
array(str_repeat("\x01", 24), pack('H*', '0000100000000000'), pack('H*', '329A8ED523D71AEC')), [str_repeat("\x01", 24), pack('H*', '0000100000000000'), pack('H*', '329A8ED523D71AEC')],
array(str_repeat("\x01", 24), pack('H*', '0000080000000000'), pack('H*', 'E7FCE22557D23C97')), [str_repeat("\x01", 24), pack('H*', '0000080000000000'), pack('H*', 'E7FCE22557D23C97')],
array(str_repeat("\x01", 24), pack('H*', '0000040000000000'), pack('H*', '12A9F5817FF2D65D')), [str_repeat("\x01", 24), pack('H*', '0000040000000000'), pack('H*', '12A9F5817FF2D65D')],
array(str_repeat("\x01", 24), pack('H*', '0000020000000000'), pack('H*', 'A484C3AD38DC9C19')), [str_repeat("\x01", 24), pack('H*', '0000020000000000'), pack('H*', 'A484C3AD38DC9C19')],
array(str_repeat("\x01", 24), pack('H*', '0000010000000000'), pack('H*', 'FBE00A8A1EF8AD72')), [str_repeat("\x01", 24), pack('H*', '0000010000000000'), pack('H*', 'FBE00A8A1EF8AD72')],
array(str_repeat("\x01", 24), pack('H*', '0000008000000000'), pack('H*', '750D079407521363')), [str_repeat("\x01", 24), pack('H*', '0000008000000000'), pack('H*', '750D079407521363')],
array(str_repeat("\x01", 24), pack('H*', '0000004000000000'), pack('H*', '64FEED9C724C2FAF')), [str_repeat("\x01", 24), pack('H*', '0000004000000000'), pack('H*', '64FEED9C724C2FAF')],
array(str_repeat("\x01", 24), pack('H*', '0000002000000000'), pack('H*', 'F02B263B328E2B60')), [str_repeat("\x01", 24), pack('H*', '0000002000000000'), pack('H*', 'F02B263B328E2B60')],
array(str_repeat("\x01", 24), pack('H*', '0000001000000000'), pack('H*', '9D64555A9A10B852')), [str_repeat("\x01", 24), pack('H*', '0000001000000000'), pack('H*', '9D64555A9A10B852')],
array(str_repeat("\x01", 24), pack('H*', '0000000800000000'), pack('H*', 'D106FF0BED5255D7')), [str_repeat("\x01", 24), pack('H*', '0000000800000000'), pack('H*', 'D106FF0BED5255D7')],
array(str_repeat("\x01", 24), pack('H*', '0000000400000000'), pack('H*', 'E1652C6B138C64A5')), [str_repeat("\x01", 24), pack('H*', '0000000400000000'), pack('H*', 'E1652C6B138C64A5')],
array(str_repeat("\x01", 24), pack('H*', '0000000200000000'), pack('H*', 'E428581186EC8F46')), [str_repeat("\x01", 24), pack('H*', '0000000200000000'), pack('H*', 'E428581186EC8F46')],
array(str_repeat("\x01", 24), pack('H*', '0000000100000000'), pack('H*', 'AEB5F5EDE22D1A36')), [str_repeat("\x01", 24), pack('H*', '0000000100000000'), pack('H*', 'AEB5F5EDE22D1A36')],
array(str_repeat("\x01", 24), pack('H*', '0000000080000000'), pack('H*', 'E943D7568AEC0C5C')), [str_repeat("\x01", 24), pack('H*', '0000000080000000'), pack('H*', 'E943D7568AEC0C5C')],
array(str_repeat("\x01", 24), pack('H*', '0000000040000000'), pack('H*', 'DF98C8276F54B04B')), [str_repeat("\x01", 24), pack('H*', '0000000040000000'), pack('H*', 'DF98C8276F54B04B')],
array(str_repeat("\x01", 24), pack('H*', '0000000020000000'), pack('H*', 'B160E4680F6C696F')), [str_repeat("\x01", 24), pack('H*', '0000000020000000'), pack('H*', 'B160E4680F6C696F')],
array(str_repeat("\x01", 24), pack('H*', '0000000010000000'), pack('H*', 'FA0752B07D9C4AB8')), [str_repeat("\x01", 24), pack('H*', '0000000010000000'), pack('H*', 'FA0752B07D9C4AB8')],
array(str_repeat("\x01", 24), pack('H*', '0000000008000000'), pack('H*', 'CA3A2B036DBC8502')), [str_repeat("\x01", 24), pack('H*', '0000000008000000'), pack('H*', 'CA3A2B036DBC8502')],
array(str_repeat("\x01", 24), pack('H*', '0000000004000000'), pack('H*', '5E0905517BB59BCF')), [str_repeat("\x01", 24), pack('H*', '0000000004000000'), pack('H*', '5E0905517BB59BCF')],
array(str_repeat("\x01", 24), pack('H*', '0000000002000000'), pack('H*', '814EEB3B91D90726')), [str_repeat("\x01", 24), pack('H*', '0000000002000000'), pack('H*', '814EEB3B91D90726')],
array(str_repeat("\x01", 24), pack('H*', '0000000001000000'), pack('H*', '4D49DB1532919C9F')), [str_repeat("\x01", 24), pack('H*', '0000000001000000'), pack('H*', '4D49DB1532919C9F')],
array(str_repeat("\x01", 24), pack('H*', '0000000000800000'), pack('H*', '25EB5FC3F8CF0621')), [str_repeat("\x01", 24), pack('H*', '0000000000800000'), pack('H*', '25EB5FC3F8CF0621')],
array(str_repeat("\x01", 24), pack('H*', '0000000000400000'), pack('H*', 'AB6A20C0620D1C6F')), [str_repeat("\x01", 24), pack('H*', '0000000000400000'), pack('H*', 'AB6A20C0620D1C6F')],
array(str_repeat("\x01", 24), pack('H*', '0000000000200000'), pack('H*', '79E90DBC98F92CCA')), [str_repeat("\x01", 24), pack('H*', '0000000000200000'), pack('H*', '79E90DBC98F92CCA')],
array(str_repeat("\x01", 24), pack('H*', '0000000000100000'), pack('H*', '866ECEDD8072BB0E')), [str_repeat("\x01", 24), pack('H*', '0000000000100000'), pack('H*', '866ECEDD8072BB0E')],
array(str_repeat("\x01", 24), pack('H*', '0000000000080000'), pack('H*', '8B54536F2F3E64A8')), [str_repeat("\x01", 24), pack('H*', '0000000000080000'), pack('H*', '8B54536F2F3E64A8')],
array(str_repeat("\x01", 24), pack('H*', '0000000000040000'), pack('H*', 'EA51D3975595B86B')), [str_repeat("\x01", 24), pack('H*', '0000000000040000'), pack('H*', 'EA51D3975595B86B')],
array(str_repeat("\x01", 24), pack('H*', '0000000000020000'), pack('H*', 'CAFFC6AC4542DE31')), [str_repeat("\x01", 24), pack('H*', '0000000000020000'), pack('H*', 'CAFFC6AC4542DE31')],
array(str_repeat("\x01", 24), pack('H*', '0000000000010000'), pack('H*', '8DD45A2DDF90796C')), [str_repeat("\x01", 24), pack('H*', '0000000000010000'), pack('H*', '8DD45A2DDF90796C')],
array(str_repeat("\x01", 24), pack('H*', '0000000000008000'), pack('H*', '1029D55E880EC2D0')), [str_repeat("\x01", 24), pack('H*', '0000000000008000'), pack('H*', '1029D55E880EC2D0')],
array(str_repeat("\x01", 24), pack('H*', '0000000000004000'), pack('H*', '5D86CB23639DBEA9')), [str_repeat("\x01", 24), pack('H*', '0000000000004000'), pack('H*', '5D86CB23639DBEA9')],
array(str_repeat("\x01", 24), pack('H*', '0000000000002000'), pack('H*', '1D1CA853AE7C0C5F')), [str_repeat("\x01", 24), pack('H*', '0000000000002000'), pack('H*', '1D1CA853AE7C0C5F')],
array(str_repeat("\x01", 24), pack('H*', '0000000000001000'), pack('H*', 'CE332329248F3228')), [str_repeat("\x01", 24), pack('H*', '0000000000001000'), pack('H*', 'CE332329248F3228')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000800'), pack('H*', '8405D1ABE24FB942')), [str_repeat("\x01", 24), pack('H*', '0000000000000800'), pack('H*', '8405D1ABE24FB942')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000400'), pack('H*', 'E643D78090CA4207')), [str_repeat("\x01", 24), pack('H*', '0000000000000400'), pack('H*', 'E643D78090CA4207')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000200'), pack('H*', '48221B9937748A23')), [str_repeat("\x01", 24), pack('H*', '0000000000000200'), pack('H*', '48221B9937748A23')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000100'), pack('H*', 'DD7C0BBD61FAFD54')), [str_repeat("\x01", 24), pack('H*', '0000000000000100'), pack('H*', 'DD7C0BBD61FAFD54')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000080'), pack('H*', '2FBC291A570DB5C4')), [str_repeat("\x01", 24), pack('H*', '0000000000000080'), pack('H*', '2FBC291A570DB5C4')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000040'), pack('H*', 'E07C30D7E4E26E12')), [str_repeat("\x01", 24), pack('H*', '0000000000000040'), pack('H*', 'E07C30D7E4E26E12')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000020'), pack('H*', '0953E2258E8E90A1')), [str_repeat("\x01", 24), pack('H*', '0000000000000020'), pack('H*', '0953E2258E8E90A1')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000010'), pack('H*', '5B711BC4CEEBF2EE')), [str_repeat("\x01", 24), pack('H*', '0000000000000010'), pack('H*', '5B711BC4CEEBF2EE')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000008'), pack('H*', 'CC083F1E6D9E85F6')), [str_repeat("\x01", 24), pack('H*', '0000000000000008'), pack('H*', 'CC083F1E6D9E85F6')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000004'), pack('H*', 'D2FD8867D50D2DFE')), [str_repeat("\x01", 24), pack('H*', '0000000000000004'), pack('H*', 'D2FD8867D50D2DFE')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000002'), pack('H*', '06E7EA22CE92708F')), [str_repeat("\x01", 24), pack('H*', '0000000000000002'), pack('H*', '06E7EA22CE92708F')],
array(str_repeat("\x01", 24), pack('H*', '0000000000000001'), pack('H*', '166B40B44ABA4BD6')) [str_repeat("\x01", 24), pack('H*', '0000000000000001'), pack('H*', '166B40B44ABA4BD6')]
); ];
$result = array(); $result = [];
foreach ($this->engines as $engine) { foreach ($this->engines as $engine) {
foreach ($tests as $test) { foreach ($tests as $test) {
$result[] = array($engine, $test[0], $test[1], $test[2]); $result[] = [$engine, $test[0], $test[1], $test[2]];
} }
} }
@ -119,33 +119,33 @@ class Unit_Crypt_TripleDESTest extends PhpseclibTestCase
public function engineIVVectors() public function engineIVVectors()
{ {
$engines = array( $engines = [
'PHP', 'PHP',
'Eval', 'Eval',
'mcrypt', 'mcrypt',
'OpenSSL', 'OpenSSL',
); ];
// tests from http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf // tests from http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf
$tests = array( $tests = [
// key, iv, plaintext, ciphertext // key, iv, plaintext, ciphertext
array( [
pack('H*', '627f460e08104a10' . '43cd265d5840eaf1' . '313edf97df2a8a8c'), pack('H*', '627f460e08104a10' . '43cd265d5840eaf1' . '313edf97df2a8a8c'),
pack('H*', '8e29f75ea77e5475'), pack('H*', '8e29f75ea77e5475'),
pack('H*', '326a494cd33fe756'), pack('H*', '326a494cd33fe756'),
pack('H*', 'b22b8d66de970692')), pack('H*', 'b22b8d66de970692')],
array( [
pack('H*', '37ae5ebf46dff2dc' . '0754b94f31cbb385' . '5e7fd36dc870bfae'), pack('H*', '37ae5ebf46dff2dc' . '0754b94f31cbb385' . '5e7fd36dc870bfae'),
pack('H*', '3d1de3cc132e3b65'), pack('H*', '3d1de3cc132e3b65'),
pack('H*', '84401f78fe6c10876d8ea23094ea5309'), pack('H*', '84401f78fe6c10876d8ea23094ea5309'),
pack('H*', '7b1f7c7e3b1c948ebd04a75ffba7d2f5')) pack('H*', '7b1f7c7e3b1c948ebd04a75ffba7d2f5')]
); ];
$result = array(); $result = [];
foreach ($engines as $engine) { foreach ($engines as $engine) {
foreach ($tests as $test) { foreach ($tests as $test) {
$result[] = array($engine, $test[0], $test[1], $test[2], $test[3]); $result[] = [$engine, $test[0], $test[1], $test[2], $test[3]];
} }
} }

View File

@ -11,12 +11,12 @@ class Unit_Crypt_TwofishTest extends PhpseclibTestCase
{ {
public function testVectors() public function testVectors()
{ {
$engines = array( $engines = [
'PHP', 'PHP',
'Eval', 'Eval',
'mcrypt', 'mcrypt',
'OpenSSL', 'OpenSSL',
); ];
foreach ($engines as $engine) { foreach ($engines as $engine) {
$tf = new Twofish('cbc'); $tf = new Twofish('cbc');

View File

@ -15,53 +15,53 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
*/ */
public function testAnyString() public function testAnyString()
{ {
$KDC_REP = array( $KDC_REP = [
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => array( 'children' => [
'pvno' => array( 'pvno' => [
'constant' => 0, 'constant' => 0,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY), 'type' => ASN1::TYPE_ANY],
'msg-type' => array( 'msg-type' => [
'constant' => 1, 'constant' => 1,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY), 'type' => ASN1::TYPE_ANY],
'padata' => array( 'padata' => [
'constant' => 2, 'constant' => 2,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY), 'type' => ASN1::TYPE_ANY],
'crealm' => array( 'crealm' => [
'constant' => 3, 'constant' => 3,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY), 'type' => ASN1::TYPE_ANY],
'cname' => array( 'cname' => [
'constant' => 4, 'constant' => 4,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY), 'type' => ASN1::TYPE_ANY],
'ticket' => array( 'ticket' => [
'constant' => 5, 'constant' => 5,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY), 'type' => ASN1::TYPE_ANY],
'enc-part' => array( 'enc-part' => [
'constant' => 6, 'constant' => 6,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY) 'type' => ASN1::TYPE_ANY]
) ]
); ];
$AS_REP = array( $AS_REP = [
'class' => ASN1::CLASS_APPLICATION, 'class' => ASN1::CLASS_APPLICATION,
'cast' => 11, 'cast' => 11,
'optional' => true, 'optional' => true,
'explicit' => true 'explicit' => true
) + $KDC_REP; ] + $KDC_REP;
$str = 'a4IC3jCCAtqgAwIBBaEDAgELoi8wLTAroQMCAROiJAQiMCAwHqADAgEXoRcbFUNSRUFUVUlUWS5ORVR0ZXN0dXNlcqMPGw' . $str = 'a4IC3jCCAtqgAwIBBaEDAgELoi8wLTAroQMCAROiJAQiMCAwHqADAgEXoRcbFUNSRUFUVUlUWS5ORVR0ZXN0dXNlcqMPGw' .
'1DUkVBVFVJVFkuTkVUpBUwE6ADAgEBoQwwChsIdGVzdHVzZXKlggFOYYIBSjCCAUagAwIBBaEPGw1DUkVBVFVJVFkuTkVU' . '1DUkVBVFVJVFkuTkVUpBUwE6ADAgEBoQwwChsIdGVzdHVzZXKlggFOYYIBSjCCAUagAwIBBaEPGw1DUkVBVFVJVFkuTkVU' .
@ -87,132 +87,132 @@ class Unit_File_ASN1Test extends PhpseclibTestCase
*/ */
public function testIncorrectString() public function testIncorrectString()
{ {
$PA_DATA = array( $PA_DATA = [
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => array( 'children' => [
'padata-type' => array( 'padata-type' => [
'constant' => 1, 'constant' => 1,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_INTEGER 'type' => ASN1::TYPE_INTEGER
), ],
'padata-value' => array( 'padata-value' => [
'constant' => 2, 'constant' => 2,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_OCTET_STRING 'type' => ASN1::TYPE_OCTET_STRING
) ]
) ]
); ];
$PrincipalName = array( $PrincipalName = [
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => array( 'children' => [
'name-type' => array( 'name-type' => [
'constant' => 0, 'constant' => 0,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_INTEGER 'type' => ASN1::TYPE_INTEGER
), ],
'name-string' => array( 'name-string' => [
'constant' => 1, 'constant' => 1,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'min' => 0, 'min' => 0,
'max' => -1, 'max' => -1,
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => array('type' => ASN1::TYPE_IA5_STRING) // should be \phpseclib\File\ASN1::TYPE_GENERAL_STRING 'children' => ['type' => ASN1::TYPE_IA5_STRING] // should be \phpseclib\File\ASN1::TYPE_GENERAL_STRING
) ]
) ]
); ];
$Ticket = array( $Ticket = [
'class' => ASN1::CLASS_APPLICATION, 'class' => ASN1::CLASS_APPLICATION,
'cast' => 1, 'cast' => 1,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => array( 'children' => [
'tkt-vno' => array( 'tkt-vno' => [
'constant' => 0, 'constant' => 0,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_INTEGER 'type' => ASN1::TYPE_INTEGER
), ],
'realm' => array( 'realm' => [
'constant' => 1, 'constant' => 1,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY 'type' => ASN1::TYPE_ANY
), ],
'sname' => array( 'sname' => [
'constant' => 2, 'constant' => 2,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY 'type' => ASN1::TYPE_ANY
), ],
'enc-part' => array( 'enc-part' => [
'constant' => 3, 'constant' => 3,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY 'type' => ASN1::TYPE_ANY
) ]
) ]
); ];
$KDC_REP = array( $KDC_REP = [
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => array( 'children' => [
'pvno' => array( 'pvno' => [
'constant' => 0, 'constant' => 0,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_INTEGER), 'type' => ASN1::TYPE_INTEGER],
'msg-type' => array( 'msg-type' => [
'constant' => 1, 'constant' => 1,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_INTEGER), 'type' => ASN1::TYPE_INTEGER],
'padata' => array( 'padata' => [
'constant' => 2, 'constant' => 2,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'min' => 0, 'min' => 0,
'max' => -1, 'max' => -1,
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => $PA_DATA), 'children' => $PA_DATA],
'crealm' => array( 'crealm' => [
'constant' => 3, 'constant' => 3,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_OCTET_STRING), 'type' => ASN1::TYPE_OCTET_STRING],
'cname' => array( 'cname' => [
'constant' => 4, 'constant' => 4,
'optional' => true, 'optional' => true,
'explicit' => true) + $PrincipalName, 'explicit' => true] + $PrincipalName,
//'type' => ASN1::TYPE_ANY), //'type' => ASN1::TYPE_ANY),
'ticket' => array( 'ticket' => [
'constant' => 5, 'constant' => 5,
'optional' => true, 'optional' => true,
'implicit' => true, 'implicit' => true,
'min' => 0, 'min' => 0,
'max' => 1, 'max' => 1,
'type' => ASN1::TYPE_SEQUENCE, 'type' => ASN1::TYPE_SEQUENCE,
'children' => $Ticket), 'children' => $Ticket],
'enc-part' => array( 'enc-part' => [
'constant' => 6, 'constant' => 6,
'optional' => true, 'optional' => true,
'explicit' => true, 'explicit' => true,
'type' => ASN1::TYPE_ANY) 'type' => ASN1::TYPE_ANY]
) ]
); ];
$AS_REP = array( $AS_REP = [
'class' => ASN1::CLASS_APPLICATION, 'class' => ASN1::CLASS_APPLICATION,
'cast' => 11, 'cast' => 11,
'optional' => true, 'optional' => true,
'explicit' => true 'explicit' => true
) + $KDC_REP; ] + $KDC_REP;
$str = 'a4IC3jCCAtqgAwIBBaEDAgELoi8wLTAroQMCAROiJAQiMCAwHqADAgEXoRcbFUNSRUFUVUlUWS5ORVR0ZXN0dXNlcqMPGw' . $str = 'a4IC3jCCAtqgAwIBBaEDAgELoi8wLTAroQMCAROiJAQiMCAwHqADAgEXoRcbFUNSRUFUVUlUWS5ORVR0ZXN0dXNlcqMPGw' .
'1DUkVBVFVJVFkuTkVUpBUwE6ADAgEBoQwwChsIdGVzdHVzZXKlggFOYYIBSjCCAUagAwIBBaEPGw1DUkVBVFVJVFkuTkVU' . '1DUkVBVFVJVFkuTkVUpBUwE6ADAgEBoQwwChsIdGVzdHVzZXKlggFOYYIBSjCCAUagAwIBBaEPGw1DUkVBVFVJVFkuTkVU' .

View File

@ -115,7 +115,7 @@ U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ
37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0= 37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=
-----END RSA PRIVATE KEY-----'); -----END RSA PRIVATE KEY-----');
$x509->setPrivateKey($rsa); $x509->setPrivateKey($rsa);
$x509->setDN(array('cn' => 'website.com')); $x509->setDN(['cn' => 'website.com']);
$x509->saveCSR($x509->signCSR('sha256WithRSAEncryption'), X509::FORMAT_DER); $x509->saveCSR($x509->signCSR('sha256WithRSAEncryption'), X509::FORMAT_DER);
} }
} }

View File

@ -299,14 +299,14 @@ f/1y2XuLNhBNHMAyTqpYPX8Yvav1c+Z50OMaSXHAnTa20zv8UtiHbaAhwlifCelU
Mj93S Mj93S
-----END CERTIFICATE-----'); -----END CERTIFICATE-----');
$x509->loadX509($x509->saveX509($decoded)); $x509->loadX509($x509->saveX509($decoded));
$expected = array( $expected = [
array( [
array('utf8String' => "Al. Marsza\xC5\x82ka Pi\xC5\x82sudskiego 52/54"), ['utf8String' => "Al. Marsza\xC5\x82ka Pi\xC5\x82sudskiego 52/54"],
array('utf8String' => '81-382 Gdynia'), ['utf8String' => '81-382 Gdynia'],
array('utf8String' => 'Polska'), ['utf8String' => 'Polska'],
array('utf8String' => 'pomorskie') ['utf8String' => 'pomorskie']
) ]
); ];
$this->assertEquals($x509->getDNProp('id-at-postalAddress'), $expected); $this->assertEquals($x509->getDNProp('id-at-postalAddress'), $expected);
$expected = "C=PL, O=Urz\xC4\x85d Miasta Gdyni/serialNumber=PESEL: 61060603118, CN=Jerzy Przeworski/postalAddress=" . '0F\X0C"AL. MARSZA\XC5\X82KA PI\XC5\X82SUDSKIEGO 52/54\X0C\X0D81-382 GDYNIA\X0C\X06POLSKA\X0C\X09POMORSKIE/givenName=Jerzy, SN=Przeworski'; $expected = "C=PL, O=Urz\xC4\x85d Miasta Gdyni/serialNumber=PESEL: 61060603118, CN=Jerzy Przeworski/postalAddress=" . '0F\X0C"AL. MARSZA\XC5\X82KA PI\XC5\X82SUDSKIEGO 52/54\X0C\X0D81-382 GDYNIA\X0C\X06POLSKA\X0C\X09POMORSKIE/givenName=Jerzy, SN=Przeworski';

View File

@ -9,19 +9,19 @@ class Unit_Net_SSH1Test extends PhpseclibTestCase
{ {
public function formatLogDataProvider() public function formatLogDataProvider()
{ {
return array( return [
array( [
array('hello world'), ['hello world'],
array('<--'), ['<--'],
"<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n" "<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n"
), ],
array( [
array('hello', 'world'), ['hello', 'world'],
array('<--', '<--'), ['<--', '<--'],
"<--\r\n00000000 68:65:6c:6c:6f hello\r\n\r\n" . "<--\r\n00000000 68:65:6c:6c:6f hello\r\n\r\n" .
"<--\r\n00000000 77:6f:72:6c:64 world\r\n\r\n" "<--\r\n00000000 77:6f:72:6c:64 world\r\n\r\n"
), ],
); ];
} }
/** /**
@ -34,7 +34,7 @@ class Unit_Net_SSH1Test extends PhpseclibTestCase
->setMethods(null) ->setMethods(null)
->getMock(); ->getMock();
$result = self::callFunc($ssh, 'format_log', array($message_log, $message_number_log)); $result = self::callFunc($ssh, 'format_log', [$message_log, $message_number_log]);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }

View File

@ -10,19 +10,19 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase
{ {
public function formatLogDataProvider() public function formatLogDataProvider()
{ {
return array( return [
array( [
array('hello world'), ['hello world'],
array('<--'), ['<--'],
"<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n" "<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n"
), ],
array( [
array('hello', 'world'), ['hello', 'world'],
array('<--', '<--'), ['<--', '<--'],
"<--\r\n00000000 68:65:6c:6c:6f hello\r\n\r\n" . "<--\r\n00000000 68:65:6c:6c:6f hello\r\n\r\n" .
"<--\r\n00000000 77:6f:72:6c:64 world\r\n\r\n" "<--\r\n00000000 77:6f:72:6c:64 world\r\n\r\n"
), ],
); ];
} }
/** /**
@ -32,7 +32,7 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase
{ {
$ssh = $this->createSSHMock(); $ssh = $this->createSSHMock();
$result = self::callFunc($ssh, 'format_log', array($message_log, $message_number_log)); $result = self::callFunc($ssh, 'format_log', [$message_log, $message_number_log]);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -129,7 +129,7 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase
{ {
return $this->getMockBuilder('phpseclib\Net\SSH2') return $this->getMockBuilder('phpseclib\Net\SSH2')
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(array('__destruct')) ->setMethods(['__destruct'])
->getMock(); ->getMock();
} }
} }