-
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
Added minimal TLSv1.3-only client configuration #9797
base: development
Are you sure you want to change the base?
Added minimal TLSv1.3-only client configuration #9797
Conversation
Hi @NadavTasher , the CI is failing because the DCO check is not passing. Can you please resubmit with a signed off commit? e.g. |
72ee720
to
210126f
Compare
@tom-daubney-arm Done. |
Hi @NadavTasher, you have an issue with code style in this PR. You can either manually fix this, or you can run |
a616c83
to
ffffa17
Compare
@tom-daubney-arm Fixed. |
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 for contributing this configuration! It is a useful purpose. I mostly agree with the selection (except for curves). A few things will need to change, and we'll need a test component.
We are moving a lot of files and renaming identifiers around at the moment, in preparation for the next major release, so this is likely to require more adaptations. I suggest waiting until things stabilize before doing rework. It should us take a couple of months to reach a more stable state.
configs/config-aes-gcm-tls1_3.h
Outdated
#define MBEDTLS_X509_USE_C | ||
|
||
/* Enable ECP algorithms */ | ||
#define MBEDTLS_ECP_DP_BP256R1_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.
Since this is supposed to be a minimal configuration, shouldn't this specify just one curve? If users want to have more curve available, they can easily tweak the example to support more curves (and we can put a comment stating you can do that, or have common curves commented out, e.g. default to secp256r1 and have secp384r1 and curve25519 commented out).
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 agree with you for the most part - this does give the user a more "minimal" configuration, but this configuration might be too minimal to communicate with real servers OOTB.
As you suggested, I have removed these values and added the PSA_WANT_ECC_SECP_R1_256
define in crypto-config-aes-gcm-tls1_3.h
, but I think more WANT_ECC
macros should be added.
WDYT?
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 think there's more value in showing a minimal configuration where it's easy for people to add more things, than in showing a large configuration which will have people wondering what they can remove. A few things could have comments “if you need feature X, uncomment the next line”. For curves, I think it's fairly easy to figure out how to add one.
The current configuration with just AES-GCM and secp256r1 is close to what RFC 8446 §9.1 defines as the default minimal TLS 1.3 profile, except:
- No RSA here.
- There's
TLS_AES_256_GCM_SHA384
as well asTLS_AES_128_GCM_SHA256
.
I wonder if it would make sense to have exactly the RFC 8446 minimal profile? Or at least have comments explaining the differences?
@@ -0,0 +1,74 @@ | |||
/** |
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 a test component to build and test this configuration in tests/scripts/components-configuration-tls.sh
, similar to component_test_config_suite_b
.
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 have added a minimal compilation test. I am not quite sure what we want to test here since we are disabling most features - what is your opinion?
IMO if we could somehow have a functionality test using mini_client
against openssl s_server
that would be best.
Thank you very much for updating this! Unfortunately we aren't allowed to use commits that are missing a signoff line — this signoff line is how you convey that you allow us to use your contribution. Would you mind pushing a rebased version that the DCO check accepts? |
Oh yeah I completely forgot about that - will do that ASAP. |
8f164d0
to
e198a22
Compare
@tom-daubney-arm Done. |
@tom-daubney-arm Any updates? |
@gilles-peskine-arm Can you tell me what's left to do here? |
Thanks for updating the pull request and bringing this to our attention. The ball is now on our side, we need to find time to review (always a problem I'm afraid). I'll try to do at least a first pass quickly, but I can't promise a full review any time soon. |
I can help as second reviewer as @tom-daubney-arm will not be able to continue on that I think. |
/* Configuration values for test suite */ | ||
#define MBEDTLS_BASE64_C | ||
#define MBEDTLS_PEM_PARSE_C | ||
#define MBEDTLS_X509_CREATE_C |
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.
Why MBEDTLS_X509_CREATE_C
? I don't think it's needed in TLS tests.
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.
Actually, when compiling without MBEDTLS_X509_CREATE_C
, make test
fails:
make[1]: Entering directory '/home/nadav/Local/mbedtls/tests'
CC test_suite_x509write.c
/usr/bin/ld: /tmp/ccEzn7RP.o: in function `test_oid_from_numeric_string':
test_suite_x509write.c:(.text+0x1ca): undefined reference to `mbedtls_oid_from_numeric_string'
collect2: error: ld returned 1 exit status
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's a discrepancy between the library code and the test code: we shouldn't try to test a function that isn't defined. I think it makes sense that mbedtls_oid_from_numeric_string()
is only defined when MBEDTLS_X509_CREATE_C
is enabled. The test function has depends_on:MBEDTLS_X509_USE_C
, that looks like a mistake or copypasta. Would you mind changing this to depends_on:MBEDTLS_X509_CREATE_C
? Then you shouldn't need MBEDTLS_X509_CREATE_C
in the configuration.
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.
Yeah sure I'll do that :)
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.
Fixed in 8edf898.
configs/config-aes-gcm-tls1_3.h
Outdated
#define MBEDTLS_X509_USE_C | ||
|
||
/* Enable ECP algorithms */ | ||
#define MBEDTLS_ECP_DP_BP256R1_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.
I think there's more value in showing a minimal configuration where it's easy for people to add more things, than in showing a large configuration which will have people wondering what they can remove. A few things could have comments “if you need feature X, uncomment the next line”. For curves, I think it's fairly easy to figure out how to add one.
The current configuration with just AES-GCM and secp256r1 is close to what RFC 8446 §9.1 defines as the default minimal TLS 1.3 profile, except:
- No RSA here.
- There's
TLS_AES_256_GCM_SHA384
as well asTLS_AES_128_GCM_SHA256
.
I wonder if it would make sense to have exactly the RFC 8446 minimal profile? Or at least have comments explaining the differences?
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've done a full review. The configuration almost looks good to me. We'll need some testing, and the CI is slightly unhappy.
MBEDTLS_CONFIG="configs/config-aes-gcm-tls1_3.h" | ||
CC=$ASAN_CC cmake -D GEN_FILES=Off -DMBEDTLS_CONFIG_FILE="$MBEDTLS_CONFIG" -D CMAKE_BUILD_TYPE:String=Asan . | ||
make | ||
} |
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 run make test
. It's expected to pass in all configurations. It doesn't have a lot of TLS testing, but it has some, and that's better than nothing.
MBEDTLS_CONFIG="configs/config-aes-gcm-tls1_3.h" | ||
CC=$ASAN_CC cmake -D GEN_FILES=Off -DMBEDTLS_CONFIG_FILE="$MBEDTLS_CONFIG" -D CMAKE_BUILD_TYPE:String=Asan . | ||
make | ||
} |
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 run at least a subset of tests/ssl-opt.sh
, in a build with debug (like component_test_config_suite_b
).
(No compat.sh
because that's not applicable to TLS 1.3. For 1.3, the similar tests are in ssl-opt.sh
.)
In principle, we should just run tests/ssl-opt.sh
with no arguments. It has declarations to skip tests that rely on features that are missing from the configuration. In practice, that may or may not work, because ssl-opt.sh
is missing a lot of feature dependency statements. However, the TLS 1.3 tests are a lot cleaner than the older tests, so there's hope. Can you please try tests/ssl-opt.sh
? And if it's failing due to missing dependencies that aren't trivial to fix, either exclude problematic tests with -e 'REGEX'
or include only certain tests with -f 'REGEX'
. At least tests/ssl-opt.sh
with no option should skip all TLS 1.2 tests, since we already run it on 1.3-only configurations. What might be missing is dependencies on optional TLS 1.3 features or on cryptographic mechanisms.
Thank you all for your review. |
Signed-off-by: Nadav Tasher <[email protected]>
e198a22
to
d530841
Compare
Signed-off-by: Nadav Tasher <[email protected]>
Signed-off-by: Nadav Tasher <[email protected]>
…tring Signed-off-by: Nadav Tasher <[email protected]>
Description
Added a minimal configuration for a TLSv1.3-only client with certificate handshake support.
Useful for minimal clients in embedded solutions.
Can be tested using
mini_client
.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.