-
Notifications
You must be signed in to change notification settings - Fork 19
cipher: swith from ECB to CBC mode for AES lookups #293
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: v2
Are you sure you want to change the base?
Conversation
newEVPCipher function returns AES cipher of any supported modes. It does so by loading an AES cipher with ECB mode. Pure stand-alone ECB mode (but not as a primitive in other modes) is deprecated and will be retired by upcoming [NIST SP 800-131A Rev. 3](https://csrc.nist.gov/pubs/sp/800/131/a/r3/ipd). Separately geomys module upstream blocks ECB mode completely in FIPS mode. I think this is a minimal change, which shouldn't affect any existing matrix of any providers, as far as I can tell CBC is available everywhere ECB is. But this change fixes using OpenSSL FIPS providers that make ECB mode private.
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.
Looks good to me.
|
aes.NewCipher returns a ECB cipher, and that function is implemented by I guess you just want to call aes.NewCipher to then pass it tocipher.NewCBCDecrypter, or friends, and then discard the ECB cipher. But with the current implementation, if the provider fail to allocate an ECB cipher, aes.NewCipher errors. If that's the case, then I would instead update |
Does it? It seems to return a new struct of kind aes without any mode reference at all. Would you agree to add mode argument to this API call and make all callers set that?
I think all of the above already happens. |
|
Forget my previous comment, you are right, we already lazy-init the ECB OpenSSL cipher in Encrypt/Decrypt. In fact, we only instantiate the ECB cipher in I'm still don't like the solution, though. We only the the block size in case the caller uses |
ack
Maybe, but there is a lot of code and tests that expects blockSize to be already set, and asserts on exact errors that happen before that. This code change adds compatibility with a FIPS module under submission that removes ECB mode as available, whilst being backwards compatible with all other implementations as well. Also I agree that blocksize checks are miss-placed as it can be 16, 12, 1 => and yet many tests expect it as always 16. If this passes all CI for all implementation, I would prefer to merge this as is; and then work on redoing things. |
I don't think the refactor is that big. Current code has been working well for years with ECB, except for the case you report. I don't know if by switching to CBC we will hit a corner case elsewhere. So I would rather do the right thing in this same PR. |
newEVPCipher function returns AES cipher of any supported modes. It
does so by loading an AES cipher with ECB mode.
Pure stand-alone ECB mode (but not as a primitive in other modes) is
deprecated and will be retired by upcoming NIST SP 800-131A Rev. 3.
Separately geomys module upstream blocks ECB mode completely in FIPS
mode.
I think this is a minimal change, which shouldn't affect any existing
matrix of any providers, as far as I can tell CBC is available
everywhere ECB is.
But this change fixes using OpenSSL FIPS providers that make ECB mode
private.