From patchwork Wed Jan 19 23:11:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2236 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.31.255.6]) by backend41.mail.ord1d.rsapps.net with LMTP id 5JtlKJc16WEKEwAAqwncew (envelope-from ) for ; Thu, 20 Jan 2022 05:12:39 -0500 Received: from proxy5.mail.iad3b.rsapps.net ([172.31.255.6]) by director9.mail.ord1d.rsapps.net with LMTP id yEW2MZc16WFqQQAAalYnBA (envelope-from ) for ; Thu, 20 Jan 2022 05:12:39 -0500 Received: from smtp19.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy5.mail.iad3b.rsapps.net with LMTPS id eJTcKpc16WHcUgAA13hMnw (envelope-from ) for ; Thu, 20 Jan 2022 05:12:39 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp19.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 7e602fce-79d9-11ec-ab0a-525400cbaf6c-1-1 Received: from [216.105.38.7] ([216.105.38.7:59048] helo=lists.sourceforge.net) by smtp19.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 9D/E1-05396-69539E16; Thu, 20 Jan 2022 05:12:39 -0500 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.94.2) (envelope-from ) id 1nAUPj-00032W-O9; Thu, 20 Jan 2022 10:11:30 +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.94.2) (envelope-from ) id 1nAUPh-00032E-P4 for openvpn-devel@lists.sourceforge.net; Thu, 20 Jan 2022 10:11:28 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CnonR9i+Sq6kbGPW5ZvqB7mnuMN+qcpcYN1dMhJY4AY=; b=ORPK93iIQPIa4pNLy3/NRpLlLf 412A5YweCnDyW51RDOmz96WOwf/bq6OBZwRKm7yRygz904gqStcEZuVMVK/5pY4Fge4j4jNA+6gPt n/80kfDTzK81ZRxlUzzzFtl+2CxGrAuwPkvt/SGcfRkSxR8DOcrMMmFX3SITq21wLGnw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=CnonR9i+Sq6kbGPW5ZvqB7mnuMN+qcpcYN1dMhJY4AY=; b=U ZUVZQ8clG98Cqy8rP8vMI+Dk8RBL9O3huUZgtzsG+76aWI21C41wTH4duy46DZzhBSOhhJzfy3m7z PrT0tqvhVpmzMsCEZvFYgRbwKmNTGatlij72GJxQsdr5XQt2DKjqauy87lDCEt9QE7w+s1MjX3RiN OA/Y2AWrLvYl1uGw=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1nAUPe-004kcO-76 for openvpn-devel@lists.sourceforge.net; Thu, 20 Jan 2022 10:11:28 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Thu, 20 Jan 2022 11:11:25 +0100 Message-Id: <20220120101125.31234-1-a@unstable.cc> MIME-Version: 1.0 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: This unit-test did not consider the case when USE_COMP is not defined, thus generating a compiler error. Adapt the test to the case when no compression is available and while at it, decompose the expected MTU values by featureso that it is easier to understand. Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1nAUPe-004kcO-76 Subject: [Openvpn-devel] [PATCH] unit-test: fix test_crypto when USE_COMP is not defined 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: , Cc: Antonio Quartulli Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This unit-test did not consider the case when USE_COMP is not defined, thus generating a compiler error. Adapt the test to the case when no compression is available and while at it, decompose the expected MTU values by featureso that it is easier to understand. Cc: Arne Schwabe Signed-off-by: Antonio Quartulli --- tests/unit_tests/openvpn/test_crypto.c | 52 +++++++++++++++----------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/openvpn/test_crypto.c index 19ce174e..851696fe 100644 --- a/tests/unit_tests/openvpn/test_crypto.c +++ b/tests/unit_tests/openvpn/test_crypto.c @@ -255,7 +255,7 @@ test_occ_mtu_calculation(void **state) o.ciphername = "none"; o.authname = "none"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1400); + assert_int_equal(linkmtu, o.ce.tun_mtu); /* Static key OCC examples */ o.shared_secret_file = "not null"; @@ -264,44 +264,51 @@ test_occ_mtu_calculation(void **state) o.ciphername = "none"; o.authname = "none"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1408); + assert_int_equal(linkmtu, o.ce.tun_mtu + 8); /* secret, cipher AES-128-CBC, auth none */ o.ciphername = "AES-128-CBC"; o.authname = "none"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1440); + assert_int_equal(linkmtu, o.ce.tun_mtu + 8 + 32); /* secret, cipher none, auth SHA256 */ o.ciphername = "none"; o.authname = "SHA256"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1440); + assert_int_equal(linkmtu, o.ce.tun_mtu + 8 + 32); - /* --secret, cipher BF-CBC, auth SHA1 */ + /* secret, cipher BF-CBC, auth SHA1 */ o.ciphername = "BF-CBC"; o.authname = "SHA1"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1444); + assert_int_equal(linkmtu, o.ce.tun_mtu + 8 + 36); - /* --secret, cipher BF-CBC, auth SHA1, tcp-client */ + /* secret, cipher BF-CBC, auth SHA1, tcp-client */ o.ce.proto = PROTO_TCP_CLIENT; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1446); + assert_int_equal(linkmtu, o.ce.tun_mtu + 8 + 36 + 2); o.ce.proto = PROTO_UDP; - /* --secret, comp-lzo yes, cipher BF-CBC, auth SHA1 */ + int comp_bytes = 0; +#if defined(USE_COMP) + /* secret, comp-lzo yes, cipher BF-CBC, auth SHA1 */ o.comp.alg = COMP_ALG_LZO; + comp_bytes = 1; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1445); + assert_int_equal(linkmtu, o.ce.tun_mtu + 8 + comp_bytes + 36); +#endif - /* --secret, comp-lzo yes, cipher BF-CBC, auth SHA1, fragment 1200 */ + /* secret, comp-lzo yes, cipher BF-CBC, auth SHA1, fragment 1200 */ o.ce.fragment = 1200; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1449); + assert_int_equal(linkmtu, o.ce.tun_mtu + 8 + comp_bytes + 36 + 4); + comp_bytes = 0; +#if defined(USE_COMP) o.comp.alg = COMP_ALG_UNDEF; +#endif o.ce.fragment = 0; /* TLS mode */ @@ -309,32 +316,32 @@ test_occ_mtu_calculation(void **state) o.tls_client = true; o.pull = true; - /* tls client, cipher AES-128-CBC, auth SHA1, tls-auth*/ + /* tls client, cipher AES-128-CBC, auth SHA1, tls-auth */ o.authname = "SHA1"; o.ciphername = "AES-128-CBC"; o.tls_auth_file = "dummy"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1457); + assert_int_equal(linkmtu, o.ce.tun_mtu + 5 + 8 + 32 + 12); /* tls client, cipher AES-128-CBC, auth SHA1 */ o.tls_auth_file = NULL; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1457); + assert_int_equal(linkmtu, o.ce.tun_mtu + 5 + 8 + 32 + 12); /* tls client, cipher none, auth none */ o.authname = "none"; o.ciphername = "none"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1405); + assert_int_equal(linkmtu, o.ce.tun_mtu + 5); /* tls client, auth none, cipher none, no-replay */ o.replay = false; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1401); + assert_int_equal(linkmtu, o.ce.tun_mtu + 1); o.replay = true; @@ -343,19 +350,22 @@ test_occ_mtu_calculation(void **state) o.authname = "SHA1"; o.ciphername = "AES-256-GCM"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1449); + assert_int_equal(linkmtu, o.ce.tun_mtu + 5 + 44); + o.ce.fragment = 1200; +#if defined(USE_COMP) /* tls client, auth SHA1, cipher AES-256-GCM, fragment, comp-lzo yes */ o.comp.alg = COMP_ALG_LZO; - o.ce.fragment = 1200; + comp_bytes = 1; +#endif linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1454); + assert_int_equal(linkmtu, o.ce.tun_mtu + 5 + 44 + 4 + comp_bytes); /* tls client, auth SHA1, cipher AES-256-GCM, fragment, comp-lzo yes, socks */ o.ce.socks_proxy_server = "socks.example.com"; linkmtu = calc_options_string_link_mtu(&o, &f); - assert_int_equal(linkmtu, 1464); + assert_int_equal(linkmtu, o.ce.tun_mtu + 5 + 44 + 4 + comp_bytes + 10); gc_free(&gc); }