From: "flichtenheld (Code Review)" Date: Wed, 18 Sep 2024 10:50:19 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <35d04bb835d08fe2cb539c0cc8cd7cb3a9426413-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="BjiQt/XKfV0="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: tests: Allow to test for arbitrary ciphers and digests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --BjiQt/XKfV0= 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/+/752?usp=3Demail to review the following change. Change subject: tests: Allow to test for arbitrary ciphers and digests ...................................................................... tests: Allow to test for arbitrary ciphers and digests Add program crypto_support that is more generic than ntlm_support. First intended usage is to test for availability of BF-CBC in t_client.sh. Change-Id: I6fe225db807626a79a160132ee05897554695597 Signed-off-by: Frank Lichtenheld --- M tests/Makefile.am A tests/crypto_support.c 2 files changed, 73 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/752/1 diff --git a/tests/Makefile.am b/tests/Makefile.am index f26b3b8..7b9f38a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -20,7 +20,7 @@ if !WIN32 test_scripts =3D t_client.sh t_lpback.sh t_cltsrv.sh t_server_null.sh -check_PROGRAMS =3D ntlm_support +check_PROGRAMS =3D ntlm_support crypto_support if HAVE_SITNL test_scripts +=3D t_net.sh endif @@ -57,3 +57,15 @@ $(top_srcdir)/src/openvpn/otime.c \ $(top_srcdir)/src/openvpn/packet_id.c \ $(top_srcdir)/src/openvpn/platform.c + +crypto_support_CFLAGS =3D -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src= /compat -I$(top_srcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@ +crypto_support_LDFLAGS =3D @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn $(OP= TIONAL_CRYPTO_LIBS) +crypto_support_SOURCES =3D crypto_support.c \ + unit_tests/openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \ + $(top_srcdir)/src/openvpn/buffer.c \ + $(top_srcdir)/src/openvpn/crypto.c \ + $(top_srcdir)/src/openvpn/crypto_openssl.c \ + $(top_srcdir)/src/openvpn/crypto_mbedtls.c \ + $(top_srcdir)/src/openvpn/otime.c \ + $(top_srcdir)/src/openvpn/packet_id.c \ + $(top_srcdir)/src/openvpn/platform.c diff --git a/tests/crypto_support.c b/tests/crypto_support.c new file mode 100644 index 0000000..fc4cbd1 --- /dev/null +++ b/tests/crypto_support.c @@ -0,0 +1,60 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2023-2024 OpenVPN Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "syshead.h" + +#include "crypto.h" +#include "error.h" + +#include + +int +main(int argc, char *argv[]) +{ +#if defined(ENABLE_CRYPTO_OPENSSL) + crypto_load_provider("legacy"); + crypto_load_provider("default"); +#endif + if (argc <=3D 2) + { + msg(M_FATAL, "Usage: ./crypto_support (cipher|digest) "); + } + if (strcmp(argv[1], "digest") =3D=3D 0) + { + if (!md_valid(argv[2])) + { + msg(M_FATAL, "digest %s not supported", argv[2]); + } + } + else if (strcmp(argv[1], "cipher") =3D=3D 0) + { + if (!cipher_valid(argv[2])) + { + msg(M_FATAL, "cipher %s not supported", argv[2]); + } + } +} -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/752?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: I6fe225db807626a79a160132ee05897554695597 Gerrit-Change-Number: 752 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --BjiQt/XKfV0= 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

tests: Allow to test for arbitrary ciphers and digests
Add program crypto_support that is more generic than
ntlm_support. Firs= t intended usage is to test for
availability of BF-CBC in t_client.sh.
Change-Id: I6fe225db807626a79a160132ee05897554695597
Signed-off-by= : Frank Lichtenheld <frank@...2641...>
---
M tests/Makefile.am<= br>A tests/crypto_support.c
2 files changed, 73 insertions(+), 1 deletio= n(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes=
/52/752/1
diff --git a/tests/Makefile.am b/tests/Makefile.am=

index f26b3b8..7b9f38a 100644
--- a/tests/Makefil= e.am
+++ b/tests/Makefile.am
@@ -20,7 +20,7= @@
if !WIN32
test_scripts =3D t_client.s= h t_lpback.sh t_cltsrv.sh t_server_null.sh

-check_PROGRAMS =3D ntlm_support
+check_PROGRAMS =3D ntlm_= support crypto_support
if HAVE_SITNL
test= _scripts +=3D t_net.sh
endif
@@ -57,3 +57,= 15 @@
$(top_srcdir)/src/openvpn/otime.c \
$(top_srcdir)/src/openvpn/packet_id.c \
$(top_srcdir)/= src/openvpn/platform.c
+crypto_support_C= FLAGS =3D -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat -I$(top_s= rcdir)/tests/unit_tests/openvpn -DNO_CMOCKA @TEST_CFLAGS@
+crypto_support_LDFLAGS =3D @TEST_LDFL= AGS@ -L$(top_srcdir)/src/openvpn $(OPTIONAL_CRYPTO_LIBS)
+crypto_support_SOURCES =3D crypto_supp= ort.c \
+ unit_tests/= openvpn/mock_msg.c unit_tests/openvpn/mock_msg.h \
+ $(top_srcdir)/src/openvpn/buffer.c \=
+ $(top_srcdir)/src/openvpn= /crypto.c \
+ $(top_s= rcdir)/src/openvpn/crypto_openssl.c \
+ $(top_srcdir)/src/openvpn/crypto_mbedtls.c \
<= span style=3D"color: hsl(120, 100%, 40%);">+ $(top_srcdir)/src/openvpn/otim= e.c \
+ $(top_srcdir)= /src/openvpn/packet_id.c \
+ $(top_srcdir)/src/openvpn/platform.c
diff --git a/t= ests/crypto_support.c b/tests/crypto_support.c
new file mod= e 100644
index 0000000..fc4cbd1
--- /dev/nu= ll
+++ b/tests/crypto_support.c
@@ -0,0 +1,= 60 @@
+/*
<= span style=3D"color: hsl(120, 100%, 40%);">+ * OpenVPN -- An application t= o securely tunnel IP networks
+ * over a single UDP port, with support for SSL/TLS-b= ased
+ * = session authentication and key exchange,
+ * packet encryption, packet authenticatio= n, and
+ * = packet compression.
+ *
+ * Copyright (C= ) 2023-2024 OpenVPN Inc <sales@...515...>
+ *
+ * This program is free software; you can redistribute it and/o= r modify
+ * it unde= r the terms of the GNU General Public License version 2
+ * as published by the Free Software F= oundation.
+ *=
+ * This program is distri= buted in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implie= d warranty of
+ * ME= RCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for = more details.
+ *
+ * You should have rec= eived a copy of the GNU General Public License along
+ * with this program; if not, write to t= he Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U= SA.
+ */
+

+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+#incl= ude "crypto.h"
+#include "error.h"
+
+#incl= ude <string.h>
= +
+int
+main(int argc, char *argv[])

+{
+#if defined(ENABLE_CRYPTO_OPENSSL)=
+ crypto_load_provider(&= quot;legacy");
+= crypto_load_provider("default");
+#endif
+ if (argc <=3D 2)
+ {
+ msg(M_FATAL, "Usage: ./crypto_support (cipher|digest) <= name>");
+ = }
+ if (strcmp(ar= gv[1], "digest") =3D=3D 0)
+ {
+ {
+ msg(M_FATAL, "digest %s not supported", argv[2])= ;
+ }+ }
+ else if (strcmp(argv[1], "cipher= ") =3D=3D 0)
+ = {
+ if (!cip= her_valid(argv[2]))
+= {
+ = msg(M_FATAL, "cipher %s not supported", argv[2]);
+ }
+ }
+}

To view, visit change 752<= /a>. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6fe225db807626a79a160132ee0= 5897554695597
Gerrit-Change-Number: 752
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
--BjiQt/XKfV0=--