@@ -172,6 +172,24 @@ public function testMiddleKey3()
172
172
phpseclib_mcrypt_encrypt ('rijndael-128 ' , $ key , $ plaintext , 'cbc ' , $ iv );
173
173
}
174
174
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
+
175
193
/**
176
194
* adapted from the example at http://php.net/manual/en/filters.encryption.php
177
195
*/
@@ -233,4 +251,6 @@ public function testStream()
233
251
// when enough are present for another block to be added
234
252
$ this ->assertNotEquals (strlen ($ mcrypt ), strlen ($ plaintext ) * 2 );
235
253
}
254
+
255
+ // i'd have a testRC4Stream method were it not for https://bugs.php.net/72535
236
256
}
0 commit comments