pass padding of 0 to EVP_CIPHER_CTX_set_padding #3450
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Security concerns:
Padding currently being enabled in main branch is not a security issue since we apply padding manually and provide the encrypt function with data that is a multiple of the block size. This essentially mean a noop when openssl tries to apply padding.
Description of changes:
This is part of the effort to integrate s2n-tls with openssl3.
The error originates from the usage of the function
EVP_CIPHER_CTX_set_padding
. This function controls padding when performing encrypt/decrypt operations on a block of data. Padding is enabled by default and can be disabled if desired.Based on the documentation and source code this doesnt seem to have been used correctly. The
EVP_CIPHER_CTX_set_padding
fn expects 1 or 0 while the value ofEVP_CIPH_NO_PADDING
is0x100
and seems to be used to toggle the flag on the internally used context.FIX:
The fix here should be to call
EVP_CIPHER_CTX_set_padding
with0
instead ofEVP_CIPH_NO_PADDING
.https://github.com/toidiu/s2n-tls/compare/ak-openssl3_padding?expand=1
Links:
EVP_CIPHER_CTX_set_padding
https://github.com/openssl/openssl/blob/openssl-3.0.5/crypto/evp/evp_enc.c#L1024
https://github.com/openssl/openssl/blob/OpenSSL_1_1_0/crypto/evp/evp_enc.c#L561
EVP_CIPH_NO_PADDING 0x100
https://github.com/openssl/openssl/blob/openssl-3.0.5/include/openssl/evp.h#L321
https://github.com/openssl/openssl/blob/OpenSSL_1_1_0/include/openssl/evp.h#L243
Testing:
Unit tests for openssl1.1.1 and openssl3 passed.
Is this a refactor change? If so, how have you proved that the intended behavior hasn't changed?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.