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
fix: cert verify test fix #4545
base: main
Are you sure you want to change the base?
Conversation
It looks like this test is no failing when we build with FIPS-validated libcryptos? You'll need to investigate that. |
/* Use a hash algorithm different from sender by prepending corresponding iana value */ | ||
EXPECT_SUCCESS(s2n_stuffer_rewrite(&verifying_conn->handshake.io)); | ||
if (sig_scheme.sig_alg == S2N_SIGNATURE_ECDSA) { | ||
EXPECT_SUCCESS(s2n_stuffer_write_uint16(&verifying_conn->handshake.io, TLS_SIGNATURE_SCHEME_ECDSA_SHA384)); | ||
} else { | ||
EXPECT_SUCCESS(s2n_stuffer_write_uint16(&verifying_conn->handshake.io, TLS_SIGNATURE_SCHEME_RSA_PSS_PSS_SHA384)); | ||
} | ||
EXPECT_SUCCESS(s2n_stuffer_skip_write(&verifying_conn->handshake.io, write_cursor_position)); |
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's a shame that RSA-PSS was added in TLS1.3 so doesn't follow the TLS1.2 formula of the first byte being the hash and the second byte being the sig alg. That would have made this test easier :( https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.4.1
But this is incredibly fragile as-is. You need a sig scheme that matches for one field but not for the other. You should probably add a field to the s2n_tls13_cert_verify_test struct so that we can specify the "sig scheme with different hash" when we specify the test sig scheme.
Resolved issues:
Resolves #4431
Description of changes:
Previously, a test case was not running due to missing
#include "crypto/s2n_rsa_pss.h"
. This is now added so the corresponding test is running.One of the test cases were failing even if the tests were enabled and this change fixes it. Specifically, the test was failing on calling s2n_tls_cert_verify_send() because The test runs in a for-loop with different configuration. The first iteration uses s2n_ecdsa_sha256 as signature scheme for the test and the second iteration uses s2n_rsa_pss_pss_sha256 as the signature scheme. The first iteration passes, but the second iteration fails because we're always setting test_scheme.sig_alg = S2N_SIGNATURE_ECDSA; this causes mismatch with RSA_PSS_PSS when sending cert_verify.
Negative test cases were using a single connection object to send and receive cert_verify message. This is an incorrect set up as we do not want to introduce another source of failure other than the ones we are explicitly testing,. Therefore the tests are modified to use two connections (sending_conn and verifying_conn) to properly simulate the test cases
In order to get better test result, change EXPECT_FAILURE() calls to EXPECT_FAILURE_WITH_ERRNO() with specific error to expect in each test case
Clean up code to reduce redundancy and improve readability
Call-outs:
Testing:
Confirmed s2n_tls_cert_verify_test now runs all tests and passes all cases
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.