XU XUv0.8.8
中文

API

#crypto/aes

import: #crypto/aes

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

AES-128/192/256 single block. CBC/CTR/GCM live in crypto/cipher.

const block_size

XuAPI
pub const block_size = 16

Purpose

AES (FIPS-197) aligned with `crypto/aes` NewCipher + Block. Optimized 32-bit Te/Td lookup tables with scalar state registers and in-place buffer APIs. Pure i64 with masked words/bytes. Not constant-time. XU-CT-CLASS: variable-time Value `16`.

Parameters

none

struct Cipher

XuAPI
pub struct Cipher {
    pub nr int
    pub rk []int
    pub sbox []int
    pub inv []int
    pub te []int
    pub td []int
    pub erk []int
    pub drk []int
    pub hw_accel bool
    pub rk_bytes string
    pub drk_bytes string
}

Purpose

Public struct `Cipher`.

Parameters

nr int
field (int)
rk []int
field ([]int)
sbox []int
field ([]int)
inv []int
field ([]int)
te []int
field ([]int)
td []int
field ([]int)
erk []int
field ([]int)
drk []int
field ([]int)
hw_accel bool
field (bool)
rk_bytes string
field (string)
drk_bytes string
field (string)

new_cipher

XuAPI
pub fn new_cipher(key &string) Cipher

Purpose

Construct cipher. Throws on failure.

Parameters

key &string
key (borrowed; caller keeps it; type &string)

Returns

Cipher — a value of this type

(&Cipher) block_size

XuAPI
pub fn (c &Cipher) block_size() int

Purpose

Method on `&Cipher`: block size.

Parameters

c &Cipher
receiver &Cipher (borrow)

Returns

int — a value of this type

(&Cipher) encrypt

XuAPI
pub fn (c &Cipher) encrypt(src &string) string

Purpose

Method on `&Cipher`: encrypt. Throws on failure.

Parameters

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

Returns

string — result string

(&Cipher) encrypt_block

XuAPI
pub fn (c &Cipher) encrypt_block(dst &mut []int, src &[]int) bool

Purpose

Method on `&Cipher`: encrypt block. Throws on failure.

Parameters

c &Cipher
receiver &Cipher (borrow)
dst &mut []int
destination (exclusive borrow; type &mut []int)
src &[]int
source (borrowed; caller keeps it; type &[]int)

Returns

bool — true or false

(&Cipher) decrypt

XuAPI
pub fn (c &Cipher) decrypt(src &string) string

Purpose

Method on `&Cipher`: decrypt. Throws on failure.

Parameters

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

Returns

string — result string

(&Cipher) decrypt_block

XuAPI
pub fn (c &Cipher) decrypt_block(dst &mut []int, src &[]int) bool

Purpose

Method on `&Cipher`: decrypt block. Throws on failure.

Parameters

c &Cipher
receiver &Cipher (borrow)
dst &mut []int
destination (exclusive borrow; type &mut []int)
src &[]int
source (borrowed; caller keeps it; type &[]int)

Returns

bool — true or false