code wiki / (root) / tls13.nx

tls13.nx

buildroot/runtime/tls13.nx

6834 B188 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic tls13
docsdependenciesstructsconstsfunctions

about

tls13.nx -- TLS 1.3 (RFC 8446) record-layer constants + framing. This is the skeleton of the TLS 1.3 implementation, not the full state machine. Ships: - ContentType + HandshakeType enum constants - ExtensionType enum constants - Version constants - Record-layer struct definitions + byte-level parse / emit What it does NOT ship (follow-up): - ClientHello / ServerHello / EncryptedExtensions / Finished state-machine driver - HKDF-based key-schedule ordering - 0-RTT / session resumption - Full extension parsing (SNI, ALPN, signature_algorithms, etc.) Pair with AEAD (chacha20-poly1305 shipped; AES-256-GCM pending) + HMAC + HKDF + X25519 + Ed25519 + X.509 primitives that are all already in-tree. References: RFC 8446 (TLS 1.3) -- primary specification RFC 9001 (QUIC TLS) -- alternate framing; outside this file's scope RFC 9578 (X25519Kyber768Draft00) -- PQ hybrid; tls13_extension constants prepared for it

dependencies 1 imports · 0 importers

syscalls.nx tls13.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main tls_write_record_header tls_read_record_header

structs

none

consts

35const TLS_LEGACY_VERSION: i64 = 0x0303 // TLS 1.2 wire value
36const TLS_13_VERSION: i64 = 0x0304 // "real" TLS 1.3 advertised via extension
40const CT_INVALID: i64 = 0
41const CT_CHANGE_CIPHER_SPEC: i64 = 20
42const CT_ALERT: i64 = 21
43const CT_HANDSHAKE: i64 = 22
44const CT_APPLICATION_DATA: i64 = 23
45const CT_HEARTBEAT: i64 = 24
49const HT_CLIENT_HELLO: i64 = 1
50const HT_SERVER_HELLO: i64 = 2
51const HT_NEW_SESSION_TICKET: i64 = 4
52const HT_END_OF_EARLY_DATA: i64 = 5
53const HT_ENCRYPTED_EXTENSIONS: i64 = 8
54const HT_CERTIFICATE: i64 = 11
55const HT_CERTIFICATE_REQUEST: i64 = 13
56const HT_CERTIFICATE_VERIFY: i64 = 15
57const HT_FINISHED: i64 = 20
58const HT_KEY_UPDATE: i64 = 24
59const HT_MESSAGE_HASH: i64 = 254
63const EXT_SERVER_NAME: i64 = 0
64const EXT_MAX_FRAGMENT_LENGTH: i64 = 1
65const EXT_STATUS_REQUEST: i64 = 5
66const EXT_SUPPORTED_GROUPS: i64 = 10
67const EXT_SIGNATURE_ALGORITHMS: i64 = 13
68const EXT_USE_SRTP: i64 = 14
69const EXT_APPLICATION_LAYER_PROTOCOL: i64 = 16 // ALPN
70const EXT_SIGNED_CERTIFICATE_TIMESTAMP: i64 = 18
71const EXT_PADDING: i64 = 21
72const EXT_PRE_SHARED_KEY: i64 = 41
73const EXT_EARLY_DATA: i64 = 42
74const EXT_SUPPORTED_VERSIONS: i64 = 43
75const EXT_COOKIE: i64 = 44
76const EXT_PSK_KEY_EXCHANGE_MODES: i64 = 45
77const EXT_CERTIFICATE_AUTHORITIES: i64 = 47
78const EXT_OID_FILTERS: i64 = 48
79const EXT_POST_HANDSHAKE_AUTH: i64 = 49
80const EXT_SIGNATURE_ALGORITHMS_CERT: i64 = 50
81const EXT_KEY_SHARE: i64 = 51
88const NG_SECP256R1: i64 = 23
89const NG_SECP384R1: i64 = 24
90const NG_SECP521R1: i64 = 25
91const NG_X25519: i64 = 29
92const NG_X448: i64 = 30
94const NG_X25519_KYBER768_DRAFT00: i64 = 0x6399
98const SS_RSA_PKCS1_SHA256: i64 = 0x0401
99const SS_RSA_PKCS1_SHA384: i64 = 0x0501
100const SS_RSA_PKCS1_SHA512: i64 = 0x0601
101const SS_ECDSA_SECP256R1_SHA256: i64 = 0x0403
102const SS_ECDSA_SECP384R1_SHA384: i64 = 0x0503
103const SS_ED25519: i64 = 0x0807
104const SS_ED448: i64 = 0x0808
105const SS_RSA_PSS_RSAE_SHA256: i64 = 0x0804
106const SS_RSA_PSS_RSAE_SHA384: i64 = 0x0805
107const SS_RSA_PSS_RSAE_SHA512: i64 = 0x0806
118const TLS_MAX_RECORD: i64 = 16384 // 2^14 bytes TLSPlaintext cap

functions

123func tls_read_record_header(buf: *u8, buf_len: i64,
called by 1: main
137func tls_write_record_header(buf: *u8,
called by 1: main
149func tls_read_u24_be(buf: *u8, off: i64) -> i64 {
153func tls_write_u24_be(buf: *u8, off: i64, v: i64) -> i64 {
162func tls_read_u16_be(buf: *u8, off: i64) -> i64 {
166func tls_write_u16_be(buf: *u8, off: i64, v: i64) -> i64 {
174func main() -> i64 {