XU XUv0.8.8
EN

API

#crypto/gmtls

import: #crypto/gmtls

counts: 2 函数, 3 方法, 2 类型, 5 常量, 0 方法集

GMTLS 1.1 子集(SM2 双证 + SM4)。进程内 net.pipe,无 Listen。零 C、非商密认证。

const version_gmtls11

XuAPI
pub const version_gmtls11 = 257

用途

公开常量 `version_gmtls11`。 值为 `257`

参数

无

const ecc_sm4_gcm_sm3

XuAPI
pub const ecc_sm4_gcm_sm3 = 57427

用途

公开常量 `ecc_sm4_gcm_sm3`。 值为 `57427`

参数

无

const ecdhe_sm4_gcm_sm3

XuAPI
pub const ecdhe_sm4_gcm_sm3 = 57425

用途

公开常量 `ecdhe_sm4_gcm_sm3`。 值为 `57425`

参数

无

const ecc_sm4_cbc_sm3

XuAPI
pub const ecc_sm4_cbc_sm3 = 57363

用途

公开常量 `ecc_sm4_cbc_sm3`。 值为 `57363`

参数

无

const ecdhe_sm4_cbc_sm3

XuAPI
pub const ecdhe_sm4_cbc_sm3 = 57361

用途

公开常量 `ecdhe_sm4_cbc_sm3`。 值为 `57361`

参数

无

struct Config

XuAPI
pub struct Config {
    pub server_name string
    pub client_name string
    pub insecure_skip_verify bool
    pub sign_cert string
    pub sign_key string
    pub enc_cert string
    pub enc_key string
    pub cipher_suite int
}

用途

公开结构体 `Config`。

参数

server_name string
字段(string)
client_name string
字段(string)
insecure_skip_verify bool
字段(bool)
sign_cert string
字段(string)
sign_key string
字段(string)
enc_cert string
字段(string)
enc_key string
字段(string)
cipher_suite int
字段(int)

struct Conn

XuAPI
pub struct Conn {
    pub handshake_complete bool
    pub cipher_suite int
    pub server_name string
    pub peer_sign_cert string
    pub peer_enc_cert string
}

用途

公开结构体 `Conn`。

参数

handshake_complete bool
字段(bool)
cipher_suite int
字段(int)
server_name string
字段(string)
peer_sign_cert string
字段(string)
peer_enc_cert string
字段(string)

client

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

用途

客户端。失败时 throw。

参数

c net.PipeConn
字节或字符码(net.PipeConn)
cfg &Config
cfg(借用,调用方仍持有;类型 &Config)

返回

Conn — 该类型的值

server

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

用途

服务端。失败时 throw。

参数

c net.PipeConn
字节或字符码(net.PipeConn)
cfg &Config
cfg(借用,调用方仍持有;类型 &Config)

返回

Conn — 该类型的值

(&mut Conn) write

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

用途

`&mut Conn` 上的方法:写入数据,返回写入的字节数。失败时 throw。

参数

c &mut Conn
接收者 &mut Conn(可变借用)
data &string
数据(借用,调用方仍持有;类型 &string)

返回

int — 写入的字节数

(&mut Conn) read

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

用途

`&mut Conn` 上的方法:读出最多 max 字节。失败时 throw。

参数

c &mut Conn
接收者 &mut Conn(可变借用)

返回

string — 结果字符串

(&mut Conn) close

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

用途

`&mut Conn` 上的方法:关闭资源。失败时 throw。

参数

c &mut Conn
接收者 &mut Conn(可变借用)

返回

int — 该类型的值