Files
mautrix-telegram/pkg/gotd
Igor Artamonov ccb349f3d2
Go / Lint (old) (push) Failing after 4m40s
Go / Lint (latest) (push) Failing after 4m39s
Go / Lint (old) (pull_request) Failing after 4m41s
Go / Lint (latest) (pull_request) Failing after 4m40s
obfuscated2: only XOR bytes actually delivered on Read
Read called XORKeyStream(b, b) — XOR-ing the entire caller buffer even
when the underlying transport returned fewer bytes. AES-CTR's keystream
position is then advanced by len(b), but the peer only consumed n
bytes' worth of keystream. After a single short read the two
keystreams diverge for the lifetime of the connection, every
subsequent MTProto message decrypts to garbage, and the engine fails
with "consume message: decrypt: msg_key is invalid".

The faketls layer makes short reads routine: each Read returns at most
one TLS Application record's payload, regardless of how big the caller
buffer is. So in practice the stream desynced almost immediately on
high-traffic clients (active supergroups, post-relogin catch-up) and
intermittently on quiet ones.

Match the upstream gotd/td fix and only XOR the n bytes that came out
of the transport. Add a regression test (chunkConn delivers ciphertext
in 7-byte chunks; client reads through Obfuscated2.Read with a 128-byte
buffer; plaintext must round-trip).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 12:33:44 +03:00
..
2025-06-27 20:03:37 -07:00
2026-04-01 21:08:49 +03:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2026-02-26 18:24:51 +02:00
2025-12-03 17:11:20 +02:00
2025-06-27 20:03:37 -07:00
2026-04-01 21:08:49 +03:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2026-02-26 18:24:51 +02:00
2026-03-28 16:50:51 +02:00
2026-02-16 15:41:08 +02:00
2025-06-27 20:03:37 -07:00
2025-12-03 17:11:20 +02:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2026-04-01 21:08:49 +03:00
2025-06-27 20:03:37 -07:00
2025-07-31 14:02:14 +03:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2025-06-27 20:03:37 -07:00
2026-03-28 16:58:28 +02:00
2026-03-28 16:58:28 +02:00
2025-12-03 17:11:20 +02:00

gotd

Fork of https://github.com/gotd/td.

Everything under this directory is licensed under MIT like upstream gotd.