-
Notifications
You must be signed in to change notification settings - Fork 722
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
openssl3 integration: load legacy provider for rc4 cipher #3457
Conversation
tagging @loqs |
988ecaf
to
2c8e0ee
Compare
Using just the C code 4a439b9 on top of 8ca9445 with OpenSSL 1.1.1q
Which is expected as the header was added with OpenSSL 3. |
2c8e0ee
to
b58d6fc
Compare
crypto/s2n_libcrypto.c
Outdated
*/ | ||
RESULT_ENSURE_NE(OSSL_PROVIDER_load(NULL, "legacy"), NULL); |
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.
These will return a pretty generic "S2N_ERR_SAFETY". Do you want a more specific error code?
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 should be ok since the operation is only doing one things (loading provider). We dont really have insight into why it might fail to load so I am not sure there is much to add other than "failed to load".
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.
But the customer will be calling s2n_init, not s2n_libcrypot_init. s2n_init does a lot of things :)
3a5f52c
to
f7cfc54
Compare
f7cfc54
to
456f944
Compare
#3082
Description of changes:
openssl3 has a concept of legacy algorithms which it deems outdated and therefore does not load them by default. The way to access these old algorithms is to load the "legacy" provider (discussed in section above). This provider is loaded along side other providers and make legacy algorithms available for use.
Fix1
It is possible to load the "legacy" provider at library initialization via a config file. This is done along side the "default" provider so that other ciphers are also available. This solution is more ideal since it would avoid any extra load time during application execution. It also avoid
#ifdef
usage for theOSSL_PROVIDER_load(NULL, "legacy");
call, which is ideal for keeping the code clean.The custom openssl config can be loaded by specifing the
OPENSSL_CONF=$(realpath codebuild/openssl.config);
env variable as stated in https://github.com/openssl/openssl/blob/master/README-PROVIDERS.md#loading-providers and https://www.openssl.org/docs/manmaster/man5/config.htmlFix2 (recommended)
Why recommended: while we generally try to avoid
ifdefs
, in this case the library will not work if the provider is not loaded for openssl3. This paired with the fact that its possible for flags to get lost in our build scripts, the preferred solution here is to load the provider from C code if we detect that openssl3 is being used.RC4 is considered a legacy algorithm and needs to be loaded via a provider.
OSSL_PROVIDER_load(NULL, "legacy");
can be used to load the provider globally (NULL). The loading can happen ins2n_stream_cipher_rc4_init
, which is called prior to the cipher usage.Testing:
Local testing also shows that both providers were loaded correctly.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.