interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / docs / CRYPTO_CONSTANT_TIME.md

40 lines · 2145 bytes Raw Blame History Rendered
1# Constant-time AES/POLYVAL and secret wiping
2
3Scope: `crates/aienos-crypto` (AES-256, POLYVAL, AES-256-GCM-SIV) and the
4kernel envelope decrypt scratchpad. All code is in-house; no outside crates.
5
6## What changed
7
8- **AES S-box is computed, not looked up.** Each byte is inverted in GF(2^8)
9 as `x^254` (fixed chain of 11 multiplications) and passed through the
10 FIPS 197 affine transform. Only shifts, masks and XORs; 16 bytes at a time
11 packed in a `u128`. Used by both encryption (`SubBytes`) and key expansion
12 (`SubWord`). `xtime` in MixColumns is branch-free.
13- **POLYVAL multiply is branch-free.** The conditional add and the reduction
14 step use all-ones/all-zeros masks instead of `if`.
15- **Secrets are wiped on every path.** Derived GCM-SIV keys, the key-derivation
16 scratch block, the CTR keystream and padded plaintext tails live in a
17 self-wiping buffer (volatile writes on drop). AES round keys are built in
18 place in the returned key object; encryption works in the caller's buffer
19 with no extra state copy. The kernel envelope decrypt scratchpad is wiped
20 after its plaintext is copied out.
21- The public `derive_keys` returns self-wiping buffers with redacted debug
22 output. Callers borrow the contained arrays; explicit copies remain the
23 caller's responsibility.
24
25## What is and is not claimed
26
27- Constant-time by construction in the source, plus an AArch64 release
28 disassembly spot-check of the S-box routine (no conditional branches, no
29 data-indexed loads).
30- **Not measured** on hardware. **No independent side-channel review.**
31- Envelope storage is reserved once after the first chunk authenticates the
32 complete bounded header. Later chunks cannot trigger growth that leaves
33 plaintext in freed heap blocks. Allocation failures wipe the temporary chunk.
34- Existing FIPS 197 and RFC 8452 known-answer vectors pass unchanged; a new
35 test checks the computed S-box against the standard table for all 256 inputs.
36
37## Future speedup (not implemented)
38
39ARMv8 FEAT_AES instructions (`AESE`/`AESMC`) are constant-time in hardware and
40much faster than this software S-box. They are a possible future speedup.