From patchwork Fri Sep 22 16:04:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3365 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7301:2697:b0:d7:3b0f:3938 with SMTP id ha23csp3864238dyb; Fri, 22 Sep 2023 09:05:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqXwKWhusxGwfTtUfHrkiZS9PmxXM4YnoJv+BYf3MjjTqFwuIIFbgoLYZd6BQ9NRD7+Q2u X-Received: by 2002:a17:90a:1056:b0:26d:4ade:fcf0 with SMTP id y22-20020a17090a105600b0026d4adefcf0mr71181pjd.4.1695398710715; Fri, 22 Sep 2023 09:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695398710; cv=none; d=google.com; s=arc-20160816; b=Pj8Y9FtD2CHJCDR8FFbnY4g8Q2kOz120A1Kci87w6sm3vOU0mqkbLrMyXnz7E5tBww dwGv5mXZSvqenXqASe/OhRvAy6ssfkRoZYMzTAP+tTVQZJohauU8L7y/tZeuf9R9IeG7 isUksJabOP9yR3uSR4RZAAWNFbGJHvkg/4859GK8fO6lehmFHfScA7PvN1w2wXPzX4pM VAeR180dtsgGBmrazj5Cp2Da5P73vU7TXOc1zcGpi7QTXzN5n/aO0O5lusqawl3g4v0r c1cGzmlB9l2yXXGmNwYFvSgLiekVbvgyj3n3Ecv23m09X40//Hn38iq1ZkQ2ERWjEs9P swlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:cc: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=Bh73dJJc0z5NNfwWUd+JHkyDIqH1Gv11UVUpNx1TKKM=; fh=H6mFs2pVe2/avHEN3ZXlblBRMUbfPBnqHVZOzcm8npI=; b=MrNePJYgIVQX4kK8bhjgcAlzSrLHZAd/ZM+frxzzESg2xPp7ou6SbeRwdqEMg7g0D+ XUWVQzxHHMicPH0EyGnIfRGeuFKycYUUG8NOCzCEn3Lsb6kYuienymQL15ANQqwC/VWU HqKXsiRI76hTKAXm/3Nx641WYZ4ex77Kndddyp5MgdN3Be/Mj2JtVCE99Oeycy6adFGm S7K/BPxFExVCw+Oqv/Yr66Uy0f5r6+07RPY7Y8fbmOjvFcG0ZVXSCPCi+zfXyE7mm+7w CnQ3fc3QOYqXhB246f1WuJsyo2D0R0CJmD8dau8qHhnIQg/AnWN87E6toWIXnxf2KWmr j1uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=fEHnec5D; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=QvAaIIKc; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=iZ+Uyu4B; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id cq21-20020a17090af99500b00276a0aaf7e5si4404832pjb.148.2023.09.22.09.05.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2023 09:05:10 -0700 (PDT) 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=fEHnec5D; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=QvAaIIKc; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=iZ+Uyu4B; 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 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 1qjide-0007Qm-8I; Fri, 22 Sep 2023 16:04:18 +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 1qjidc-0007Qc-Ks for openvpn-devel@lists.sourceforge.net; Fri, 22 Sep 2023 16:04:16 +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=CjYbgqDP5BP/3DQ7uXIxv1zRjrYYrG/VvtkW3DfAhQ8=; b=fEHnec5DEe05uBKfUtNXD//CYx C3oGizJtXydRLLclnmlsTTGccos3qgzTMz/sMWzIVQqp66d5Wv1geotY5W31xcpC575qDy+eaLGl2 oJ6Fjpt3+nsz6jefW+Fdh8O3A9PMvR+WX69ZQJB4FGvEnMGw4wVGmRns+f+AnnONL3cI=; 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=CjYbgqDP5BP/3DQ7uXIxv1zRjrYYrG/VvtkW3DfAhQ8=; b=QvAaIIKcWSQAZsZAPBrccPJ9vY RstxtYn7anwCYuekb5CtBk1yDktSkyvPYK782QsoDczMifxsuz/2fRc6F3LpFTlYsSuxZCVm9mrpQ kxJ4ND4rZe4C9LUPI0+kRtHL+N1EjOarpgQeK936/FyHwLt5+3R6ednmnmwUVXFR2Ijc=; Received: from mout-p-202.mailbox.org ([80.241.56.172]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1qjidb-0006DW-GN for openvpn-devel@lists.sourceforge.net; Fri, 22 Sep 2023 16:04:16 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4RscX72bcQz9scJ; Fri, 22 Sep 2023 18:04:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1695398647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CjYbgqDP5BP/3DQ7uXIxv1zRjrYYrG/VvtkW3DfAhQ8=; b=iZ+Uyu4B/juuzxhFfQ+F2ksXlYVOcp6ZoMjwawk1vhfMXa9UTYeTVBltnn3Vrn7V5LWs5I GuQ3ImolHg+l9TFVH6V8sL+FXjO/iHc4fI/B9irR0jXNKeu/zUd2I8ak1kNrKct/tCeOTX VUbxVc3E+7blBik0QNgbshq3z2301QMVHa2+aGQZ4Sjcgf5Qt98yIs7ZZ0JVFPUu/VTiMl m3VcuCarxTZMZgE5OX1FPDkdjluc5dWScav2vkJSgffQgm6A1mVi7LD/yjlxTYZjNYEGWo uPcvJe+4yx48z3+4X16+9ylZBrOwz2zRwrkXeot6sX/WIwT7g0c2sY8q0bNX4A== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Fri, 22 Sep 2023 18:04:05 +0200 Message-Id: <20230922160405.167057-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4RscX72bcQz9scJ X-Spam-Score: -0.9 (/) 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 - Do not use non-literal initializers for static objects - Replace empty initializer {} by {0} Change-Id: Ifb961a4df2b8b8300633192e1a268669f6f41a35 Signed-off-by: Selva Nair Acked-by: Heiko Hund Acked-by: Selva Nair Acked-by: Lev [...] Content analysis details: (-0.9 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 -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.172 listed in list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Headers-End: 1qjidb-0006DW-GN Subject: [Openvpn-devel] [PATCH] Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant 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: Heiko Hund Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1777754398116193946?= X-GMAIL-MSGID: =?utf-8?q?1777754398116193946?= From: Selva Nair - Do not use non-literal initializers for static objects - Replace empty initializer {} by {0} Change-Id: Ifb961a4df2b8b8300633192e1a268669f6f41a35 Signed-off-by: Selva Nair Acked-by: Heiko Hund Acked-by: Selva Nair Acked-by: Lev Stipakov Co-authored-by: Frank Lichtenheld Acked-by: Frank Lichtenheld --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to release/2.6. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/312 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Heiko Hund Selva Nair Lev Stipakov diff --git a/tests/unit_tests/openvpn/cert_data.h b/tests/unit_tests/openvpn/cert_data.h index 33de35e..0886b07 100644 --- a/tests/unit_tests/openvpn/cert_data.h +++ b/tests/unit_tests/openvpn/cert_data.h @@ -79,7 +79,7 @@ "HeTsAlHjfFEReVDiNCI9vMQLKFKKWnAorT2+iyRueA3bt2gchf863BBhZvJddL7Q\n" "KBa0osXw+eGBRAwsm7m1qCho3b3fN2nFAa+k07ptRkOeablmFdXE81nVlA==\n" "-----END CERTIFICATE-----\n"; -static const char *const key2 = key1; +#define key2 key1 static const char *const hash2 = "FA18FD34BAABE47D6E2910E080F421C109CA97F5"; static const char *const cname2 = "ovpn-test-ec2"; @@ -159,8 +159,8 @@ "353PpJJ9s2b/Fqoc4d7udqhQogA7jqbayTKhJxbT134l2NzqDROzuS0kXbX8bXCi\n" "mXSa4c8=\n" "-----END CERTIFICATE-----\n"; -static const char *const key4 = key3; +#define key4 key3 static const char *const hash4 = "E1401D4497C944783E3D62CDBD2A1F69F5E5071E"; -static const char *const cname4 = cname3; /* same CN as that of cert3 */ +#define cname4 cname3 /* same CN as that of cert3 */ #endif /* CERT_DATA_H */ diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/openvpn/test_cryptoapi.c index e64a1de..0859b58 100644 --- a/tests/unit_tests/openvpn/test_cryptoapi.c +++ b/tests/unit_tests/openvpn/test_cryptoapi.c @@ -104,17 +104,26 @@ const char *const friendly_name; /* identifies certs loaded to the store -- keep unique */ const char *hash; /* SHA1 fingerprint */ int valid; /* nonzero if certificate has not expired */ -} certs[] = { - {cert1, key1, cname1, "OVPN TEST CA1", "OVPN Test Cert 1", hash1, 1}, - {cert2, key2, cname2, "OVPN TEST CA2", "OVPN Test Cert 2", hash2, 1}, - {cert3, key3, cname3, "OVPN TEST CA1", "OVPN Test Cert 3", hash3, 1}, - {cert4, key4, cname4, "OVPN TEST CA2", "OVPN Test Cert 4", hash4, 0}, - {} -}; +} certs[5]; static bool certs_loaded; static HCERTSTORE user_store; +/* Fill-in certs[] array */ +void +init_cert_data() +{ + struct test_cert certs_local[] = { + {cert1, key1, cname1, "OVPN TEST CA1", "OVPN Test Cert 1", hash1, 1}, + {cert2, key2, cname2, "OVPN TEST CA2", "OVPN Test Cert 2", hash2, 1}, + {cert3, key3, cname3, "OVPN TEST CA1", "OVPN Test Cert 3", hash3, 1}, + {cert4, key4, cname4, "OVPN TEST CA2", "OVPN Test Cert 4", hash4, 0}, + {0} + }; + assert(sizeof(certs_local) == sizeof(certs)); + memcpy(certs, certs_local, sizeof(certs_local)); +} + /* Lookup a certificate in our certificate/key db */ static struct test_cert * lookup_cert(const char *friendly_name) @@ -136,6 +145,7 @@ { return; } + init_cert_data(); user_store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER |CERT_STORE_OPEN_EXISTING_FLAG, L"MY"); assert_non_null(user_store);