From 2440be341df4b1c2483d5dcdfc44d52f4e437b70 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 21 Feb 2018 08:10:06 -0600 Subject: [PATCH] Tests/AES: add test for ECB mode --- tests/Unit/Crypt/AES/TestCase.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index 6ebfc34d..643123a6 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -392,4 +392,19 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $expected = pack('H*', '6572617574689e1be8d2d8d43c594cf3'); $this->assertSame($plaintext, $expected); } + + public function testECBDecrypt() + { + $aes = new AES('ecb'); + $aes->setPreferredEngine($this->engine); + $aes->setKey(str_repeat('x', 16)); + + $this->_checkEngine($aes); + + $plaintext = str_repeat('a', 16); + + $actual = $aes->decrypt($aes->encrypt($plaintext)); + + $this->assertEquals($plaintext, $actual); + } }