mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 22:51:11 +01:00
Fix update2fa
This commit is contained in:
parent
5298b9cc76
commit
33b3d9fd67
@ -1575,7 +1575,7 @@ abstract class InternalDoc
|
|||||||
*
|
*
|
||||||
* The params array can contain password, new_password, email and hint params.
|
* The params array can contain password, new_password, email and hint params.
|
||||||
*
|
*
|
||||||
* @param array $params The params
|
* @param array{password?: string, new_password?: string, email?: string, hint?: string} $params The params
|
||||||
*/
|
*/
|
||||||
public function update2fa(array $params): void
|
public function update2fa(array $params): void
|
||||||
{
|
{
|
||||||
|
@ -53,17 +53,17 @@ final class PasswordCalculator
|
|||||||
* The algorithm to use for calculatuing the hash of the current password (a PasswordKdfAlgo object).
|
* The algorithm to use for calculatuing the hash of the current password (a PasswordKdfAlgo object).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private array $current_algo;
|
private ?array $current_algo;
|
||||||
/**
|
/**
|
||||||
* SRP b parameter.
|
* SRP b parameter.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private BigInteger $srp_B;
|
private ?BigInteger $srp_B;
|
||||||
/**
|
/**
|
||||||
* SRP b parameter for hashing.
|
* SRP b parameter for hashing.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private string $srp_BForHash;
|
private ?string $srp_BForHash;
|
||||||
/**
|
/**
|
||||||
* SRP ID.
|
* SRP ID.
|
||||||
*/
|
*/
|
||||||
@ -90,9 +90,6 @@ final class PasswordCalculator
|
|||||||
if ($object['_'] !== 'account.password') {
|
if ($object['_'] !== 'account.password') {
|
||||||
throw new Exception('Wrong constructor');
|
throw new Exception('Wrong constructor');
|
||||||
}
|
}
|
||||||
if ($object['has_secure_values']) {
|
|
||||||
//throw new Exception('Cannot parse secure values');
|
|
||||||
}
|
|
||||||
if ($object['has_password']) {
|
if ($object['has_password']) {
|
||||||
switch ($object['current_algo']['_']) {
|
switch ($object['current_algo']['_']) {
|
||||||
case 'passwordKdfAlgoUnknown':
|
case 'passwordKdfAlgoUnknown':
|
||||||
@ -135,8 +132,10 @@ final class PasswordCalculator
|
|||||||
Crypt::checkPG($object['new_algo']['p'], $object['new_algo']['g']);
|
Crypt::checkPG($object['new_algo']['p'], $object['new_algo']['g']);
|
||||||
$object['new_algo']['gForHash'] = \str_pad($object['new_algo']['g']->toBytes(), 256, \chr(0), STR_PAD_LEFT);
|
$object['new_algo']['gForHash'] = \str_pad($object['new_algo']['g']->toBytes(), 256, \chr(0), STR_PAD_LEFT);
|
||||||
$object['new_algo']['pForHash'] = \str_pad($object['new_algo']['p']->toBytes(), 256, \chr(0), STR_PAD_LEFT);
|
$object['new_algo']['pForHash'] = \str_pad($object['new_algo']['p']->toBytes(), 256, \chr(0), STR_PAD_LEFT);
|
||||||
$object['current_algo']['salt1'] = (string) $object['current_algo']['salt1'];
|
if (isset($object['current_algo'])) {
|
||||||
$object['current_algo']['salt2'] = (string) $object['current_algo']['salt2'];
|
$object['current_algo']['salt1'] = (string) $object['current_algo']['salt1'];
|
||||||
|
$object['current_algo']['salt2'] = (string) $object['current_algo']['salt2'];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception("Unknown KDF algo {$object['new_algo']['_']}");
|
throw new Exception("Unknown KDF algo {$object['new_algo']['_']}");
|
||||||
@ -237,8 +236,8 @@ final class PasswordCalculator
|
|||||||
$return = ['password' => $oldPassword, 'new_settings' => ['_' => 'account.passwordInputSettings', 'new_algo' => ['_' => 'passwordKdfAlgoUnknown'], 'new_password_hash' => '', 'hint' => '']];
|
$return = ['password' => $oldPassword, 'new_settings' => ['_' => 'account.passwordInputSettings', 'new_algo' => ['_' => 'passwordKdfAlgoUnknown'], 'new_password_hash' => '', 'hint' => '']];
|
||||||
$new_settings =& $return['new_settings'];
|
$new_settings =& $return['new_settings'];
|
||||||
if (isset($params['new_password']) && ((string) $params['new_password']) !== '') {
|
if (isset($params['new_password']) && ((string) $params['new_password']) !== '') {
|
||||||
$client_salt = $this->createSalt($this->new_algo['salt1']);
|
$client_salt = $this->createSalt((string) $this->new_algo['salt1']);
|
||||||
$server_salt = $this->new_algo['salt2'];
|
$server_salt = (string) $this->new_algo['salt2'];
|
||||||
$g = $this->new_algo['g'];
|
$g = $this->new_algo['g'];
|
||||||
$p = $this->new_algo['p'];
|
$p = $this->new_algo['p'];
|
||||||
$pForHash = $this->new_algo['pForHash'];
|
$pForHash = $this->new_algo['pForHash'];
|
||||||
|
@ -249,7 +249,7 @@ trait Login
|
|||||||
*
|
*
|
||||||
* The params array can contain password, new_password, email and hint params.
|
* The params array can contain password, new_password, email and hint params.
|
||||||
*
|
*
|
||||||
* @param array $params The params
|
* @param array{password?: string, new_password?: string, email?: string, hint?: string} $params The params
|
||||||
*/
|
*/
|
||||||
public function update2fa(array $params): void
|
public function update2fa(array $params): void
|
||||||
{
|
{
|
||||||
|
@ -8,11 +8,6 @@ if (defined('MADELINE_POLYFILLED')) {
|
|||||||
|
|
||||||
define('MADELINE_POLYFILLED', true);
|
define('MADELINE_POLYFILLED', true);
|
||||||
|
|
||||||
use Amp\Http\Client\Cookie\InMemoryCookieJar;
|
|
||||||
use Amp\Http\Client\Cookie\LocalCookieJar;
|
|
||||||
use Amp\Socket\EncryptableSocket;
|
|
||||||
use Amp\Socket\ResourceSocket;
|
|
||||||
|
|
||||||
$ampFilePolyfill = 'namespace Amp\\File {';
|
$ampFilePolyfill = 'namespace Amp\\File {';
|
||||||
foreach ([
|
foreach ([
|
||||||
'open' => 'openFile',
|
'open' => 'openFile',
|
||||||
@ -41,4 +36,3 @@ foreach ([
|
|||||||
$ampFilePolyfill .= '}';
|
$ampFilePolyfill .= '}';
|
||||||
eval($ampFilePolyfill);
|
eval($ampFilePolyfill);
|
||||||
unset($ampFilePolyfill);
|
unset($ampFilePolyfill);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user