-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add CNSA presets #9460
base: development
Are you sure you want to change the base?
Add CNSA presets #9460
Conversation
Thank you very much for contributing this! We'll review it shortly. |
e6a6878
to
7ffd018
Compare
Please avoid rebasing once the pull request is in review. It's ok for now because I haven't started reviewing yet, but if you want to make more changes, please make them in separate commits. |
Sorry, I did read those instructions, but old habit of rebase, will follow that norm, thanks. |
CNSA supersedes NSA SuiteB crypto suites, esp. brings back RSA with higher modulus (>=3072). This was based on RFC9151, see [1]. Implements Mbed-TLS#4602. [1] - https://datatracker.ietf.org/doc/rfc9151/ Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
7ffd018
to
415bf01
Compare
CNSA supersedes NSA SuiteB crypto suites, esp. brings back RSA with higher modulus (>=3072). This was based on RFC9151, see [1]. Implements #4602. [1] - https://datatracker.ietf.org/doc/rfc9151/ Upstream PR: Mbed-TLS/mbedtls#9460 Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
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.
Thank you very much for contributing this! I've reviewed the code and there are a few things I'm not sure of, perhaps because I'm not deeply familiar with TLS 1.3.
At some point, we'll need to rebase or merge with the current development
branch, because the preprocessor symbols that control cryptographic mechanisms are evolving. However, given that this evolution is still ongoing and I can't promise fast reviews, it would be best to wait until further notice.
@@ -0,0 +1,2 @@ | |||
Features | |||
* Add support for CNSA preset that supersedes NSA SuiteB. |
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 bit nitpicky, but in the context of Mbed TLS, the CNSA preset doesn't supersede the suite B preset: we now have both.
Also, for the unfamiliar, it's not clear what “CNSA preset” is about.
Suggestion:
Add a CNSA certificate profile for X.509 and TLS. This is intended as a successor of NSA Suite B.
MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384, | ||
MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, |
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.
We're going to remove RSA-encryption and non-EC DH in TLS 1.2 , so we won't have these two cipher suites anymore.
@@ -5651,6 +5651,16 @@ static const int ssl_preset_suiteb_ciphersuites[] = { | |||
0 |
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 really in scope, but maybe we should add MBEDTLS_TLS1_3_AES_128_GCM_SHA256
and MBEDTLS_TLS1_3_AES_256_GCM_SHA384
to suiteb?
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.
Yes, I will make a separate commit
@@ -5795,6 +5805,38 @@ static uint16_t ssl_tls12_preset_suiteb_sig_algs[] = { | |||
}; | |||
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ | |||
|
|||
|
|||
/* As per rfc9151 */ | |||
static const uint16_t ssl_preset_cnsa_sig_algs[] = { |
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.
As far as I understand, this list is supposed to cover both TLS 1.2 and TLS 1.3. Is this actually the case, given that the sigalgs for RSA in TLS 1.3 require the use of PSS, but TLS 1.2 doesn't do PSS? (It wasn't a problem for the other presets because if they allow RSA, they allow RSA without PSS.)
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.
Yes, the RFC does mention both 1.2 and 1.3., hence added separate entries: ssl_preset_cnsa_sig_algs
and ssl_tls12_preset_cnsa_sig_algs
.
|
||
/* As per rfc9151 */ | ||
static const uint16_t ssl_preset_cnsa_sig_algs[] = { | ||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDSA_CERT_REQ_ANY_ALLOWED_ENABLED) && \ |
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.
That macro covers both 1.2 and 1.3, but the code here is specific to 1.3.
#if defined(MBEDTLS_KEY_EXCHANGE_ECDSA_CERT_REQ_ANY_ALLOWED_ENABLED) && \ | |
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED) && \ | |
defined(PSA_HAVE_ALG_SOME_ECDSA) && \ |
PSA_HAVE_ALG_SOME_ECDSA
replaces MBEDTLS_PK_CAN_ECDSA_SOME
. It may be necessary to rebase this pull request for the CI to pass with PSA_HAVE_ALG_SOME_ECDSA
.
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.
Should I do the rebase once code review is done? or before? Please suggest.
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.
I'm afraid that due to an increased workload, we've had to downgrade the priority of #4602 and many other issues. So I can't promise a re-review any time soon. I'm sorry about this.
Given the time between reviews, it would be easiest for us if you rebase just before we're ready for re-review (we'll let you know). Preferably, git range-diff origin/development OLD-COMMIT-ID NEW-COMMIT-ID
should give a usable result.
defined(PSA_WANT_ECC_SECP_R1_384) | ||
MBEDTLS_SSL_TLS12_SIG_AND_HASH_ALG(MBEDTLS_SSL_SIG_ECDSA, MBEDTLS_SSL_HASH_SHA384), | ||
#endif | ||
#if defined(MBEDTLS_RSA_C) && defined(PSA_WANT_ALG_SHA_384) |
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.
By the time we release Mbed TLS 4.0, we want to have
#if defined(MBEDTLS_RSA_C) && defined(PSA_WANT_ALG_SHA_384) | |
#if defined(PSA_WANT_ALG_RSA_PKCS1V15_SIGN) && defined(PSA_WANT_ALG_SHA_384) |
@@ -5807,6 +5849,18 @@ static const uint16_t ssl_preset_suiteb_groups[] = { | |||
MBEDTLS_SSL_IANA_TLS_GROUP_NONE | |||
}; | |||
|
|||
static const uint16_t ssl_preset_cnsa_groups[] = { | |||
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) |
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.
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) | |
#if defined(PSA_WANT_ALG_ECDH) && defined(PSA_WANT_ECC_SECP_R1_384) |
MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072, | ||
MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE4096, |
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.
MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072, | |
MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE4096, | |
#if defined(PSA_WANT_DH_RFC7919_3072) | |
MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072, | |
#endif | |
#if defined(PSA_WANT_DH_RFC7919_4096) | |
MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE4096, | |
#endif |
/** | ||
* CNSA profile. | ||
*/ | ||
extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_cnsa; |
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.
Please add some test cases to test_suite_x509parse
that exercise the CNSA profile (similar to what we already have for suiteb). E.g. have a test case with an RSA-3072 or RSA-4096 signature that's accepted, and one with an RSA-2048 signature that's rejected.
@@ -326,6 +326,7 @@ | |||
|
|||
#define MBEDTLS_SSL_PRESET_DEFAULT 0 | |||
#define MBEDTLS_SSL_PRESET_SUITEB 2 | |||
#define MBEDTLS_SSL_PRESET_CNSA 3 |
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.
Please add some test cases for the CNSA preset in TLS. I'm not sure what they should look like; we don't seem to have tests for the existing SUITEB profile. We should have some test cases that demonstrate that if all the mechanisms are allowed then the handshake goes through, and some test cases that demonstrate that if a mechanism is rejected then the handshake is rejected. This should be doable in test_suite_ssl
, but will require a new function that calls mbedtls_ssl_config_defaults
with a preset that's given in the test data.
In particular, I want test cases that clarify the situation with respect to RSA signature algorithms in TLS 1.2 vs TLS 1.3.
CNSA supersedes NSA SuiteB crypto suites, esp. brings back RSA with higher modulus (>=3072). This was based on RFC9151, see [1].
Implements #4602.
[1] - https://datatracker.ietf.org/doc/rfc9151/
Description
Add support for CNSA preset, mainly for RSA3K support, else need to fallback to DEFAULT to use RSA instead of SuiteB.
PR checklist
Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line.
If the provided content is part of the present PR remove the # symbol.