mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced rand_value util function with openssl::RandomValue.
This commit is contained in:
parent
c90258664d
commit
d4bbbdb65c
29 changed files with 106 additions and 54 deletions
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_sending.h"
|
#include "api/api_sending.h"
|
||||||
|
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
|
@ -76,7 +77,7 @@ void SendExistingMedia(
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
session->data().nextLocalMessageId());
|
session->data().nextLocalMessageId());
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
|
|
||||||
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
||||||
auto clientFlags = NewMessageClientFlags();
|
auto clientFlags = NewMessageClientFlags();
|
||||||
|
@ -249,7 +250,7 @@ bool SendDice(Api::MessageToSend &message) {
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
session->data().nextLocalMessageId());
|
session->data().nextLocalMessageId());
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
|
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
||||||
|
|
|
@ -4025,7 +4025,7 @@ void ApiWrap::forwardMessages(
|
||||||
ids.reserve(count);
|
ids.reserve(count);
|
||||||
randomIds.reserve(count);
|
randomIds.reserve(count);
|
||||||
for (const auto item : items) {
|
for (const auto item : items) {
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
if (genClientSideMessage) {
|
if (genClientSideMessage) {
|
||||||
if (const auto message = item->toHistoryMessage()) {
|
if (const auto message = item->toHistoryMessage()) {
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
|
@ -4348,7 +4348,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
auto newId = FullMsgId(
|
auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
auto randomId = rand_value<uint64>();
|
auto randomId = openssl::RandomValue<uint64>();
|
||||||
|
|
||||||
TextUtilities::Trim(sending);
|
TextUtilities::Trim(sending);
|
||||||
|
|
||||||
|
@ -4481,7 +4481,7 @@ void ApiWrap::sendBotStart(not_null<UserData*> bot, PeerData *chat) {
|
||||||
sendMessage(std::move(message));
|
sendMessage(std::move(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
request(MTPmessages_StartBot(
|
request(MTPmessages_StartBot(
|
||||||
bot->inputUser,
|
bot->inputUser,
|
||||||
chat ? chat->input : MTP_inputPeerEmpty(),
|
chat ? chat->input : MTP_inputPeerEmpty(),
|
||||||
|
@ -4507,7 +4507,7 @@ void ApiWrap::sendInlineResult(
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peerToChannel(peer->id),
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
|
|
||||||
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
||||||
auto clientFlags = NewMessageClientFlags();
|
auto clientFlags = NewMessageClientFlags();
|
||||||
|
@ -4659,7 +4659,7 @@ void ApiWrap::sendMedia(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
const MTPInputMedia &media,
|
const MTPInputMedia &media,
|
||||||
Api::SendOptions options) {
|
Api::SendOptions options) {
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
_session->data().registerMessageRandomId(randomId, item->fullId());
|
_session->data().registerMessageRandomId(randomId, item->fullId());
|
||||||
|
|
||||||
sendMediaWithRandomId(item, media, options, randomId);
|
sendMediaWithRandomId(item, media, options, randomId);
|
||||||
|
@ -4727,7 +4727,7 @@ void ApiWrap::sendAlbumWithUploaded(
|
||||||
const MessageGroupId &groupId,
|
const MessageGroupId &groupId,
|
||||||
const MTPInputMedia &media) {
|
const MTPInputMedia &media) {
|
||||||
const auto localId = item->fullId();
|
const auto localId = item->fullId();
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
_session->data().registerMessageRandomId(randomId, localId);
|
_session->data().registerMessageRandomId(randomId, localId);
|
||||||
|
|
||||||
const auto albumIt = _sendingAlbums.find(groupId.raw());
|
const auto albumIt = _sendingAlbums.find(groupId.raw());
|
||||||
|
@ -5275,7 +5275,7 @@ void ApiWrap::createPoll(
|
||||||
MTP_int(replyTo),
|
MTP_int(replyTo),
|
||||||
PollDataToInputMedia(&data),
|
PollDataToInputMedia(&data),
|
||||||
MTP_string(),
|
MTP_string(),
|
||||||
MTP_long(rand_value<uint64>()),
|
MTP_long(openssl::RandomValue<uint64>()),
|
||||||
MTPReplyMarkup(),
|
MTPReplyMarkup(),
|
||||||
MTPVector<MTPMessageEntity>(),
|
MTPVector<MTPMessageEntity>(),
|
||||||
MTP_int(action.options.scheduled)
|
MTP_int(action.options.scheduled)
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "base/flat_set.h"
|
#include "base/flat_set.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "boxes/confirm_phone_box.h" // ExtractPhonePrefix.
|
#include "boxes/confirm_phone_box.h" // ExtractPhonePrefix.
|
||||||
#include "boxes/photo_crop_box.h"
|
#include "boxes/photo_crop_box.h"
|
||||||
|
@ -382,7 +383,7 @@ void AddContactBox::save() {
|
||||||
lastName = QString();
|
lastName = QString();
|
||||||
}
|
}
|
||||||
_sentName = firstName;
|
_sentName = firstName;
|
||||||
_contactId = rand_value<uint64>();
|
_contactId = openssl::RandomValue<uint64>();
|
||||||
_addRequest = _session->api().request(MTPcontacts_ImportContacts(
|
_addRequest = _session->api().request(MTPcontacts_ImportContacts(
|
||||||
MTP_vector<MTPInputContact>(
|
MTP_vector<MTPInputContact>(
|
||||||
1,
|
1,
|
||||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unique_qptr.h"
|
#include "base/unique_qptr.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
@ -885,7 +886,7 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
|
||||||
object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
|
|
||||||
const auto id = rand_value<uint64>();
|
const auto id = openssl::RandomValue<uint64>();
|
||||||
const auto error = lifetime().make_state<Errors>(Error::Question);
|
const auto error = lifetime().make_state<Errors>(Error::Question);
|
||||||
|
|
||||||
auto result = object_ptr<Ui::VerticalLayout>(this);
|
auto result = object_ptr<Ui::VerticalLayout>(this);
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
|
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
|
@ -35,7 +36,7 @@ void ShareBotGame(not_null<UserData*> bot, not_null<PeerData*> chat) {
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
const auto requestType = Data::Histories::RequestType::Send;
|
const auto requestType = Data::Histories::RequestType::Send;
|
||||||
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
|
histories.sendRequest(history, requestType, [=](Fn<void()> finish) {
|
||||||
const auto randomId = rand_value<uint64>();
|
const auto randomId = openssl::RandomValue<uint64>();
|
||||||
const auto api = &chat->session().api();
|
const auto api = &chat->session().api();
|
||||||
history->sendRequestId = api->request(MTPmessages_SendMedia(
|
history->sendRequestId = api->request(MTPmessages_SendMedia(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
|
|
|
@ -232,7 +232,7 @@ void Call::startOutgoing() {
|
||||||
_api.request(MTPphone_RequestCall(
|
_api.request(MTPphone_RequestCall(
|
||||||
MTP_flags(flags),
|
MTP_flags(flags),
|
||||||
_user->inputUser,
|
_user->inputUser,
|
||||||
MTP_int(rand_value<int32>()),
|
MTP_int(openssl::RandomValue<int32>()),
|
||||||
MTP_bytes(_gaHash),
|
MTP_bytes(_gaHash),
|
||||||
MTP_phoneCallProtocol(
|
MTP_phoneCallProtocol(
|
||||||
MTP_flags(MTPDphoneCallProtocol::Flag::f_udp_p2p
|
MTP_flags(MTPDphoneCallProtocol::Flag::f_udp_p2p
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_group_call.h"
|
#include "data/data_group_call.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "base/global_shortcuts.h"
|
#include "base/global_shortcuts.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "webrtc/webrtc_media_devices.h"
|
#include "webrtc/webrtc_media_devices.h"
|
||||||
#include "webrtc/webrtc_create_adm.h"
|
#include "webrtc/webrtc_create_adm.h"
|
||||||
|
|
||||||
|
@ -201,7 +202,7 @@ void GroupCall::playConnectingSoundOnce() {
|
||||||
void GroupCall::start() {
|
void GroupCall::start() {
|
||||||
_createRequestId = _api.request(MTPphone_CreateGroupCall(
|
_createRequestId = _api.request(MTPphone_CreateGroupCall(
|
||||||
_peer->input,
|
_peer->input,
|
||||||
MTP_int(rand_value<int32>())
|
MTP_int(openssl::RandomValue<int32>())
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
_acceptFields = true;
|
_acceptFields = true;
|
||||||
_peer->session().api().applyUpdates(result);
|
_peer->session().api().applyUpdates(result);
|
||||||
|
|
|
@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
|
@ -636,7 +637,7 @@ void FieldAutocomplete::showAnimated() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_cache.isNull()) {
|
if (_cache.isNull()) {
|
||||||
_stickersSeed = rand_value<uint64>();
|
_stickersSeed = openssl::RandomValue<uint64>();
|
||||||
_scroll->show();
|
_scroll->show();
|
||||||
_cache = Ui::GrabWidget(this);
|
_cache = Ui::GrabWidget(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,12 +117,6 @@ inline std::array<char, 32> hashMd5Hex(const void *data, int size) {
|
||||||
|
|
||||||
// good random (using openssl implementation)
|
// good random (using openssl implementation)
|
||||||
void memset_rand(void *data, uint32 len);
|
void memset_rand(void *data, uint32 len);
|
||||||
template <typename T>
|
|
||||||
T rand_value() {
|
|
||||||
T result;
|
|
||||||
memset_rand(&result, sizeof(result));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString translitRusEng(const QString &rus);
|
QString translitRusEng(const QString &rus);
|
||||||
QString rusKeyboardLayoutSwitch(const QString &from);
|
QString rusKeyboardLayoutSwitch(const QString &from);
|
||||||
|
|
|
@ -59,6 +59,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "facades.h" // Notify::switchInlineBotButtonReceived
|
#include "facades.h" // Notify::switchInlineBotButtonReceived
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "styles/style_boxes.h" // st::backgroundSize
|
#include "styles/style_boxes.h" // st::backgroundSize
|
||||||
|
@ -2427,7 +2428,7 @@ PhotoData *Session::photoFromWeb(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return photo(
|
return photo(
|
||||||
rand_value<PhotoId>(),
|
openssl::RandomValue<PhotoId>(),
|
||||||
uint64(0),
|
uint64(0),
|
||||||
QByteArray(),
|
QByteArray(),
|
||||||
base::unixtime::now(),
|
base::unixtime::now(),
|
||||||
|
@ -2692,7 +2693,7 @@ DocumentData *Session::documentFromWeb(
|
||||||
const ImageLocation &thumbnailLocation,
|
const ImageLocation &thumbnailLocation,
|
||||||
const ImageLocation &videoThumbnailLocation) {
|
const ImageLocation &videoThumbnailLocation) {
|
||||||
const auto result = document(
|
const auto result = document(
|
||||||
rand_value<DocumentId>(),
|
openssl::RandomValue<DocumentId>(),
|
||||||
uint64(0),
|
uint64(0),
|
||||||
QByteArray(),
|
QByteArray(),
|
||||||
base::unixtime::now(),
|
base::unixtime::now(),
|
||||||
|
@ -2714,7 +2715,7 @@ DocumentData *Session::documentFromWeb(
|
||||||
const ImageLocation &thumbnailLocation,
|
const ImageLocation &thumbnailLocation,
|
||||||
const ImageLocation &videoThumbnailLocation) {
|
const ImageLocation &videoThumbnailLocation) {
|
||||||
const auto result = document(
|
const auto result = document(
|
||||||
rand_value<DocumentId>(),
|
openssl::RandomValue<DocumentId>(),
|
||||||
uint64(0),
|
uint64(0),
|
||||||
QByteArray(),
|
QByteArray(),
|
||||||
base::unixtime::now(),
|
base::unixtime::now(),
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/image/image_location_factory.h"
|
#include "ui/image/image_location_factory.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
|
||||||
|
@ -313,7 +314,7 @@ bool Stickers::applyArchivedResultFake() {
|
||||||
const auto raw = set.get();
|
const auto raw = set.get();
|
||||||
if ((raw->flags & MTPDstickerSet::Flag::f_installed_date)
|
if ((raw->flags & MTPDstickerSet::Flag::f_installed_date)
|
||||||
&& !(raw->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
&& !(raw->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||||
if (rand_value<uint32>() % 128 < 64) {
|
if (openssl::RandomValue<uint32>() % 128 < 64) {
|
||||||
const auto data = MTP_stickerSet(
|
const auto data = MTP_stickerSet(
|
||||||
MTP_flags(raw->flags | MTPDstickerSet::Flag::f_archived),
|
MTP_flags(raw->flags | MTPDstickerSet::Flag::f_archived),
|
||||||
MTP_int(raw->installDate),
|
MTP_int(raw->installDate),
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "history/history_message.h"
|
#include "history/history_message.h"
|
||||||
|
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -291,7 +292,7 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
||||||
auto generateRandom = [&] {
|
auto generateRandom = [&] {
|
||||||
auto result = QVector<MTPlong>(data->msgIds.size());
|
auto result = QVector<MTPlong>(data->msgIds.size());
|
||||||
for (auto &value : result) {
|
for (auto &value : result) {
|
||||||
value = rand_value<MTPlong>();
|
value = openssl::RandomValue<MTPlong>();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "api/api_send_progress.h"
|
#include "api/api_send_progress.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
@ -99,7 +100,7 @@ enum class FilterType {
|
||||||
[[nodiscard]] not_null<DocumentData*> DummyDocument(
|
[[nodiscard]] not_null<DocumentData*> DummyDocument(
|
||||||
not_null<Data::Session*> owner) {
|
not_null<Data::Session*> owner) {
|
||||||
return owner->document(
|
return owner->document(
|
||||||
rand_value<DocumentId>(),
|
openssl::RandomValue<DocumentId>(),
|
||||||
uint64(0),
|
uint64(0),
|
||||||
QByteArray(),
|
QByteArray(),
|
||||||
base::unixtime::now(),
|
base::unixtime::now(),
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "inline_bots/inline_bot_result.h"
|
#include "inline_bots/inline_bot_result.h"
|
||||||
|
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -417,7 +418,7 @@ void Result::createGame(not_null<Main::Session*> session) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto gameId = rand_value<GameId>();
|
const auto gameId = openssl::RandomValue<GameId>();
|
||||||
_game = session->data().game(
|
_game = session->data().game(
|
||||||
gameId,
|
gameId,
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -51,6 +51,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_domain.h" // Domain::activeSessionValue.
|
#include "main/main_domain.h" // Domain::activeSessionValue.
|
||||||
|
@ -2688,7 +2689,7 @@ void OverlayWidget::initThemePreview() {
|
||||||
|
|
||||||
const auto weakSession = base::make_weak(&_document->session());
|
const auto weakSession = base::make_weak(&_document->session());
|
||||||
const auto path = _document->location().name();
|
const auto path = _document->location().name();
|
||||||
const auto id = _themePreviewId = rand_value<uint64>();
|
const auto id = _themePreviewId = openssl::RandomValue<uint64>();
|
||||||
const auto weak = Ui::MakeWeak(this);
|
const auto weak = Ui::MakeWeak(this);
|
||||||
crl::async([=, data = std::move(current)]() mutable {
|
crl::async([=, data = std::move(current)]() mutable {
|
||||||
auto preview = GeneratePreview(
|
auto preview = GeneratePreview(
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "mtproto/config_loader.h"
|
#include "mtproto/config_loader.h"
|
||||||
|
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "mtproto/special_config_request.h"
|
#include "mtproto/special_config_request.h"
|
||||||
#include "mtproto/facade.h"
|
#include "mtproto/facade.h"
|
||||||
#include "mtproto/mtproto_dc_options.h"
|
#include "mtproto/mtproto_dc_options.h"
|
||||||
|
@ -174,7 +175,8 @@ void ConfigLoader::sendSpecialRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto weak = base::make_weak(this);
|
const auto weak = base::make_weak(this);
|
||||||
const auto index = rand_value<uint32>() % _specialEndpoints.size();
|
const auto index = openssl::RandomValue<uint32>()
|
||||||
|
% _specialEndpoints.size();
|
||||||
const auto endpoint = _specialEndpoints.begin() + index;
|
const auto endpoint = _specialEndpoints.begin() + index;
|
||||||
_specialEnumCurrent = specialToRealDcId(endpoint->dcId);
|
_specialEnumCurrent = specialToRealDcId(endpoint->dcId);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "mtproto/connection_http.h"
|
#include "mtproto/connection_http.h"
|
||||||
|
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "base/qthelp_url.h"
|
#include "base/qthelp_url.h"
|
||||||
|
|
||||||
namespace MTP {
|
namespace MTP {
|
||||||
|
@ -20,7 +21,7 @@ constexpr auto kFullConnectionTimeout = crl::time(8000);
|
||||||
|
|
||||||
HttpConnection::HttpConnection(QThread *thread, const ProxyData &proxy)
|
HttpConnection::HttpConnection(QThread *thread, const ProxyData &proxy)
|
||||||
: AbstractConnection(thread, proxy)
|
: AbstractConnection(thread, proxy)
|
||||||
, _checkNonce(rand_value<MTPint128>()) {
|
, _checkNonce(openssl::RandomValue<MTPint128>()) {
|
||||||
_manager.moveToThread(thread);
|
_manager.moveToThread(thread);
|
||||||
_manager.setProxy(ToNetworkProxy(proxy));
|
_manager.setProxy(ToNetworkProxy(proxy));
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,11 +192,11 @@ bytes::span TcpConnection::Protocol::VersionD::finalizePacket(
|
||||||
Expects(buffer.size() > 2 && buffer.size() < 0x1000003U);
|
Expects(buffer.size() > 2 && buffer.size() < 0x1000003U);
|
||||||
|
|
||||||
const auto intsSize = uint32(buffer.size() - 2);
|
const auto intsSize = uint32(buffer.size() - 2);
|
||||||
const auto padding = rand_value<uint32>() & 0x0F;
|
const auto padding = openssl::RandomValue<uint32>() & 0x0F;
|
||||||
const auto bytesSize = intsSize * sizeof(mtpPrime) + padding;
|
const auto bytesSize = intsSize * sizeof(mtpPrime) + padding;
|
||||||
buffer[1] = bytesSize;
|
buffer[1] = bytesSize;
|
||||||
for (auto added = 0; added < padding; added += 4) {
|
for (auto added = 0; added < padding; added += 4) {
|
||||||
buffer.push_back(rand_value<mtpPrime>());
|
buffer.push_back(openssl::RandomValue<mtpPrime>());
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes::make_span(buffer).subspan(4, 4 + bytesSize);
|
return bytes::make_span(buffer).subspan(4, 4 + bytesSize);
|
||||||
|
@ -244,7 +244,7 @@ TcpConnection::TcpConnection(
|
||||||
const ProxyData &proxy)
|
const ProxyData &proxy)
|
||||||
: AbstractConnection(thread, proxy)
|
: AbstractConnection(thread, proxy)
|
||||||
, _instance(instance)
|
, _instance(instance)
|
||||||
, _checkNonce(rand_value<MTPint128>()) {
|
, _checkNonce(openssl::RandomValue<MTPint128>()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionPointer TcpConnection::clone(const ProxyData &proxy) {
|
ConnectionPointer TcpConnection::clone(const ProxyData &proxy) {
|
||||||
|
|
|
@ -2518,7 +2518,7 @@ void SessionPrivate::authKeyChecked() {
|
||||||
resendAll();
|
resendAll();
|
||||||
} // else receive salt in bad_server_salt first, then try to send all the requests
|
} // else receive salt in bad_server_salt first, then try to send all the requests
|
||||||
|
|
||||||
_pingIdToSend = rand_value<uint64>(); // get server_salt
|
_pingIdToSend = openssl::RandomValue<uint64>(); // get server_salt
|
||||||
_sessionData->queueNeedToResumeAndSend();
|
_sessionData->queueNeedToResumeAndSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,7 @@ EncryptedData EncryptData(
|
||||||
constexpr auto kFromPadding = kMinPadding + kAlignTo - 1;
|
constexpr auto kFromPadding = kMinPadding + kAlignTo - 1;
|
||||||
constexpr auto kPaddingDelta = kMaxPadding - kFromPadding;
|
constexpr auto kPaddingDelta = kMaxPadding - kFromPadding;
|
||||||
const auto randomPadding = kFromPadding
|
const auto randomPadding = kFromPadding
|
||||||
+ (rand_value<uint32>() % kPaddingDelta);
|
+ (openssl::RandomValue<uint32>() % kPaddingDelta);
|
||||||
const auto padding = randomPadding
|
const auto padding = randomPadding
|
||||||
- ((bytes.size() + randomPadding) % kAlignTo);
|
- ((bytes.size() + randomPadding) % kAlignTo);
|
||||||
Assert(padding >= kMinPadding && padding <= kMaxPadding);
|
Assert(padding >= kMinPadding && padding <= kMaxPadding);
|
||||||
|
|
|
@ -1421,7 +1421,7 @@ void FormController::restoreScan(
|
||||||
void FormController::prepareFile(
|
void FormController::prepareFile(
|
||||||
EditFile &file,
|
EditFile &file,
|
||||||
const QByteArray &content) {
|
const QByteArray &content) {
|
||||||
const auto fileId = rand_value<uint64>();
|
const auto fileId = openssl::RandomValue<uint64>();
|
||||||
file.fields.size = content.size();
|
file.fields.size = content.size();
|
||||||
file.fields.id = fileId;
|
file.fields.id = fileId;
|
||||||
file.fields.dcId = _controller->session().mainDcId();
|
file.fields.dcId = _controller->session().mainDcId();
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "base/platform/mac/base_utilities_mac.h"
|
#include "base/platform/mac/base_utilities_mac.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -229,7 +230,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
Manager::Private::Private(Manager *manager)
|
Manager::Private::Private(Manager *manager)
|
||||||
: _managerId(rand_value<uint64>())
|
: _managerId(openssl::RandomValue<uint64>())
|
||||||
, _managerIdString(QString::number(_managerId))
|
, _managerIdString(QString::number(_managerId))
|
||||||
, _delegate([[NotificationDelegate alloc] initWithManager:manager managerId:_managerId]) {
|
, _delegate([[NotificationDelegate alloc] initWithManager:manager managerId:_managerId]) {
|
||||||
updateDelegate();
|
updateDelegate();
|
||||||
|
|
|
@ -58,7 +58,7 @@ FileKey GenerateKey(const QString &basePath) {
|
||||||
path.reserve(basePath.size() + 0x11);
|
path.reserve(basePath.size() + 0x11);
|
||||||
path += basePath;
|
path += basePath;
|
||||||
do {
|
do {
|
||||||
result = rand_value<FileKey>();
|
result = openssl::RandomValue<FileKey>();
|
||||||
path.resize(basePath.size());
|
path.resize(basePath.size());
|
||||||
path += ToFilePart(result);
|
path += ToFilePart(result);
|
||||||
} while (!result || KeyAlreadyUsed(path));
|
} while (!result || KeyAlreadyUsed(path));
|
||||||
|
|
|
@ -58,7 +58,7 @@ PreparedFileThumbnail PrepareFileThumbnail(QImage &&original) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto result = PreparedFileThumbnail();
|
auto result = PreparedFileThumbnail();
|
||||||
result.id = rand_value<uint64>();
|
result.id = openssl::RandomValue<uint64>();
|
||||||
const auto scaled = (width > kThumbnailSize || height > kThumbnailSize);
|
const auto scaled = (width > kThumbnailSize || height > kThumbnailSize);
|
||||||
const auto scaledWidth = [&] {
|
const auto scaledWidth = [&] {
|
||||||
return (width > height)
|
return (width > height)
|
||||||
|
@ -222,7 +222,7 @@ SendMediaReady PreparePeerPhoto(MTP::DcId dcId, PeerId peerId, QImage &&image) {
|
||||||
push("b", scaled(320));
|
push("b", scaled(320));
|
||||||
push("c", std::move(image), jpeg);
|
push("c", std::move(image), jpeg);
|
||||||
|
|
||||||
const auto id = rand_value<PhotoId>();
|
const auto id = openssl::RandomValue<PhotoId>();
|
||||||
const auto photo = MTP_photo(
|
const auto photo = MTP_photo(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
MTP_long(id),
|
MTP_long(id),
|
||||||
|
@ -402,7 +402,7 @@ void TaskQueueWorker::onTaskAdded() {
|
||||||
_inTaskAdded = false;
|
_inTaskAdded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendingAlbum::SendingAlbum() : groupId(rand_value<uint64>()) {
|
SendingAlbum::SendingAlbum() : groupId(openssl::RandomValue<uint64>()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendingAlbum::fillMedia(
|
void SendingAlbum::fillMedia(
|
||||||
|
@ -496,7 +496,7 @@ FileLoadTask::FileLoadTask(
|
||||||
const TextWithTags &caption,
|
const TextWithTags &caption,
|
||||||
std::shared_ptr<SendingAlbum> album,
|
std::shared_ptr<SendingAlbum> album,
|
||||||
MsgId msgIdToEdit)
|
MsgId msgIdToEdit)
|
||||||
: _id(rand_value<uint64>())
|
: _id(openssl::RandomValue<uint64>())
|
||||||
, _session(session)
|
, _session(session)
|
||||||
, _dcId(session->mainDcId())
|
, _dcId(session->mainDcId())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
|
@ -518,7 +518,7 @@ FileLoadTask::FileLoadTask(
|
||||||
const VoiceWaveform &waveform,
|
const VoiceWaveform &waveform,
|
||||||
const FileLoadTo &to,
|
const FileLoadTo &to,
|
||||||
const TextWithTags &caption)
|
const TextWithTags &caption)
|
||||||
: _id(rand_value<uint64>())
|
: _id(openssl::RandomValue<uint64>())
|
||||||
, _session(session)
|
, _session(session)
|
||||||
, _dcId(session->mainDcId())
|
, _dcId(session->mainDcId())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "base/variant.h"
|
#include "base/variant.h"
|
||||||
#include "api/api_common.h"
|
#include "api/api_common.h"
|
||||||
#include "ui/chat/attach/attach_prepare.h"
|
#include "ui/chat/attach/attach_prepare.h"
|
||||||
|
@ -22,13 +23,47 @@ enum class SendMediaType {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SendMediaPrepare {
|
struct SendMediaPrepare {
|
||||||
SendMediaPrepare(const QString &file, const PeerId &peer, SendMediaType type, MsgId replyTo) : id(rand_value<PhotoId>()), file(file), peer(peer), type(type), replyTo(replyTo) {
|
SendMediaPrepare(
|
||||||
|
const QString &file,
|
||||||
|
const PeerId &peer,
|
||||||
|
SendMediaType type,
|
||||||
|
MsgId replyTo) : id(openssl::RandomValue<PhotoId>()),
|
||||||
|
file(file),
|
||||||
|
peer(peer),
|
||||||
|
type(type),
|
||||||
|
replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
SendMediaPrepare(const QImage &img, const PeerId &peer, SendMediaType type, MsgId replyTo) : id(rand_value<PhotoId>()), img(img), peer(peer), type(type), replyTo(replyTo) {
|
SendMediaPrepare(
|
||||||
|
const QImage &img,
|
||||||
|
const PeerId &peer,
|
||||||
|
SendMediaType type,
|
||||||
|
MsgId replyTo) : id(openssl::RandomValue<PhotoId>()),
|
||||||
|
img(img),
|
||||||
|
peer(peer),
|
||||||
|
type(type),
|
||||||
|
replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
SendMediaPrepare(const QByteArray &data, const PeerId &peer, SendMediaType type, MsgId replyTo) : id(rand_value<PhotoId>()), data(data), peer(peer), type(type), replyTo(replyTo) {
|
SendMediaPrepare(
|
||||||
|
const QByteArray &data,
|
||||||
|
const PeerId &peer,
|
||||||
|
SendMediaType type,
|
||||||
|
MsgId replyTo) : id(openssl::RandomValue<PhotoId>()),
|
||||||
|
data(data),
|
||||||
|
peer(peer),
|
||||||
|
type(type),
|
||||||
|
replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
SendMediaPrepare(const QByteArray &data, int duration, const PeerId &peer, SendMediaType type, MsgId replyTo) : id(rand_value<PhotoId>()), data(data), peer(peer), type(type), duration(duration), replyTo(replyTo) {
|
SendMediaPrepare(
|
||||||
|
const QByteArray &data,
|
||||||
|
int duration,
|
||||||
|
const PeerId &peer,
|
||||||
|
SendMediaType type,
|
||||||
|
MsgId replyTo) : id(openssl::RandomValue<PhotoId>()),
|
||||||
|
data(data),
|
||||||
|
peer(peer),
|
||||||
|
type(type),
|
||||||
|
duration(duration),
|
||||||
|
replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
PhotoId id;
|
PhotoId id;
|
||||||
QString file;
|
QString file;
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/notifications_utilities.h"
|
#include "window/notifications_utilities.h"
|
||||||
|
|
||||||
#include "base/platform/base_platform_file_utilities.h"
|
#include "base/platform/base_platform_file_utilities.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
|
@ -59,7 +60,9 @@ QString CachedUserpics::get(
|
||||||
} else {
|
} else {
|
||||||
v.until = 0;
|
v.until = 0;
|
||||||
}
|
}
|
||||||
v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(rand_value<uint64>(), 16) + qsl(".png");
|
v.path = u"%1tdata/temp/%2.png"_q
|
||||||
|
.arg(cWorkingDir())
|
||||||
|
.arg(QString::number(openssl::RandomValue<uint64>(), 16));
|
||||||
if (key.first || key.second) {
|
if (key.first || key.second) {
|
||||||
if (peer->isSelf()) {
|
if (peer->isSelf()) {
|
||||||
const auto method = (_type == Type::Rounded)
|
const auto method = (_type == Type::Rounded)
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "storage/localimageloader.h"
|
#include "storage/localimageloader.h"
|
||||||
#include "storage/file_upload.h"
|
#include "storage/file_upload.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "base/parse_helper.h"
|
#include "base/parse_helper.h"
|
||||||
#include "base/zlib_help.h"
|
#include "base/zlib_help.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
@ -476,7 +477,7 @@ SendMediaReady PrepareWallPaper(MTP::DcId dcId, const QImage &image) {
|
||||||
attributes.push_back(MTP_documentAttributeImageSize(
|
attributes.push_back(MTP_documentAttributeImageSize(
|
||||||
MTP_int(image.width()),
|
MTP_int(image.width()),
|
||||||
MTP_int(image.height())));
|
MTP_int(image.height())));
|
||||||
const auto id = rand_value<DocumentId>();
|
const auto id = openssl::RandomValue<DocumentId>();
|
||||||
const auto document = MTP_document(
|
const auto document = MTP_document(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
MTP_long(id),
|
MTP_long(id),
|
||||||
|
|
|
@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/base_file_utilities.h"
|
#include "base/base_file_utilities.h"
|
||||||
#include "base/zlib_help.h"
|
#include "base/zlib_help.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
#include "base/openssl_help.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_cloud_themes.h"
|
#include "data/data_cloud_themes.h"
|
||||||
|
@ -341,7 +342,7 @@ bool CopyColorsToPalette(
|
||||||
auto result = QString();
|
auto result = QString();
|
||||||
result.reserve(kRandomSlugSize);
|
result.reserve(kRandomSlugSize);
|
||||||
for (auto i = 0; i != kRandomSlugSize; ++i) {
|
for (auto i = 0; i != kRandomSlugSize; ++i) {
|
||||||
const auto value = rand_value<uint8>() % values;
|
const auto value = openssl::RandomValue<uint8>() % values;
|
||||||
if (value < letters) {
|
if (value < letters) {
|
||||||
result.append(char('A' + value));
|
result.append(char('A' + value));
|
||||||
} else if (value < 2 * letters) {
|
} else if (value < 2 * letters) {
|
||||||
|
@ -447,7 +448,7 @@ SendMediaReady PrepareThemeMedia(
|
||||||
auto attributes = QVector<MTPDocumentAttribute>(
|
auto attributes = QVector<MTPDocumentAttribute>(
|
||||||
1,
|
1,
|
||||||
MTP_documentAttributeFilename(MTP_string(filename)));
|
MTP_documentAttributeFilename(MTP_string(filename)));
|
||||||
const auto id = rand_value<DocumentId>();
|
const auto id = openssl::RandomValue<DocumentId>();
|
||||||
const auto document = MTP_document(
|
const auto document = MTP_document(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
MTP_long(id),
|
MTP_long(id),
|
||||||
|
|
|
@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "window/themes/window_themes_generate_name.h"
|
#include "window/themes/window_themes_generate_name.h"
|
||||||
|
|
||||||
|
#include "base/openssl_help.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
namespace Theme {
|
namespace Theme {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -337,13 +339,13 @@ QString GenerateName(const QColor &accent) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
const auto random = [&](const std::vector<const char*> &values) {
|
const auto random = [&](const std::vector<const char*> &values) {
|
||||||
const auto index = rand_value<size_t>() % values.size();
|
const auto index = openssl::RandomValue<size_t>() % values.size();
|
||||||
return capitalized(values[index]);
|
return capitalized(values[index]);
|
||||||
};
|
};
|
||||||
const auto min = ranges::min_element(kColors, pred);
|
const auto min = ranges::min_element(kColors, pred);
|
||||||
Assert(min != end(kColors));
|
Assert(min != end(kColors));
|
||||||
const auto color = capitalized(min->second);
|
const auto color = capitalized(min->second);
|
||||||
return (rand_value<uint8>() % 2 == 0)
|
return (openssl::RandomValue<uint8>() % 2 == 0)
|
||||||
? random(kAdjectives) + ' ' + color
|
? random(kAdjectives) + ' ' + color
|
||||||
: color + ' ' + random(kSubjectives);
|
: color + ' ' + random(kSubjectives);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue