From e4369cc9dc7c7420a4ae37c7de7b410de7af0aca Mon Sep 17 00:00:00 2001 From: Nguyen Van Nguyen Date: Fri, 15 Dec 2023 12:09:43 +0700 Subject: [PATCH] WIP Signed-off-by: Nguyen Van Nguyen --- src/Common/S2K.php | 6 +++--- src/Cryptor/Aead/GCM.php | 4 ++-- src/Cryptor/Aead/OCB.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Common/S2K.php b/src/Common/S2K.php index bb34a076..d147daee 100644 --- a/src/Common/S2K.php +++ b/src/Common/S2K.php @@ -115,9 +115,9 @@ public function getLength(): int * Parsing function for a string-to-key specifier * * @param string $bytes - Payload of string-to-key specifier - * @return static + * @return self */ - public static function fromBytes(string $bytes): static + public static function fromBytes(string $bytes): self { $salt = ''; $itCount = self::DEFAULT_IT_COUNT; @@ -133,7 +133,7 @@ public static function fromBytes(string $bytes): static $itCount = ord($bytes[10]); break; } - return new static($salt, $type, $hash, $itCount); + return new self($salt, $type, $hash, $itCount); } /** diff --git a/src/Cryptor/Aead/GCM.php b/src/Cryptor/Aead/GCM.php index 95694190..8f80a301 100644 --- a/src/Cryptor/Aead/GCM.php +++ b/src/Cryptor/Aead/GCM.php @@ -33,7 +33,7 @@ final class GCM implements AeadCipher * @return self */ public function __construct( - private readonly string $key, + string $key, SymmetricAlgorithm $symmetric = SymmetricAlgorithm::Aes128 ) { @@ -79,7 +79,7 @@ public function getNonce(string $iv, string $chunkIndex): string { $nonce = $iv; for ($i = 0; $i < strlen($chunkIndex); $i++) { - $nonce[4 + $i] = $nonce[4 + $i] ^ $chunkIndex[i]; + $nonce[4 + $i] = $nonce[4 + $i] ^ $chunkIndex[$i]; } return $nonce; } diff --git a/src/Cryptor/Aead/OCB.php b/src/Cryptor/Aead/OCB.php index 04708baa..39fcfea7 100644 --- a/src/Cryptor/Aead/OCB.php +++ b/src/Cryptor/Aead/OCB.php @@ -53,7 +53,7 @@ final class OCB implements AeadCipher * @return self */ public function __construct( - private readonly string $key, + string $key, SymmetricAlgorithm $symmetric = SymmetricAlgorithm::Aes128 ) { @@ -133,7 +133,7 @@ public function getNonce(string $iv, string $chunkIndex): string * Encrypt/decrypt data. * * @param BlockCipher $cipher - Encryption/decryption block cipher function - * @param string $ciphertext - The cleartext or ciphertext (without tag) input + * @param string $text - The cleartext or ciphertext (without tag) input * @param string $nonce - The nonce (15 bytes) * @param string $adata - Associated data to sign * @return string The ciphertext or plaintext output, with tag appended in both cases.