mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 08:14:14 +03:00
Raise AssertionError instead TypeNotFoundError on authenticator
This commit is contained in:
parent
a4fa652d35
commit
b3f04fd359
|
@ -9,7 +9,7 @@ from ..tl.types import (
|
||||||
from .. import helpers as utils
|
from .. import helpers as utils
|
||||||
from ..crypto import AES, AuthKey, Factorization
|
from ..crypto import AES, AuthKey, Factorization
|
||||||
from ..crypto import rsa
|
from ..crypto import rsa
|
||||||
from ..errors import SecurityError, TypeNotFoundError
|
from ..errors import SecurityError
|
||||||
from ..extensions import BinaryReader
|
from ..extensions import BinaryReader
|
||||||
from ..network import MtProtoPlainSender
|
from ..network import MtProtoPlainSender
|
||||||
from ..tl.functions import (
|
from ..tl.functions import (
|
||||||
|
@ -25,7 +25,7 @@ def do_authentication(connection, retries=5):
|
||||||
while retries:
|
while retries:
|
||||||
try:
|
try:
|
||||||
return _do_authentication(connection)
|
return _do_authentication(connection)
|
||||||
except (SecurityError, TypeNotFoundError, NotImplementedError) as e:
|
except (SecurityError, AssertionError, NotImplementedError) as e:
|
||||||
last_error = e
|
last_error = e
|
||||||
retries -= 1
|
retries -= 1
|
||||||
raise last_error
|
raise last_error
|
||||||
|
@ -48,7 +48,7 @@ def _do_authentication(connection):
|
||||||
|
|
||||||
res_pq = req_pq_request.result
|
res_pq = req_pq_request.result
|
||||||
if not isinstance(res_pq, ResPQ):
|
if not isinstance(res_pq, ResPQ):
|
||||||
raise TypeNotFoundError(type(res_pq).constructor_id)
|
raise AssertionError(res_pq)
|
||||||
|
|
||||||
if res_pq.nonce != req_pq_request.nonce:
|
if res_pq.nonce != req_pq_request.nonce:
|
||||||
raise SecurityError('Invalid nonce from server')
|
raise SecurityError('Invalid nonce from server')
|
||||||
|
@ -101,7 +101,7 @@ def _do_authentication(connection):
|
||||||
raise SecurityError('Server DH params fail: TODO')
|
raise SecurityError('Server DH params fail: TODO')
|
||||||
|
|
||||||
if not isinstance(server_dh_params, ServerDHParamsOk):
|
if not isinstance(server_dh_params, ServerDHParamsOk):
|
||||||
raise TypeNotFoundError(type(server_dh_params).constructor_id)
|
raise AssertionError(server_dh_params)
|
||||||
|
|
||||||
if server_dh_params.nonce != res_pq.nonce:
|
if server_dh_params.nonce != res_pq.nonce:
|
||||||
raise SecurityError('Invalid nonce from server')
|
raise SecurityError('Invalid nonce from server')
|
||||||
|
@ -121,7 +121,7 @@ def _do_authentication(connection):
|
||||||
reader.read(20) # hash sum
|
reader.read(20) # hash sum
|
||||||
server_dh_inner = reader.tgread_object()
|
server_dh_inner = reader.tgread_object()
|
||||||
if not isinstance(server_dh_inner, ServerDHInnerData):
|
if not isinstance(server_dh_inner, ServerDHInnerData):
|
||||||
raise TypeNotFoundError(server_dh_inner)
|
raise AssertionError(server_dh_inner)
|
||||||
|
|
||||||
if server_dh_inner.nonce != res_pq.nonce:
|
if server_dh_inner.nonce != res_pq.nonce:
|
||||||
print(server_dh_inner.nonce, res_pq.nonce)
|
print(server_dh_inner.nonce, res_pq.nonce)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user