From 50f9e1a71a24326b0fc6c4b662e378e52d2dbc3a Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 2 Dec 2018 11:58:07 -0600 Subject: [PATCH] Tests/AES: add unit test for encrypting without a key --- tests/Unit/Crypt/AES/TestCase.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Unit/Crypt/AES/TestCase.php b/tests/Unit/Crypt/AES/TestCase.php index 643123a6..523a45f3 100644 --- a/tests/Unit/Crypt/AES/TestCase.php +++ b/tests/Unit/Crypt/AES/TestCase.php @@ -407,4 +407,16 @@ abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase $this->assertEquals($plaintext, $actual); } + + /** + * @expectedException \UnexpectedValueException + */ + public function testNoKey() + { + $aes = new AES('cbc'); + $aes->setPreferredEngine($this->engine); + $aes->setIV(str_repeat('x', 16)); + + $aes->encrypt(str_repeat('a', 16)); + } }