-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ICP: AES-GCM: Unify gcm_init_ctx() and gmac_init_ctx() #14529
ICP: AES-GCM: Unify gcm_init_ctx() and gmac_init_ctx() #14529
Conversation
The only difference I see is that previously, I'm not sure if that was intentional or not, but it is a difference. (It does seem like both checks should always be done, ie, doesn't matter how we decide to use AVX, but if we do, we should consider all the details). |
Thanks, well spotted, this is very helpful feedback. Only Not checking for a byte swapped key schedule if we are using the AVX implementation (as opposed to the cycle implementation) is a major bug with the potential of pool corruption. I could easily produce a panic by setting In summary, the key schedule byte swap check should be done for both, the cycle and the AVX implementation. In the cycle case we can silently fallback to a non-AVX implementation but for the AVX case we should print a warning in addition to the fallback at least. The proper fix of course would be to deny setting the GCM implementation to one which won't work with the AES one and vice versa. Unfortunately this is a bit tricky since it would require synchronizing the routines setting the AES and GCM implementation. Not sure if it's worth the effort for such an edge case. |
df2159d
to
bce39aa
Compare
Added fixes, rebased to master and force pushed to get a clean test run. |
@AttilaFueloep rebasing one more time should sort of the GitHub Actions CI infrastructure issue so you can get a clean test run. |
bce39aa
to
1024656
Compare
Rebased. I wonder if we have the equivalent of |
The make failures seem to be related to #14527. The zloop failure ( |
1024656
to
0132fda
Compare
@AttilaFueloep merged #14567, I'll get this merged once you rebase. |
gmac_init_ctx() duplicates most of the code in gcm_int_ctx() while it just needs to set its own IV length and AAD tag length. Introduce gcm_init_ctx_impl() which handles the GCM and GMAC differences while reusing the duplicated code. While here, fix a flaw where the AVX implementation would accept a context using a byte swapped key schedule which it could not handle. Also constify the IV and AAD pointers passed to gcm_init{,_avx}(). Signed-off-by: Attila Fülöp <attila@fueloep.org>
8630b06
to
de478ad
Compare
Rebased, squashed and updated the commit message. |
gmac_init_ctx() duplicates most of the code in gcm_int_ctx() while it just needs to set its own IV length and AAD tag length. Introduce gcm_init_ctx_impl() which handles the GCM and GMAC differences while reusing the duplicated code. While here, fix a flaw where the AVX implementation would accept a context using a byte swapped key schedule which it could not handle. Also constify the IV and AAD pointers passed to gcm_init{,_avx}(). Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <robn@despairlabs.com> Signed-off-by: Attila Fülöp <attila@fueloep.org> Closes openzfs#14529
gmac_init_ctx() duplicates most of the code in gcm_int_ctx() while it just needs to set its own IV length and AAD tag length. Introduce gcm_init_ctx_impl() which handles the GCM and GMAC differences while reusing the duplicated code. While here, fix a flaw where the AVX implementation would accept a context using a byte swapped key schedule which it could not handle. Also constify the IV and AAD pointers passed to gcm_init{,_avx}(). Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <robn@despairlabs.com> Signed-off-by: Attila Fülöp <attila@fueloep.org> Closes openzfs#14529
Motivation and Context
gmac_init_ctx()
duplicates most of the code ingcm_int_ctx()
while it just needs to set its own IV length and AAD tag length.Description
Introduce
gcm_init_ctx_impl()
which handles the GCM and GMAC differences while reusing the duplicated code.While here, constify the IV and AAD pointers passed to gcm_init{,_avx}().
How Has This Been Tested?
Builds, included in another PR which passes testing.
Types of changes
Checklist:
Signed-off-by
.