Skip to content
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

Added certificate signature preferences #2370

Merged
merged 16 commits into from Dec 3, 2020
Merged

Conversation

maddeleine
Copy link
Contributor

@maddeleine maddeleine commented Nov 6, 2020

Resolved issues:

resolves #1538 #1442

Description of changes:

This adds a certificate signature preferences struct to our security policies. This struct indicates which signature algorithms the peer will accept on the certificate. The only security policy to take advantage of this is the "default_tls13" policy, which now will not allow SHA-1 legacy signatures in certificates. Also I found a few spelling mistakes.

Call-outs:

Our test certificates aren't named for the signature algorithms they contain, so if you would like to check that I am testing the correct signature algorithms, use the openssl command:
openssl x509 -noout -text -in name_of_certfile.pem | grep "Signature Algorithm"

Another call out is that I had to add the Openssl ids for signature schemes as s2n uses Openssl's x509 functions to parse certificates.

Testing:

How is this change tested (unit tests, fuzz tests, etc.)? Are there any testing steps to be verified by the reviewer?

Unit tests, integ tests that use authentication still pass.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-io
Copy link

codecov-io commented Nov 7, 2020

Codecov Report

Merging #2370 (a927ef0) into main (28d64f6) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2370      +/-   ##
==========================================
+ Coverage   81.92%   81.96%   +0.03%     
==========================================
  Files         271      271              
  Lines       18663    18703      +40     
==========================================
+ Hits        15290    15330      +40     
  Misses       3373     3373              

Impacted file tree graph

tests/testlib/s2n_testlib.h Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_signature_scheme.h Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_signature_scheme.h Outdated Show resolved Hide resolved
@@ -138,20 +151,23 @@ const struct s2n_signature_scheme s2n_rsa_pss_rsae_sha256 = {
.iana_value = TLS_SIGNATURE_SCHEME_RSA_PSS_RSAE_SHA256,
.hash_alg = S2N_HASH_SHA256,
.sig_alg = S2N_SIGNATURE_RSA_PSS_RSAE,
.libcrypto_nid = NID_rsassaPss,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right nid? Why does this id not include the hash algorithm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still looking into why the id does not include the hash, but this is the correct id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved offline; I will make a github issue to track this.

tls/s2n_signature_scheme.c Outdated Show resolved Hide resolved
tls/s2n_signature_algorithms.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_security_policies.c Outdated Show resolved Hide resolved
tests/unit/s2n_x509_validator_test.c Outdated Show resolved Hide resolved
docs/USAGE-GUIDE.md Outdated Show resolved Hide resolved
tests/testlib/s2n_testlib.h Outdated Show resolved Hide resolved
@@ -87,7 +89,7 @@ void s2n_x509_trust_store_wipe(struct s2n_x509_trust_store *store);
/** Initialize the validator in unsafe mode. No validity checks for OCSP, host checks, or X.509 will be performed. */
int s2n_x509_validator_init_no_x509_validation(struct s2n_x509_validator *validator);

/** Initialize the validator in safe mode. Will use trust store to validate x.509 cerficiates, ocsp responses, and will call
/** Initialize the validator in safe mode. Will use trust store to validate x.509 certificates, ocsp responses, and will call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loving all these spelling fixes!

Comment on lines 567 to 568
if (conn->config->security_policy->certificate_signature_preferences == NULL) {
*validation_code = S2N_CERT_OK;
return S2N_RESULT_OK;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if there's an override policy on the connection? You need to use s2n_connection_get_security_policy to retrieve the policy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do you have a test for this case? It's a pretty important case.

tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_security_policies_test.c Outdated Show resolved Hide resolved
tls/s2n_server_cert.c Outdated Show resolved Hide resolved
tests/testlib/s2n_testlib.h Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Outdated Show resolved Hide resolved
tls/s2n_security_policies.c Outdated Show resolved Hide resolved
tls/s2n_security_policies.c Outdated Show resolved Hide resolved
tests/unit/s2n_security_policies_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_security_policies_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tests/unit/s2n_certificate_signatures_test.c Outdated Show resolved Hide resolved
tls/s2n_x509_validator.c Show resolved Hide resolved
Copy link
Contributor

@ttjsu-aws ttjsu-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@maddeleine maddeleine merged commit 97dd2b1 into aws:main Dec 3, 2020
@maddeleine maddeleine deleted the sha1_removal branch December 3, 2020 17:41
feliperodri pushed a commit that referenced this pull request Dec 4, 2020
* Added certificate signature preferences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support certificate signature restrictions
5 participants