Change in openvpn[master]: Fix MBEDTLS_DEPRECATED_REMOVED build errors
A message that is not in the archive (sent off-list or not yet received): gerrit.1718271320000.If96c2ebd2af16b18ed34820e8c0531547e2076d9@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
to review the following change.
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Fix MBEDTLS_DEPRECATED_REMOVED build errors
This commit allows compiling OpenVPN with recent versions of mbed TLS if MBEDTLS_DEPRECATED_REMOVED is defined.
Also disables TLS 1.0 and 1.1 because these are dropped in recent versions of mbed TLS.
---
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_mbedtls.h
3 files changed, 72 insertions(+), 42 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/681/1
src/openvpn/mbedtls_compat.h +46 -0
@@ -40,6 +40,7 @@#include <mbedtls/cipher.h> #include <mbedtls/ctr_drbg.h> #include <mbedtls/dhm.h> +#include <mbedtls/ecp.h> #include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h>
@@ -51,6 +52,13 @@#include <psa/crypto.h> #endif +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +typedef uint16_t mbedtls_compat_group_id ; +#else +#define MBEDTLS_SSL_IANA_TLS_GROUP_NONE MBEDTLS_ECP_DP_NONE +typedef mbedtls_ecp_group_id mbedtls_compat_group_id ; +#endif +static inline void mbedtls_compat_psa_crypto_init (void ) {
@@ -64,6 +72,16 @@#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ } +static inline mbedtls_compat_group_id +mbedtls_compat_get_group_id (const mbedtls_ecp_curve_info *curve_info) +{ +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +return curve_info->tls_id; +#else +return curve_info->grp_id; +#endif +} +/* * In older versions of mbedtls, mbedtls_ctr_drbg_update() did not return an * error code, and it was deprecated in favor of mbedtls_ctr_drbg_update_ret()
@@ -124,6 +142,34 @@ }#if MBEDTLS_VERSION_NUMBER <0x03020100 +typedef enum { +MBEDTLS_SSL_VERSION_UNKNOWN ,/*!< Context not in use or version not yet negotiated. */ +MBEDTLS_SSL_VERSION_TLS1_2 =0x0303 ,/*!< (D)TLS 1.2 */ +MBEDTLS_SSL_VERSION_TLS1_3 =0x0304 ,/*!< (D)TLS 1.3 */ +}mbedtls_ssl_protocol_version ; + +static inline void +mbedtls_ssl_conf_min_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_min_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_max_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_max_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_groups (mbedtls_ssl_config *conf,mbedtls_compat_group_id *groups) +{ +mbedtls_ssl_conf_curves (conf, groups); +} +static inline size_t mbedtls_cipher_info_get_block_size (const mbedtls_cipher_info_t *cipher) {
src/openvpn/ssl_mbedtls.c +23 -41
130 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +3 -1
@@ -39,6 +39,8 @@#include <pkcs11-helper-1.0/pkcs11h-certificate.h> #endif +#include "mbedtls_compat.h" +typedef struct _buffer_entry buffer_entry ;struct _buffer_entry {
@@ -118,7 +120,7 @@#endif struct external_context external_key;/**< External key context */ int *allowed_ciphers;/**< List of allowed ciphers for this connection */ -mbedtls_ecp_group_id *groups;/**< List of allowed groups for this connection */ +mbedtls_compat_group_id *groups;/**< List of allowed groups for this connection */ mbedtls_x509_crt_profile cert_profile;/**< Allowed certificate types */ };
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
MaxF has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/681?usp=email )
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
I could ACK this, but I don't know if I should because I collaborated with Rein on this.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 13 Jun 2024 10:46:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: MaxF, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/681?usp=email )
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
Patchset:
PS1:
Generally looks sensible. But I would vote for splitting up the TLS version check and the other changes. Feels like that would make each change clearer.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Thu, 13 Jun 2024 13:47:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, plaisthos.
MaxF has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/681?usp=email )
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Quoted 1 line
Generally looks sensible. […]
Splitting up these changes is difficult because the new mbedtls_ssl_protocol_version enum doesn't contain values for TLS 1.0 or 1.1 in the first place.
Should we first make a commit to disable old TLS versions, and then a commit to switch to the new functions?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 13 Jun 2024 15:43:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: MaxF, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/681?usp=email )
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Quoted 1 line
Splitting up these changes is difficult because the new
mbedtls_ssl_protocol_versionenum doesn't co […]
Sounds good to me. I do not think it is important in which order they need to be applied, only that the first commit doesn't break anything.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Thu, 13 Jun 2024 19:44:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: MaxF <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: MaxF, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/681?usp=email )
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Quoted 1 line
Sounds good to me. […]
And when I say "doesn't break anything" I mean that like "building". Obviously it is fine to disable the TLS 1.0/1.1 support if that is what the commit intends to do 😎
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 1
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Thu, 13 Jun 2024 19:46:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: MaxF <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: MaxF, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Fix MBEDTLS_DEPRECATED_REMOVED build errors
This commit allows compiling OpenVPN with recent versions of mbed TLS if MBEDTLS_DEPRECATED_REMOVED is defined.
---
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_mbedtls.h
3 files changed, 75 insertions(+), 28 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/681/2
src/openvpn/mbedtls_compat.h +45 -0
@@ -40,6 +40,7 @@#include <mbedtls/cipher.h> #include <mbedtls/ctr_drbg.h> #include <mbedtls/dhm.h> +#include <mbedtls/ecp.h> #include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h>
@@ -51,6 +52,12 @@#include <psa/crypto.h> #endif +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +typedef uint16_t mbedtls_compat_group_id ; +#else +typedef mbedtls_ecp_group_id mbedtls_compat_group_id ; +#endif +static inline void mbedtls_compat_psa_crypto_init (void ) {
@@ -64,6 +71,16 @@#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ } +static inline mbedtls_compat_group_id +mbedtls_compat_get_group_id (const mbedtls_ecp_curve_info *curve_info) +{ +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +return curve_info->tls_id; +#else +return curve_info->grp_id; +#endif +} +/* * In older versions of mbedtls, mbedtls_ctr_drbg_update() did not return an * error code, and it was deprecated in favor of mbedtls_ctr_drbg_update_ret()
@@ -124,6 +141,34 @@ }#if MBEDTLS_VERSION_NUMBER <0x03020100 +typedef enum { +MBEDTLS_SSL_VERSION_UNKNOWN ,/*!< Context not in use or version not yet negotiated. */ +MBEDTLS_SSL_VERSION_TLS1_2 =0x0303 ,/*!< (D)TLS 1.2 */ +MBEDTLS_SSL_VERSION_TLS1_3 =0x0304 ,/*!< (D)TLS 1.3 */ +}mbedtls_ssl_protocol_version ; + +static inline void +mbedtls_ssl_conf_min_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_min_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_max_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_max_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_groups (mbedtls_ssl_config *conf,mbedtls_compat_group_id *groups) +{ +mbedtls_ssl_conf_curves (conf, groups); +} +static inline size_t mbedtls_cipher_info_get_block_size (const mbedtls_cipher_info_t *cipher) {
src/openvpn/ssl_mbedtls.c +27 -27
119 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +3 -1
@@ -39,6 +39,8 @@#include <pkcs11-helper-1.0/pkcs11h-certificate.h> #endif +#include "mbedtls_compat.h" +typedef struct _buffer_entry buffer_entry ;struct _buffer_entry {
@@ -118,7 +120,7 @@#endif struct external_context external_key;/**< External key context */ int *allowed_ciphers;/**< List of allowed ciphers for this connection */ -mbedtls_ecp_group_id *groups;/**< List of allowed groups for this connection */ +mbedtls_compat_group_id *groups;/**< List of allowed groups for this connection */ mbedtls_x509_crt_profile cert_profile;/**< Allowed certificate types */ };
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 2
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: MaxF, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
to look at the new patch set (#3).
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Fix MBEDTLS_DEPRECATED_REMOVED build errors
This commit allows compiling OpenVPN with recent versions of mbed TLS if MBEDTLS_DEPRECATED_REMOVED is defined.
---
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_mbedtls.h
3 files changed, 76 insertions(+), 29 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/681/3
src/openvpn/mbedtls_compat.h +45 -0
@@ -40,6 +40,7 @@#include <mbedtls/cipher.h> #include <mbedtls/ctr_drbg.h> #include <mbedtls/dhm.h> +#include <mbedtls/ecp.h> #include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h>
@@ -51,6 +52,12 @@#include <psa/crypto.h> #endif +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +typedef uint16_t mbedtls_compat_group_id ; +#else +typedef mbedtls_ecp_group_id mbedtls_compat_group_id ; +#endif +static inline void mbedtls_compat_psa_crypto_init (void ) {
@@ -64,6 +71,16 @@#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ } +static inline mbedtls_compat_group_id +mbedtls_compat_get_group_id (const mbedtls_ecp_curve_info *curve_info) +{ +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +return curve_info->tls_id; +#else +return curve_info->grp_id; +#endif +} +/* * In older versions of mbedtls, mbedtls_ctr_drbg_update() did not return an * error code, and it was deprecated in favor of mbedtls_ctr_drbg_update_ret()
@@ -124,6 +141,34 @@ }#if MBEDTLS_VERSION_NUMBER <0x03020100 +typedef enum { +MBEDTLS_SSL_VERSION_UNKNOWN ,/*!< Context not in use or version not yet negotiated. */ +MBEDTLS_SSL_VERSION_TLS1_2 =0x0303 ,/*!< (D)TLS 1.2 */ +MBEDTLS_SSL_VERSION_TLS1_3 =0x0304 ,/*!< (D)TLS 1.3 */ +}mbedtls_ssl_protocol_version ; + +static inline void +mbedtls_ssl_conf_min_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_min_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_max_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_max_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_groups (mbedtls_ssl_config *conf,mbedtls_compat_group_id *groups) +{ +mbedtls_ssl_conf_curves (conf, groups); +} +static inline size_t mbedtls_cipher_info_get_block_size (const mbedtls_cipher_info_t *cipher) {
src/openvpn/ssl_mbedtls.c +28 -28
120 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +3 -1
@@ -39,6 +39,8 @@#include <pkcs11-helper-1.0/pkcs11h-certificate.h> #endif +#include "mbedtls_compat.h" +typedef struct _buffer_entry buffer_entry ;struct _buffer_entry {
@@ -118,7 +120,7 @@#endif struct external_context external_key;/**< External key context */ int *allowed_ciphers;/**< List of allowed ciphers for this connection */ -mbedtls_ecp_group_id *groups;/**< List of allowed groups for this connection */ +mbedtls_compat_group_id *groups;/**< List of allowed groups for this connection */ mbedtls_x509_crt_profile cert_profile;/**< Allowed certificate types */ };
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 3
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: MaxF, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
to look at the new patch set (#4).
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Fix MBEDTLS_DEPRECATED_REMOVED build errors
This commit allows compiling OpenVPN with recent versions of mbed TLS if MBEDTLS_DEPRECATED_REMOVED is defined.
---
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_mbedtls.h
3 files changed, 75 insertions(+), 29 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/681/4
src/openvpn/mbedtls_compat.h +45 -0
@@ -40,6 +40,7 @@#include <mbedtls/cipher.h> #include <mbedtls/ctr_drbg.h> #include <mbedtls/dhm.h> +#include <mbedtls/ecp.h> #include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h>
@@ -51,6 +52,12 @@#include <psa/crypto.h> #endif +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +typedef uint16_t mbedtls_compat_group_id ; +#else +typedef mbedtls_ecp_group_id mbedtls_compat_group_id ; +#endif +static inline void mbedtls_compat_psa_crypto_init (void ) {
@@ -64,6 +71,16 @@#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ } +static inline mbedtls_compat_group_id +mbedtls_compat_get_group_id (const mbedtls_ecp_curve_info *curve_info) +{ +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +return curve_info->tls_id; +#else +return curve_info->grp_id; +#endif +} +/* * In older versions of mbedtls, mbedtls_ctr_drbg_update() did not return an * error code, and it was deprecated in favor of mbedtls_ctr_drbg_update_ret()
@@ -124,6 +141,34 @@ }#if MBEDTLS_VERSION_NUMBER <0x03020100 +typedef enum { +MBEDTLS_SSL_VERSION_UNKNOWN ,/*!< Context not in use or version not yet negotiated. */ +MBEDTLS_SSL_VERSION_TLS1_2 =0x0303 ,/*!< (D)TLS 1.2 */ +MBEDTLS_SSL_VERSION_TLS1_3 =0x0304 ,/*!< (D)TLS 1.3 */ +}mbedtls_ssl_protocol_version ; + +static inline void +mbedtls_ssl_conf_min_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_min_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_max_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_max_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_groups (mbedtls_ssl_config *conf,mbedtls_compat_group_id *groups) +{ +mbedtls_ssl_conf_curves (conf, groups); +} +static inline size_t mbedtls_cipher_info_get_block_size (const mbedtls_cipher_info_t *cipher) {
src/openvpn/ssl_mbedtls.c +27 -28
120 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +3 -1
@@ -39,6 +39,8 @@#include <pkcs11-helper-1.0/pkcs11h-certificate.h> #endif +#include "mbedtls_compat.h" +typedef struct _buffer_entry buffer_entry ;struct _buffer_entry {
@@ -118,7 +120,7 @@#endif struct external_context external_key;/**< External key context */ int *allowed_ciphers;/**< List of allowed ciphers for this connection */ -mbedtls_ecp_group_id *groups;/**< List of allowed groups for this connection */ +mbedtls_compat_group_id *groups;/**< List of allowed groups for this connection */ mbedtls_x509_crt_profile cert_profile;/**< Allowed certificate types */ };
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 4
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: MaxF, flichtenheld.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/681?usp=email )
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Patch Set 4: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 4
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: MaxF <[email protected]...>
Gerrit-Comment-Date: Tue, 18 Jun 2024 11:54:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v4 1/1 Fix MBEDTLS_DEPRECATED_REMOVED build errors
In reply to a message not in the archiveFrom: rein.vanbaaren <[email protected]...>
This commit allows compiling OpenVPN with recent versions of mbed TLS if MBEDTLS_DEPRECATED_REMOVED is defined.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/681
This mail reflects revision 4 of this Change.
Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
src/openvpn/mbedtls_compat.h +45 -0
@@ -40,6 +40,7 @@#include <mbedtls/cipher.h> #include <mbedtls/ctr_drbg.h> #include <mbedtls/dhm.h> +#include <mbedtls/ecp.h> #include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h>
@@ -51,6 +52,12 @@#include <psa/crypto.h> #endif +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +typedef uint16_t mbedtls_compat_group_id ; +#else +typedef mbedtls_ecp_group_id mbedtls_compat_group_id ; +#endif +static inline void mbedtls_compat_psa_crypto_init (void ) {
@@ -64,6 +71,16 @@#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ } +static inline mbedtls_compat_group_id +mbedtls_compat_get_group_id (const mbedtls_ecp_curve_info *curve_info) +{ +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +return curve_info->tls_id; +#else +return curve_info->grp_id; +#endif +} +/* * In older versions of mbedtls, mbedtls_ctr_drbg_update() did not return an * error code, and it was deprecated in favor of mbedtls_ctr_drbg_update_ret()
@@ -124,6 +141,34 @@ }#if MBEDTLS_VERSION_NUMBER <0x03020100 +typedef enum { +MBEDTLS_SSL_VERSION_UNKNOWN ,/*!< Context not in use or version not yet negotiated. */ +MBEDTLS_SSL_VERSION_TLS1_2 =0x0303 ,/*!< (D)TLS 1.2 */ +MBEDTLS_SSL_VERSION_TLS1_3 =0x0304 ,/*!< (D)TLS 1.3 */ +}mbedtls_ssl_protocol_version ; + +static inline void +mbedtls_ssl_conf_min_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_min_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_max_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_max_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_groups (mbedtls_ssl_config *conf,mbedtls_compat_group_id *groups) +{ +mbedtls_ssl_conf_curves (conf, groups); +} +static inline size_t mbedtls_cipher_info_get_block_size (const mbedtls_cipher_info_t *cipher) {
src/openvpn/ssl_mbedtls.c +27 -28
120 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +3 -1
@@ -39,6 +39,8 @@#include <pkcs11-helper-1.0/pkcs11h-certificate.h> #endif +#include "mbedtls_compat.h" +typedef struct _buffer_entry buffer_entry ;struct _buffer_entry {
@@ -118,7 +120,7 @@#endif struct external_context external_key;/**< External key context */ int *allowed_ciphers;/**< List of allowed ciphers for this connection */ -mbedtls_ecp_group_id *groups;/**< List of allowed groups for this connection */ +mbedtls_compat_group_id *groups;/**< List of allowed groups for this connection */ mbedtls_x509_crt_profile cert_profile;/**< Allowed certificate types */ };
[Openvpn-devel] [PATCH applied] Re: Fix MBEDTLS_DEPRECATED_REMOVED build errors
Mildly tested via GHA compilation. Not sure what option I need to really trigger an "it would break without that patch" scenario so not really tested that much.
Your patch has been applied to the master branch.
commit 8eb397de3656402872f9c9584c6f703b87b50762
Author: rein.vanbaaren Date: Tue Jun 18 14:01:26 2024 +0200
Fix MBEDTLS_DEPRECATED_REMOVED build errors
Signed-off-by: Max Fillinger <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28771.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
MaxF has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/681?usp=email )
Change subject: Fix MBEDTLS_DEPRECATED_REMOVED build errors
......................................................................
Fix MBEDTLS_DEPRECATED_REMOVED build errors
This commit allows compiling OpenVPN with recent versions of mbed TLS if MBEDTLS_DEPRECATED_REMOVED is defined.
Reviewed-on: http://gerrit.openvpn.net/c/openvpn/+/681
---
M src/openvpn/mbedtls_compat.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_mbedtls.h
3 files changed, 75 insertions(+), 29 deletions(-)
Approvals:
plaisthos: Looks good to me, approved
src/openvpn/mbedtls_compat.h +45 -0
@@ -40,6 +40,7 @@#include <mbedtls/cipher.h> #include <mbedtls/ctr_drbg.h> #include <mbedtls/dhm.h> +#include <mbedtls/ecp.h> #include <mbedtls/md.h> #include <mbedtls/pem.h> #include <mbedtls/pk.h>
@@ -51,6 +52,12 @@#include <psa/crypto.h> #endif +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +typedef uint16_t mbedtls_compat_group_id ; +#else +typedef mbedtls_ecp_group_id mbedtls_compat_group_id ; +#endif +static inline void mbedtls_compat_psa_crypto_init (void ) {
@@ -64,6 +71,16 @@#endif /* HAVE_MBEDTLS_PSA_CRYPTO_H && defined(MBEDTLS_PSA_CRYPTO_C) */ } +static inline mbedtls_compat_group_id +mbedtls_compat_get_group_id (const mbedtls_ecp_curve_info *curve_info) +{ +#if MBEDTLS_VERSION_NUMBER >=0x03000000 +return curve_info->tls_id; +#else +return curve_info->grp_id; +#endif +} +/* * In older versions of mbedtls, mbedtls_ctr_drbg_update() did not return an * error code, and it was deprecated in favor of mbedtls_ctr_drbg_update_ret()
@@ -124,6 +141,34 @@ }#if MBEDTLS_VERSION_NUMBER <0x03020100 +typedef enum { +MBEDTLS_SSL_VERSION_UNKNOWN ,/*!< Context not in use or version not yet negotiated. */ +MBEDTLS_SSL_VERSION_TLS1_2 =0x0303 ,/*!< (D)TLS 1.2 */ +MBEDTLS_SSL_VERSION_TLS1_3 =0x0304 ,/*!< (D)TLS 1.3 */ +}mbedtls_ssl_protocol_version ; + +static inline void +mbedtls_ssl_conf_min_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_min_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_max_tls_version (mbedtls_ssl_config *conf,mbedtls_ssl_protocol_version tls_version) +{ +int major = (tls_version >>8 ) &0xff ; +int minor = tls_version &0xff ; +mbedtls_ssl_conf_max_version (conf, major, minor); +} + +static inline void +mbedtls_ssl_conf_groups (mbedtls_ssl_config *conf,mbedtls_compat_group_id *groups) +{ +mbedtls_ssl_conf_curves (conf, groups); +} +static inline size_t mbedtls_cipher_info_get_block_size (const mbedtls_cipher_info_t *cipher) {
src/openvpn/ssl_mbedtls.c +27 -28
120 lines not on this page · raw message
src/openvpn/ssl_mbedtls.h +3 -1
@@ -39,6 +39,8 @@#include <pkcs11-helper-1.0/pkcs11h-certificate.h> #endif +#include "mbedtls_compat.h" +typedef struct _buffer_entry buffer_entry ;struct _buffer_entry {
@@ -118,7 +120,7 @@#endif struct external_context external_key;/**< External key context */ int *allowed_ciphers;/**< List of allowed ciphers for this connection */ -mbedtls_ecp_group_id *groups;/**< List of allowed groups for this connection */ +mbedtls_compat_group_id *groups;/**< List of allowed groups for this connection */ mbedtls_x509_crt_profile cert_profile;/**< Allowed certificate types */ };
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/681?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: If96c2ebd2af16b18ed34820e8c0531547e2076d9
Gerrit-Change-Number: 681
Gerrit-PatchSet: 5
Gerrit-Owner: MaxF <[email protected]...>
Gerrit-Reviewer: MaxF <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: comododragon <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged