From patchwork Sat Feb 4 06:40:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 3050 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp1685830dyk; Fri, 3 Feb 2023 22:41:18 -0800 (PST) X-Google-Smtp-Source: AK7set9t7r8qx33P9QOq3Oc6itGMbx+wSyfof56hiHJZBqCS43pNojKNKZ35eR6uEkqugsD9ZIxa X-Received: by 2002:aa7:809a:0:b0:593:efc9:17c9 with SMTP id v26-20020aa7809a000000b00593efc917c9mr5665522pff.12.1675492878019; Fri, 03 Feb 2023 22:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675492878; cv=none; d=google.com; s=arc-20160816; b=MwLokh1W0AOoWUtt+NxR3DOVVmGsawuOjR4HBQ439q0nYIYrgTL592c+iKLLTTaWR7 CtWgnZ+Amrz7fGyMHAVyhhFkEc3cHwZl8P+BnoPf1bxJzRYys9Zc83x4u5uIhTDuAzVC sEYW1CDwN2XCaqr8fd9knmFULk1a5dB5ytr29AmH4CFSVscJAH6hg0fIr55DMIKMw3hC C42htmZYvzcqoFFS3ZGYVWYyl+iaXY+/F4MTD4hhmhf0TqwsQdabM54D9V5TndRqq2oG /v9ayIqK840tptMJNhLND+CDQ26eqLkwX2yC8uFwrQMEIcorfEJub1CAtoVHQbHBaDVL LpyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=p043BQVJgIXHODx47zzvDk3XwpBgaxW5QH0W6yNnHlA=; b=VzDWwqw5Vv774SKGQMTjo9HHUZ2/qS6rH3jxQ2prq5mwJtJ/aqC+jh5w10pRFxihq3 xKbrQIfBH/l3qAo2L6tITjhtznfaZvBpNdIC6xU43JRT8THfqACV8jiueKAyRXj2NAyp v7mLSPdGGHiRHR+vmIOuFNz8G+rw8TiaKTTsreEcpQryA0hz7w0hkA9t5wfM7Rz/mqql USpUEiU8Zoncay82qLV5qVGZzAYiYfiILBDg3yA67V9/bRnEAKP24shMFhLjGSBTcH/8 dVAmrPGJJyHRA8Lf53w45SgpPt5fM/xlfRTwvvnOn3qa+pvC4G1PcfLF5T9n0CTjp0r8 AFHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=e6qkpHpJ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mH3vY1KO; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=QOzKrlcj; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id e188-20020a621ec5000000b00593d0ecaf38si4749347pfe.307.2023.02.03.22.41.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2023 22:41:17 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=e6qkpHpJ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mH3vY1KO; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=QOzKrlcj; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pOCDn-0000KZ-Uq; Sat, 04 Feb 2023 06:40:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pOCDm-0000KS-G0 for openvpn-devel@lists.sourceforge.net; Sat, 04 Feb 2023 06:40:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=T55Ae1uowFwUpt+X0Qu/EIdL9TjmnqyOZpH1YDKprvE=; b=e6qkpHpJVNo8N5QSGl2kxIMjgU KQ4j4Ujb/G6D/Gfi6n8f+4DZoY/JbphgkcuhYvB6MmcQTVr6/FADLvpjV1KIcxn6gDAthCYkX9D0Z MYGXu0aggxxBnT0yFJN0ztfcqjnvka73R9swS2BXGuDyTbxoSai1eter74h46kZtHQWI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=T55Ae1uowFwUpt+X0Qu/EIdL9TjmnqyOZpH1YDKprvE=; b=mH3vY1KOe7nZfmFUae2oKOiPe3 76SP2cvMDpHafh29Oz9vMrz1Tr4tifaZyKhmHaLD7T4Gda5tkhGBBnK2tiJBbnzdv//2GNCAyhVin If6ItD5RN0DEA8zF/p9riROUH9UhkzGvKUj/bc+DnPWLYhJk93j2nT6jaGs2hJCNrq3k=; Received: from mail-il1-f171.google.com ([209.85.166.171]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pOCDj-00ApXu-O2 for openvpn-devel@lists.sourceforge.net; Sat, 04 Feb 2023 06:40:21 +0000 Received: by mail-il1-f171.google.com with SMTP id i6so2948182ilq.8 for ; Fri, 03 Feb 2023 22:40:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T55Ae1uowFwUpt+X0Qu/EIdL9TjmnqyOZpH1YDKprvE=; b=QOzKrlcj8uU7Uinl7bG2kBWtKR2DwFdlbalJJCJf1dpA492i6FRQ0cFa/NHYhawLR7 zOvpdf1/tIMY/1kGHpoS6FstgUlylaEC95jIVShxzVPHSFGuiE7594ZMuZ7DB3HtQa/i SvN+INqJcRENi5fR1/bmyjAzAs4c/tvAlYYCEDs0ULkDCNLHYc+LcnhRNPhwQqCF6xQP DyYgXfy3pW0V9l5fQnIZ/aKkZNkfbH2lN8OKfwsb/U8LmOOOvKwh9JKZAzB6m9CiqocV MEopWVI0yGF/3myHDRB9qwX3GFz2gEj+oam8Qm1hSvtrEeJZfn8FVV8DKQ/SQe1I5clq a5+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T55Ae1uowFwUpt+X0Qu/EIdL9TjmnqyOZpH1YDKprvE=; b=C0kNLjuNyN9bShyQ3/Cs8NgDkbE9VtFS5AFWhyLbNtaXoox398QH+0xtluhKXnU9e4 qbFaP2f7gilc+Kzrajfv3PIwonoT11N7OcbXY61GmrUKmdY8rq7Iz3WCdRxhMB08tP8j ZoXlkxFDdhNyRSp1F72uaBQHakMzdW5OS9PxDCmuPhXNgUqy5AEkioEK28+KnHmHxqDd eMsXP0KWWm/nsNvHV4hpOm9rUXKKrsdOQ8Kd0Vj7umo+QWKSQ/9HX/Fh7ly4r0yIg04a iNpH3sBIGwtx03ZQDzu2nCPmnOKluE3LDsXZWvgnzvGKiEfVo/ucabUPS0L61GPtfN9r rrCA== X-Gm-Message-State: AO0yUKUtXPvve57Ezyu+xU5GwIyAdI+ogkzcfglluxUPz1mDN26Usc42 s30zWudZ+zDJs9O5qdGChAitdx4Tj6I= X-Received: by 2002:a92:c5b2:0:b0:310:9adc:e1bb with SMTP id r18-20020a92c5b2000000b003109adce1bbmr8231383ilt.0.1675492813802; Fri, 03 Feb 2023 22:40:13 -0800 (PST) Received: from uranus.sansel.ca (bras-vprn-tnhlon4053w-lp130-01-70-51-222-66.dsl.bell.ca. [70.51.222.66]) by smtp.gmail.com with ESMTPSA id 18-20020a056e0211b200b0030bfd384821sm1365072ilj.81.2023.02.03.22.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 22:40:13 -0800 (PST) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Sat, 4 Feb 2023 01:40:09 -0500 Message-Id: <20230204064010.257925-1-selva.nair@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204004512.250271-2-selva.nair@gmail.com> References: <20230204004512.250271-2-selva.nair@gmail.com> MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Selva Nair - Minor changes to the build system to include some dependencies for Windows build - test_tls_crypt not built as it will pull in win32.c and its dependencies Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [selva.nair[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.171 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.171 listed in wl.mailspike.net] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-Headers-End: 1pOCDj-00ApXu-O2 Subject: [Openvpn-devel] [PATCH v2 2/3] Build unit tests in mingw Windows build X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1756859252319732427?= X-GMAIL-MSGID: =?utf-8?q?1756881619870922153?= From: Selva Nair - Minor changes to the build system to include some dependencies for Windows build - test_tls_crypt not built as it will pull in win32.c and its dependencies - If cross-compiling, "make check" will only build the tests but not run any. Copy to Windows and run manually. Executables are in /tests/unit_tests/openvpn/.libs/ and these depend on cmocka.dll in addition to openssl libs that some tests link to. Building with mingw on Windows should run the tests (untested). v2: networking_testdriver was mistakenly enabled to run, while originally it was only set to build. Corrected. Signed-off-by: Selva Nair --- configure.ac | 2 ++ tests/Makefile.am | 2 ++ tests/unit_tests/example_test/Makefile.am | 2 ++ tests/unit_tests/openvpn/Makefile.am | 28 +++++++++++++++++++---- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 95d795c3..66ba6f38 100644 --- a/configure.ac +++ b/configure.ac @@ -364,6 +364,8 @@ case "$host" in ;; esac +AM_CONDITIONAL([CROSS_COMPILING], test "${cross_compiling}" = "yes") + PKG_PROG_PKG_CONFIG AC_PROG_CPP AC_PROG_INSTALL diff --git a/tests/Makefile.am b/tests/Makefile.am index 87dd7e17..a46f2573 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,10 +14,12 @@ MAINTAINERCLEANFILES = \ SUBDIRS = unit_tests +if !WIN32 test_scripts = t_client.sh t_lpback.sh t_cltsrv.sh if HAVE_SITNL test_scripts += t_net.sh endif +endif TESTS_ENVIRONMENT = top_srcdir="$(top_srcdir)" TESTS = $(test_scripts) diff --git a/tests/unit_tests/example_test/Makefile.am b/tests/unit_tests/example_test/Makefile.am index 04a5ad35..24eb0ba1 100644 --- a/tests/unit_tests/example_test/Makefile.am +++ b/tests/unit_tests/example_test/Makefile.am @@ -2,7 +2,9 @@ AUTOMAKE_OPTIONS = foreign check_PROGRAMS = example_testdriver example2_testdriver +if !CROSS_COMPILING TESTS = $(check_PROGRAMS) +endif example_testdriver_CFLAGS = @TEST_CFLAGS@ example_testdriver_LDFLAGS = @TEST_LDFLAGS@ diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 7720a85d..8d2386e0 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -7,14 +7,22 @@ test_binaries += argv_testdriver buffer_testdriver endif test_binaries += crypto_testdriver packet_id_testdriver auth_token_testdriver ncp_testdriver misc_testdriver \ - pkt_testdriver + pkt_testdriver if HAVE_LD_WRAP_SUPPORT +if !WIN32 test_binaries += tls_crypt_testdriver endif +endif test_binaries += provider_testdriver +if WIN32 +LDADD = -lws2_32 +endif + +if !CROSS_COMPILING TESTS = $(test_binaries) +endif check_PROGRAMS = $(test_binaries) if HAVE_SITNL @@ -31,12 +39,14 @@ argv_testdriver_SOURCES = test_argv.c mock_msg.c mock_msg.h \ mock_get_random.c \ $(openvpn_srcdir)/platform.c \ $(openvpn_srcdir)/buffer.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/argv.c buffer_testdriver_CFLAGS = @TEST_CFLAGS@ -I$(openvpn_srcdir) -I$(compat_srcdir) buffer_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(openvpn_srcdir) -Wl,--wrap=parse_line buffer_testdriver_SOURCES = test_buffer.c mock_msg.c mock_msg.h \ mock_get_random.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/platform.c crypto_testdriver_CFLAGS = @TEST_CFLAGS@ \ @@ -51,6 +61,7 @@ crypto_testdriver_SOURCES = test_crypto.c mock_msg.c mock_msg.h \ $(openvpn_srcdir)/packet_id.c \ $(openvpn_srcdir)/platform.c \ $(openvpn_srcdir)/mtu.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/mss.c packet_id_testdriver_CFLAGS = @TEST_CFLAGS@ \ @@ -63,14 +74,14 @@ packet_id_testdriver_SOURCES = test_packet_id.c mock_msg.c mock_msg.h \ $(openvpn_srcdir)/packet_id.c \ $(openvpn_srcdir)/platform.c \ $(openvpn_srcdir)/reliable.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/session_id.c - pkt_testdriver_CFLAGS = @TEST_CFLAGS@ \ -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) pkt_testdriver_LDFLAGS = @TEST_LDFLAGS@ pkt_testdriver_SOURCES = test_pkt.c mock_msg.c mock_msg.h \ -$(openvpn_srcdir)/argv.c \ + $(openvpn_srcdir)/argv.c \ $(openvpn_srcdir)/base64.c \ $(openvpn_srcdir)/buffer.c \ $(openvpn_srcdir)/crypto.c \ @@ -84,9 +95,10 @@ $(openvpn_srcdir)/argv.c \ $(openvpn_srcdir)/run_command.c \ $(openvpn_srcdir)/session_id.c \ $(openvpn_srcdir)/ssl_pkt.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/tls_crypt.c - +if !WIN32 tls_crypt_testdriver_CFLAGS = @TEST_CFLAGS@ \ -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) tls_crypt_testdriver_LDFLAGS = @TEST_LDFLAGS@ \ @@ -106,6 +118,7 @@ tls_crypt_testdriver_SOURCES = test_tls_crypt.c mock_msg.c mock_msg.h \ $(openvpn_srcdir)/packet_id.c \ $(openvpn_srcdir)/platform.c \ $(openvpn_srcdir)/run_command.c +endif if HAVE_SITNL networking_testdriver_CFLAGS = @TEST_CFLAGS@ \ @@ -136,6 +149,7 @@ provider_testdriver_SOURCES = test_provider.c mock_msg.c \ $(openvpn_srcdir)/buffer.c \ $(openvpn_srcdir)/base64.c \ mock_get_random.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/platform.c auth_token_testdriver_CFLAGS = @TEST_CFLAGS@ \ @@ -152,6 +166,7 @@ auth_token_testdriver_SOURCES = test_auth_token.c mock_msg.c \ $(openvpn_srcdir)/otime.c \ $(openvpn_srcdir)/packet_id.c \ $(openvpn_srcdir)/platform.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/base64.c @@ -169,6 +184,8 @@ ncp_testdriver_SOURCES = test_ncp.c mock_msg.c \ $(openvpn_srcdir)/otime.c \ $(openvpn_srcdir)/packet_id.c \ $(openvpn_srcdir)/platform.c \ + $(openvpn_srcdir)/win32-util.c \ + $(compat_srcdir)/compat-strsep.c \ $(openvpn_srcdir)/ssl_util.c misc_testdriver_CFLAGS = @TEST_CFLAGS@ \ @@ -177,8 +194,9 @@ misc_testdriver_CFLAGS = @TEST_CFLAGS@ \ misc_testdriver_LDFLAGS = @TEST_LDFLAGS@ misc_testdriver_SOURCES = test_misc.c mock_msg.c \ - mock_get_random.c \ + mock_get_random.c \ $(openvpn_srcdir)/buffer.c \ $(openvpn_srcdir)/options_util.c \ $(openvpn_srcdir)/ssl_util.c \ + $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/platform.c From patchwork Sat Feb 4 06:40:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selva Nair X-Patchwork-Id: 3049 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp1685831dyk; Fri, 3 Feb 2023 22:41:18 -0800 (PST) X-Google-Smtp-Source: AK7set8uYG5ofkBRWx1TWb5CmqwkmWXIM7GatUP+s2tSHAWcAkHbl9rpcpDWnRzdvHFcaE7CN2VX X-Received: by 2002:a05:6a20:7d88:b0:b5:a231:107f with SMTP id v8-20020a056a207d8800b000b5a231107fmr16611580pzj.12.1675492878067; Fri, 03 Feb 2023 22:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675492878; cv=none; d=google.com; s=arc-20160816; b=LqtdG4KKogbTvVU50g2Av+4kPFx5+Ku5/yb6nIvTzDS8fN/9R0jgedLysKUFiVvVHD b1E0qbXzobbvcQCszWnHoq/NA8F2VSJz5QRGMNx4J5JYbor8LCIv1SiVN9xqgaoWNJIK 11YSMadUvtWa3fzDXek66/JQEaNYY0uUBPGBD6d3zz+GP/jKGOf/9n3AvjouSxEVCVL+ dTqBu4ETz2Yt/tj+37ju1S3U8t1rN9z+ZYPh5mZpjv3s55pDUAKp+6XqfIesmiV8F8Ip mkDAGz7rAnmERH+oufLCcpJlZVlpVHG3yNJ/q67AMSUv1R+3fHlNNTQCBuu/myGegVrd We0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=MDziRzoIR+vgrNNliwl9xx8uccSlgGSWOe8cBXLqP/I=; b=ckjztGjpP0egk6CSM2ogjXTwoRt0RJO+xwdy67v9gsV7QLujMqylQY8EiVSFelUAxp Vvxh9SMk8lVx7qAUn9eA0gvGj/W6zAuZSuvOgeVWUztN9t+TbHBJTPMuIJeXc2w7U7Gt ki+ZkZKo5QHIyHAEeFJQFUD/x7iKqNS71DIKepvTZgx2VRa9m1QPHTIugIksMLu3vIJT KIxC3bQMUL70PxESeELK2nE+zpnciYZ9R8rAzuo7Q445rdJN+LJUejuNilcfFP2hYngz cn8TJvmuFdzdCLoNKgdR9bKihMHcHJKZ9clk3UI3hdG+lhnYTtWLJ8LDR/PpCaL8QoHC AKpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=htWYw67e; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=KgOKP72K; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=qtHBMR4A; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id p17-20020a637411000000b004cd1e13283fsi5184128pgc.318.2023.02.03.22.41.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2023 22:41:18 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=htWYw67e; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=KgOKP72K; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=qtHBMR4A; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pOCDp-0000qD-64; Sat, 04 Feb 2023 06:40:24 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pOCDn-0000q7-Lh for openvpn-devel@lists.sourceforge.net; Sat, 04 Feb 2023 06:40:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0y+994P5JiKutMN6z75w8esE/bC5PZVg9kwFWCl8R+Y=; b=htWYw67e2lsdxDzr1yXFpiB5o2 DAjSz8Jl/Z+0AOjPbU+eNI4WPV5ICVhmWO0F61Y3wDvGInnU4Y7XF58yPCLUOr/cmN1euZpRBNBno VBrf0WSNtRyS3L+H5DX77/+Su2VxtjZHERT7CSe1Ub0o09czJdpB6eZmE5Q3qDrnfxNY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0y+994P5JiKutMN6z75w8esE/bC5PZVg9kwFWCl8R+Y=; b=KgOKP72K//R4C8+WbqCShSYLro LVcQfrDVv7XBY7hFrjDuuKVcYqGWNvKWpE8voYeLQ2oRg8qGDMV9tnE2ed9TmuOvi3J92BXRoQApk 3CsncJ33Pe7w6RnP33HXtGv5lZPzYS0lVJ2lBv+EgoUupeKUZFiFRD9olWtkaOzPNYzs=; Received: from mail-il1-f181.google.com ([209.85.166.181]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1pOCDk-0006rM-Bl for openvpn-devel@lists.sourceforge.net; Sat, 04 Feb 2023 06:40:22 +0000 Received: by mail-il1-f181.google.com with SMTP id u7so2952602ilg.4 for ; Fri, 03 Feb 2023 22:40:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0y+994P5JiKutMN6z75w8esE/bC5PZVg9kwFWCl8R+Y=; b=qtHBMR4AIlBdpEoauqgoewcjUYoigmx+6hHEB0iq7YerJ+j+f7tkiTipjIdyorUqf4 mTj9RHF6G3K9ccpqTfhKoTFqyWlNNoOWOekM0mLjAFh5p2wuMepFQAfj16rEs2JltbOZ hUBbcVt4OltmLgck3wh6K+H04oEFmwE/hMQjpok+gd4XFZoqNyBAN4tz75i1ra0WZUMh MvYHQ8bbY1/b0PROQ4Quxyz0luDBk3CYA5Pk1nZ0d+/DxQrl5Zeo6LjHE+ao7y6tdWBG XqsreoTm9XzYFJw56WV/nddqAHxRnbfcQOYVho1OAe1xtjS0Ixd8UDbsQxDEhK7/AXmP 6msQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0y+994P5JiKutMN6z75w8esE/bC5PZVg9kwFWCl8R+Y=; b=MkQLSJ1+hDLEsZ3L30N4UPmEsq7Mm9q5+4RjUSla1JL3McYKEmqW3sPoCr2Y5qO3Sk D6n41DQT+/kgNc7KO1t0oNNNp4UrUubLx2muTdY/760ZbX9BAhJEC2Y8mS2jgc2sdrom NqBnUOjpiaYe1GdtV3C4LNTiBZAOzw2qHI358unKh+ydFffCfjSw0aA2/lGeN/JlXvpt VjSWExe9U0olMyN/cAmNOwx1HKa7Bfdc9DJlKpkRwMOp6sFFGqA2uhBE56wB4aGzCJPq N/CCpEC6wmxWAKWs1XHBEJHihe2bpvkuKI8UkuHYD4rqym8gnHjAn+9kAKwnxDBGEfPi wY1Q== X-Gm-Message-State: AO0yUKXAxOczdZ3sci/aQnG30+VRE9HTyoe/j4OQumIO9lc16gwAKPCx 1G/DMTbvuhJYYiHTqnQKLwTXmqpAbTo= X-Received: by 2002:a05:6e02:221e:b0:304:c683:3c8a with SMTP id j30-20020a056e02221e00b00304c6833c8amr8588711ilf.3.1675492815286; Fri, 03 Feb 2023 22:40:15 -0800 (PST) Received: from uranus.sansel.ca (bras-vprn-tnhlon4053w-lp130-01-70-51-222-66.dsl.bell.ca. [70.51.222.66]) by smtp.gmail.com with ESMTPSA id 18-20020a056e0211b200b0030bfd384821sm1365072ilj.81.2023.02.03.22.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 22:40:15 -0800 (PST) From: selva.nair@gmail.com To: openvpn-devel@lists.sourceforge.net Date: Sat, 4 Feb 2023 01:40:10 -0500 Message-Id: <20230204064010.257925-2-selva.nair@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204064010.257925-1-selva.nair@gmail.com> References: <20230204004512.250271-2-selva.nair@gmail.com> <20230204064010.257925-1-selva.nair@gmail.com> MIME-Version: 1.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Selva Nair - Though named cryptoapi_testdriver, right now this only tests parsing of thumbprint specified as a selector for --cryptioapicert option. More tests coming.. v2: a line that belongs here was mistakenly included in the previous commit. Corrected. Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [selva.nair[at]gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.166.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.181 listed in wl.mailspike.net] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1pOCDk-0006rM-Bl Subject: [Openvpn-devel] [PATCH v2 3/3] Add a unit test for functions in cryptoapi.c X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1756881620371918184?= X-GMAIL-MSGID: =?utf-8?q?1756881620371918184?= From: Selva Nair - Though named cryptoapi_testdriver, right now this only tests parsing of thumbprint specified as a selector for --cryptioapicert option. More tests coming.. v2: a line that belongs here was mistakenly included in the previous commit. Corrected. Signed-off-by: Selva Nair --- tests/unit_tests/openvpn/Makefile.am | 16 +++ tests/unit_tests/openvpn/test_cryptoapi.c | 126 ++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 tests/unit_tests/openvpn/test_cryptoapi.c diff --git a/tests/unit_tests/openvpn/Makefile.am b/tests/unit_tests/openvpn/Makefile.am index 8d2386e0..ee0a3d8a 100644 --- a/tests/unit_tests/openvpn/Makefile.am +++ b/tests/unit_tests/openvpn/Makefile.am @@ -17,6 +17,7 @@ endif test_binaries += provider_testdriver if WIN32 +test_binaries += cryptoapi_testdriver LDADD = -lws2_32 endif @@ -152,6 +153,21 @@ provider_testdriver_SOURCES = test_provider.c mock_msg.c \ $(openvpn_srcdir)/win32-util.c \ $(openvpn_srcdir)/platform.c +if WIN32 +cryptoapi_testdriver_CFLAGS = @TEST_CFLAGS@ \ + -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) \ + $(OPTIONAL_CRYPTO_CFLAGS) +cryptoapi_testdriver_LDFLAGS = @TEST_LDFLAGS@ \ + $(OPTIONAL_CRYPTO_LIBS) -lcrypt32 -lncrypt +cryptoapi_testdriver_SOURCES = test_cryptoapi.c mock_msg.c \ + $(openvpn_srcdir)/xkey_helper.c \ + $(openvpn_srcdir)/buffer.c \ + $(openvpn_srcdir)/base64.c \ + $(openvpn_srcdir)/platform.c \ + mock_get_random.c \ + $(openvpn_srcdir)/win32-util.c +endif + auth_token_testdriver_CFLAGS = @TEST_CFLAGS@ \ -I$(openvpn_includedir) -I$(compat_srcdir) -I$(openvpn_srcdir) \ $(OPTIONAL_CRYPTO_CFLAGS) diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/openvpn/test_cryptoapi.c new file mode 100644 index 00000000..2bea3f42 --- /dev/null +++ b/tests/unit_tests/openvpn/test_cryptoapi.c @@ -0,0 +1,126 @@ +/* + * 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 Selva Nair + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 2 of the License, + * or (at your option) any later version. + * + * 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" +#elif defined(_MSC_VER) +#include "config-msvc.h" +#endif + +#include "syshead.h" +#include "manage.h" +#include "integer.h" +#include "xkey_common.h" + +#if defined(HAVE_XKEY_PROVIDER) && defined (ENABLE_CRYPTOAPI) +#include +#include +#include +#include +#include +#include + +#include +#include /* pull-in the whole file to test static functions */ + +struct management *management; /* global */ + +/* mock a management function that xkey_provider needs */ +char * +management_query_pk_sig(struct management *man, const char *b64_data, + const char *algorithm) +{ + (void) man; + (void) b64_data; + (void) algorithm; + return NULL; +} + +/* tls_libctx is defined in ssl_openssl.c which we do not want to compile in */ +OSSL_LIB_CTX *tls_libctx; + +#ifndef _countof +#define _countof(x) sizeof((x))/sizeof(*(x)) +#endif + +/* test data */ +static const uint8_t test_hash[] = { + 0x77, 0x38, 0x65, 0x00, 0x1e, 0x96, 0x48, 0xc6, 0x57, 0x0b, 0xae, + 0xc0, 0xb7, 0x96, 0xf9, 0x66, 0x4d, 0x5f, 0xd0, 0xb7 +}; + +/* valid test strings to test with and without embedded and trailing spaces */ +static const char *valid_str[] = { + "773865001e9648c6570baec0b796f9664d5fd0b7", + " 77 386500 1e 96 48 c6570b aec0b7 96f9664d5f d0 b7", + " 773865001e9648c6570baec0b796f9664d5fd0b7 ", +}; + +/* some invalid strings to test with and without embedded and trailing spaces */ +static const char *invalid_str[] = { + "773 865001e9648c6570baec0b796f9664d5fd012", /* space within byte */ + "77:38:65001e9648c6570baec0b796f9664d5fd0b7", /* invalid separator */ + "7738x5001e9648c6570baec0b796f9664d5fd0b7", /* non hex character */ +}; + +static void +test_parse_hexstring(void **state) +{ + unsigned char hash[255]; + (void) state; + + for (int i = 0; i < _countof(valid_str); i++) + { + int len = parse_hexstring(valid_str[i], hash, _countof(hash)); + assert_int_equal(len, sizeof(test_hash)); + assert_memory_equal(hash, test_hash, sizeof(test_hash)); + memset(hash, 0, _countof(hash)); + } + + for (int i = 0; i < _countof(invalid_str); i++) + { + int len = parse_hexstring(invalid_str[i], hash, _countof(hash)); + assert_int_equal(len, 0); + } +} + +int +main(void) +{ + const struct CMUnitTest tests[] = { cmocka_unit_test(test_parse_hexstring) }; + + int ret = cmocka_run_group_tests_name("cryptoapi tests", tests, NULL, NULL); + + return ret; +} + +#else /* ifdef HAVE_XKEY_PROVIDER */ + +int +main(void) +{ + return 0; +} + +#endif /* ifdef HAVE_XKEY_PROVIDER */