3namespace Bitrix\Main\Security\Mfa;
5use Bitrix\Main\Config\Option;
6use Bitrix\Main\ArgumentOutOfRangeException;
7use Bitrix\Main\Security\OtpException;
8use Bitrix\Main\Localization\Loc;
10Loc::loadMessages(__FILE__);
15 protected static $type =
'totp';
24 if (isset($initParams[
'startTimestamp']) && (
int)$initParams[
'startTimestamp'] > 0)
26 $this->startTimestamp = (int)$initParams[
'startTimestamp'];
29 $interval = (int)Option::get(
'security',
'totp_interval');
41 $input = (string)$input;
48 if (!preg_match(
'#^\d+$#D', $input))
53 [$userOffset, $lastTimeCode] = explode(
':',
$params);
54 $userOffset = (int)$userOffset;
55 $lastTimeCode = (int)$lastTimeCode;
68 $checkOffsets[] = $userOffset;
78 $checkOffsets = array_merge(
80 range($userOffset - $this->window, $userOffset + $this->window)
88 foreach ($checkOffsets as $offset)
90 $code = $timeCode + $offset;
92 if ($lastTimeCode &&
$code <= $lastTimeCode)
100 $resultOffset = $offset;
101 $resultTimeCode =
$code;
106 if ($isSuccess ===
true)
108 return [
true, sprintf(
'%d:%d', $resultOffset, $resultTimeCode)];
111 return [
false,
null];
120 return parent::generateUri($label, $opts);
175 [$isSuccess,] = $this->
verify($inputA, $offset);
180 $offset = -self::SYNC_WINDOW;
181 for (
$i = $offset;
$i < self::SYNC_WINDOW;
$i++)
183 [$isSuccess,] = $this->
verify($inputA, $offset);
192 if ($offset === self::SYNC_WINDOW)
194 throw new OtpException(
'Cannot synchronize this secret key with the provided password values.');
197 return sprintf(
'%d:%d', $offset, 0);
isStringsEqual($expected, $actual)
getSyncParameters($inputA, $inputB)
__construct(array $initParams=[])
verify($input, $params=null, $time=null)
generateUri($label, array $opts=[])
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']