Skip to content

Commit cbcf750

Browse files
committed
Tests: add testShortKeyIVStream
1 parent 72e0da6 commit cbcf750

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/MCryptCompatTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,29 @@ public function testStream()
253253
}
254254

255255
// i'd have a testRC4Stream method were it not for https://bugs.php.net/72535
256+
257+
public function testShortKeyIVStream()
258+
{
259+
$plaintext = 'Secret secret secret data';
260+
261+
$iv = 'z';
262+
$key = 'z';
263+
$opts = array('iv' => $iv, 'key' => $key);
264+
265+
$fp = fopen('php://memory', 'wb+');
266+
stream_filter_append($fp, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
267+
fwrite($fp, $plaintext);
268+
rewind($fp);
269+
$mcrypt = bin2hex(fread($fp, 1024));
270+
fclose($fp);
271+
272+
$fp = fopen('php://memory', 'wb+');
273+
stream_filter_append($fp, 'phpseclib.mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
274+
fwrite($fp, $plaintext);
275+
rewind($fp);
276+
$compat = bin2hex(fread($fp, 1024));
277+
fclose($fp);
278+
279+
$this->assertEquals($mcrypt, $compat);
280+
}
256281
}

0 commit comments

Comments
 (0)