Linux cryptographic layer development
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] lib/crypto: Add AEGIS-128X4
@ 2026-11-12 12:54 Antonio Quartulli
  2026-11-12 12:54 ` [RFC PATCH 1/5] lib/crypto: tests: Make the AEAD dst clearing check effective Antonio Quartulli
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Antonio Quartulli @ 2026-11-12 12:54 UTC (permalink / raw)
  To: linux-crypto
  Cc: Antonio Quartulli, Eric Biggers, Ard Biesheuvel,
	Jason A . Donenfeld, Herbert Xu

From: Antonio Quartulli <antonio@mandelbit.com>

This series adds AEGIS-128X4, the 4-way parallel variant of AEGIS-128L
specified in RFC 10032 (Informational, September 2026), as a crypto
library with an x86_64 VAES-AVX512 implementation, a KUnit test suite
and benchmark, and a crypto API wrapper.

AEGIS-128X4 runs four AEGIS-128L instances, one per 128-bit lane of a
512-bit vector, so that each state update is eight VAESENC instructions
on zmm registers.  On CPUs with VAES and AVX-512 it is very fast even for
short messages, which is what makes it attractive for network protocols.

The intended user is ovpn, the OpenVPN data channel offload driver. In
single-stream ovpn tests over a 100 Gbit/s link, with both ciphers used
through the crypto API, the sending CPU spent 1266 cycles per packet with
AEGIS-128X4 against 1448 with AES-GCM over TCP, and 1032 against 1122
with UDP GSO input. It is posted as an RFC because ovpn can't use it
yet.

The library mirrors the AES-GCM one: one-shot encryption and decryption,
and an incremental API for nonlinear data.  The generic code keeps the
state in the same layout as the assembly, so the incremental functions
can switch between the two between any two calls, as needed when the FPU
isn't usable.

Encryption throughput from the KUnit benchmark on a Ryzen 9 9950X, in
MB/s:

  data_len   generic   VAES-AVX512
        16        10           581
        64        41          2351
       256       159          8986
      1420       576         34521
      4096       987         46761
     16384      1308         79588

Open questions:

- There is no AVX2 code yet. AEGIS-128X4 can also run with VAES on
  ymm registers, two per state word, which would cover CPUs without
  AVX-512; for now they use the generic code. For the same reason,
  unlike AES-GCM, the AVX-512 code is used on CPUs with
  X86_FEATURE_PREFER_YMM too. Should an AVX2 version be part of this
  series?

- Is the crypto API wrapper (patch 5) wanted? ovpn currently uses the
  crypto API for AES-GCM and ChaCha20-Poly1305 (but it could call the
  library directly).

- The assembly is a port of the libaegis AVX-512 code by Frank Denis
  from C intrinsics; as libaegis is MIT licensed, the file is
  dual-licensed GPL-2.0-only OR MIT and keeps his copyright line.

Patch 1 is independent of the rest: the AEAD test template's check that
decryption clears dst on authentication failure can't fail with its
all-zero plaintext. AES-GCM and AES-CCM pass it with a random one.

Testing: the KUnit suite passes (RFC 10032 test vectors, the shared AEAD
test cases and a Monte Carlo checksum from an independent Python
implementation in gen-aead-testvecs.py) with the VAES-AVX512 code, with
it built in but AVX-512 hidden from the guest, and with the generic code
only. The crypto API self-tests pass with CRYPTO_SELFTESTS_FULL.

Antonio Quartulli (5):
  lib/crypto: tests: Make the AEAD dst clearing check effective
  lib/crypto: aegis128x4: Add AEGIS-128X4 library
  lib/crypto: tests: Add KUnit test suite for AEGIS-128X4
  lib/crypto: x86/aegis128x4: Add VAES-AVX512 optimized code
  crypto: aegis128x4 - Add AEGIS-128X4 AEAD algorithm

 crypto/Kconfig                          |  11 +
 crypto/Makefile                         |   1 +
 crypto/aegis128x4.c                     | 173 ++++++++
 crypto/testmgr.c                        |   7 +
 crypto/testmgr.h                        | 119 ++++++
 include/crypto/aegis128x4.h             | 275 +++++++++++++
 lib/crypto/.kunitconfig                 |   1 +
 lib/crypto/Kconfig                      |  14 +
 lib/crypto/Makefile                     |   9 +
 lib/crypto/aegis128x4.c                 | 509 ++++++++++++++++++++++++
 lib/crypto/tests/Kconfig                |  10 +
 lib/crypto/tests/Makefile               |   1 +
 lib/crypto/tests/aead-test-template.h   |   5 +
 lib/crypto/tests/aegis128x4_kunit.c     | 352 ++++++++++++++++
 lib/crypto/x86/aegis128x4-vaes-avx512.S | 470 ++++++++++++++++++++++
 lib/crypto/x86/aegis128x4.h             | 167 ++++++++
 scripts/crypto/gen-aead-testvecs.py     | 166 +++++++-
 17 files changed, 2284 insertions(+), 6 deletions(-)
 create mode 100644 crypto/aegis128x4.c
 create mode 100644 include/crypto/aegis128x4.h
 create mode 100644 lib/crypto/aegis128x4.c
 create mode 100644 lib/crypto/tests/aegis128x4_kunit.c
 create mode 100644 lib/crypto/x86/aegis128x4-vaes-avx512.S
 create mode 100644 lib/crypto/x86/aegis128x4.h


base-commit: 33b4f31b1aea3f62b61c892daefc0e6a77859032
-- 
2.56.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-11-13  3:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 12:54 [RFC PATCH 0/5] lib/crypto: Add AEGIS-128X4 Antonio Quartulli
2026-11-12 12:54 ` [RFC PATCH 1/5] lib/crypto: tests: Make the AEAD dst clearing check effective Antonio Quartulli
2026-11-13  3:07   ` Eric Biggers
2026-11-12 12:54 ` [RFC PATCH 2/5] lib/crypto: aegis128x4: Add AEGIS-128X4 library Antonio Quartulli
2026-11-12 12:54 ` [RFC PATCH 3/5] lib/crypto: tests: Add KUnit test suite for AEGIS-128X4 Antonio Quartulli
2026-11-12 12:54 ` [RFC PATCH 4/5] lib/crypto: x86/aegis128x4: Add VAES-AVX512 optimized code Antonio Quartulli
2026-11-12 12:54 ` [RFC PATCH 5/5] crypto: aegis128x4 - Add AEGIS-128X4 AEAD algorithm Antonio Quartulli
2026-11-12 16:20 ` [RFC PATCH 0/5] lib/crypto: Add AEGIS-128X4 Ard Biesheuvel
2026-11-12 16:44   ` Jason A. Donenfeld
2026-11-12 22:54     ` Antonio Quartulli
2026-11-13  2:06       ` Eric Biggers
2026-11-12 16:50 ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox