Skip to content

ext/sodium: Add crypto_kem (X-Wing) and crypto_kem_mlkem768 bindings - #23420

Open
ZacharyDuBois wants to merge 3 commits into
php:masterfrom
ZacharyDuBois:sodium-kem
Open

ext/sodium: Add crypto_kem (X-Wing) and crypto_kem_mlkem768 bindings#23420
ZacharyDuBois wants to merge 3 commits into
php:masterfrom
ZacharyDuBois:sodium-kem

Conversation

@ZacharyDuBois

Copy link
Copy Markdown

libsodium 1.0.22 introduced a KEM API: X-Wing (hybrid ML-KEM768+X25519, upstream's recommended KEM) and ML-KEM768 (FIPS 203). This exposes both:

  • sodium_crypto_kem_{keypair,seed_keypair,secretkey,publickey,enc,dec}
  • sodium_crypto_kem_mlkem768_{keypair,seed_keypair,secretkey,publickey,enc,dec} + SODIUM_CRYPTO_KEM[_MLKEM768]_*BYTES constants

@ZacharyDuBois

Copy link
Copy Markdown
Author

Tried sending an email to internals but seems like y'all don't support DMARC with p=reject as it just bounced as the mailing list seems to be changing my DKIM signature.

@NickSdot

NickSdot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Tried sending an email to internals but seems like y'all don't support DMARC with p=reject as it just bounced as the mailing list seems to be changing my DKIM signature.

While the subscribe step? If yes, you maybe want to ping @ derickr.

@ZacharyDuBois

Copy link
Copy Markdown
Author

But you did the subscribe step? If yes, you maybe want to ping @ derickr.

Yep, sent an intro (I think on Thursday) and that went though but shortly after I got the forensic report and it showed both SPF and DKIM failed. Looking at the headers, looks like it hit a relay causing the failure. Running an outbound test reports my email is all good.

@NickSdot

Copy link
Copy Markdown
Contributor

But you did the subscribe step? If yes, you maybe want to ping @ derickr.

Yep, sent an intro (I think on Thursday) and that went though but shortly after I got the forensic report and it showed both SPF and DKIM failed. Looking at the headers, looks like it hit a relay causing the failure. Running an outbound test reports my email is all good.

Fwiw, it went through anyway: https://news-web.php.net/php.internals/132308

@Ayesh
Ayesh requested a review from jedisct1 August 23, 2026 17:58
@jedisct1

Copy link
Copy Markdown
Contributor

The changes look good to me.

Thanks a lot for adding these functions!

@ZacharyDuBois

Copy link
Copy Markdown
Author

@jedisct1 no problem! I have a project I am working on that needed some post-quantum stuff added in (more so for playing around). Saw these were missing and didn't feel like hassling someone to add them when I am perfectly capable of it.

This is my first PR for PHP so let me know if I am missing anything! More than happy to make any edits. From what I heard on the mailing list, 8.6 is on a feature freeze so sadly it sounds like this won't make it out for 8.6 :(

Expose the libsodium 1.0.22 generic KEM API (X-Wing, hybrid
ML-KEM768+X25519). Guarded so older libsodium builds are unaffected.
Expose libsodium 1.0.22's ML-KEM768 (FIPS 203) KEM with the same shape
as the generic crypto_kem API.
@ZacharyDuBois

Copy link
Copy Markdown
Author

Fixed the merge conflict with NEWS

@Girgias

Girgias commented Aug 24, 2026

Copy link
Copy Markdown
Member

Probably best for @paragonie-scott / @paragonie-security to review this. :)

@ZacharyDuBois

Copy link
Copy Markdown
Author

@Girgias more the merrier but this is only direct passthrough to libsodium which is maintained by @jedisct1 with a bit of conversion to make it PHP-esque. That and a bunch of tests that are similar to the ones in place for the other libsodium calls.

@Girgias

Girgias commented Aug 24, 2026

Copy link
Copy Markdown
Member

@Girgias more the merrier but this is only direct passthrough to libsodium which is maintained by @jedisct1 with a bit of conversion to make it PHP-esque. That and a bunch of tests that are similar to the ones in place for the other libsodium calls.

He does maintain https://github.com/jedisct1/libsodium-php so his input would probably be useful too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants