std.x.tls.handshake [x] std.x.tls.handshake.concat pub fn concat(a: List[byte], b: List[byte]) -> List[byte] — a followed by b — the byte-sequence concatenation the callers and the transcript build on. std.x.tls.handshake.hs_client_hello pub fn hs_client_hello() -> int — HandshakeType client_hello (1). std.x.tls.handshake.hs_server_hello pub fn hs_server_hello() -> int — HandshakeType server_hello (2). std.x.tls.handshake.hs_encrypted_extensions pub fn hs_encrypted_extensions() -> int — HandshakeType encrypted_extensions (8). std.x.tls.handshake.hs_certificate pub fn hs_certificate() -> int — HandshakeType certificate (11). std.x.tls.handshake.hs_certificate_verify pub fn hs_certificate_verify() -> int — HandshakeType certificate_verify (15). std.x.tls.handshake.hs_finished pub fn hs_finished() -> int — HandshakeType finished (20). std.x.tls.handshake.handshake pub fn handshake(msg_type: int, body: List[byte]) -> List[byte] — Frame a handshake message: msg_type byte, a big-endian uint24 length of body, then body (§4). std.x.tls.handshake.ext pub fn ext(extension_type: int, data: List[byte]) -> List[byte] — One Extension: extension_type (uint16) then a uint16-length-prefixed extension_data. std.x.tls.handshake.ext_server_name pub fn ext_server_name(host: str) -> List[byte] — server_name (0), a single host_name (§3 of RFC 6066): a ServerNameList of one ServerName { NameType host_name(0), HostName opaque<1..2^16-1> }. std.x.tls.handshake.ext_server_name_ack pub fn ext_server_name_ack() -> List[byte] — server_name (0) as the server's empty acknowledgement in EncryptedExtensions (§4.2.10): the extension_data is empty. std.x.tls.handshake.ext_renegotiation_info_empty pub fn ext_renegotiation_info_empty() -> List[byte] — renegotiation_info (0xff01) with an empty renegotiated_connection (RFC 5746): a single zero length byte. std.x.tls.handshake.ext_supported_groups pub fn ext_supported_groups(groups: List[int]) -> List[byte] — supported_groups (0x000a, §4.2.7): a NamedGroupList, each group a big-endian uint16, uint16-length-prefixed. std.x.tls.handshake.ext_session_ticket_empty pub fn ext_session_ticket_empty() -> List[byte] — session_ticket (0x0023, RFC 5077) with an empty ticket. std.x.tls.handshake.ext_key_share_client_x25519 pub fn ext_key_share_client_x25519(pubkey: List[byte]) -> List[byte] — key_share (0x0033, §4.2.8) for a ClientHello: a KeyShareClientHello = a uint16-length-prefixed vector of one KeyShareEntry { NamedGroup x25519(0x001d), key_exchange opaque<1..2^16-1> = the 32 point bytes }. std.x.tls.handshake.ext_key_share_server_x25519 pub fn ext_key_share_server_x25519(pubkey: List[byte]) -> List[byte] — key_share (0x0033, §4.2.8) for a ServerHello: a KeyShareServerHello = a single KeyShareEntry (NO client_shares vector wrapper). std.x.tls.handshake.ext_supported_versions_client pub fn ext_supported_versions_client() -> List[byte] — supported_versions (0x002b, §4.2.1) for a ClientHello: a uint8-length-prefixed list of ProtocolVersions, here the single TLS 1.3 (0x0304). std.x.tls.handshake.ext_supported_versions_server pub fn ext_supported_versions_server() -> List[byte] — supported_versions (0x002b, §4.2.1) for a ServerHello: the single selected_version (0x0304), NOT length-prefixed. std.x.tls.handshake.ext_signature_algorithms pub fn ext_signature_algorithms(schemes: List[int]) -> List[byte] — signature_algorithms (0x000d, §4.2.3): a SignatureSchemeList, each scheme a big-endian uint16, uint16-length-prefixed. std.x.tls.handshake.ext_psk_key_exchange_modes pub fn ext_psk_key_exchange_modes(modes: List[byte]) -> List[byte] — psk_key_exchange_modes (0x002d, §4.2.9): a uint8-length-prefixed list of PskKeyExchangeMode bytes (0x01 = psk_dhe_ke). std.x.tls.handshake.ext_record_size_limit pub fn ext_record_size_limit(limit: int) -> List[byte] — record_size_limit (0x001c, RFC 8449): a single big-endian uint16. std.x.tls.handshake.client_hello pub fn client_hello( random: List[byte], session_id: List[byte], cipher_suites: List[byte], extensions: List[byte], ) -> List[byte] — ClientHello (§4.1.2): legacy_version 0x0303, a 32-byte random, an opaque legacy_session_id<0..32>, a CipherSuite vector<2..2^16-2> (raw suite bytes, uint16-length-prefixed here), the single null legacy_compression_method, and the extensions vector<8..2^16-1>. std.x.tls.handshake.server_hello pub fn server_hello( random: List[byte], session_id: List[byte], cipher_suite: int, extensions: List[byte], ) -> List[byte] — ServerHello (§4.1.3): legacy_version 0x0303, a 32-byte random, the echoed opaque legacy_session_id_echo<0..32>, the selected cipher_suite (uint16), the null legacy_compression_method, and the extensions vector<6..2^16-1>. std.x.tls.handshake.encrypted_extensions pub fn encrypted_extensions(extensions: List[byte]) -> List[byte] — EncryptedExtensions (§4.3.1): the extensions vector<0..2^16-1>. std.x.tls.handshake.certificate pub fn certificate(context: List[byte], cert_der: List[byte]) -> List[byte] — Certificate (§4.4.2) — OPAQUE cert bytes here (no ASN.1 parse): a certificate_request_context<0..255> then a certificate_list<0..2^24-1> of one CertificateEntry { cert_data opaque<1..2^24-1> = the DER blob, extensions Extension<0..2^16-1> = empty }. std.x.tls.handshake.certificate_verify pub fn certificate_verify(algorithm: int, signature: List[byte]) -> List[byte] — CertificateVerify (§4.4.3): the SignatureScheme algorithm (uint16) and the opaque signature<0..2^16-1>. std.x.tls.handshake.certificate_verify_content pub fn certificate_verify_content(context: str, transcript_hash: List[byte]) -> List[byte] — The octet string a CertificateVerify signature is computed over (§4.4.3): 64 0x20 (space) octets, then the ASCII context string ("TLS 1.3, server CertificateVerify" or "...client..."), then a single 0x00 separator, then the Transcript-Hash up to but not including the CertificateVerify. std.x.tls.handshake.finished_message pub fn finished_message(verify_data: List[byte]) -> List[byte] — Finished (§4.4.4): the verify_data (an HMAC-SHA256 output, 32 bytes) framed as a handshake message. std.x.tls.handshake.transcript_new pub fn transcript_new() -> List[byte] — A fresh, empty transcript. std.x.tls.handshake.transcript_add pub fn transcript_add(mut acc: List[byte], msg: List[byte]) — Append one handshake message's exact wire bytes (header included) to the running transcript, in order (§4.4.1). std.x.tls.handshake.transcript_hash pub fn transcript_hash(acc: List[byte]) -> List[byte] — The Transcript-Hash: SHA-256 of the accumulated handshake messages (§4.4.1). std.x.tls.handshake.ecdhe_shared pub fn ecdhe_shared(private: List[byte], peer_public: List[byte]) -> List[byte] ! {zero} — The (EC)DHE shared secret for the handshake extract (§7.4.2): the X25519 of your private scalar against the peer's peer_public point (sc18). std.x.tls.handshake.early_secret pub fn early_secret() -> List[byte] — The early secret (§7.1): HKDF-Extract(0, 0) for the no-PSK handshake — salt and IKM both 32 zero bytes. std.x.tls.handshake.handshake_secret pub fn handshake_secret(early: List[byte], dh: List[byte]) -> List[byte] — The handshake secret (§7.1): HKDF-Extract with salt Derive-Secret(early, "derived", "") and IKM the (EC)DHE shared secret. std.x.tls.handshake.master_secret pub fn master_secret(hs: List[byte]) -> List[byte] — The master secret (§7.1): HKDF-Extract with salt Derive-Secret(handshake, "derived", "") and IKM 32 zero bytes. std.x.tls.handshake.client_handshake_traffic pub fn client_handshake_traffic(hs: List[byte], th_ch_sh: List[byte]) -> List[byte] — client_handshake_traffic_secret (§7.1): Derive-Secret(handshake, "c hs traffic", Transcript-Hash(ClientHello..ServerHello)). std.x.tls.handshake.server_handshake_traffic pub fn server_handshake_traffic(hs: List[byte], th_ch_sh: List[byte]) -> List[byte] — server_handshake_traffic_secret (§7.1): Derive-Secret(handshake, "s hs traffic", Transcript-Hash(ClientHello..ServerHello)). std.x.tls.handshake.client_application_traffic pub fn client_application_traffic(master: List[byte], th_sfin: List[byte]) -> List[byte] — client_application_traffic_secret_0 (§7.1): Derive-Secret(master, "c ap traffic", Transcript-Hash(ClientHello..server Finished)). std.x.tls.handshake.server_application_traffic pub fn server_application_traffic(master: List[byte], th_sfin: List[byte]) -> List[byte] — server_application_traffic_secret_0 (§7.1): Derive-Secret(master, "s ap traffic", Transcript-Hash(ClientHello..server Finished)). std.x.tls.handshake.exporter_master pub fn exporter_master(master: List[byte], th_sfin: List[byte]) -> List[byte] — exporter_master_secret (§7.1): Derive-Secret(master, "exp master", Transcript-Hash(ClientHello..server Finished)). std.x.tls.handshake.resumption_master pub fn resumption_master(master: List[byte], th_cfin: List[byte]) -> List[byte] — resumption_master_secret (§7.1): Derive-Secret(master, "res master", Transcript-Hash(ClientHello..client Finished)). std.x.tls.handshake.finished_verify_data pub fn finished_verify_data(base_secret: List[byte], transcript_hash: List[byte]) -> List[byte] — The Finished verify_data (§4.4.4): HMAC-SHA256(finished_key, Transcript-Hash), where finished_key = HKDF-Expand-Label(base_secret, "finished", "", 32) (sc20's record.finished_key). std.x.tls.handshake.finished_for pub fn finished_for(base_secret: List[byte], transcript_hash: List[byte]) -> List[byte] — The complete Finished handshake message for a sender: frame the verify_data computed from base_secret over transcript_hash. std.x.tls.handshake.ct_eq pub fn ct_eq(a: List[byte], b: List[byte]) -> bool — Constant-time-shaped byte equality (§4.4.4's compare, sc17's tag discipline): fold every position's difference into an accumulator and test ONCE at the end — no early exit on the first mismatch, no secret-dependent branch. std.x.tls.handshake.verify_finished pub fn verify_finished( base_secret: List[byte], transcript_hash: List[byte], received: List[byte], ) -> bool — Verify a peer's Finished (§4.4.4): recompute the expected verify_data from base_secret (the peer's handshake traffic secret) over transcript_hash and compare it constant-time-shaped to received. std.x.tls.handshake.accept_finished pub fn accept_finished( base_secret: List[byte], transcript_hash: List[byte], received: List[byte], ) -> int ! {decrypt_error} — Accept a peer's Finished or raise the handshake-abort alert (§4.4.4 + §6.2): return 1 when the constant-time compare holds, otherwise the decrypt_error row — a wrong Finished aborts the handshake with the named alert and NO key material exposed (the recompute reveals nothing the peer did not already send; nothing derived-onward is returned on the miss). std.x.tls.handshake.role_client pub fn role_client() -> int — The client role (0) — sends ClientHello, then receives the server's flight (ServerHello, EncryptedExtensions, Certificate, CertificateVerify, Finished), then sends its own Finished. std.x.tls.handshake.role_server pub fn role_server() -> int — The server role (1) — receives ClientHello, sends its flight, then receives the client's Finished. std.x.tls.handshake.hs_expected pub fn hs_expected(role: int, stage: int) -> int — The handshake message type the given role legally receives at stage, or -1 when the flow expects no further message (the flight is complete). std.x.tls.handshake.hs_step pub fn hs_step(role: int, stage: int, msg_type: int) -> int ! {unexpected_message} — Drive one received message through the state machine (§4.1): if msg_type is the message the flow expects next for role at stage, return the next stage; otherwise raise unexpected_message (§6.2) — the reordered/dropped/illegal-message reject, by name. std.x.tls.handshake.hs_client_flight_complete pub fn hs_client_flight_complete(stage: int) -> bool — Whether the client has received the full server flight (its own Finished is next to SEND): stage 5 after ServerHello..server Finished. std.x.tls.handshake.hs_server_complete pub fn hs_server_complete(stage: int) -> bool — Whether the server has received the client's Finished — the handshake is complete: stage 2 after ClientHello and client Finished. std.x.tls.handshake.HandshakeResult pub struct HandshakeResult { cipher_suite: int, client_handshake_secret: List[byte], server_handshake_secret: List[byte], client_application_secret: List[byte], server_application_secret: List[byte], exporter_master_secret: List[byte], resumption_master_secret: List[byte], } — The negotiated result of a completed handshake (the ws05 seam): the selected cipher_suite, the client/server handshake and application traffic secrets, and the exporter/resumption master secrets. std.x.tls.handshake.handshake_result pub fn handshake_result( cipher_suite: int, client_handshake_secret: List[byte], server_handshake_secret: List[byte], client_application_secret: List[byte], server_application_secret: List[byte], exporter_master_secret: List[byte], resumption_master_secret: List[byte], ) -> HandshakeResult — Build the frozen ws05 result (the constructor — a module-qualified struct literal handshake.HandshakeResult { } does not parse across the module boundary, E0201, so the seam is a function exactly as sha2.new256 is). std.x.tls.handshake.to_hex pub fn to_hex(b: List[byte]) -> str — Lowercase hex of a byte list.