-
Notifications
You must be signed in to change notification settings - Fork 8k
Properly initialize AEAD cipher flags in OpenSSL backend #20853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
2cff66b to
7de1357
Compare
|
Please review commits 1 by 1 since I am not sure if the change from The second commit allows AAD to be null since it behaves differently than when only an empty string is given. The matches other implementations like |
bukka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable. Just some minor things really.
| #if defined(EVP_CIPH_FLAG_AEAD_CIPHER) | ||
| if (EVP_CIPHER_flags(cipher_type) & EVP_CIPH_FLAG_AEAD_CIPHER) { | ||
| php_openssl_set_aead_flags(mode); | ||
| } | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to add EVP_CIPH_SIV_MODE to the switch if exists and set the right mode if there are some differences.
| /* Only pass AAD to OpenSSL if caller provided it. | ||
| This makes NULL mean zero AAD items, while "" with len 0 means one empty AAD item. */ | ||
| if (mode->is_aead && aad != NULL && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (const unsigned char *)aad, (int)aad_len)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for SIV or is this for all modes. I thought that empty string won't make difference but I guess it might.
In general allowing null should be fine for master so it's not really a problem. Just want to know the reasoning as I haven't checked this propertly.
Fixes #20851
Add support for AEAD ciphers like AES-SIV by detecting and initializing AEAD flags during cipher mode loading.
Includes test case for AES-256-SIV encryption/decryption roundtrip.