1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
hotpalgorithm.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Security\Mfa
;
4
5
use
Bitrix\Main\Config\Option
;
6
use
Bitrix\Main\ArgumentOutOfRangeException
;
7
use
Bitrix\Main\Security\OtpException
;
8
use
Bitrix\Main\Localization\Loc
;
9
10
Loc::loadMessages(__FILE__);
11
12
class
HotpAlgorithm
extends
OtpAlgorithm
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
;
41
$window
=
$this->window
;
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
}
Bitrix\Main\ArgumentOutOfRangeException
Определения
ArgumentOutOfRangeException.php:9
Bitrix\Main\Config\Option
Определения
option.php:15
Bitrix\Main\Localization\Loc
Определения
loc.php:12
Bitrix\Main\Security\Mfa\HotpAlgorithm
Определения
hotpalgorithm.php:13
Bitrix\Main\Security\Mfa\HotpAlgorithm\__construct
__construct()
Определения
hotpalgorithm.php:18
Bitrix\Main\Security\Mfa\HotpAlgorithm\$window
$window
Определения
hotpalgorithm.php:16
Bitrix\Main\Security\Mfa\HotpAlgorithm\getSyncParameters
getSyncParameters($inputA, $inputB)
Определения
hotpalgorithm.php:72
Bitrix\Main\Security\Mfa\HotpAlgorithm\SYNC_WINDOW
const SYNC_WINDOW
Определения
hotpalgorithm.php:14
Bitrix\Main\Security\Mfa\HotpAlgorithm\$type
static $type
Определения
hotpalgorithm.php:15
Bitrix\Main\Security\Mfa\HotpAlgorithm\generateUri
generateUri($label, array $opts=[])
Определения
hotpalgorithm.php:63
Bitrix\Main\Security\Mfa\HotpAlgorithm\verify
verify($input, $params=null)
Определения
hotpalgorithm.php:30
Bitrix\Main\Security\Mfa\OtpAlgorithm
Определения
otpalgorithm.php:10
Bitrix\Main\Security\Mfa\OtpAlgorithm\isStringsEqual
isStringsEqual($expected, $actual)
Определения
otpalgorithm.php:170
Bitrix\Main\Security\Mfa\OtpAlgorithm\generateOTP
generateOTP($counter)
Определения
otpalgorithm.php:125
Bitrix\Main\Security\OtpException
Определения
otpexception.php:6
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
Bitrix\Main\Security\Mfa
Определения
hotpalgorithm.php:3
$counter
$counter
Определения
options.php:5
$i
$i
Определения
factura.php:643
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
main
lib
security
mfa
hotpalgorithm.php
Создано системой
1.14.0