Skip to content

Commit 34ec54a

Browse files
committed
add unit test for last commit
1 parent 2ea74ed commit 34ec54a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/MCryptCompatTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,34 @@ public function testShortKeyIVStream()
711711
$this->assertEquals($mcrypt, $compat);
712712
}
713713

714+
/**
715+
* @group github18
716+
*/
717+
public function testBadSizeStream()
718+
{
719+
$original = 'Hello, this a sample file content to be encrypted and decrypted.... END of file.';
720+
721+
$key = 'ae6fa3da6ae39b05ce17e69d5e18c236a7341c80592626d81d7c70013b7d436d';
722+
$iv = '5dc7a17ebe32b6e62f0b5f9519d57afb';
723+
$opts = array('iv' => $iv, 'key' => $key);
724+
725+
$filename = tempnam(sys_get_temp_dir(), 'phpseclib-test-');
726+
727+
$fp = fopen($filename, 'wb');
728+
stream_filter_append($fp, 'convert.base64-encode', STREAM_FILTER_WRITE);
729+
stream_filter_append($fp, 'phpseclib.mcrypt.rijndael-256', STREAM_FILTER_WRITE, $opts);
730+
fwrite($fp, $original);
731+
fclose($fp);
732+
733+
$fp = fopen($filename, 'rb');
734+
stream_filter_append($fp, 'phpseclib.mdecrypt.rijndael-256', STREAM_FILTER_READ, $opts);
735+
stream_filter_append($fp, 'convert.base64-decode', STREAM_FILTER_READ);
736+
$decrypted = fread($fp, 1024);
737+
fclose($fp);
738+
739+
$this->assertEquals($original, $decrypted);
740+
}
741+
714742
public function testBlowfish()
715743
{
716744
if (!extension_loaded('mcrypt')) {

0 commit comments

Comments
 (0)