diff --git a/td/mtproto/PacketInfo.h b/td/mtproto/PacketInfo.h index c49df9fb5..2d8c9d388 100644 --- a/td/mtproto/PacketInfo.h +++ b/td/mtproto/PacketInfo.h @@ -7,7 +7,6 @@ #pragma once #include "td/utils/common.h" -#include "td/utils/UInt.h" namespace td { namespace mtproto { @@ -16,7 +15,6 @@ struct PacketInfo { enum { Common, EndToEnd } type = Common; uint64 auth_key_id{0}; uint32 message_ack{0}; - UInt128 message_key; uint64 salt{0}; uint64 session_id{0}; diff --git a/td/mtproto/Transport.cpp b/td/mtproto/Transport.cpp index ef0440ef6..f949d2263 100644 --- a/td/mtproto/Transport.cpp +++ b/td/mtproto/Transport.cpp @@ -362,19 +362,13 @@ void Transport::write_crypto_impl(int X, const Storer &storer, const AuthKey &au Random::secure_bytes(pad.ubegin(), pad.size()); MutableSlice to_encrypt = MutableSlice(header->encrypt_begin(), pad.uend()); - if (info->version == 1) { - std::tie(info->message_ack, info->message_key) = calc_message_ack_and_key(*header, data_size); - } else { - std::tie(info->message_ack, info->message_key) = calc_message_key2(auth_key, X, to_encrypt); - } - - header->message_key = info->message_key; - UInt256 aes_key; UInt256 aes_iv; if (info->version == 1) { + std::tie(info->message_ack, header->message_key) = calc_message_ack_and_key(*header, data_size); KDF(auth_key.key(), header->message_key, X, &aes_key, &aes_iv); } else { + std::tie(info->message_ack, header->message_key) = calc_message_key2(auth_key, X, to_encrypt); KDF2(auth_key.key(), header->message_key, X, &aes_key, &aes_iv); }