XU XUv0.16.0

#crypto/tls

import: #crypto/tls

counts: 10 functions, 13 methods, 4 types, 6 constants, 0 method sets

TLS 1.2/1.3 client subset implemented in Xu, with system-root verification by default. ECDH, RSA, AES and GHASH are variable-time on current backends.

const VERSION_TLS12

XuAPI
pub const VERSION_TLS12 = 771

Purpose

Constant VERSION_TLS12, defining protocol or algorithm parameters.

const VERSION_TLS13

XuAPI
pub const VERSION_TLS13 = 772

Purpose

Constant VERSION_TLS13, defining protocol or algorithm parameters.

const TLS_AES_128_GCM_SHA256

XuAPI
pub const TLS_AES_128_GCM_SHA256 = 4865

Purpose

Constant TLS_AES_128_GCM_SHA256, defining protocol or algorithm parameters.

const TLS_RSA_WITH_AES_128_GCM_SHA256

XuAPI
pub const TLS_RSA_WITH_AES_128_GCM_SHA256 = 156

Purpose

Constant TLS_RSA_WITH_AES_128_GCM_SHA256, defining protocol or algorithm parameters.

const TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256

XuAPI
pub const TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 49195

Purpose

Constant TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, defining protocol or algorithm parameters.

const TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

XuAPI
pub const TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 49199

Purpose

Constant TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, defining protocol or algorithm parameters.

struct Config

XuAPI
pub struct Config {
    pub server_name string
    pub insecure_skip_verify bool
    pub root_cas x509.CertPool
    pub cert_pem string
    pub key_pem string
}

Purpose

Tls Configuration parameters and options set.

Public fields

server_name string
field (string)
insecure_skip_verify bool
field (bool)
root_cas x509.CertPool
field (x509.CertPool)
cert_pem string
field (string)
key_pem string
field (string)

struct Dialer

XuAPI
pub struct Dialer {
    pub timeout_ns int
    pub config Config
}

Purpose

Structure encapsulating timeout_ns, config.

Public fields

timeout_ns int
timeout in nanoseconds
config Config
field (Config)

struct Conn

XuAPI
pub struct Conn {
    pub server_name string
    pub handshake_complete bool
    pub cipher_suite int
    pub version int
    pub negotiated_protocol string
    pub read_deadline_ns int
    pub write_deadline_ns int
}

Purpose

Structure encapsulating server_name, handshake_complete, cipher_suite, version, negotiated_protocol.

Public fields

server_name string
field (string)
handshake_complete bool
field (bool)
cipher_suite int
field (int)
version int
field (int)
negotiated_protocol string
field (string)
read_deadline_ns int
field (int)
write_deadline_ns int
field (int)

struct ConnectionState

XuAPI
pub struct ConnectionState {
    pub server_name string
    pub handshake_complete bool
    pub cipher_suite int
    pub version int
    pub negotiated_protocol string
}

Purpose

Structure encapsulating server_name, handshake_complete, cipher_suite, version, negotiated_protocol.

Public fields

server_name string
field (string)
handshake_complete bool
field (bool)
cipher_suite int
field (int)
version int
field (int)
negotiated_protocol string
field (string)

new_config

XuAPI
pub fn new_config(server_name string) Config

Purpose

Construct config.

Parameters

server_name string
server_name (string)

Returns

Config — a value of this type

($&Config) set_next_protos

XuAPI
pub fn (c $&Config) set_next_protos(protocols []string)

Purpose

Set the ordered ALPN protocols offered by this client. Empty omits ALPN each nonempty name must contain at most 255 bytes, checked at handshake.

Parameters

c $&Config
The Config instance used by this call (exclusive borrow).
protocols []string
protocols ([]string)

Returns

This call does not return a value.

new_dialer

XuAPI
pub fn new_dialer() Dialer

Purpose

Construct dialer.

Parameters

No arguments are required.

Returns

Dialer — a value of this type

closed_conn

XuAPI
pub fn closed_conn() Conn

Purpose

Inert transport placeholder for owners that do not currently use TLS. It owns no descriptor and cannot perform a handshake without a transport.

Parameters

No arguments are required.

Returns

Conn — a value of this type

client

XuAPI
pub fn client(c net.Conn, config &Config) Conn

Purpose

Execute client. Throws on failure; handle the error or propagate it to the caller.

Parameters

c net.Conn
byte or character code (net.Conn)
config &Config
config (read-only borrow; caller keeps the original; type &Config)

Returns

Conn — a value of this type

client_pipe

XuAPI
pub fn client_pipe(c net.PipeConn, config &Config) Conn

Purpose

Client pipe. Throws on failure; handle the error or propagate it to the caller.

Parameters

c net.PipeConn
byte or character code (net.PipeConn)
config &Config
config (read-only borrow; caller keeps the original; type &Config)

Returns

Conn — a value of this type

server

XuAPI
pub fn server(c net.Conn, config &Config) Conn

Purpose

Execute server. Throws on failure; handle the error or propagate it to the caller.

Parameters

c net.Conn
byte or character code (net.Conn)
config &Config
config (read-only borrow; caller keeps the original; type &Config)

Returns

Conn — a value of this type

server_pipe

XuAPI
pub fn server_pipe(c net.PipeConn, config &Config) Conn

Purpose

Server pipe. Throws on failure; handle the error or propagate it to the caller.

Parameters

c net.PipeConn
byte or character code (net.PipeConn)
config &Config
config (read-only borrow; caller keeps the original; type &Config)

Returns

Conn — a value of this type

client_fd

XuAPI
pub fn client_fd(fd int, server_name string) Conn

Purpose

Client fd. Throws on failure; handle the error or propagate it to the caller.

Parameters

fd int
file descriptor (int)
server_name string
server_name (string)

Returns

Conn — a value of this type

dial

XuAPI
pub fn dial(network string, addr string, config &Config) Conn

Purpose

Dial a connection. Throws on failure; handle the error or propagate it to the caller.

Parameters

network string
network (string)
addr string
address (string)
config &Config
config (read-only borrow; caller keeps the original; type &Config)

Returns

Conn — a value of this type

dial_context

XuAPI
pub fn dial_context(ctx &context.Context, network string, addr string, config &Config) Conn

Purpose

Dial context. Throws on failure; handle the error or propagate it to the caller.

Parameters

ctx &context.Context
ctx (read-only borrow; caller keeps the original; type &context.Context)
network string
network (string)
addr string
address (string)
config &Config
config (read-only borrow; caller keeps the original; type &Config)

Returns

Conn — a value of this type

(Dialer) dial

XuAPI
pub fn (d Dialer) dial(network string, addr string) Conn

Purpose

Operation on Dialer: dial a connection. Throws on failure; handle the error or propagate it to the caller.

Parameters

d Dialer
The Dialer instance used by this call (value receiver).
network string
network (string)
addr string
address (string)

Returns

Conn — a value of this type

(Dialer) dial_context

XuAPI
pub fn (d Dialer) dial_context(ctx &context.Context, network string, addr string) Conn

Purpose

Operation on Dialer: dial context. Throws on failure; handle the error or propagate it to the caller.

Parameters

d Dialer
The Dialer instance used by this call (value receiver).
ctx &context.Context
ctx (read-only borrow; caller keeps the original; type &context.Context)
network string
network (string)
addr string
address (string)

Returns

Conn — a value of this type

(&Conn) handshake

XuAPI
pub fn (c &Conn) handshake() int

Purpose

Execute handshake on &Conn. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Conn
The Conn instance used by this call (borrow).

Returns

int — a value of this type

(Conn) connection_state

XuAPI
pub fn (c Conn) connection_state() ConnectionState

Purpose

Operation on Conn: connection state.

Parameters

c Conn
The Conn instance used by this call (value receiver).

Returns

ConnectionState — a value of this type

($&Conn) set_deadline

XuAPI
pub fn (c $&Conn) set_deadline(t_ns int) int

Purpose

Operation on $&Conn: set deadline. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).
t_ns int
t_ns (int)

Returns

int — a value of this type

($&Conn) set_read_deadline

XuAPI
pub fn (c $&Conn) set_read_deadline(t_ns int) int

Purpose

Operation on $&Conn: set read deadline. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).
t_ns int
t_ns (int)

Returns

int — a value of this type

($&Conn) set_write_deadline

XuAPI
pub fn (c $&Conn) set_write_deadline(t_ns int) int

Purpose

Operation on $&Conn: set write deadline. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).
t_ns int
t_ns (int)

Returns

int — a value of this type

($&Conn) read

XuAPI
pub fn (c $&Conn) read(max int) string

Purpose

Operation on $&Conn: read up to max bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).
max int
maximum (int)

Returns

string — result string

($&Conn) write

XuAPI
pub fn (c $&Conn) write(data &string) int

Purpose

Operation on $&Conn: write data and return the byte count. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

($&Conn) close

XuAPI
pub fn (c $&Conn) close() int

Purpose

Operation on $&Conn: close the resource. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).

Returns

int — a value of this type

($&Conn) read_result

XuAPI
pub fn (c $&Conn) read_result(n int) io.ReadResult

Purpose

Operation on $&Conn: read result.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

io.ReadResult — a value of this type

($&Conn) write_result

XuAPI
pub fn (c $&Conn) write_result(data string) io.WriteResult

Purpose

Operation on $&Conn: write result.

Parameters

c $&Conn
The Conn instance used by this call (exclusive borrow).
data string
data (string)

Returns

io.WriteResult — a value of this type