2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Make cloud password methods raise NotImplementedError. See #178

The protocol changed (SRP) and they are currently not re-implemented.
This commit is contained in:
Dan 2018-12-23 01:05:44 +01:00
parent 7ee89c94cb
commit 0371f4ce8b
3 changed files with 59 additions and 64 deletions

View File

@ -16,10 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import os
from hashlib import sha256
from pyrogram.api import functions, types
from ...ext import BaseClient from ...ext import BaseClient
@ -46,23 +42,25 @@ class ChangeCloudPassword(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error. :class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
""" """
r = self.send(functions.account.GetPassword()) raise NotImplementedError
if isinstance(r, types.account.Password): # r = self.send(functions.account.GetPassword())
current_password_hash = sha256(r.current_salt + current_password.encode() + r.current_salt).digest() #
# if isinstance(r, types.account.Password):
new_salt = r.new_salt + os.urandom(8) # current_password_hash = sha256(r.current_salt + current_password.encode() + r.current_salt).digest()
new_password_hash = sha256(new_salt + new_password.encode() + new_salt).digest() #
# new_salt = r.new_salt + os.urandom(8)
return self.send( # new_password_hash = sha256(new_salt + new_password.encode() + new_salt).digest()
functions.account.UpdatePasswordSettings( #
current_password_hash=current_password_hash, # return self.send(
new_settings=types.account.PasswordInputSettings( # functions.account.UpdatePasswordSettings(
new_salt=new_salt, # current_password_hash=current_password_hash,
new_password_hash=new_password_hash, # new_settings=types.account.PasswordInputSettings(
hint=new_hint # new_salt=new_salt,
) # new_password_hash=new_password_hash,
) # hint=new_hint
) # )
else: # )
return False # )
# else:
# return False

View File

@ -16,10 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import os
from hashlib import sha256
from pyrogram.api import functions, types
from ...ext import BaseClient from ...ext import BaseClient
@ -48,22 +44,24 @@ class EnableCloudPassword(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error. :class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
""" """
r = self.send(functions.account.GetPassword()) raise NotImplementedError
if isinstance(r, types.account.NoPassword): # r = self.send(functions.account.GetPassword())
salt = r.new_salt + os.urandom(8) #
password_hash = sha256(salt + password.encode() + salt).digest() # if isinstance(r, types.account.NoPassword):
# salt = r.new_salt + os.urandom(8)
return self.send( # password_hash = sha256(salt + password.encode() + salt).digest()
functions.account.UpdatePasswordSettings( #
current_password_hash=salt, # return self.send(
new_settings=types.account.PasswordInputSettings( # functions.account.UpdatePasswordSettings(
new_salt=salt, # current_password_hash=salt,
new_password_hash=password_hash, # new_settings=types.account.PasswordInputSettings(
hint=hint, # new_salt=salt,
email=email # new_password_hash=password_hash,
) # hint=hint,
) # email=email
) # )
else: # )
return False # )
# else:
# return False

View File

@ -16,9 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from hashlib import sha256
from pyrogram.api import functions, types
from ...ext import BaseClient from ...ext import BaseClient
@ -37,20 +34,22 @@ class RemoveCloudPassword(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error. :class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
""" """
r = self.send(functions.account.GetPassword()) raise NotImplementedError
if isinstance(r, types.account.Password): # r = self.send(functions.account.GetPassword())
password_hash = sha256(r.current_salt + password.encode() + r.current_salt).digest() #
# if isinstance(r, types.account.Password):
return self.send( # password_hash = sha256(r.current_salt + password.encode() + r.current_salt).digest()
functions.account.UpdatePasswordSettings( #
current_password_hash=password_hash, # return self.send(
new_settings=types.account.PasswordInputSettings( # functions.account.UpdatePasswordSettings(
new_salt=b"", # current_password_hash=password_hash,
new_password_hash=b"", # new_settings=types.account.PasswordInputSettings(
hint="" # new_salt=b"",
) # new_password_hash=b"",
) # hint=""
) # )
else: # )
return False # )
# else:
# return False