Skip to content

Commit 72e0da6

Browse files
committed
Tests: add testShortKey
1 parent 79f065b commit 72e0da6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/MCryptCompatTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,24 @@ public function testMiddleKey3()
172172
phpseclib_mcrypt_encrypt('rijndael-128', $key, $plaintext, 'cbc', $iv);
173173
}
174174

175+
public function testShortKey()
176+
{
177+
$key = str_repeat('z', 4);
178+
$iv = str_repeat('z', 16);
179+
180+
$plaintext = 'a';
181+
182+
$td = mcrypt_module_open('rijndael-128', '', 'cbc', '');
183+
mcrypt_generic_init($td, $key, $iv);
184+
$mcrypt = bin2hex(mcrypt_generic($td, 'This is very important data'));
185+
186+
$td = phpseclib_mcrypt_module_open('rijndael-128', '', 'cbc', '');
187+
phpseclib_mcrypt_generic_init($td, $key, $iv);
188+
$phpseclib = bin2hex(phpseclib_mcrypt_generic($td, 'This is very important data'));
189+
190+
$this->assertEquals($mcrypt, $phpseclib);
191+
}
192+
175193
/**
176194
* adapted from the example at http://php.net/manual/en/filters.encryption.php
177195
*/
@@ -233,4 +251,6 @@ public function testStream()
233251
// when enough are present for another block to be added
234252
$this->assertNotEquals(strlen($mcrypt), strlen($plaintext) * 2);
235253
}
254+
255+
// i'd have a testRC4Stream method were it not for https://bugs.php.net/72535
236256
}

0 commit comments

Comments
 (0)