Tests: CS adjustments

This commit is contained in:
terrafrost 2014-12-13 13:47:37 -06:00
parent 9a55ab1892
commit 4d6e7efda6
3 changed files with 14 additions and 14 deletions

View File

@ -11,7 +11,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
{
protected $engine;
private function checkEngine($aes)
private function _checkEngine($aes)
{
if ($aes->getEngine() != $this->engine) {
$engine = 'internal';
@ -78,7 +78,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
$aes->setIV($iv);
$aes->setKey($key);
$this->checkEngine($aes);
$this->_checkEngine($aes);
$actual = '';
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->disablePadding();
$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'));
$this->assertEquals($ciphertext, pack('H*', '231d844639b31b412211cfe93712b880'));
}
@ -116,7 +116,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
$aes->setPreferredEngine($this->engine);
$aes->disablePadding();
$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'));
$this->assertEquals($ciphertext, pack('H*', 'c109292b173f841b88e0ee49f13db8c0'));
}
@ -135,10 +135,10 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
);
$combos = array(
array(16),
array(17),
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(16),
array(17),
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(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(16, 16), // two full size blocks
@ -176,7 +176,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
$aes->setKey($key);
$aes->setIV($iv);
$this->checkEngine($aes);
$this->_checkEngine($aes);
$str = '';
$result = '';
@ -193,7 +193,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
$aes->setKey($key);
$aes->setIV($iv);
$this->checkEngine($aes);
$this->_checkEngine($aes);
foreach ($test as $len) {
$temp = str_repeat('d', $len);
@ -205,4 +205,4 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
$this->assertSame(bin2hex($c1), bin2hex($c2));
}
}
}

View File

@ -66,4 +66,4 @@ class Unit_Crypt_DES_TestCase extends PhpseclibTestCase
self::markTestSkipped('Unable to initialize OpenSSL engine');
}
}
}
}

View File

@ -21,7 +21,7 @@ class Unit_Crypt_RC2_TestCase extends PhpseclibTestCase
// admittedly, phpseclib is inconsistent in this regard. RC4 and Blowfish support arbitrary key lengths between a certain range, as well,
// and they don't have any way to set the key length. but then again, neither do those algorithms have their own key expansion algorithm,
// whereas RC2 does. and technically, AES / Rijndael (and even Twofish) don't support arbitrary key lengths - they support variable key
// lengths. so in some ways, i suppose this inconsistency somewhat makes sense, although the fact that Crypt_Twofish doesn't have a
// lengths. so in some ways, i suppose this inconsistency somewhat makes sense, although the fact that Crypt_Twofish doesn't have a
// setKeyLength() function whereas Crypt_AES / Crypt_Rijndael do not is, itself, an inconsistency.
// but that said, Crypt_RC2 is inconsistent in other ways: if you pass a 128-bit (16-byte) key to it via setKey() the key is not treated
@ -68,4 +68,4 @@ class Unit_Crypt_RC2_TestCase extends PhpseclibTestCase
self::markTestSkipped('Unable to initialize OpenSSL engine');
}
}
}
}