XU XUv0.16.0

#crypto/zuc

导入方式: #crypto/zuc

公开 API: 4 函数, 1 方法, 1 类型, 1 常量, 0 方法集

ZUC-128 与 128-EEA3/EIA3。零 C、非商密认证。

const KEY_SIZE

XuAPI
pub const KEY_SIZE = 16

用途

常量 KEY_SIZE,定义了相关的协议或算法配置参数。

struct Cipher

XuAPI
pub struct Cipher {
    pub s []int
    pub r1 int
    pub r2 int
    pub x0 int
    pub x1 int
    pub x2 int
    pub x3 int
    pub s0 []int
    pub s1 []int
    pub hold int
    pub nleft int
}

用途

Zuc 密码算法的分组或流式加解密上下文。

公开字段

s []int
源字符串
r1 int
字段(int)
r2 int
字段(int)
x0 int
字段(int)
x1 int
字段(int)
x2 int
字段(int)
x3 int
字段(int)
s0 []int
字段([]int)
s1 []int
字段([]int)
hold int
字段(int)
nleft int
字段(int)

new_cipher

XuAPI
pub fn new_cipher(key &string, iv &string) Cipher

用途

构造 cipher。失败时抛出错误,调用方需处理或继续传播。

参数

key &string
键(只读借用,调用方仍持有原值;类型 &string)
iv &string
整数载荷或初始向量(只读借用,调用方仍持有原值;类型 &string)

返回值

Cipher — 该类型的值

($&Cipher) xor_key_stream

XuAPI
pub fn (c $&Cipher) xor_key_stream(src &string) string

用途

$&Cipher 上的操作:执行 xor key stream 操作。

参数

c $&Cipher
本次调用使用的 Cipher 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
src &string
源数据(只读借用,调用方仍持有原值;类型 &string)

返回值

string — 结果字符串

encrypt_eea3

XuAPI
pub fn encrypt_eea3(key &string, count int, bearer int, direction int, src &string, bit_len int) string

用途

加密eea3。失败时抛出错误,调用方需处理或继续传播。

参数

key &string
键(只读借用,调用方仍持有原值;类型 &string)
count int
count(int)
bearer int
bearer(int)
direction int
direction(int)
src &string
源数据(只读借用,调用方仍持有原值;类型 &string)
bit_len int
bit_len(int)

返回值

string — 结果字符串

decrypt_eea3

XuAPI
pub fn decrypt_eea3(key &string, count int, bearer int, direction int, src &string, bit_len int) string

用途

解密eea3。失败时抛出错误,调用方需处理或继续传播。

参数

key &string
键(只读借用,调用方仍持有原值;类型 &string)
count int
count(int)
bearer int
bearer(int)
direction int
direction(int)
src &string
源数据(只读借用,调用方仍持有原值;类型 &string)
bit_len int
bit_len(int)

返回值

string — 结果字符串

sum_eia3

XuAPI
pub fn sum_eia3(key &string, count int, bearer int, direction int, src &string, bit_len int) string

用途

摘要eia3。失败时抛出错误,调用方需处理或继续传播。

参数

key &string
键(只读借用,调用方仍持有原值;类型 &string)
count int
count(int)
bearer int
bearer(int)
direction int
direction(int)
src &string
源数据(只读借用,调用方仍持有原值;类型 &string)
bit_len int
bit_len(int)

返回值

string — 结果字符串