Skip to content

Commit

Permalink
add unit test for last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Jul 10, 2018
1 parent 2ea74ed commit 34ec54a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/MCryptCompatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,34 @@ public function testShortKeyIVStream()
$this->assertEquals($mcrypt, $compat);
}

/**
* @group github18
*/
public function testBadSizeStream()
{
$original = 'Hello, this a sample file content to be encrypted and decrypted.... END of file.';

$key = 'ae6fa3da6ae39b05ce17e69d5e18c236a7341c80592626d81d7c70013b7d436d';
$iv = '5dc7a17ebe32b6e62f0b5f9519d57afb';
$opts = array('iv' => $iv, 'key' => $key);

$filename = tempnam(sys_get_temp_dir(), 'phpseclib-test-');

$fp = fopen($filename, 'wb');
stream_filter_append($fp, 'convert.base64-encode', STREAM_FILTER_WRITE);
stream_filter_append($fp, 'phpseclib.mcrypt.rijndael-256', STREAM_FILTER_WRITE, $opts);
fwrite($fp, $original);
fclose($fp);

$fp = fopen($filename, 'rb');
stream_filter_append($fp, 'phpseclib.mdecrypt.rijndael-256', STREAM_FILTER_READ, $opts);
stream_filter_append($fp, 'convert.base64-decode', STREAM_FILTER_READ);
$decrypted = fread($fp, 1024);
fclose($fp);

$this->assertEquals($original, $decrypted);
}

public function testBlowfish()
{
if (!extension_loaded('mcrypt')) {
Expand Down

0 comments on commit 34ec54a

Please sign in to comment.