Remove redundant call to account.getPasswordSettings.

GitOrigin-RevId: 8b4ee1f2ef3206cbae4d8231c723d57b286a80c0
This commit is contained in:
levlam 2018-08-12 22:25:04 +03:00
parent 6a94c83f66
commit 4404267ec4
2 changed files with 11 additions and 0 deletions

View File

@ -332,6 +332,12 @@ Result<secure_storage::Secret> PasswordManager::decrypt_secure_secret(
}
void PasswordManager::do_get_full_state(string password, PasswordState state, Promise<PasswordFullState> promise) {
if (!state.has_password) {
PasswordFullState result;
result.state = std::move(state);
return promise.set_value(std::move(result));
}
auto hash = get_input_check_password(password, state);
send_with_promise(
G()->net_query_creator().create(create_storer(telegram_api::account_getPasswordSettings(std::move(hash)))),
@ -339,6 +345,7 @@ void PasswordManager::do_get_full_state(string password, PasswordState state, Pr
[promise = std::move(promise), state = std::move(state), password](Result<NetQueryPtr> r_query) mutable {
promise.set_result([&]() -> Result<PasswordFullState> {
TRY_RESULT(result, fetch_result<telegram_api::account_getPasswordSettings>(std::move(r_query)));
LOG(INFO) << "Receive password settings: " << to_string(result);
PasswordPrivateState private_state;
private_state.email = std::move(result->email_);
@ -580,6 +587,7 @@ void PasswordManager::do_get_state(Promise<PasswordState> promise) {
return promise.set_error(r_result.move_as_error());
}
auto password = r_result.move_as_ok();
LOG(INFO) << "Receive password info: " << to_string(password);
Random::add_seed(password->secure_random_.as_slice());
PasswordState state;

View File

@ -30,10 +30,12 @@ static AesCbcState calc_aes_cbc_state_hash(Slice hash) {
as_slice(key).copy_from(hash.substr(0, 32));
UInt128 iv;
as_slice(iv).copy_from(hash.substr(32, 16));
LOG(INFO) << "End AES CBC state calculation";
return AesCbcState{key, iv};
}
AesCbcState calc_aes_cbc_state_pbkdf2(Slice secret, Slice salt) {
LOG(INFO) << "Begin AES CBC state calculation";
UInt<512> hash;
auto hash_slice = as_slice(hash);
pbkdf2_sha512(secret, salt, 100000, hash_slice);
@ -41,6 +43,7 @@ AesCbcState calc_aes_cbc_state_pbkdf2(Slice secret, Slice salt) {
}
AesCbcState calc_aes_cbc_state_sha512(Slice seed) {
LOG(INFO) << "Begin AES CBC state calculation";
UInt<512> hash;
auto hash_slice = as_slice(hash);
sha512(seed, hash_slice);