libgcrypt: Add optimized implementation of Kyber/Dilithium using CPU specific vector extention
Open, WishlistPublic

Assigned To
Authored By
• gniibe
Apr 1 2026, 7:30 AM
Subscribers

Description

To gcrypt-devel, Power 8 version is submitted.

In the upstream reference implementation, we can find the one with AVX2.

It's good libgcrypt incorporate those.

Event Timeline

• gniibe triaged this task as Wishlist priority.Apr 1 2026, 7:30 AM
• gniibe created this task.
• gniibe mentioned this in Unknown Object (Maniphest Task).Apr 13 2026, 6:35 AM
• gniibe mentioned this in Unknown Object (Maniphest Task).Jul 20 2026, 6:39 AM
• gniibe mentioned this in Unknown Object (Maniphest Task).Jul 27 2026, 8:16 AM
• gniibe mentioned this in Unknown Object (Maniphest Task).Aug 3 2026, 4:44 AM
• gniibe mentioned this in Unknown Object (Maniphest Task).Aug 31 2026, 2:58 AM
• gniibe mentioned this in Unknown Object (Maniphest Task).Sep 7 2026, 3:53 AM
This comment was removed by • gniibe.

I rebase the branch gniibe/t8204 to master.
The commit rC320f0d209bff: Clean up unused functions. has compile-time selection with AVX2.
Then, I realized that libgcrypt always offers runtime selection of such CPU specific feature.
Thus, I modified the implementation like:

  • optimized version should have variant for these three functions: kyber_keypair, kyber_encap, kyber_decap
  • In kem.c, checking the hardware feature, select relevant variant for that
• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Sep 14, 3:54 AM
• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Sep 21, 3:41 AM

In the reference implementation of Dilithium, AVX2 version has a commit of 5eaf6e94129967a89f7f2cb51006ff2666beac4d, for better data locality in signature generation.

To respect this improvement, we don't share crypto_sign_signature_internal and crypto_sign_verify_internal between non-vector version and AVX2 version.

• gniibe mentioned this in Unknown Object (Maniphest Task).Mon, Oct 12, 3:48 AM