Skip to content

Commit 2f08f6b

Browse files
committed
add unit test for cfb
1 parent 34ec54a commit 2f08f6b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/MCryptCompatTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,22 @@ public function testTripleDESECBParameters()
918918
$this->assertSame(8, $iv_size);
919919
}
920920

921+
/**
922+
* @dataProvider mcryptBlockModuleNameProvider
923+
*/
924+
public function testMcryptGenericMode($modeName, $validMode)
925+
{
926+
if (!$validMode) {
927+
return;
928+
}
929+
$key = str_repeat('a', 16);
930+
$iv = str_repeat('b', 16);
931+
$plaintext = str_repeat('c', 16);
932+
$mcrypt = mcrypt_encrypt('rijndael-128', $key, $plaintext, $modeName, $iv);
933+
$compat = phpseclib_mcrypt_encrypt('rijndael-128', $key, $plaintext, $modeName, $iv);
934+
$this->assertEquals(bin2hex($mcrypt), bin2hex($compat));
935+
}
936+
921937
public function mcryptModuleNameProvider()
922938
{
923939
return array(
@@ -952,6 +968,7 @@ public function mcryptBlockModuleNameProvider()
952968
array('cbc', true),
953969
array('ctr', true),
954970
array('ecb', true),
971+
array('cfb', true),
955972
array('ncfb', true),
956973
array('nofb', true),
957974
array('invalid-mode', false)

0 commit comments

Comments
 (0)