mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-03 12:28:30 +00:00
AES: update unit tests
This commit is contained in:
parent
c8b55b8929
commit
e7708b0d20
@ -9,9 +9,8 @@ class Unit_Crypt_AES_InternalTest extends Unit_Crypt_AES_TestCase
|
||||
{
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
self::$engine = CRYPT_MODE_INTERNAL;
|
||||
|
||||
self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL);
|
||||
self::ensureConstant('CRYPT_RIJNDAEL_MODE', CRYPT_RIJNDAEL_MODE_INTERNAL);
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,8 @@ class Unit_Crypt_AES_McryptTest extends Unit_Crypt_AES_TestCase
|
||||
self::markTestSkipped('mcrypt extension is not available.');
|
||||
}
|
||||
|
||||
parent::setUpBeforeClass();
|
||||
self::$engine = CRYPT_MODE_MCRYPT;
|
||||
|
||||
self::ensureConstant('CRYPT_AES_MODE', CRYPT_AES_MODE_MCRYPT);
|
||||
self::ensureConstant('CRYPT_RIJNDAEL_MODE', CRYPT_RIJNDAEL_MODE_MCRYPT);
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ require_once 'Crypt/AES.php';
|
||||
|
||||
abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
||||
{
|
||||
protected static $engine;
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::reRequireFile('Crypt/Rijndael.php');
|
||||
self::reRequireFile('Crypt/AES.php');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,6 +63,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
||||
public function testEncryptDecryptWithContinuousBuffer($mode, $plaintext, $iv, $key)
|
||||
{
|
||||
$aes = new Crypt_AES(constant($mode));
|
||||
$aes->setEngine(self::$engine);
|
||||
$aes->enableContinuousBuffer();
|
||||
$aes->setIV($iv);
|
||||
$aes->setKey($key);
|
||||
@ -85,6 +85,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
||||
// https://web.archive.org/web/20070209120224/http://fp.gladman.plus.com/cryptography_technology/rijndael/aesdvec.zip
|
||||
|
||||
$aes = new Crypt_Rijndael();
|
||||
$aes->setEngine(self::$engine);
|
||||
$aes->disablePadding();
|
||||
$aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. Valid in Rijndael.
|
||||
$ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734'));
|
||||
@ -99,6 +100,7 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
|
||||
// same as the above - just with a different ciphertext
|
||||
|
||||
$aes = new Crypt_AES();
|
||||
$aes->setEngine(self::$engine);
|
||||
$aes->disablePadding();
|
||||
$aes->setKey(pack('H*', '2b7e151628aed2a6abf7158809cf4f3c762e7160')); // 160-bit key. AES should null pad to 192-bits
|
||||
$ciphertext = $aes->encrypt(pack('H*', '3243f6a8885a308d313198a2e0370734'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user