-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Finish adding support for AES-CCM mode #569
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
Conversation
- Add #ossl_is_ccm macro for AES-128-CCM, AES-192-CCM and AES-256-CCM - Modify OpenSSL::Cipher#authenticated? to return true for CCM modes - Add ossl_ccm_set_auth_tag and ossl_ccm_get_auth_tag methods - Modify OpenSSL::Cipher#auth_tag and OpenSSL::Cipher#auth_tag= to support CCM - Add OpenSSL::Cipher#iv_len= method to support non-standard CCM IV lengths - Add some documentation on how to use non-standard CCM IV lengths
Does anyone have pointers as to what is missing for this PR to be considered for inclusion? |
@louismullie This needs approval of @emboss |
@nahi Can you review this? |
I'm not sold on this patch, and releasing "as-is" is taking priority at the moment. I also think making |
OpenSSL needs to know the plaintext length before setting the AAD or starting encrypting. So if we want support AES-CCM in OpenSSL::Cipher, we need another method #plaintext_len=, and of course this is a very bad idea. |
Add OpenSSL::Cipher#iv_len=. For interoperability with other applications, it is sometimes required. Normally 'IV' is fixed-length, but in OpenSSL, some ciphers such as aes-128-gcm make use of it as 'nonce', which is variable-length. Changing the IV length in Cipher#iv= is also an option but I decided not to choose it. Because in Ruby <= 2.3 Cipher#iv= truncates the input when the length is longer than the current IV length, changing the behavior might cause unexpected encryption result. [Bug #8667] [Bug #10420] [GH ruby/ruby#569]
Add OpenSSL::Cipher#iv_len=. For interoperability with other applications, it is sometimes required. Normally 'IV' is fixed-length, but in OpenSSL, some ciphers such as aes-128-gcm make use of it as 'nonce', which is variable-length. Changing the IV length in Cipher#iv= is also an option but I decided not to choose it. Because in Ruby <= 2.3 Cipher#iv= truncates the input when the length is longer than the current IV length, changing the behavior might cause unexpected encryption result. [Bug #8667] [Bug #10420] [GH ruby/ruby#569]
ruby openssl itself needs to be updated to support OpenSSL::Cipher#iv_len= ruby/ruby#569 ApplePay uses 16 as iv_len, not ruby default's 12.
As commented before, CCM does not fit with the interface of OpenSSL::Cipher. Please open a new issue at https://github.com/ruby/openssl if you have ideas about this. |
Currently, only the GCM mode of authenticated encryption is supported in Ruby. This patch adds support for the CCM mode of authenticated encryption. It also adds support for explicitly setting IV length, which is required by OpenSSL when dealing with non-standard IV lengths in CCM mode. See https://bugs.ruby-lang.org/issues/9642 for more information.
More details:
support CCM
lengths