mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-20 04:00:55 +00:00
Tests: CS adjustments
This commit is contained in:
parent
9a55ab1892
commit
4d6e7efda6
@ -11,7 +11,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
|||||||
{
|
{
|
||||||
protected $engine;
|
protected $engine;
|
||||||
|
|
||||||
private function checkEngine($aes)
|
private function _checkEngine($aes)
|
||||||
{
|
{
|
||||||
if ($aes->getEngine() != $this->engine) {
|
if ($aes->getEngine() != $this->engine) {
|
||||||
$engine = 'internal';
|
$engine = 'internal';
|
||||||
@ -78,7 +78,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
|||||||
$aes->setIV($iv);
|
$aes->setIV($iv);
|
||||||
$aes->setKey($key);
|
$aes->setKey($key);
|
||||||
|
|
||||||
$this->checkEngine($aes);
|
$this->_checkEngine($aes);
|
||||||
|
|
||||||
$actual = '';
|
$actual = '';
|
||||||
for ($i = 0, $strlen = strlen($plaintext); $i < $strlen; ++$i) {
|
for ($i = 0, $strlen = strlen($plaintext); $i < $strlen; ++$i) {
|
||||||
@ -100,7 +100,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
|||||||
$aes->setPreferredEngine($this->engine);
|
$aes->setPreferredEngine($this->engine);
|
||||||
$aes->disablePadding();
|
$aes->disablePadding();
|
||||||
$aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. Valid in Rijndael.
|
$aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. Valid in Rijndael.
|
||||||
//$this->checkEngine($aes); // should only work in internal mode
|
//$this->_checkEngine($aes); // should only work in internal mode
|
||||||
$ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734'));
|
$ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734'));
|
||||||
$this->assertEquals($ciphertext, pack('H*', '231d844639b31b412211cfe93712b880'));
|
$this->assertEquals($ciphertext, pack('H*', '231d844639b31b412211cfe93712b880'));
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
|||||||
$aes->setPreferredEngine($this->engine);
|
$aes->setPreferredEngine($this->engine);
|
||||||
$aes->disablePadding();
|
$aes->disablePadding();
|
||||||
$aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. AES should null pad to 192-bits
|
$aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. AES should null pad to 192-bits
|
||||||
$this->checkEngine($aes);
|
$this->_checkEngine($aes);
|
||||||
$ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734'));
|
$ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734'));
|
||||||
$this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0'));
|
$this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0'));
|
||||||
}
|
}
|
||||||
@ -135,10 +135,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$combos = array(
|
$combos = array(
|
||||||
array(16),
|
array(16),
|
||||||
array(17),
|
array(17),
|
||||||
array(1, 16),
|
array(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)
|
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)
|
||||||
array(15, 4), // (15 to test openssl_encrypt call and buffer creation and 4 to test something that spans multpile bloc
|
array(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
|
array(3, 6, 10, 16), // this is why the strlen check in the buffer-only code was needed
|
||||||
array(16, 16), // two full size blocks
|
array(16, 16), // two full size blocks
|
||||||
@ -176,7 +176,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
|||||||
$aes->setKey($key);
|
$aes->setKey($key);
|
||||||
$aes->setIV($iv);
|
$aes->setIV($iv);
|
||||||
|
|
||||||
$this->checkEngine($aes);
|
$this->_checkEngine($aes);
|
||||||
|
|
||||||
$str = '';
|
$str = '';
|
||||||
$result = '';
|
$result = '';
|
||||||
@ -193,7 +193,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
|||||||
$aes->setKey($key);
|
$aes->setKey($key);
|
||||||
$aes->setIV($iv);
|
$aes->setIV($iv);
|
||||||
|
|
||||||
$this->checkEngine($aes);
|
$this->_checkEngine($aes);
|
||||||
|
|
||||||
foreach ($test as $len) {
|
foreach ($test as $len) {
|
||||||
$temp = str_repeat('d', $len);
|
$temp = str_repeat('d', $len);
|
||||||
|
Loading…
Reference in New Issue
Block a user