package core:crypto/tls
Overview
Index
Types (6)
Constants (1)
Variables (0)
This section is empty.
Procedures (6)
Procedure Groups (0)
This section is empty.
Types
Alpn_Protocols ¶
Alpn_Protocols :: enum int { None, // Invalid Http_0_9, // "http/0.9" Http_1_0, // "http/1.0" Http_1_1, // "http/1.1" Spdy_1, // "spdy/1" Spdy_2, // "spdy/2" Spdy_3, // "spdy/3" Turn, // "stun.turn" Stun, // "stun.nat-discovery" Http_2, // "h2" // Http_2_Tcp, // "h2c" (Not valid for TLS ALPN) Webrtc, // "webrtc" Confidential_Webrtc, // "c-webrtc" Ftp, // "ftp" Imap, // "imap" Pop3, // "pop3" Managesieve, // "managesieve" Coap_Tls, // "coap" Coap_Dtls, // "co" Xmpp_Client, // "xmpp-client" Xmpp_Server, // "xmpp-server" Acme_Tls_1, // "acme-tls/1" Mqtt, // "mqtt" Dot, // "dot" (DNS-over-TLS) Ntske_1, // "ntske/1" Sunrpc, // "sunrpc" Http_3, // "h3" Smb2, // "smb" Irc, // "irc" Nntp_Reading, // "nntp" Nntp_Transit, // "nnsp" Doq, // "doq" Sip, // "sip/2" Tds_8_0, // "tds/8.0" Dicom, // "dicom" Postgresql, // "postgresql" Radius_1_0, // "radius/1.0" Radius_1_1, // "radius/1.1" Npmp_Control, // "netperfmeter/control" Npmp_Data, // "netperfmeter/data" N_Pamp, // "n-pamp/2" Eoq, // "EoQ" Snif_Over_Quic, // "snifq/1" }
Error ¶
Error :: union { runtime.Allocator_Error, io.Error, net.TCP_Send_Error, net.TCP_Recv_Error, General_Error, Protocol_Error, }
Error is the common error returned from all TLS calls.
Related Procedures With Returns
General_Error ¶
General_Error :: enum int { Nonblocking_Socket, Invalid_SNI_Hostname, Failed_Key_Share_Generation, Unsupported_Client_Certificate_Requested, }
General_Error are errors related to the implementation.
Protocol_Error ¶
Protocol_Error :: enum int { None = 0, // Alerts Close_Notify, Unexpected_Message, Bad_Record_Mac, Record_Overflow, Handshake_Failure, Bad_Certificate, Unsupported_Certificate, Certificate_Revoked, Certificate_Expired, Certificate_Unknown, Illegal_Parameter, Unknown_Ca, Access_Denied, Decode_Error, Decrypt_Error, Protocol_Version, Insufficient_Security, Internal_Error, Inappropriate_Fallback, User_Canceled, Missing_Extension, Unsupported_Extension, Unrecognized_Name, Bad_Certificate_Status_Response, Unknown_Psk_Identity, Certificate_Required, General_Error, No_Application_Protocol, }
Protocol_Error is errors translated from TLS protocol layer alerts.
Socket ¶
Socket :: struct { fd: net.TCP_Socket, cipher_suite: Cipher_Suite, alpn_protocol: Alpn_Protocols, _state: Socket_State, }
Socket is a TLS socket. It MUST NOT be copied as the internal state contains thread synchronization primitives.
Related Procedures With Parameters
Constants
SNI_MAX_HOSTNAME_SIZE ¶
SNI_MAX_HOSTNAME_SIZE :: 253
Maximum length of a SNI host name based on DNS limits.
Variables
This section is empty.
Procedures
client_handshake ¶
@(require_results) client_handshake :: proc( socket: ^Socket, net_socket: net.TCP_Socket, host_name: string, trust_roots: []^x509.Certificate, alpn_protocols: []Alpn_Protocols = nil, unsafe_skip_verify: bool = false, unsafe_secret_logger: ^os.File = nil, allocator := context.allocator, ) -> Error {…}
client_handshake performs a TLS handshake given an established
TCP connection (net_socket). trust_roots is expected to be
populated with certificate authority certificates.
Debugging options (that destroy security):
- unsafe_skip_verify: Omits checking the certificate chain.
- unsafe_secret_logger: Writes the handshake key material for use with Wireshark and similar tools.
Once this function returns with a non-error result close MUST
be called to free up resources.
close ¶
close will close a Socket, and release related resources. This will also close the underlying TCP socket.
Warning: Once a Socket is successfully initialized, close MUST be called to free resources and sanitize secrets.
recv ¶
recv receives data from an established Socket into the provided buffer, returning the actual number of bytes received and an error if any.
Notes: Partial reads are to be expected, so n MUST be checked.
An error of Protocol_Error.Close_Notify indicates that the peer will
not send anymore data, however it still is possible to send data to
the peer.
send ¶
send transmits data over an established connection, and returns the number of bytes sent and an error if any.
Note: Errors should be treated as fatal, and close should be called on the connection.
socket_error ¶
socket_error returns the error status of a Socket.
to_stream ¶
to_stream wraps a handshaked Socket in a Stream.
The caller MUST call io.close or io.destroy to clean up
resources (or close the original socket).
Procedure Groups
This section is empty.
Source Files
- api.odin
- doc.odin
- tls_buffer.odin
- tls_client.odin
- tls_constants.odin
- tls_internal.odin
- tls_key_schedule.odin
- tls_params.odin
- tls_worker.odin
Generation Information
Generated with odin version dev-2026-11 (vendor "odin") Windows_amd64 @ 2026-11-13 21:04:54.431483000 +0000 UTC