XU XUv0.8.8
中文

API

#crypto/tls

import: #crypto/tls

counts: 10 fns, 12 methods, 4 types, 5 consts, 0 ifaces

TLS client subset. Handshake uses the host library (SecureTransport on macOS; Linux/Windows currently throw).

const version_tls12

XuAPI
pub const version_tls12 = 771

Purpose

`crypto/tls` Client subset. Handshake is a software TLS 1.2/1.3 record layer: RSA and ECDHE-RSA AES-128-GCM for TLS 1.2, plus TLS_AES_128_GCM_SHA256 with P-256 key shares for TLS 1.3. No platform TLS. RootCAs defaults to the system pool when empty. Config.insecure_skip_verify explicitly disables certificate chain, time, and DNS verification. server is for in-process tests (pipe or tcp). XU-CT-CLASS: variable-time ECDH, RSA, AES and GHASH are variable-time on current XU backends. Value `771`.

Parameters

none

const version_tls13

XuAPI
pub const version_tls13 = 772

Purpose

Public constant `version_tls13`. Value `772`.

Parameters

none

const tls_aes_128_gcm_sha256

XuAPI
pub const tls_aes_128_gcm_sha256 = 4865

Purpose

Public constant `tls_aes_128_gcm_sha256`. Value `4865`.

Parameters

none

const tls_rsa_with_aes_128_gcm_sha256

XuAPI
pub const tls_rsa_with_aes_128_gcm_sha256 = 156

Purpose

Public constant `tls_rsa_with_aes_128_gcm_sha256`. Value `156`.

Parameters

none

const tls_ecdhe_rsa_with_aes_128_gcm_sha256

XuAPI
pub const tls_ecdhe_rsa_with_aes_128_gcm_sha256 = 49199

Purpose

Public constant `tls_ecdhe_rsa_with_aes_128_gcm_sha256`. Value `49199`.

Parameters

none

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

Public struct `Config`.

Parameters

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

Public struct `Dialer`.

Parameters

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 read_deadline_ns int
    pub write_deadline_ns int
}

Purpose

Public struct `Conn`.

Parameters

server_name string
field (string)
handshake_complete bool
field (bool)
cipher_suite int
field (int)
version int
field (int)
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
}

Purpose

Public struct `ConnectionState`.

Parameters

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

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

new_dialer

XuAPI
pub fn new_dialer() Dialer

Purpose

Construct dialer.

Parameters

none

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

none

Returns

Conn — a value of this type

client

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

Purpose

client; returns Conn. Throws on failure.

Parameters

c net.Conn
byte or character code (net.Conn)
config &Config
config (borrowed; caller keeps it; 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.

Parameters

c net.PipeConn
byte or character code (net.PipeConn)
config &Config
config (borrowed; caller keeps it; type &Config)

Returns

Conn — a value of this type

server

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

Purpose

server; returns Conn. Throws on failure.

Parameters

c net.Conn
byte or character code (net.Conn)
config &Config
config (borrowed; caller keeps it; 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.

Parameters

c net.PipeConn
byte or character code (net.PipeConn)
config &Config
config (borrowed; caller keeps it; 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.

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.

Parameters

network string
network (string)
addr string
address (string)
config &Config
config (borrowed; caller keeps it; 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.

Parameters

ctx &context.Context
ctx (borrowed; caller keeps it; type &context.Context)
network string
network (string)
addr string
address (string)
config &Config
config (borrowed; caller keeps it; type &Config)

Returns

Conn — a value of this type

(Dialer) dial

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

Purpose

Method on `Dialer`: dial a connection. Throws on failure.

Parameters

d Dialer
receiver Dialer (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

Method on `Dialer`: dial context. Throws on failure.

Parameters

d Dialer
receiver Dialer (value receiver)
ctx &context.Context
ctx (borrowed; caller keeps it; 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

Call `handshake` on `&Conn`. Throws on failure.

Parameters

c &Conn
receiver &Conn (borrow)

Returns

int — a value of this type

(Conn) connection_state

XuAPI
pub fn (c Conn) connection_state() ConnectionState

Purpose

Method on `Conn`: connection state.

Parameters

c Conn
receiver Conn (value receiver)

Returns

ConnectionState — a value of this type

(&mut Conn) set_deadline

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

Purpose

Method on `&mut Conn`: set deadline.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
t_ns int
t_ns (int)

Returns

int — a value of this type

(&mut Conn) set_read_deadline

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

Purpose

Method on `&mut Conn`: set read deadline.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
t_ns int
t_ns (int)

Returns

int — a value of this type

(&mut Conn) set_write_deadline

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

Purpose

Method on `&mut Conn`: set write deadline.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
t_ns int
t_ns (int)

Returns

int — a value of this type

(&mut Conn) read

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

Purpose

Method on `&mut Conn`: read up to max bytes. Throws on failure.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
max int
maximum (int)

Returns

string — result string

(&mut Conn) write

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

Purpose

Method on `&mut Conn`: write data and return the byte count. Throws on failure.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
data &string
data (borrowed; caller keeps it; type &string)

Returns

int — bytes written

(&mut Conn) close

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

Purpose

Method on `&mut Conn`: close the resource. Throws on failure.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)

Returns

int — a value of this type

(&mut Conn) read_result

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

Purpose

Method on `&mut Conn`: read result.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
n int
count, length, or limit (int)

Returns

io.ReadResult — a value of this type

(&mut Conn) write_result

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

Purpose

Method on `&mut Conn`: write result.

Parameters

c &mut Conn
receiver &mut Conn (exclusive borrow)
data string
data (string)

Returns

io.WriteResult — a value of this type