zupt/jasmin/zupt_aes_ctr4.jazz
Cristian Cezar Moisés e5f5d32aab v2.2.2
2026-05-01 09:58:47 -03:00

25 lines
1 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Zupt — AES-256-CTR 4-Block Pipeline via AES-NI (Jasmin)
* Copyright (c) 2026 Cristian Cezar Moisés
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* CT-REQUIRED: AES-NI has no data-dependent timing.
*
* Interleaves 4 independent counter blocks through the AES round
* pipeline. AES-NI has 4-cycle latency, 1-cycle throughput — so
* 4 independent blocks saturate the pipeline for ~4× throughput.
*
* Expected: ~3.5 GB/s AES-256-CTR on modern x86-64 (Zen3/Alder Lake).
*
* Interface:
* zupt_aes256_ctr4(out, in, key, ctr, nblocks)
* Encrypts nblocks×16 bytes. Counter is incremented in the last 8 bytes
* (big-endian) after each block. Processes 4 blocks per iteration;
* remaining 1-3 blocks fall back to zupt_aes256_blk.
*
* NOTE: This is the Jasmin source for documentation. The actual linked
* assembly is in zupt_aes_ctr4.s (hand-written to match this logic).
*/
/* See zupt_aes_ctr4.s for the production assembly.
* This .jazz file documents the algorithm but is not compiled
* (jasminc is not required at build time). */