1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
hotpalgorithm.php
См. документацию.
1<?php
2
4
9
10Loc::loadMessages(__FILE__);
11
13{
14 const SYNC_WINDOW = 15000;
15 protected static $type = 'hotp';
16 protected $window = 10;
17
18 public function __construct()
19 {
20 $window = (int)Option::get('security', 'hotp_user_window', 10);
21 if ($window && $window > 0)
22 {
23 $this->window = $window;
24 }
25 }
26
30 public function verify($input, $params = null)
31 {
32 $input = (string)$input;
33
34 if (!preg_match('#^\d+$#D', $input))
35 {
36 throw new ArgumentOutOfRangeException('input', 'string with numbers');
37 }
38
39 $counter = (int)$params;
40 $result = false;
42 while ($window--)
43 {
44 if ($this->isStringsEqual($input, $this->generateOTP($counter)))
45 {
46 $result = true;
47 break;
48 }
49 $counter++;
50 }
51
52 if ($result === true)
53 {
54 return [true, $counter + 1];
55 }
56
57 return [false, null];
58 }
59
63 public function generateUri($label, array $opts = [])
64 {
65 $opts += ['counter' => 1];
66 return parent::generateUri($label, $opts);
67 }
68
72 public function getSyncParameters($inputA, $inputB)
73 {
74 $counter = 0;
75 $this->window = 1;
76 for ($i = 0; $i < self::SYNC_WINDOW; $i++)
77 {
78 [$verifyA,] = $this->verify($inputA, $counter);
79 [$verifyB,] = $this->verify($inputB, $counter + 1);
80 $counter++;
81 if ($verifyA && $verifyB)
82 {
83 break;
84 }
85 }
86
87 if ($i === self::SYNC_WINDOW)
88 {
89 throw new OtpException('Cannot synchronize this secret key with the provided password values.');
90 }
91
92 return $counter;
93 }
94}
getSyncParameters($inputA, $inputB)
Определения hotpalgorithm.php:72
generateUri($label, array $opts=[])
Определения hotpalgorithm.php:63
verify($input, $params=null)
Определения hotpalgorithm.php:30
isStringsEqual($expected, $actual)
Определения otpalgorithm.php:170
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$counter
Определения options.php:5
$i
Определения factura.php:643
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799