2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Apply all MTP Key generation checks to calls.

Also move all OpenSSL BN_* calls to base/openssl_help header.
This commit is contained in:
John Preston
2017-04-24 15:16:38 +03:00
parent 4925af69e2
commit b267957abe
13 changed files with 446 additions and 403 deletions

View File

@@ -146,7 +146,7 @@ auto PassKey = MTP::AuthKeyPtr();
auto LocalKey = MTP::AuthKeyPtr();
void createLocalKey(const QByteArray &pass, QByteArray *salt, MTP::AuthKeyPtr *result) {
auto key = MTP::AuthKey::Data { { 0 } };
auto key = MTP::AuthKey::Data { { gsl::byte{} } };
auto iterCount = pass.size() ? LocalEncryptIterCount : LocalEncryptNoPwdIterCount; // dont slow down for no password
auto newSalt = QByteArray();
if (!salt) {
@@ -931,9 +931,8 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
case dbiKey: {
qint32 dcId;
auto key = MTP::AuthKey::Data { { 0 } };
stream >> dcId;
stream.readRawData(key.data(), key.size());
auto key = Serialize::read<MTP::AuthKey::Data>(stream);
if (!_checkStreamStatus(stream)) return false;
Messenger::Instance().setMtpKey(dcId, key);
@@ -1900,8 +1899,8 @@ ReadMapState _readMap(const QByteArray &pass) {
LOG(("App Info: could not decrypt pass-protected key from map file, maybe bad password..."));
return ReadMapPassNeeded;
}
auto key = MTP::AuthKey::Data { { 0 } };
if (keyData.stream.readRawData(key.data(), key.size()) != key.size() || !keyData.stream.atEnd()) {
auto key = Serialize::read<MTP::AuthKey::Data>(keyData.stream);
if (keyData.stream.status() != QDataStream::Ok || !keyData.stream.atEnd()) {
LOG(("App Error: could not read pass-protected key from map file"));
return ReadMapFailed;
}