From aa88c5621b3305054ff9cf7012a205d01692975f Mon Sep 17 00:00:00 2001 From: thephilosoft Date: Fri, 3 Dec 2021 13:08:08 -0500 Subject: [PATCH] fix: fix syntax errors in ChaCha20 and Salsa20 tests --- tests/Unit/Crypt/ChaCha20.php | 18 +++++++++--------- tests/Unit/Crypt/Salsa20.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Unit/Crypt/ChaCha20.php b/tests/Unit/Crypt/ChaCha20.php index 4b2fc68f..67acaae7 100644 --- a/tests/Unit/Crypt/ChaCha20.php +++ b/tests/Unit/Crypt/ChaCha20.php @@ -26,7 +26,7 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase $expected = pack('H*', $expected); $engines = ['PHP', 'OpenSSL', 'libsodium']; - for ($engines as $engine) { + foreach ($engines as $engine) { $c = new ChaCha20(); $c->setKey($key); $c->setNonce($nonce); @@ -63,8 +63,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase $expected = str_replace(' ', '', $expected); $expected = pack('H*', $expected); - $engines = ['PHP', OpenSSL', 'libsodium']; - for ($engines as $engine) { + $engines = ['PHP', 'OpenSSL', 'libsodium']; + foreach ($engines as $engine) { $c = new ChaCha20(); $c->setKey($key); $c->setNonce($nonce); @@ -119,8 +119,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase $expected = str_replace(' ', '', $expected); $expected = pack('H*', $expected); - $engines = ['PHP', OpenSSL', 'libsodium']; - for ($engines as $engine) { + $engines = ['PHP', 'OpenSSL', 'libsodium']; + foreach ($engines as $engine) { $c = new ChaCha20(); $c->setKey($key); $c->setNonce($nonce); @@ -163,8 +163,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase $tag = str_replace(' ', '', $tag); $tag = pack('H*', $tag); - $engines = ['PHP', OpenSSL', 'libsodium']; - for ($engines as $engine) { + $engines = ['PHP', 'OpenSSL', 'libsodium']; + foreach ($engines as $engine) { $c = new ChaCha20(); $c->enablePoly1305(); $c->setKey($key); @@ -189,8 +189,8 @@ class Unit_Crypt_ChaCha20Test extends PhpseclibTestCase $plaintext = str_repeat("\0", array_sum($partitions)); - $engines = ['PHP', OpenSSL', 'libsodium']; - for ($engines as $engine) { + $engines = ['PHP', 'OpenSSL', 'libsodium']; + foreach ($engines as $engine) { $c = new ChaCha20(); $c->setKey($key); $c->setNonce($nonce); diff --git a/tests/Unit/Crypt/Salsa20.php b/tests/Unit/Crypt/Salsa20.php index 974feba7..8d2f8a3f 100644 --- a/tests/Unit/Crypt/Salsa20.php +++ b/tests/Unit/Crypt/Salsa20.php @@ -154,7 +154,7 @@ class Unit_Crypt_Salsa20Test extends PhpseclibTestCase if ($cipher->getEngine() != $engine) { 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"); } }