From: Tim Düsterhus Date: Mon, 9 Nov 2020 12:40:36 +0000 (+0100) Subject: Add namespace to all functions and constants for TotpMultifactorMethod X-Git-Tag: 5.4.0_Alpha_1~555^2~53^2~15 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d38ad96997b26ffefdbe45760a4f96e1d548cfd0;p=GitHub%2FWoltLab%2FWCF.git Add namespace to all functions and constants for TotpMultifactorMethod --- diff --git a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php index 76df9b4d9b..dffca00603 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/TotpMultifactorMethod.class.php @@ -113,7 +113,7 @@ class TotpMultifactorMethod implements IMultifactorMethod { public function processManagementForm(IFormDocument $form, int $setupId): void { $formData = $form->getData(); - assert( + \assert( (!empty($formData['data']) && empty($formData['delete'])) || (empty($formData['data']) && !empty($formData['delete'])) ); @@ -152,7 +152,7 @@ class TotpMultifactorMethod implements IMultifactorMethod { $formData['data']['deviceName'] ?: $defaultName, $formData['data']['secret'], $formData['data']['code']['minCounter'], - TIME_NOW, + \TIME_NOW, ]); } } @@ -255,7 +255,7 @@ class TotpMultifactorMethod implements IMultifactorMethod { AND minCounter < ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute([ - TIME_NOW, + \TIME_NOW, $formData['data']['code']['minCounter'], $setupId, $formData['data']['deviceID'], diff --git a/wcfsetup/install/files/lib/system/user/multifactor/totp/Totp.class.php b/wcfsetup/install/files/lib/system/user/multifactor/totp/Totp.class.php index f512549bf5..eeedaafc0e 100644 --- a/wcfsetup/install/files/lib/system/user/multifactor/totp/Totp.class.php +++ b/wcfsetup/install/files/lib/system/user/multifactor/totp/Totp.class.php @@ -56,7 +56,7 @@ final class Totp { ((\ord($hash[$offset + 2]) & 0xff) << 8) | ((\ord($hash[$offset + 3]) & 0xff) << 0); - $otp = \str_pad($binary % \pow(10, self::CODE_LENGTH), self::CODE_LENGTH, "0", \STR_PAD_LEFT); + $otp = \str_pad($binary % (10 ** self::CODE_LENGTH), self::CODE_LENGTH, "0", \STR_PAD_LEFT); return $otp; } @@ -77,7 +77,7 @@ final class Totp { * was used for verification. You MUST store the updated $minCounter to prevent code re-use. */ public function validateTotpCode(string $userCode, int &$minCounter, \DateTime $time): bool { - $counter = intval($time->getTimestamp() / self::TIME_STEP); + $counter = \intval($time->getTimestamp() / self::TIME_STEP); for ($offset = -self::LEEWAY; $offset < self::LEEWAY; $offset++) { $possibleCode = $this->generateHotpCode($counter + $offset);