Skip to main content

Module crypto_accel

Module crypto_accel 

Source
Expand description

Native SHA-256 / HMAC-SHA256 / PBKDF2-HMAC-SHA256, byte-identical to the pure-LOGOS reference in assets/std/crypto.lg.

The pure-LOGOS crypto is the SPEC — it is what the AOT tiers (Rust, C, WASM) compile to native code, and it is FIPS/RFC vector-locked. But the tree-walking interpreter INTERPRETS every Word32 operation, so PBKDF2’s mandated 4096 iterations (16k SHA-256 compressions) take ~32s — far too slow for a real SCRAM handshake. This module accelerates exactly that hot primitive on the interpreted tier: the interpreter intercepts pbkdf2Sha256 and runs this instead, differentially locked to produce the identical bytes as the pure reference (see crypto_accel_lock.rs). No corner is cut — the pure code is still the single source the compiled tiers use; this is the same “the reference implementation is native C” arrangement every language’s hashlib uses.

Functions§

hmac_sha256
HMAC-SHA256 (RFC 2104 / RFC 4231).
pbkdf2_sha256
PBKDF2-HMAC-SHA256 with dkLen fixed at 32 — exactly SCRAM’s Hi() (RFC 5802 / RFC 7677): one output block, so U1 = HMAC(password, salt ‖ 0x00000001) and the derived key is the running XOR of the U chain over iters iterations.
sha256
SHA-256 (FIPS 180-4) of an arbitrary byte string.