Hysen Labs
Open-source project
Trisia/gotlcp avatar
Trisia

gotlcp

Go语言实现的传输层密码协议(TLCP GMSSL),TLCP协议遵循 GB/T 38636-2020 Information security technology Transport Layer Cryptography Protocol (TLCP)

100 stars25 forksGoMIT
01
DEEP OPEN-SOURCE ANALYSIS

gotlcp: TLCP and DTLCP in Go

Two Chinese cryptographic transport standards, GB/T 38636-2020 for TLCP and GM/T 0128-2023 for DTLCP, both implemented in Go, each with its own set of documentation.

02
DEEP OPEN-SOURCE ANALYSIS

Two protocols, one library

gotlcp is a Go implementation of the Transport Layer Cryptography Protocol, built to the GB/T 38636-2020 standard and based on TCP transport, also known as GMSSL. Alongside it the library covers DTLCP, the datagram version, which follows GM/T 0128-2023 and runs over UDP for scenarios that cannot rely on reliable TCP transport.

03
DEEP OPEN-SOURCE ANALYSIS

DTLCP under the hood

The DTLCP feature list is specific. The server requires dual certificates, a signature certificate and an encryption certificate. Session reuse works through an LRU cache and session tickets. The handshake is a four state machine covering preparing, sending, waiting, and finished. On top of that there is exponential backoff retransmission and stateless cookie protection against denial of service.

04
DEEP OPEN-SOURCE ANALYSIS

The docs that ship with it

Documentation is split by protocol. The TLCP side links to guides on the protocol introduction, the handshake flow, cipher suites, certificate and key preparation for dual certificates, client and server config field details, and HTTPS configuration for TLCP clients and Gin or Fiber servers. The DTLCP side points to a quick start guide, a config and usage guide with security recommendations, and a design document covering the protocol stack architecture, record layer, handshake protocol, flight mechanism, retransmission state machine, and cookie based DoS protection. Together they are meant to be the reference for building TLCP and DTLCP applications.

05
DEEP OPEN-SOURCE ANALYSIS

Where the crypto comes from

The acknowledgements matter here. The SM series algorithms are implemented by the emmansun gmsm project, which optimizes algorithm efficiency through CPU instruction sets. The TLCP protocol code is trimmed from the Go 1.19 crypto tls module in the Go standard library. That gives anyone reading the repo a clear picture of where the cryptographic code originates.

07
DEEP OPEN-SOURCE ANALYSIS

Official sources

08
Community notes

Community notes