Add AES-GCM-SIV AEAD support (RFC 8452)#1
Add AES-GCM-SIV AEAD support (RFC 8452)#1Rakdos8 wants to merge 1 commit intojordikroon:fix/gh20851from
Conversation
Rakdos8
commented
Apr 25, 2026
- Replaces Fix GH-20851: AES-SIV / AES-GCM-SIV not handled as AEAD in openssl_encrypt php/php-src#21872 (closed)
- Consolidates with Properly initialize AEAD cipher flags in OpenSSL backend php/php-src#20853 as suggested by @jordikroon
- Tests use cipher_tests.inc
| * EVP_CIPH_SIV_MODE (RFC 5297), it takes a single AAD input, so | ||
| * aad_supports_vector stays false. LibreSSL does not currently | ||
| * define this constant. */ | ||
| #ifdef EVP_CIPH_GCM_SIV_MODE |
There was a problem hiding this comment.
Can you put this below case EVP_CIPH_SIV_MODE? The case will then flow into php_openssl_set_aead_flags without the need to call it once more.
|
Overall looks good. Thank you for this. Just one bullet once that is addressed and tests will give a green light I will merge it into the PR. |
Builds on the AES-SIV support added in the earlier commits by also
handling EVP_CIPH_GCM_SIV_MODE in php_openssl_load_cipher_mode().
GCM-SIV (OpenSSL >= 3.2, RFC 8452) uses the standard
EVP_CTRL_AEAD_*_TAG controls and falls into the same AEAD switch arm
as SIV. The existing aad_supports_vector = (cipher_mode ==
EVP_CIPH_SIV_MODE) check keeps that flag false for GCM-SIV, since
RFC 8452 takes a single AAD input rather than vector AAD like RFC 5297
SIV. LibreSSL does not currently define EVP_CIPH_GCM_SIV_MODE, hence
the #ifdef guard.
Tests:
- cipher_tests.inc gains aes-256-gcm-siv vectors from RFC 8452
Appendix C.2 (empty plaintext, 8-byte plaintext with and without
AAD).
- openssl_encrypt_gcm_siv.phpt and openssl_decrypt_gcm_siv.phpt
consume those vectors, mirroring the SIV equivalents, and cover
the missing-tag and tampering failure paths.
2b81ae6 to
c5ff025
Compare
|
Good catch, applied. Falls through into the shared block now, much cleaner — the existing I've seen failed test in the matrix, will see how it goes after this last commit 👍 |
|
I merged other PR as it's independent and ready. Please rebase it and keep just siv gcm and will check this one later. |
|
Much appreciated. I will close this. Please rebase and target php/php-src master |