GUI compatibility: Detach interactive Config calls from MainThread

This commit is contained in:
Wizou 2021-12-05 11:47:52 +01:00
parent 409cf25619
commit 934ee9bae4
3 changed files with 11 additions and 10 deletions

View file

@ -362,7 +362,7 @@ j4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB
return output;
}
internal static InputCheckPasswordSRP Check2FA(Account_Password accountPassword, Func<string> getPassword)
internal static async Task<InputCheckPasswordSRP> Check2FA(Account_Password accountPassword, Func<Task<string>> getPassword)
{
if (accountPassword.current_algo is not PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow algo)
throw new ApplicationException("2FA authentication uses an unsupported algo: " + accountPassword.current_algo?.GetType().Name);
@ -376,7 +376,7 @@ j4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB
System.Threading.Thread.Sleep(100);
Helpers.Log(3, $"This account has enabled 2FA. A password is needed. {accountPassword.hint}");
var passwordBytes = Encoding.UTF8.GetBytes(getPassword());
var passwordBytes = Encoding.UTF8.GetBytes(await getPassword());
using var sha256 = SHA256.Create();
sha256.TransformBlock(algo.salt1, 0, algo.salt1.Length, null, 0);
@ -436,7 +436,7 @@ j4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB
sha256.TransformFinalBlock(k_a, 0, 32);
var m1 = sha256.Hash;
validTask.Wait();
await validTask;
return new InputCheckPasswordSRP { A = g_a_256, M1 = m1, srp_id = accountPassword.srp_id };
}