Skip to content

Commit 9b6397f

Browse files
committed
testAESBasic is kinda redundant so rm it
1 parent 548584b commit 9b6397f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tests/MCryptCompatTest.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ public function testAlgorithmList()
55
{
66
$this->assertInternalType('array', phpseclib_mcrypt_list_algorithms());
77
}
8-
9-
public function testAESBasicSuccess()
10-
{
11-
$mcrypt = bin2hex(mcrypt_encrypt('rijndael-128', str_repeat('a', 16), 'asdf', 'cbc', str_repeat('a', 16)));
12-
$compat = bin2hex(phpseclib_mcrypt_encrypt('rijndael-128', str_repeat('a', 16), 'asdf', 'cbc', str_repeat('a', 16)));
13-
$this->assertEquals($mcrypt, $compat);
14-
}
158

169
public function testListAlgorithms()
1710
{
@@ -78,13 +71,16 @@ public function testNullPadding()
7871
{
7972
$key = str_repeat('z', 16);
8073
$iv = str_repeat('z', 16);
81-
// a plaintext of length 1 is of an insufficient length for cbc mode
82-
$mcrypt = bin2hex(mcrypt_encrypt('rijndael-128', $key, 'a', 'cbc', $iv));
83-
$compat = bin2hex(phpseclib_mcrypt_encrypt('rijndael-128', $key, 'a', 'cbc', $iv));
74+
75+
// a plaintext / ciphertext of length 1 is of an insufficient length for cbc mode
76+
$plaintext = $ciphertext = 'a';
77+
78+
$mcrypt = bin2hex(mcrypt_encrypt('rijndael-128', $key, $plaintext, 'cbc', $iv));
79+
$compat = bin2hex(phpseclib_mcrypt_encrypt('rijndael-128', $key, $plaintext, 'cbc', $iv));
8480
$this->assertEquals($mcrypt, $compat);
8581

86-
$mcrypt = bin2hex(mcrypt_decrypt('rijndael-128', $key, 'a', 'cbc', $iv));
87-
$compat = bin2hex(phpseclib_mcrypt_decrypt('rijndael-128', $key, 'a', 'cbc', $iv));
82+
$mcrypt = bin2hex(mcrypt_decrypt('rijndael-128', $key, $ciphertext, 'cbc', $iv));
83+
$compat = bin2hex(phpseclib_mcrypt_decrypt('rijndael-128', $key, $ciphertext, 'cbc', $iv));
8884
$this->assertEquals($mcrypt, $compat);
8985
}
9086
}

0 commit comments

Comments
 (0)