From: "cron2 (Code Review)" Date: Tue, 8 Apr 2025 11:31:06 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., antonio@...2726... Message-ID: <79e74015b4a75f6cee035531eeab549c5c2807aa-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="1tBBO8j47Vc="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Use SSL_get0_peer_signature_name instead of SSL_get_peer_signature_nid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: flichtenheld , openvpn-devel --1tBBO8j47Vc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/92= 7?usp=3Demail ) Change subject: Use SSL_get0_peer_signature_name instead of SSL_get_peer_si= gnature_nid ...................................................................... Use SSL_get0_peer_signature_name instead of SSL_get_peer_signature_nid SSL_get0_peer_signature_name returns a string instead of hardcoded NIDs. NIDS do not work with provider provided signatures or the new PQ signatures introduced in OpenSSL 3.5. Remove also the comment that was added earlier that says that there is no proper API replacement for SSL_get_peer_signature_nid yet as OpenSSL 3.5.0 has now introduced it. Change-Id: I2bc782ceebcc91a8dc8ada0bb72ac042be46cad6 Signed-off-by: Arne Schwabe Acked-by: Antonio Quartulli Message-Id: <20250402153337.5262-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31= 336.html Signed-off-by: Gert Doering --- M src/openvpn/openssl_compat.h M src/openvpn/ssl_openssl.c 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index 3e3b406..e2bd9bf 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -173,4 +173,30 @@ #endif /* OPENSSL_VERSION_NUMBER < 0x30000000L */ +#if OPENSSL_VERSION_NUMBER < 0x30500000 && (!defined(LIBRESSL_VERSION_NUMB= ER) || LIBRESSL_VERSION_NUMBER > 0x3050400fL) +static inline int +SSL_get0_peer_signature_name(SSL *ssl, const char **sigalg) +{ + int peer_sig_nid; + if (SSL_get_peer_signature_nid(ssl, &peer_sig_nid) + && peer_sig_nid !=3D NID_undef) + { + *sigalg =3D OBJ_nid2sn(peer_sig_nid); + return 1; + } + return 0; +} +#elif defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER <=3D 0x3= 050400fL +/* The older LibreSSL version do not implement any variant of getting the = peer + * signature */ +static inline int +SSL_get0_peer_signature_name(const SSL *ssl, const char **sigalg) +{ + *sigalg =3D NULL; + return 0; +} +#endif /* if OPENSSL_VERSION_NUMBER < 0x30500000 && (!defined(LIBRESSL_VER= SION_NUMBER) || LIBRESSL_VERSION_NUMBER > 0x3050400fL) */ + + + #endif /* OPENSSL_COMPAT_H_ */ diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index aad79a4..23b0266 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -2454,20 +2454,17 @@ static void print_peer_signature(SSL *ssl, char *buf, size_t buflen) { - int peer_sig_nid =3D NID_undef, peer_sig_type_nid =3D NID_undef; - const char *peer_sig =3D "unknown"; + int peer_sig_type_nid =3D NID_undef; + const char *peer_sig_unknown =3D "unknown"; + const char *peer_sig =3D peer_sig_unknown; const char *peer_sig_type =3D "unknown type"; - /* Even though these methods use the deprecated NIDs instead of using - * string as new OpenSSL APIs do, there seem to be no API that replaces - * it yet */ -#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER > 0x30504= 00fL - if (SSL_get_peer_signature_nid(ssl, &peer_sig_nid) - && peer_sig_nid !=3D NID_undef) + const char *signame =3D NULL; + SSL_get0_peer_signature_name(ssl, &signame); + if (signame) { - peer_sig =3D OBJ_nid2sn(peer_sig_nid); + peer_sig =3D signame; } -#endif #if !defined(LIBRESSL_VERSION_NUMBER) \ || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >=3D 0= x3090000fL) @@ -2480,7 +2477,7 @@ } #endif - if (peer_sig_nid =3D=3D NID_undef && peer_sig_type_nid =3D=3D NID_unde= f) + if (peer_sig =3D=3D peer_sig_unknown && peer_sig_type_nid =3D=3D NID_u= ndef) { return; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/927?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: I2bc782ceebcc91a8dc8ada0bb72ac042be46cad6 Gerrit-Change-Number: 927 Gerrit-PatchSet: 5 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --1tBBO8j47Vc= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Use SSL_get0_peer_signature_name instead of SS=
L_get_peer_signature_nid

SSL_get0_peer_signature_name returns a stri= ng instead of hardcoded NIDs.
NIDS do not work with provider provided si= gnatures or the new PQ
signatures introduced in OpenSSL 3.5.

Remo= ve also the comment that was added earlier that says that there
is no pr= oper API replacement for SSL_get_peer_signature_nid yet as
OpenSSL 3.5.0= has now introduced it.

Change-Id: I2bc782ceebcc91a8dc8ada0bb72ac042= be46cad6
Signed-off-by: Arne Schwabe <arne@...1227...>
Acked-by= : Antonio Quartulli <antonio@...2726...>
Message-Id: <202504021= 53337.5262-1-gert@...1296...>
URL: https://www.mail-archive.com/openv= pn-devel@lists.sourceforge.net/msg31336.html
Signed-off-by: Gert Doering= <gert@...1296...>
---
M src/openvpn/openssl_compat.h
M src/= openvpn/ssl_openssl.c
2 files changed, 34 insertions(+), 11 deletions(-)=

diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h=

index 3e3b406..e2bd9bf 100644
--- a/src/op= envpn/openssl_compat.h
+++ b/src/openvpn/openssl_compat.h
@@ -173,4 +173,30 @@

#end= if /* OPENSSL_VERSION_NUMBER < 0x30000000L */
+#if OPENSSL_VERSION_NUMBER &= lt; 0x30500000 && (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VE= RSION_NUMBER > 0x3050400fL)
+static inline int
+SSL_get0_peer_signature_name(SSL *ssl, const char **sigalg)=
+{
+ int peer_sig_nid;
+ if (SSL_get_peer_signature_nid(ssl, &= amp;peer_sig_nid)
+ = && peer_sig_nid !=3D NID_undef)
+ {
+ *sigalg =3D OBJ_nid2sn(peer_sig_nid);
+ return 1;
+ }
+ return 0;
+}
+#e= lif defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER <= ;=3D 0x3050400fL
+/* = The older LibreSSL version do not implement any variant of getting the peer=
+ * signature */

+static inline int
+SSL_get0_peer_signature_n= ame(const SSL *ssl, const char **sigalg)
+{
+ return 0;
+}=
+#endif /* if OPENSS= L_VERSION_NUMBER < 0x30500000 && (!defined(LIBRESSL_VERSION_NUMB= ER) || LIBRESSL_VERSION_NUMBER > 0x3050400fL) */
+
+
+
#endif /* OPENSSL_COMPAT_H_ */
diff --git a/s= rc/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index = aad79a4..23b0266 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -2454,20 +2= 454,17 @@
static void
print_peer_signatur= e(SSL *ssl, char *buf, size_t buflen)
{
- int peer_sig_nid =3D NID_undef, peer= _sig_type_nid =3D NID_undef;
- const char *peer_sig =3D "unknown";
+ int peer_sig_type_nid =3D NID_unde= f;
+ const char *p= eer_sig_unknown =3D "unknown";
+ const char *peer_sig =3D peer_sig_unknown;<= br> const char *peer_sig_type =3D "unknown type";

- /* Ev= en though these methods use the deprecated NIDs instead of using
= - * string as new OpenSSL API= s do, there seem to be no API that replaces
- * it yet */
-#if !defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_= NUMBER > 0x3050400fL
- if (SSL_get_peer_signature_nid(ssl, &peer_sig_nid)
- && peer_sig_nid !=3D= NID_undef)

+ cons= t char *signame =3D NULL;
+ SSL_get0_peer_signature_name(ssl, &signame);
+ if (signame)
= {
- peer_sig = =3D OBJ_nid2sn(peer_sig_nid);
+ peer_sig =3D signame;
}
-#endif

#if !defined(LIBRESSL_VERSION_NUMBER) \
|| (de= fined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >=3D 0= x3090000fL)
@@ -2480,7 +2477,7 @@
}
#endif

- if (peer_sig_nid =3D=3D NID_undef && peer_sig= _type_nid =3D=3D NID_undef)
+ if (peer_sig =3D=3D peer_sig_unknown && peer_sig_type_n= id =3D=3D NID_undef)
{
return= ;
}

To view, visit= change 9= 27. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2bc782ceebcc91a8dc8ada0bb72= ac042be46cad6
Gerrit-Change-Number: 927
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <antonio@...2726...&= gt;
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--1tBBO8j47Vc=--