-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Zephyr TLS socket options #7118
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
Changes from all commits
de8465c
5303cb5
95207e7
9e9f822
b7dbf47
f0510d3
f38bc88
2ed2522
9ea8193
ef6c11c
8a3131a
029eee1
2c12867
ae911ca
d714929
071920a
353d667
0af76af
d9828bf
87bef22
bf8d3f9
4474b2e
cf322ec
18e80da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ config MBEDTLS_CFG_FILE | |
| string "mbed TLS configuration file" | ||
| depends on MBEDTLS_BUILTIN | ||
| default "config-mini-tls1_2.h" | ||
| default "config-tls-generic.h" if NET_TLS || NET_DTLS | ||
|
||
| help | ||
| Use a specific mbed TLS configuration file. The default is suitable to | ||
| communicate with majority of HTTPS servers on the Internet, but has | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,270 @@ | ||
| /* | ||
| * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved | ||
| * Copyright (c) 2017 Intel Corporation. | ||
| * Copyright (c) 2018 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Generic configuration for TLS, manageable by Kconfig. | ||
| */ | ||
|
|
||
| #ifndef MBEDTLS_CONFIG_H | ||
| #define MBEDTLS_CONFIG_H | ||
|
|
||
| /* System support */ | ||
| #define MBEDTLS_PLATFORM_C | ||
| #define MBEDTLS_PLATFORM_MEMORY | ||
| #define MBEDTLS_MEMORY_BUFFER_ALLOC_C | ||
| #define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS | ||
| #define MBEDTLS_PLATFORM_EXIT_ALT | ||
| #define MBEDTLS_NO_PLATFORM_ENTROPY | ||
| #define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES | ||
| #define MBEDTLS_PLATFORM_PRINTF_ALT | ||
|
|
||
| #if !defined(CONFIG_ARM) | ||
| #define MBEDTLS_HAVE_ASM | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_MBEDTLS_TEST) | ||
| #define MBEDTLS_SELF_TEST | ||
| #define MBEDTLS_DEBUG_C | ||
| #endif | ||
|
|
||
| /* mbedTLS feature support */ | ||
|
|
||
| /* Supported TLS versions */ | ||
| #if defined(CONFIG_NET_TLS) | ||
| #if defined(CONFIG_TLS_VERSION_1_0) | ||
| #define MBEDTLS_SSL_PROTO_TLS1 | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_VERSION_1_1) | ||
| #define MBEDTLS_SSL_PROTO_TLS1_1 | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_VERSION_1_2) | ||
| #define MBEDTLS_SSL_PROTO_TLS1_2 | ||
| #endif | ||
|
|
||
| /* Module required for TLS */ | ||
| #define MBEDTLS_SSL_TLS_C | ||
| #define MBEDTLS_SSL_SRV_C | ||
| #define MBEDTLS_SSL_CLI_C | ||
| #define MBEDTLS_CIPHER_C | ||
| #define MBEDTLS_MD_C | ||
|
|
||
| /* TODO Perhaps make this configurable? */ | ||
| #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH | ||
|
||
| #endif /* CONFIG_NET_TLS */ | ||
|
|
||
| #if defined(CONFIG_NET_DTLS) | ||
| #define MBEDTLS_SSL_PROTO_DTLS | ||
| #define MBEDTLS_SSL_DTLS_ANTI_REPLAY | ||
| #define MBEDTLS_SSL_DTLS_HELLO_VERIFY | ||
| #define MBEDTLS_SSL_COOKIE_C | ||
| #endif | ||
|
|
||
| /* Supported key exchange methods */ | ||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_PSK_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_DHE_PSK_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_RSA_PSK_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_RSA_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_DHE_RSA_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_KEY_EXCHANGE_ECJPAKE_ENABLED) | ||
| #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED | ||
| #endif | ||
|
|
||
| /* Supported cipher modes */ | ||
| #if defined(CONFIG_TLS_CIPHER_AES_ENABLED) | ||
| #define MBEDTLS_AES_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_CIPHER_CAMELLIA_ENABLED) | ||
| #define MBEDTLS_CAMELLIA_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_CIPHER_DES_ENABLED) | ||
| #define MBEDTLS_DES_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_CIPHER_CCM_ENABLED) | ||
| #define MBEDTLS_CCM_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_CIPHER_CBC_ENABLED) | ||
| #define MBEDTLS_CIPHER_MODE_CBC | ||
| #endif | ||
|
|
||
| /* Supported message authentication methods */ | ||
|
|
||
| #if defined(CONFIG_TLS_MAC_MD5_ENABLED) | ||
| #define MBEDTLS_MD5_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_MAC_SHA1_ENABLED) | ||
| #define MBEDTLS_SHA1_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_MAC_SHA256_ENABLED) | ||
| #define MBEDTLS_SHA256_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_TLS_MAC_SHA512_ENABLED) | ||
| #define MBEDTLS_SHA512_C | ||
| #endif | ||
|
|
||
| /* Automatic dependencies */ | ||
|
|
||
| #if defined (MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) | ||
| #define MBEDTLS_DHM_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) | ||
| #define MBEDTLS_ECDH_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) | ||
| #define MBEDTLS_RSA_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) | ||
| #define MBEDTLS_PKCS1_V15 | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \ | ||
| defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) | ||
| #define MBEDTLS_X509_CRT_PARSE_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) | ||
| #define MBEDTLS_ECDSA_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) | ||
| #define MBEDTLS_ECJPAKE_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_ECDH_C) || \ | ||
| defined(MBEDTLS_ECDSA_C) || \ | ||
| defined(MBEDTLS_ECJPAKE_C) | ||
| #define MBEDTLS_ECP_C | ||
| /* For now use single specific curve, can be configurable in the future */ | ||
| #define MBEDTLS_ECP_DP_SECP256R1_ENABLED | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_X509_CRT_PARSE_C) | ||
| #define MBEDTLS_X509_USE_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_X509_USE_C) || \ | ||
| defined(MBEDTLS_ECDSA_C) | ||
| #define MBEDTLS_ASN1_PARSE_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_ECDSA_C) | ||
| #define MBEDTLS_ASN1_WRITE_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_DHM_C) || \ | ||
| defined(MBEDTLS_ECP_C) || \ | ||
| defined(MBEDTLS_RSA_C) || \ | ||
| defined(MBEDTLS_X509_USE_C) | ||
| #define MBEDTLS_BIGNUM_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_RSA_C) || \ | ||
| defined(MBEDTLS_X509_USE_C) | ||
| #define MBEDTLS_OID_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_X509_USE_C) | ||
| #define MBEDTLS_PK_PARSE_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_PK_PARSE_C) | ||
| #define MBEDTLS_PK_C | ||
| #endif | ||
|
|
||
| /* mbedTLS modules */ | ||
| #if defined (CONFIG_NET_TLS_PEM_CERTIFICATE_FORMAT) && \ | ||
| defined(MBEDTLS_X509_CRT_PARSE_C) | ||
| #define MBEDTLS_PEM_PARSE_C | ||
| #define MBEDTLS_BASE64_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_AES_C) | ||
| #define MBEDTLS_CTR_DRBG_C | ||
| #endif | ||
|
|
||
| #if defined(MBEDTLS_SHA256_C) || defined(MBEDTLS_SHA512_C) | ||
| #define MBEDTLS_ENTROPY_C | ||
| #endif | ||
|
|
||
| /* For test certificates */ | ||
| #if defined(MBEDTLS_RSA_C) || defined(MBEDTLS_ECDSA_C) | ||
| #define MBEDTLS_CERTS_C | ||
| #endif | ||
|
|
||
| #if defined(CONFIG_MBEDTLS_DEBUG) | ||
| #define MBEDTLS_ERROR_C | ||
| #define MBEDTLS_DEBUG_C | ||
| #define MBEDTLS_SSL_DEBUG_ALL | ||
| #define MBEDTLS_SSL_ALL_ALERT_MESSAGES | ||
| #endif | ||
|
|
||
| #define MBEDTLS_SSL_MAX_CONTENT_LEN CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN | ||
|
|
||
| #include "mbedtls/check_config.h" | ||
|
|
||
| #endif /* MBEDTLS_CONFIG_H */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,9 @@ enum net_ip_protocol { | |
| IPPROTO_TCP = 6, | ||
| IPPROTO_UDP = 17, | ||
| IPPROTO_ICMPV6 = 58, | ||
| IPPROTO_TLS_1_0 = 256, | ||
|
||
| IPPROTO_TLS_1_1 = 257, | ||
| IPPROTO_TLS_1_2 = 258, | ||
| }; | ||
|
|
||
| /** Socket type */ | ||
|
|
||
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 do we have this change in this PR, instead of a separate small, clean PR, easy to review and merge?
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.
This is the pattern we are forced to use with github. In order to test the feature, all relevant patches need to be inside one PR (even if they are not fully related). This makes reviewing a bit painful but slightly faster to merge. I am personally trying to get gPTP patches reviewed but it is very slow because I am trying to send patches in smaller chunks which serializes the whole process.
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.
No, why suddenly? We used to work with Gerrit, which required a review per commit, and everything was "fine".
I'm not sure what you mean by "test". If you effectively mean "try/review", then splitting to another PR only makes it easier. And if you mean "test" literally, then we have unittest to check for regressions (and ideally, new tests should be added for new functionality, which we're behind of doing, but still easier to do in a small focused PR).
It's hardly possible to review such PRs thoroughly. How it worked before is:
So no, it doesn't make merging faster, but definitely makes it lower quality.
I don't think it's related. It's because of overall complexity of the matter, and that not everyone is familiar with the requirements for this protocol implementation in Zephyr, or with protocol itself. For example, I feel a bit shy to give +1 for it. (But then I'm sure there's no -1 at least in the initial patch I looked it, thanks to it being contained and easy to review).