Fix message packing

master
Lonami Exo 2018-07-25 17:39:27 +02:00
parent d9928e79dd
commit a08966d8ec
1 changed files with 3 additions and 5 deletions

View File

@ -38,8 +38,8 @@ public class MTProtoState {
private Pair<byte[], byte[]> calcKey(final byte[] msgKey, final boolean client) {
final int x = client ? 0 : 8;
final byte[] sha256a = Utils.sha256digest(msgKey, ByteBuffer.wrap(authKey.key, x, 36).array());
final byte[] sha256b = Utils.sha256digest(ByteBuffer.wrap(authKey.key, x + 40, 36).array(), msgKey);
final byte[] sha256a = Utils.sha256digest(msgKey, Arrays.copyOfRange(authKey.key, x, x + 36));
final byte[] sha256b = Utils.sha256digest(Arrays.copyOfRange(authKey.key, x + 40, x + 76), msgKey);
final BinaryWriter writer = new BinaryWriter(32);
writer.writeRaw(sha256a, 0, 8);
@ -61,9 +61,7 @@ public class MTProtoState {
writer.write(message);
int padding = writer.size() % 16;
if (padding != 0) {
writer.writeRaw(Utils.randomBytes(16 - padding));
}
writer.writeRaw(Utils.randomBytes(32 - padding));
final byte[] paddedData = writer.toBytes();
writer.clear();