Files
mautrix-telegram/pkg/gotd
Igor Artamonov 64bf6bfe90
Go / Lint (old) (push) Failing after 4m39s
Go / Lint (latest) (push) Failing after 4m39s
Go / Lint (old) (pull_request) Failing after 4m39s
Go / Lint (latest) (pull_request) Failing after 4m42s
faketls: emit GREASE bytes and a real padding extension
The ClientHello builder used a closure G(n) that was supposed to insert
two random GREASE bytes (RFC 8701, 0x?A?A pattern) at known positions
but expanded the buffer by zero. Every grease slot was therefore
omitted, and the trailing padding extension was written as a bare ext
id 0x0015 followed by raw zeros — its length field was never set.

Concretely, the old output looked structurally invalid to mtg's faketls
validator: the cipher list was off by two, supported_groups declared a
list_length larger than its body, and what should have been the padding
extension parsed as a stream of empty server_name extensions. mtg
responded with a fatal TLS Alert (description 50, decode_error) and
shut the connection.

Fix:
- generate seven distinct GREASE bytes per ClientHello, with the
  tdlib constraint grease[3] != grease[4]
- thread an io.Reader through writeClientHello so generation is
  deterministic in tests and keyed off the FakeTLS rand source in prod
- replace the trailing zero-pad with a proper padding extension whose
  length field is computed so the ClientHello is exactly 517 bytes

Add a regression test (structure_test.go) that feeds the result to
crypto/tls.Server: it must not return decode_error / malformed /
syntax errors. The previous output failed this; the new output passes.

The TestTLS golden vector is regenerated for the new layout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 11:15:03 +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.