tls: support for ECDSA P-384 and P-521 certificates#36369
tls: support for ECDSA P-384 and P-521 certificates#36369ggreenway merged 20 commits intoenvoyproxy:mainfrom anitabyte:p-384-plus
Conversation
Signed-off-by: anitabyte <anita@anitabyte.xyz>
|
Hi @anitabyte, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
|
From CI runs:
I haven't touched Quic in this PR - but will investigate and see if there's anything I can do to resolve. |
|
I just have task which needs these curves to be supported. Would be great if it got merged sooner! |
|
Does this have an impact on FIPS validation? AFAIR the restrictions on the curves was also due to FIPS validated algorithms. |
|
My knowledge of FIPS is limited, but I believe FIPS 186-5 refers to NIST SP800-186, which does include these curves. I don't believe that this would impact FIPS compliance by being merged, especially as we aren't changing defaults. |
Merge latest changes from main Signed-off-by: anitabyte <anita@anitabyte.xyz>
|
Merged from main; all checks now pass |
|
@ggreenway Do you recall why only P-256 curve as supported initially? I think it's the only FIPS one back in the days, was it because of that? |
#10855 (comment) explains it |
FIPS is a separate build, and we can put additional restrictions there if needed. I don't know if FIPS says anything about certificate types or not. |
|
I removed the fixed issue number from the title because otherwise when this is merged, it'll have two numbers in parentheses where the PR number usually is. The fixed issue number is part of the body of the commit message. |
Signed-off-by: anitabyte <anita@anitabyte.xyz>
We now use the ECDSA capabilities of the client to inform certificate choice The `isClientEcdaCapable` method is now `getClientEcdsaCapabilities`, returning an optional vector of curves supported by the client. We choose a context based on whether there is a shared curve in a certificate and the client capabilities. Quic helper functions have been change to define the P-256 curve as the client capability used where they had previously only asserted `true`. Given that QUICHE only supports P-256 and P-384 certs, no further effort on QUIC has been expended as part of this PR. Signed-off-by: anitabyte <anita@anitabyte.xyz>
Signed-off-by: anitabyte <anita@anitabyte.xyz>
|
Changes requested addressed with some further context in commit messages. |
ggreenway
left a comment
There was a problem hiding this comment.
This is looking much better. Please add test coverage for the new code, especially the case of a P-521 cert and a client that supports P-256/P-384, and make sure it falls back to RSA.
Also I think this would self-document better if you add a using CurveNIDSupportedVector = std::vector<int>; and using that throughout, so it's clear what the int is.
Because it can currently only ever have 3 elements, it could be an absl::InlinedVector<int, 3> instead.
/wait
Signed-off-by: anitabyte <anita@anitabyte.xyz>
|
Integration tests for client not supporting P-256 curves and client support P-256 and P-384 but server configured with a P-521 cert added. Would welcome comments on if there is anything more elegant I can do where I've have to call CBS_Init again to reset the position of a CBS when checking curve capabilities and sigalgs. Also, if the approach I've taken to replicating |
Signed-off-by: anitabyte <anita@anitabyte.xyz>
| server_ecdsa_cert_ = true; | ||
| // We have to set the server curves to allow for ECDH negotiation where client | ||
| // doesn't support P-256 | ||
| server_curves_.push_back("P-256"); |
There was a problem hiding this comment.
Can you elaborate on why this is needed? I don't understand. I would have guessed that setting the signature algorithms on the client would be enough, and leave the curves as the default.
There was a problem hiding this comment.
This appears to be required as the only time that the curves are set for the contexts is in this line, which uses the ECDH settings to set the supported curves. As the defaults enabled are X25519 and P-256, we don't get a P-384+ context if we don't explicitly enable them for ECDH curves on the server.
There was a problem hiding this comment.
Technically, the P-256 curve isn't required - the test would pass with P-384 only enabled, but we do need to explicitly enable it.
There was a problem hiding this comment.
But the curves are used for ECDH to generate ephemeral keys; I don't think they should matter for certificate selection and validation. And for that, I believe only the signature algorithms are used.
There was a problem hiding this comment.
I think I may have been thinking of something else here: our client for this test explicitly does not support P-256 for ECDH negotiation. We have to add the P-384 curve for the purposes of ECDH so that the client has a curve that it agrees on with the server to be able to do the ECDH negotiation. My earlier point about the defaults giving us only P-256 and X25519 curves available for that purpose stands.
I'll validate if the other tests pass without the specification of specific server curves.
There was a problem hiding this comment.
At least in tls 1.3, I don't think you should be setting supported curves on either client or server, you should be setting the signing algorithms on the client for what we're trying to test. I'm not sure if tls 1.2 co-mingles these or not.
There was a problem hiding this comment.
They do: the client without P-256 support does, however, require the specification of a server-side curve that is does support. New commit has been pushed removing the server curve specification from the tests that don't need it.
Signed-off-by: anitabyte <anita@anitabyte.xyz>
…_test.cc Signed-off-by: anitabyte <anita@anitabyte.xyz>
Signed-off-by: anitabyte <anita@anitabyte.xyz>
|
TLSv1.3 specifications of curves have been removed from tests as they are unnecessary. TLSv1.2 requires the explicit definition of the curves in the client: tests fail where they are not specified in the all-curves client tests where they are not specified. |
ggreenway
left a comment
There was a problem hiding this comment.
LGTM, thanks for all the work on this!
However, with the release today, there's now a conflict on the release notes file. Please resolve and we'll get this merged.
/wait
Signed-off-by: anitabyte <anita@anitabyte.xyz>
Head branch was pushed to by a user without write access
Signed-off-by: anitabyte <anita@anitabyte.xyz>
|
Not sure what happened, but you needed to merge |
|
I was trying to take a lighter touch and embarrassed myself. This should be good now, hopefully. |
|
There's a formatting problem, I'll fix it now: apologies, I'm not at my usual computer that actually has the toolchain set up. |
Signed-off-by: anitabyte <anita@anitabyte.xyz>
|
Formatting CI tasks have completed: I don't think there's anything else in the changes that should trip us up. |
Commercial National Security Algorithm Suite (CNSA) requires ECDSA keys be specified with P-384 curves. The assertion that there are [no security benefits to curves higher than P-256](envoyproxy#5224 (comment)) is no longer true. This change is intended to limit the adoptable curves to P-384 and P-521. Risk Level: Medium - removal of limitation of curves to be used for ECDSA certificates, with [potential misconfiguration and DoS risks](envoyproxy#10855 (comment)) mentioned in previous discourse on the issue. This risk is mitigated in this PR, however, by continuing to expressly limit the type of EC keys accepted to those associated with the P-256, P-384 or P-521 curves and no others. Fixes envoyproxy#10855 Signed-off-by: anitabyte <anita@anitabyte.xyz> Signed-off-by: anitabyte <111812252+anitabyte@users.noreply.github.com>
Commit Message: tls: support for ECDSA P-384 and P-521 certificates (#10855)
Additional Description: Commercial National Security Algorithm Suite (CNSA) requires ECDSA keys be specified with P-384 curves. The assertion that there are no security benefits to curves higher than P-256 is no longer true. This change is intended to limit the adoptable curves to P-384 and P-521.
Risk Level: Medium - removal of limitation of curves to be used for ECDSA certificates, with potential misconfiguration and DoS risks mentioned in previous discourse on the issue. This risk is mitigated in this PR, however, by continuing to expressly limit the type of EC keys accepted to those associated with the P-256, P-384 or P-521 curves and no others.
Testing: Testing using unit and integration tests
Ran build envoy artefact locally with below config:
Ran
openssl s_client 127.0.0.1:10000:Docs Changes: Changes made to reference that P-384 and P-521 certificates now are usable.
Fixes #10855