XU XUv0.8.8
中文

API

#crypto/subtle

import: #crypto/subtle

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

Constant-time-shaped helpers; the backend does not guarantee timing.

constant_time_compare

XuAPI
pub fn constant_time_compare(x &string, y &string) int

Purpose

Helpers aligned with `crypto/subtle`. XU-CT-CONTRACT v1: constant_time_compare, constant_time_byte_eq, constant_time_eq and constant_time_select have a fixed iteration count and branchless result selection for caller-provided public shapes. A compare length mismatch is public-shape validation and may return early. xor_bytes is not in the contracted set. This contract does not make AES, big.Int, RSA, ECDSA/ECDH or other consumers constant-time. XU-CT-CLASS: constant-time-contracted

Parameters

x &string
value (borrowed; caller keeps it; type &string)
y &string
value (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

constant_time_byte_eq

XuAPI
pub fn constant_time_byte_eq(x int, y int) int

Purpose

Constant time byte eq.

Parameters

x int
value (int)
y int
value (int)

Returns

int — a value of this type

constant_time_eq

XuAPI
pub fn constant_time_eq(x int, y int) int

Purpose

Constant time eq.

Parameters

x int
value (int)
y int
value (int)

Returns

int — a value of this type

constant_time_select

XuAPI
pub fn constant_time_select(v int, x int, y int) int

Purpose

Constant time select.

Parameters

v int
value (int)
x int
value (int)
y int
value (int)

Returns

int — a value of this type

xor_bytes

XuAPI
pub fn xor_bytes(x &string, y &string) string

Purpose

Xor bytes. Throws on failure.

Parameters

x &string
value (borrowed; caller keeps it; type &string)
y &string
value (borrowed; caller keeps it; type &string)

Returns

string — result string