-
Notifications
You must be signed in to change notification settings - Fork 724
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
chore: document OpenSSL-FIPS restriction on RSA key size #4654
Conversation
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.
Nice job figuring this out!
@@ -314,11 +315,19 @@ int main(int argc, char **argv) | |||
{ | |||
DEFER_CLEANUP(struct s2n_cert_chain_and_key *cert = NULL, s2n_cert_chain_and_key_ptr_free); | |||
/* use a very insecure cert that would not be included in any reasonable cert preferences */ | |||
EXPECT_SUCCESS(s2n_test_cert_permutation_load_server_chain(&cert, "rsae", "pkcs", "1024", "sha1")); | |||
if (s2n_is_in_fips_mode() && !s2n_libcrypto_is_awslc()) { | |||
/* OpenSSL FIPS module requires the key size for RSA to be bigger than or equal to 1024 bits. |
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.
Is it just 1.0.2 FIPs that has this restriction, or does 3.x also have this restriction?
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.
Not too sure if 3.x has the same restriction, but I wasn't able to find the same function that checks for rsa key size in 3.x.
This if (s2n_is_in_fips_mode() && !s2n_libcrypto_is_awslc())
check wouldn't include 3.x though, because the way we are detecting FIPS is not supported in 3.0 and higher. We call FIPS_mode() to determine if libcrypto is in fips mode. This function is not present in 3.x
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.
In 3.X, it seems the minimum key size for RSA is 2048:
https://github.com/openssl/openssl/blob/4f5febe2c684a803553171940634c1b6f4b7ba40/include/openssl/rsa.h#L48
- use the 1024 certs for test - simplify test with 1024 certs
- fix the error condition - comment fix
Resolved issues:
Resolves #4651
Description of changes:
Description of the error:
Error message:
RSA_public_encrypt()
returns -1, which causes "size mismatch" error:s2n-tls/crypto/s2n_rsa.c
Lines 121 to 123 in b20075b
This is because in openssl fips module, a function checks to see if RSA key size is bigger than or equal to 1024, and returns -1 when the check fails. openssl-fips-2.0.13 is the fips module we use for openssl-1.0.2-fips. This fips module can be downloaded from here. (Not sure if there is publicly accessible page to view the code on browser)
Therefore using 512 bits cert causes the error above. aws_lc_fips doesn't seem to have this minimum requirement for RSA key size.
Testing:
No functional changes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.