XU XUv0.8.8
中文

API

#crypto/zuc

import: #crypto/zuc

counts: 4 fns, 1 methods, 1 types, 1 consts, 0 ifaces

ZUC-128 and 128-EEA3/EIA3. Pure Xu, not commercial-crypto certified.

const key_size

XuAPI
pub const key_size = 16

Purpose

Public constant `key_size`. Value `16`.

Parameters

none

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
}

Purpose

Public struct `Cipher`.

Parameters

s []int
source string
r1 int
field (int)
r2 int
field (int)
x0 int
field (int)
x1 int
field (int)
x2 int
field (int)
x3 int
field (int)
s0 []int
field ([]int)
s1 []int
field ([]int)
hold int
field (int)
nleft int
field (int)

new_cipher

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

Purpose

Construct cipher. Throws on failure.

Parameters

key &string
key (borrowed; caller keeps it; type &string)
iv &string
int payload or initialization vector (borrowed; caller keeps it; type &string)

Returns

Cipher — a value of this type

(&mut Cipher) xor_key_stream

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

Purpose

Method on `&mut Cipher`: xor key stream.

Parameters

c &mut Cipher
receiver &mut Cipher (exclusive borrow)
src &string
source (borrowed; caller keeps it; type &string)

Returns

string — result string

encrypt_eea3

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

Purpose

Encrypt eea3. Throws on failure.

Parameters

key &string
key (borrowed; caller keeps it; type &string)
count int
count (int)
bearer int
bearer (int)
direction int
direction (int)
src &string
source (borrowed; caller keeps it; type &string)
bit_len int
bit_len (int)

Returns

string — result string

decrypt_eea3

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

Purpose

Decrypt eea3. Throws on failure.

Parameters

key &string
key (borrowed; caller keeps it; type &string)
count int
count (int)
bearer int
bearer (int)
direction int
direction (int)
src &string
source (borrowed; caller keeps it; type &string)
bit_len int
bit_len (int)

Returns

string — result string

sum_eia3

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

Purpose

Digest eia3. Throws on failure.

Parameters

key &string
key (borrowed; caller keeps it; type &string)
count int
count (int)
bearer int
bearer (int)
direction int
direction (int)
src &string
source (borrowed; caller keeps it; type &string)
bit_len int
bit_len (int)

Returns

string — result string