From 58e5feaf7ccef268739b856e2d022945de269ac7 Mon Sep 17 00:00:00 2001 From: Aaron Gallagher Date: Mon, 24 Dec 2018 12:10:32 -0800 Subject: [PATCH] Extend new_algo.salt1 to fix edit_2fa Apparently the salt1 you send to the server requires an additional 32 bytes of random data. It's easy to miss this requirement from reading the tdesktop source, because this extension is done in a function called `ValidateNewCloudPasswordAlgo`. https://github.com/telegramdesktop/tdesktop/blob/2e5a0e056cdb40d61d487c6062bffe1a835f6ddd/Telegram/SourceFiles/core/core_cloud_password.cpp#L210-L211 --- telethon/client/auth.py | 1 + 1 file changed, 1 insertion(+) diff --git a/telethon/client/auth.py b/telethon/client/auth.py index 94062d03..2e5c60bc 100644 --- a/telethon/client/auth.py +++ b/telethon/client/auth.py @@ -467,6 +467,7 @@ class AuthMethods(MessageParseMethods, UserMethods): return False pwd = await self(functions.account.GetPasswordRequest()) + pwd.new_algo.salt1 += os.urandom(32) assert isinstance(pwd, types.account.Password) if not pwd.has_password and current_password: current_password = None