mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-15 19:16:55 +00:00
Merge branch '2.0' into 3.0
This commit is contained in:
commit
d25f03be9a
@ -833,7 +833,6 @@ class Rijndael extends BlockCipher
|
|||||||
|
|
||||||
// Generating encrypt code:
|
// Generating encrypt code:
|
||||||
$init_encrypt .= '
|
$init_encrypt .= '
|
||||||
static $tables;
|
|
||||||
if (empty($tables)) {
|
if (empty($tables)) {
|
||||||
$tables = &$this->getTables();
|
$tables = &$this->getTables();
|
||||||
}
|
}
|
||||||
@ -890,7 +889,6 @@ class Rijndael extends BlockCipher
|
|||||||
|
|
||||||
// Generating decrypt code:
|
// Generating decrypt code:
|
||||||
$init_decrypt .= '
|
$init_decrypt .= '
|
||||||
static $invtables;
|
|
||||||
if (empty($invtables)) {
|
if (empty($invtables)) {
|
||||||
$invtables = &$this->getInvTables();
|
$invtables = &$this->getInvTables();
|
||||||
}
|
}
|
||||||
@ -947,7 +945,7 @@ class Rijndael extends BlockCipher
|
|||||||
|
|
||||||
$this->inline_crypt = $this->createInlineCryptFunction(
|
$this->inline_crypt = $this->createInlineCryptFunction(
|
||||||
[
|
[
|
||||||
'init_crypt' => '',
|
'init_crypt' => 'static $tables; static $invtables;',
|
||||||
'init_encrypt' => $init_encrypt,
|
'init_encrypt' => $init_encrypt,
|
||||||
'init_decrypt' => $init_decrypt,
|
'init_decrypt' => $init_decrypt,
|
||||||
'encrypt_block' => $encrypt_block,
|
'encrypt_block' => $encrypt_block,
|
||||||
|
@ -387,6 +387,35 @@ abstract class TestCase extends PhpseclibTestCase
|
|||||||
$this->assertSame($aes->getKeyLength(), 256);
|
$this->assertSame($aes->getKeyLength(), 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInvalidLengthKeyWithAES()
|
||||||
|
{
|
||||||
|
$plaintext = str_repeat('x', 16);
|
||||||
|
|
||||||
|
$aes = new Crypt_Rijndael();
|
||||||
|
$aes->setKey(str_repeat('a', 19));
|
||||||
|
$this->assertSame($aes->getKeyLength(), 160);
|
||||||
|
|
||||||
|
$ref = new Crypt_Rijndael();
|
||||||
|
$ref->setKey(str_repeat('a', 19) . "\0");
|
||||||
|
$this->assertSame(
|
||||||
|
bin2hex($aes->encrypt($plaintext)),
|
||||||
|
bin2hex($ref->encrypt($plaintext)),
|
||||||
|
'actual and expected value do not match for 168 bit Rijndael'
|
||||||
|
);
|
||||||
|
|
||||||
|
$aes = new Crypt_AES();
|
||||||
|
$aes->setKey(str_repeat('a', 19));
|
||||||
|
$this->assertSame($aes->getKeyLength(), 192);
|
||||||
|
|
||||||
|
$ref = new Crypt_AES();
|
||||||
|
$ref->setKey(str_repeat('a', 19) . "\0\0\0\0\0");
|
||||||
|
$this->assertSame(
|
||||||
|
bin2hex($aes->encrypt($plaintext)),
|
||||||
|
bin2hex($ref->encrypt($plaintext)),
|
||||||
|
'actual and expected value do not match for 168 bit AES'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group github938
|
* @group github938
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user