From: "flichtenheld (Code Review)" Date: Tue, 14 Jan 2025 12:34:22 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <4ebb2404ad86ec3d03d8fb9960aca0f016ce8cb1-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="QBfGAfCyGuo="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: ssl_openssl: Clean up unused functions and add missing "static" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --QBfGAfCyGuo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/860?usp=3Demail to review the following change. Change subject: ssl_openssl: Clean up unused functions and add missing "sta= tic" ...................................................................... ssl_openssl: Clean up unused functions and add missing "static" Just some misc cleanups found while looking at the code. Change-Id: Ifa06a3cb843dbf6a9639164d12aabe572aab162c Signed-off-by: Frank Lichtenheld --- M src/openvpn/ssl_backend.h M src/openvpn/ssl_mbedtls.c M src/openvpn/ssl_openssl.c 3 files changed, 5 insertions(+), 50 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/860/1 diff --git a/src/openvpn/ssl_backend.h b/src/openvpn/ssl_backend.h index a6a9695..e25727f 100644 --- a/src/openvpn/ssl_backend.h +++ b/src/openvpn/ssl_backend.h @@ -529,12 +529,12 @@ * ***************************************/ -/* +/** * Print a one line summary of SSL/TLS session handshake. */ void print_details(struct key_state_ssl *ks_ssl, const char *prefix); -/* +/** * Show the TLS ciphers that are available for us to use in the * library depending on the TLS version. This function prints * a list of ciphers without headers/footers. @@ -549,17 +549,11 @@ const char *tls_cert_profile, bool tls13); -/* +/** * Show the available elliptic curves in the crypto library */ void show_available_curves(void); -/* - * The OpenSSL library has a notion of preference in TLS ciphers. Higher - * preference =3D=3D more secure. Return the highest preference cipher. - */ -void get_highest_preference_tls_cipher(char *buf, int size); - /** * return a pointer to a static memory area containing the * name and version number of the SSL library in use diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c index 56eef36..92b52fe 100644 --- a/src/openvpn/ssl_mbedtls.c +++ b/src/openvpn/ssl_mbedtls.c @@ -1585,20 +1585,6 @@ } } -void -get_highest_preference_tls_cipher(char *buf, int size) -{ - const char *cipher_name; - const int *ciphers =3D mbedtls_ssl_list_ciphersuites(); - if (*ciphers =3D=3D 0) - { - msg(M_FATAL, "Cannot retrieve list of supported SSL ciphers."); - } - - cipher_name =3D mbedtls_ssl_get_ciphersuite_name(*ciphers); - strncpynt(buf, cipher_name, size); -} - const char * get_ssl_library_version(void) { diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index 98eba9d..89d0328 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -354,7 +354,7 @@ return true; } =20 -void +static void convert_tls_list_to_openssl(char *openssl_ciphers, size_t len, const char = *ciphers) { /* Parse supplied cipher list and pass on to OpenSSL */ @@ -461,7 +461,7 @@ } } -void +static void convert_tls13_list_to_openssl(char *openssl_ciphers, size_t len, const char *ciphers) { @@ -2638,31 +2638,6 @@ #endif /* ifndef OPENSSL_NO_EC */ } -void -get_highest_preference_tls_cipher(char *buf, int size) -{ - SSL_CTX *ctx; - SSL *ssl; - const char *cipher_name; - - ctx =3D SSL_CTX_new(SSLv23_method()); - if (!ctx) - { - crypto_msg(M_FATAL, "Cannot create SSL_CTX object"); - } - ssl =3D SSL_new(ctx); - if (!ssl) - { - crypto_msg(M_FATAL, "Cannot create SSL object"); - } - - cipher_name =3D SSL_get_cipher_list(ssl, 0); - strncpynt(buf, cipher_name, size); - - SSL_free(ssl); - SSL_CTX_free(ctx); -} - const char * get_ssl_library_version(void) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/860?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ifa06a3cb843dbf6a9639164d12aabe572aab162c Gerrit-Change-Number: 860 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --QBfGAfCyGuo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

Vi= ew Change

ssl_openssl: Clean up unused functions and add missing "=
static"

Just some misc cleanups found while looking at the code= .

Change-Id: Ifa06a3cb843dbf6a9639164d12aabe572aab162c
Signed-off= -by: Frank Lichtenheld <frank@...2641...>
---
M src/openvpn/ssl= _backend.h
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_openssl.c3 files changed, 5 insertions(+), 50 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/60/860/1
diff --git=
 a/src/openvpn/ssl_backend.h b/src/openvpn/ssl_backend.h
in= dex a6a9695..e25727f 100644
--- a/src/openvpn/ssl_backend.h=
+++ b/src/openvpn/ssl_backend.h
@@ -529,12= +529,12 @@
*
*************************= **************/

-/*
+/**
* Print a one line summary of SSL/TLS session handshake.
*/
void print_details(struct key_state_ss= l *ks_ssl, const char *prefix);

-/*
+/**
* Show the TLS ciphers that are available = for us to use in the
* library depending on the TLS versi= on. This function prints
* a list of ciphers without head= ers/footers.
@@ -549,17 +549,11 @@
= const char *tls_cert_profile,
= bool tls13);

-/*

+/**
* Show the available elliptic cu= rves in the crypto library
*/
void show_= available_curves(void);

-/*
= - * The OpenSSL library has a notion of preference in TLS ciphers. Higher<= /span>
- * preference =3D=3D m= ore secure. Return the highest preference cipher.
- */
-void get_highest_preference_tls_cipher(char *buf, int size);
-
/**
* return a pointer to a static memory area containing the
* name and version number of the SSL library in usediff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c<= /span>
index 56eef36..92b52fe 100644
--- a/src/ope= nvpn/ssl_mbedtls.c
+++ b/src/openvpn/ssl_mbedtls.c@@ -1585,20 +1585,6 @@
}
}

-void
-get_highest_preference_= tls_cipher(char *buf, int size)
-{
- const = char *cipher_name;
- = const int *ciphers =3D mbedtls_ssl_list_ciphersuites();
- if (*ciphers =3D=3D 0)
- {

- msg(M_FATAL, "Cannot retrieve list of = supported SSL ciphers.");
- }
-=
- cipher_name =3D mbedtls_= ssl_get_ciphersuite_name(*ciphers);
- strncpynt(buf, cipher_name, size);
-}
-
const char *
get_ssl_library= _version(void)
{
diff --git a/src/openvpn/= ssl_openssl.c b/src/openvpn/ssl_openssl.c
index 98eba9d..89= d0328 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c

@@ -354,7 +354,7 @@
return true;
}
-void
+static void
convert_tls_list_= to_openssl(char *openssl_ciphers, size_t len, const char *ciphers) {
/* Parse supplied cipher list and pass on t= o OpenSSL */
@@ -461,7 +461,7 @@
}
}

-void
+sta= tic void
convert_tls13_list_to_openssl(char *openssl_ciphe= rs, size_t len,
const char *= ciphers)
{
@@ -2638,31 +2638,6 @@ #endif /* ifndef OPENSSL_NO_EC */
}

-void
-get_highest_preference_tls_cipher(= char *buf, int size)

-{=
- SSL_CTX *ctx;
- SSL *ssl;
<= span style=3D"color: hsl(0, 100%, 40%);">- const char *cipher_name;
-
- ctx =3D SSL_CTX_new(SSLv23_method());
- if (!ctx)
- {

- crypto_msg(M_FATAL, "Cannot create SSL= _CTX object");
- = }
- ssl =3D SSL_ne= w(ctx);
- if (!ssl)<= /span>
- {
- crypto_msg(M_FATAL, "Cann= ot create SSL object");
- }
-- cipher_name =3D SSL_get_ci= pher_list(ssl, 0);
- = strncpynt(buf, cipher_name, size);
-
- SSL= _free(ssl);
- SSL_CT= X_free(ctx);
-}<= br>-
const char = *
get_ssl_library_version(void)
{<= br>

To view, visit change 860. To unsubscribe, or for h= elp writing mail filters, visit settings.

<= /div>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifa06a3cb843dbf6a9639164d12a= abe572aab162c
Gerrit-Change-Number: 860
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-MessageType: newchange
--QBfGAfCyGuo=--