From patchwork Fri Jul 21 13:55:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3294 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:14c5:b0:d7:3b0f:3938 with SMTP id g5csp88821dyh; Fri, 21 Jul 2023 06:56:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlE8QamCEmLpeoueA1PRrVav0DehuBfvfW1qjXSbiwTX22af/oevvv8fwqlYsWo5z920r+ZL X-Received: by 2002:a17:902:c14b:b0:1b8:987f:3f34 with SMTP id 11-20020a170902c14b00b001b8987f3f34mr1872351plj.25.1689947783572; Fri, 21 Jul 2023 06:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689947783; cv=none; d=google.com; s=arc-20160816; b=wu9rfHMiuxFgmNjeeL81jQgI3zfg68pEjhTgEQ2aMQX8f2uxxmLinCidonIVc4+XZc rvfNbeA9Drf5JmIkqdKIb4EE0CAMvf93PhhM8tIiodB3AI59PFYzYUvLtdDufvxA6wsL cCift+figeLvaFdBGvkSagSmEEe2EJSY0UpzeRqduI1PrZNWAFKi94b1LtQqIoJwJzl/ 6tQH35vrcm1sWAMDeZNEWchQZC9bhQ+QCRXWl/JXAWHsYZDlM8RsnJIPrcgZXekJIZoa JDWkKXAYJ6b8L+DhTFV5ZBjDj1EcJvt9RR4Z1dFV0YWRSb/Js856r5wzqW2sqGR0DgV3 7OZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:date:from :dkim-signature:dkim-signature:dkim-signature; bh=TyGeWBA1COnPDQVIQAMkxl14t4DFd0vHCKlbIwb5alU=; fh=ejqQk4evxSbcB4TOY987ChV164zUZaeCjiIZ6JGqg/c=; b=uaSpzaS7VBP4WEn0AHIABDU1L8wemKh1pEcLSUo8//cNk/CJxraw5/G6eIYNGflqER uxIklHrd5GL0+XOK6T46VobXd1f2OJ/oTJoxIbSBQe7mm8qwM0HkBLfDV2q9tyf6qyDX C2P4dFql/6RLzVNT7RbMwtpRqqMY4l2mnfXtf0ID17ruJch74nw0XVTEnpY5UNUPnPD3 N7t+gmsEqwIA/vziiCtWRYaBPBdtwUOBiquRVFaEXzlQ/xIfRs4Rd/d/y0lm5cNHtsw7 DcbxSca3+xhuEp0PiY/jltpzpK0V6OMwhGuPbOGSznvRnzGlZteE/lNcJpKxZTYn2jr7 3N7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=GKAK+79Y; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=cmkWwJdn; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=Onqyw+1z; 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=NONE dis=NONE) header.from=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id n7-20020a170903110700b001b89bfd0c2csi3228228plh.647.2023.07.21.06.56.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2023 06:56:23 -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=GKAK+79Y; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=cmkWwJdn; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=Onqyw+1z; 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=NONE dis=NONE) header.from=openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qMqbt-00072t-ME; Fri, 21 Jul 2023 13:55:57 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qMqbs-00072k-DO for openvpn-devel@lists.sourceforge.net; Fri, 21 Jul 2023 13:55:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:Date:From :Sender:To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IiXUdCpK6QA4zbEhYslnsWaXmaGN9vH0ebvSPTq14UY=; b=GKAK+79YHg7E7o91cJutRZfLC4 7UQ533iT4aj1cAmw8o45B+QC+AiF28UbccaQKPNKzWP/Cwum+AC65w0ShT8+THXuFvrgHLZJl7vJE bTA8bbodRTk4M8p2/kfeNoOjq6QZVWLDdq/tUC+l4CJJKLPjX7DK3M+IalOQ3CLFv5EM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:Date:From:Sender:To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=IiXUdCpK6QA4zbEhYslnsWaXmaGN9vH0ebvSPTq14UY=; b=c mkWwJdnGYdsAuumvapXZ7MHqK7FU3A9xBGOj0v4VYAiQj9b/sYrIb99a0KKdK+CS61NBobeuMOlXe XUbrEXJDpfP5IdnO7ABrbGhC9B9SalR8Gsg2HphGWj/0O/eaKFd6jbiIm3wuw3P304E5twcfqViK3 aX2BfcdKF/aePD6g=; Received: from mail-wr1-f54.google.com ([209.85.221.54]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1qMqbm-00FJgH-38 for openvpn-devel@lists.sourceforge.net; Fri, 21 Jul 2023 13:55:55 +0000 Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-31590e4e27aso1478308f8f.1 for ; Fri, 21 Jul 2023 06:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1689947743; x=1690552543; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:date:from:from:to:cc :subject:date:message-id:reply-to; bh=IiXUdCpK6QA4zbEhYslnsWaXmaGN9vH0ebvSPTq14UY=; b=Onqyw+1zz8A78T5aQ66JNJMwLGR8kxt5PbWpqpiTE/l6jWizenQQnywhdauR5ndiY6 R9h6MtGcQFlB2YlWiNrNqzMk37AqWBuWXGeMlyb7QJyG08HCDAkwoa35te8pZL8BmDpE vLbbbl8fKFlzVCvtNb4zg/kq4ixANfwf7t/wIfXI1msFXtMeiHA1MOWj5M/MjGXG7Du7 RyC930+bsxZSwFtggDfJMUgjJwjuv9G4EQQoV/DnAPBfMTuLK6snYKRAMQNmtYzoCBsF EBzDs4KR0WIezYL71FOnO0ro11K3LxxQCcWaVeh7/vu7p06MT0zPRaibFp8QpxRUYJzo q42A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689947743; x=1690552543; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IiXUdCpK6QA4zbEhYslnsWaXmaGN9vH0ebvSPTq14UY=; b=AC7Uxus4TmSqtQARU7XeW5r0rr4QhTwPKEhmhL2qpRiT1KZXQXumDb2gHm00ieMHNe EAmfs7nJPJ30Cz7oGeeVaAmOFBEFISk9KEOCwFr9xLq+hplVmMgSO5WlPSHF2gfUGaKF J3AOFMmOx68gzrBir0WY/H2Ln2B4lMxQvz/b+XIs7YzYTOQuTcTR2lJ5vipqNNHqVTla dtxsP6UloNPnVehspeb0OFXJFtU1YU2J2axxkyLSnUahi5VOPGq+sDLuMGeexPpdaT3m qeqMFuV6rMQkgBnx082wWffazcp0TJ998pT+lamt90GXGg9fmn5BFzqRXYbXmM8sY8BD Priw== X-Gm-Message-State: ABy/qLZdVgMpwaC5e57b07+LLpF5Z9tfFB+xaDAt5lUmXI8QE2BtJj36 qxsQtw6pkiwJG6xBonRwVewoi/iHyF3/xCihDYY= X-Received: by 2002:a05:6000:1d2:b0:314:4439:151a with SMTP id t18-20020a05600001d200b003144439151amr1341813wrx.6.1689947743585; Fri, 21 Jul 2023 06:55:43 -0700 (PDT) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id o5-20020a5d6845000000b0031435731dfasm4282049wrw.35.2023.07.21.06.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 06:55:42 -0700 (PDT) From: "flichtenheld (Code Review)" X-Google-Original-From: "flichtenheld (Code Review)" X-Gerrit-PatchSet: 1 Date: Fri, 21 Jul 2023 13:55:42 +0000 Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: Ifb961a4df2b8b8300633192e1a268669f6f41a35 X-Gerrit-Change-Number: 312 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 4f26d37f392beba4ccf99551941bec6139ce77eb References: Message-ID: MIME-Version: 1.0 User-Agent: Gerrit/3.8.0 X-Spam-Score: 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: Attention is currently required from: selvanair. flichtenheld has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/312?usp=email ) Change subject: Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant Content analysis details: (1.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.54 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.221.54 listed in list.dnswl.org] 1.2 MISSING_HEADERS Missing To: header -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1qMqbm-00FJgH-38 Subject: [Openvpn-devel] [S] Change in openvpn[release/2.6]: 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: , Reply-To: frank@lichtenheld.com, selva.nair@gmail.com, openvpn-devel@lists.sourceforge.net Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1772038687137443989?= X-GMAIL-MSGID: =?utf-8?q?1772038687137443989?= Attention is currently required from: selvanair. flichtenheld has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/312?usp=email ) Change subject: Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant ...................................................................... Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant - Do not use non-literal initializers for static objects - Replace empty initializer {} by {0} Change-Id: Ifb961a4df2b8b8300633192e1a268669f6f41a35 Signed-off-by: Selva Nair Co-authored-by: Frank Lichtenheld Acked-by: Frank Lichtenheld --- M tests/unit_tests/openvpn/cert_data.h M tests/unit_tests/openvpn/test_cryptoapi.c 2 files changed, 20 insertions(+), 10 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/12/312/1 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);