mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-20 04:00:55 +00:00
Tests: small unit test updates
This commit is contained in:
parent
5d0cb1cee9
commit
baf65d3fef
@ -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
|
||||||
|
@ -33,7 +33,7 @@ class Unit_Crypt_RC2_TestCase extends PhpseclibTestCase
|
|||||||
// in contrast, to my knowledge, there is no technique for expanding a key less than 128 bits to 128 bits, via RC2 key expansion. the only
|
// in contrast, to my knowledge, there is no technique for expanding a key less than 128 bits to 128 bits, via RC2 key expansion. the only
|
||||||
// scenario in that regard is null padding.
|
// scenario in that regard is null padding.
|
||||||
|
|
||||||
// simple truncation is insufficient, since, quoting RFC2268, "the purpose of th key-expansion algorithm [in RC2] is to modify the key buffer
|
// simple truncation is insufficient, since, quoting RFC2268, "the purpose of the key-expansion algorithm [in RC2] is to modify the key buffer
|
||||||
// so that each bit of the expanded key depends in a complicated way on every bit of the supplied input key".
|
// so that each bit of the expanded key depends in a complicated way on every bit of the supplied input key".
|
||||||
|
|
||||||
// now, to OpenSSL's credit, null padding is internally consistent with OpenSSL. OpenSSL only supports fixed length keys. For rc2, rc4 and
|
// now, to OpenSSL's credit, null padding is internally consistent with OpenSSL. OpenSSL only supports fixed length keys. For rc2, rc4 and
|
||||||
@ -52,10 +52,13 @@ class Unit_Crypt_RC2_TestCase extends PhpseclibTestCase
|
|||||||
$rc2->setPreferredEngine(CRYPT_ENGINE_INTERNAL);
|
$rc2->setPreferredEngine(CRYPT_ENGINE_INTERNAL);
|
||||||
$internal = $rc2->encrypt('d');
|
$internal = $rc2->encrypt('d');
|
||||||
|
|
||||||
|
$result = pack('H*', 'e3b36057f4821346');
|
||||||
|
$this->assertEquals($result, $internal, 'Failed asserting that the internal engine produced the correct result');
|
||||||
|
|
||||||
$rc2->setPreferredEngine(CRYPT_ENGINE_MCRYPT);
|
$rc2->setPreferredEngine(CRYPT_ENGINE_MCRYPT);
|
||||||
if ($rc2->getEngine() == CRYPT_ENGINE_MCRYPT) {
|
if ($rc2->getEngine() == CRYPT_ENGINE_MCRYPT) {
|
||||||
$mcrypt = $rc2->encrypt('d');
|
$mcrypt = $rc2->encrypt('d');
|
||||||
$this->assertEquals($internal, $mcrypt, 'Failed asserting that the internal and mcrypt engines produce identical results');
|
$this->assertEquals($result, $mcrypt, 'Failed asserting that the mcrypt engine produced the correct result');
|
||||||
} else {
|
} else {
|
||||||
self::markTestSkipped('Unable to initialize mcrypt engine');
|
self::markTestSkipped('Unable to initialize mcrypt engine');
|
||||||
}
|
}
|
||||||
@ -63,7 +66,7 @@ class Unit_Crypt_RC2_TestCase extends PhpseclibTestCase
|
|||||||
$rc2->setPreferredEngine(CRYPT_ENGINE_OPENSSL);
|
$rc2->setPreferredEngine(CRYPT_ENGINE_OPENSSL);
|
||||||
if ($rc2->getEngine() == CRYPT_ENGINE_OPENSSL) {
|
if ($rc2->getEngine() == CRYPT_ENGINE_OPENSSL) {
|
||||||
$openssl = $rc2->encrypt('d');
|
$openssl = $rc2->encrypt('d');
|
||||||
$this->assertEquals($internal, $openssl, 'Failed asserting that the internal and OpenSSL engines produce identical results');
|
$this->assertEquals($result, $openssl, 'Failed asserting that the OpenSSL engine produced the correct result');
|
||||||
} else {
|
} else {
|
||||||
self::markTestSkipped('Unable to initialize OpenSSL engine');
|
self::markTestSkipped('Unable to initialize OpenSSL engine');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user