Apply suggestions from code review
authorMarcel Werk <burntime@woltlab.com>
Fri, 27 Oct 2023 14:24:41 +0000 (16:24 +0200)
committerGitHub <noreply@github.com>
Fri, 27 Oct 2023 14:24:41 +0000 (16:24 +0200)
Co-authored-by: Alexander Ebert <ebert@woltlab.com>
wcfsetup/install/files/lib/system/user/authentication/password/algorithm/Pbkdf2.class.php

index f0224a22c39578498fde643d1995f563fe7213e8..c16008c11c3a1b421ab07eeed3e3e45e86a33c93 100644 (file)
@@ -24,11 +24,10 @@ final class Pbkdf2 implements IPasswordAlgorithm
         string $hash
     ): bool {
         $parts = \explode(':', $hash, 5);
-        $hash = $parts[0];
-        $salt = $parts[1];
-        $algo = $parts[2];
-        $iterations = $parts[3];
-        $length = $parts[4];
+        if (\count($parts) !== 5) {
+            return false;
+        }
+        [$hash, $salt, $algo, $iterations, $length] = $parts;
 
         return \hash_equals($hash, \hash_pbkdf2($algo, $password, $salt, $iterations, $length));
     }
@@ -46,7 +45,7 @@ final class Pbkdf2 implements IPasswordAlgorithm
         $length = 32;
         $hash = \hash_pbkdf2($algo, $password, $salt, $iterations, $length);
 
-        return implode(':', [$hash, $salt, $algo, $iterations, $length]);
+        return \implode(':', [$hash, $salt, $algo, $iterations, $length]);
     }
 
     /**