XU XUv0.16.0

#crypto/zuc

import: #crypto/zuc

counts: 4 functions, 1 methods, 1 types, 1 constants, 0 method sets

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

const KEY_SIZE

XuAPI
pub const KEY_SIZE = 16

Purpose

Constant KEY_SIZE, defining protocol or algorithm parameters.

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

Zuc Cipher context for block or stream encryption/decryption.

Public fields

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; handle the error or propagate it to the caller.

Parameters

key &string
key (read-only borrow; caller keeps the original; type &string)
iv &string
int payload or initialization vector (read-only borrow; caller keeps the original; type &string)

Returns

Cipher — a value of this type

($&Cipher) xor_key_stream

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

Purpose

Operation on $&Cipher: xor key stream.

Parameters

c $&Cipher
The Cipher instance used by this call (exclusive borrow).
src &string
source (read-only borrow; caller keeps the original; 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; handle the error or propagate it to the caller.

Parameters

key &string
key (read-only borrow; caller keeps the original; type &string)
count int
count (int)
bearer int
bearer (int)
direction int
direction (int)
src &string
source (read-only borrow; caller keeps the original; 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; handle the error or propagate it to the caller.

Parameters

key &string
key (read-only borrow; caller keeps the original; type &string)
count int
count (int)
bearer int
bearer (int)
direction int
direction (int)
src &string
source (read-only borrow; caller keeps the original; 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; handle the error or propagate it to the caller.

Parameters

key &string
key (read-only borrow; caller keeps the original; type &string)
count int
count (int)
bearer int
bearer (int)
direction int
direction (int)
src &string
source (read-only borrow; caller keeps the original; type &string)
bit_len int
bit_len (int)

Returns

string — result string