mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-29 04:23:34 +00:00
fix: fix syntax errors in ChaCha20 and Salsa20 tests
This commit is contained in:
parent
2bcb643660
commit
aa88c5621b
@ -26,7 +26,7 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase
|
|||||||
$expected = pack('H*', $expected);
|
$expected = pack('H*', $expected);
|
||||||
|
|
||||||
$engines = ['PHP', 'OpenSSL', 'libsodium'];
|
$engines = ['PHP', 'OpenSSL', 'libsodium'];
|
||||||
for ($engines as $engine) {
|
foreach ($engines as $engine) {
|
||||||
$c = new ChaCha20();
|
$c = new ChaCha20();
|
||||||
$c->setKey($key);
|
$c->setKey($key);
|
||||||
$c->setNonce($nonce);
|
$c->setNonce($nonce);
|
||||||
@ -63,8 +63,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase
|
|||||||
$expected = str_replace(' ', '', $expected);
|
$expected = str_replace(' ', '', $expected);
|
||||||
$expected = pack('H*', $expected);
|
$expected = pack('H*', $expected);
|
||||||
|
|
||||||
$engines = ['PHP', OpenSSL', 'libsodium'];
|
$engines = ['PHP', 'OpenSSL', 'libsodium'];
|
||||||
for ($engines as $engine) {
|
foreach ($engines as $engine) {
|
||||||
$c = new ChaCha20();
|
$c = new ChaCha20();
|
||||||
$c->setKey($key);
|
$c->setKey($key);
|
||||||
$c->setNonce($nonce);
|
$c->setNonce($nonce);
|
||||||
@ -119,8 +119,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase
|
|||||||
$expected = str_replace(' ', '', $expected);
|
$expected = str_replace(' ', '', $expected);
|
||||||
$expected = pack('H*', $expected);
|
$expected = pack('H*', $expected);
|
||||||
|
|
||||||
$engines = ['PHP', OpenSSL', 'libsodium'];
|
$engines = ['PHP', 'OpenSSL', 'libsodium'];
|
||||||
for ($engines as $engine) {
|
foreach ($engines as $engine) {
|
||||||
$c = new ChaCha20();
|
$c = new ChaCha20();
|
||||||
$c->setKey($key);
|
$c->setKey($key);
|
||||||
$c->setNonce($nonce);
|
$c->setNonce($nonce);
|
||||||
@ -163,8 +163,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase
|
|||||||
$tag = str_replace(' ', '', $tag);
|
$tag = str_replace(' ', '', $tag);
|
||||||
$tag = pack('H*', $tag);
|
$tag = pack('H*', $tag);
|
||||||
|
|
||||||
$engines = ['PHP', OpenSSL', 'libsodium'];
|
$engines = ['PHP', 'OpenSSL', 'libsodium'];
|
||||||
for ($engines as $engine) {
|
foreach ($engines as $engine) {
|
||||||
$c = new ChaCha20();
|
$c = new ChaCha20();
|
||||||
$c->enablePoly1305();
|
$c->enablePoly1305();
|
||||||
$c->setKey($key);
|
$c->setKey($key);
|
||||||
@ -189,8 +189,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase
|
|||||||
|
|
||||||
$plaintext = str_repeat("\0", array_sum($partitions));
|
$plaintext = str_repeat("\0", array_sum($partitions));
|
||||||
|
|
||||||
$engines = ['PHP', OpenSSL', 'libsodium'];
|
$engines = ['PHP', 'OpenSSL', 'libsodium'];
|
||||||
for ($engines as $engine) {
|
foreach ($engines as $engine) {
|
||||||
$c = new ChaCha20();
|
$c = new ChaCha20();
|
||||||
$c->setKey($key);
|
$c->setKey($key);
|
||||||
$c->setNonce($nonce);
|
$c->setNonce($nonce);
|
||||||
|
@ -154,7 +154,7 @@ class Unit_Crypt_Salsa20Test extends PhpseclibTestCase
|
|||||||
if ($cipher->getEngine() != $engine) {
|
if ($cipher->getEngine() != $engine) {
|
||||||
self::markTestSkipped('Unable to initialize ' . $engine . ' engine for ' . (strlen($key) * 8) . '-bit key');
|
self::markTestSkipped('Unable to initialize ' . $engine . ' engine for ' . (strlen($key) * 8) . '-bit key');
|
||||||
}
|
}
|
||||||
$result = $cipher->encrypt(str_repeat("\0", 64);
|
$result = $cipher->encrypt(str_repeat("\0", 64));
|
||||||
$this->assertEquals(bin2hex($result), $expected, "Failed asserting that key $key / $iv yielded expected output in $engine engine");
|
$this->assertEquals(bin2hex($result), $expected, "Failed asserting that key $key / $iv yielded expected output in $engine engine");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user