From: "cron2 (Code Review)" Date: Sat, 23 Sep 2023 10:29:32 +0000 In-Reply-To: References: Reply-To: gert@...1296..., heiko@...515..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net, frank@...2641..., lstipakov@...277... Message-ID: <7a2d9458fc1d32eab57f5b58145eb6d607036e2b-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="27cRvW/elgg="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[release/2.6]: Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , selvanair , d12fk , stipa Cc: openvpn-devel --27cRvW/elgg= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#2) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/312?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by d12fk, Code-Review+2 by selvanair, Code-Review+2 by stipa 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 Acked-by: Heiko Hund Acked-by: Selva Nair Acked-by: Lev Stipakov Co-authored-by: Frank Lichtenheld Acked-by: Frank Lichtenheld Message-Id: <20230922160405.167057-1-frank@...2641...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27= 084.html Signed-off-by: Gert Doering --- 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/2 diff --git a/tests/unit_tests/openvpn/cert_data.h b/tests/unit_tests/openvp= n/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=3D=3D\n" "-----END CERTIFICATE-----\n"; -static const char *const key2 =3D key1; +#define key2 key1 static const char *const hash2 =3D "FA18FD34BAABE47D6E2910E080F421C109CA97= F5"; static const char *const cname2 =3D "ovpn-test-ec2"; @@ -159,8 +159,8 @@ "353PpJJ9s2b/Fqoc4d7udqhQogA7jqbayTKhJxbT134l2NzqDROzuS0kXbX8bXCi\n" "mXSa4c8=3D\n" "-----END CERTIFICATE-----\n"; -static const char *const key4 =3D key3; +#define key4 key3 static const char *const hash4 =3D "E1401D4497C944783E3D62CDBD2A1F69F5E507= 1E"; -static const char *const cname4 =3D 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/o= penvpn/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[] =3D { - {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[] =3D { + {cert1, key1, cname1, "OVPN TEST CA1", "OVPN Test Cert 1", ha= sh1, 1}, + {cert2, key2, cname2, "OVPN TEST CA2", "OVPN Test Cert 2", ha= sh2, 1}, + {cert3, key3, cname3, "OVPN TEST CA1", "OVPN Test Cert 3", ha= sh3, 1}, + {cert4, key4, cname4, "OVPN TEST CA2", "OVPN Test Cert 4", ha= sh4, 0}, + {0} + }; + assert(sizeof(certs_local) =3D=3D 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 =3D CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM= _STORE_CURRENT_USER |CERT_STORE_OPEN_EXISTING_FLAG, L"MY"); assert_non_null(user_store); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/312?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: release/2.6 Gerrit-Change-Id: Ifb961a4df2b8b8300633192e1a268669f6f41a35 Gerrit-Change-Number: 312 Gerrit-PatchSet: 2 Gerrit-Owner: flichtenheld Gerrit-Reviewer: d12fk Gerrit-Reviewer: stipa Gerrit-CC: openvpn-devel Gerrit-CC: selvanair Gerrit-MessageType: newpatchset --27cRvW/elgg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #2 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outda= ted and were removed: Code-Review+2 by d12fk, Code-Review+2 by selvanair, Code-Review+2 by stipa<= /p>

=
Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant

- Do not= use non-literal initializers for static objects
- Replace empty initial= izer {} by {0}

Change-Id: Ifb961a4df2b8b8300633192e1a268669f6f41a35<= br>Signed-off-by: Selva Nair <selva.nair@...277...>
Acked-by: Heik= o Hund <heiko@...515...>
Acked-by: Selva Nair <selva.nair@...1664...= 7...>
Acked-by: Lev Stipakov <lstipakov@...277...>
Co-author= ed-by: Frank Lichtenheld <frank@...2641...>
Acked-by: Frank Lichte= nheld <frank@...2641...>
Message-Id: <20230922160405.167057-1-f= rank@...2641...>
URL: https://www.mail-archive.com/openvpn-devel@...1514...= s.sourceforge.net/msg27084.html
Signed-off-by: Gert Doering <gert@...493...= 1296...>
---
M tests/unit_tests/openvpn/cert_data.h
M tests/uni= t_tests/openvpn/test_cryptoapi.c
2 files changed, 20 insertions(+), 10 d= eletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/=
changes/12/312/2
diff --git a/tests/unit_tests/openvpn/cert_data.h =
b/tests/unit_tests/openvpn/cert_data.h
index 33de35e..0886b= 07 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+eG= BRAwsm7m1qCho3b3fN2nFAa+k07ptRkOeablmFdXE81nVlA=3D=3D\n"
"-----END CERTIFICATE-----\n";
-static const char *const key2 =3D key1;+#define key2 key1
= static const char *const hash2 =3D "FA18FD34BAABE47D6E2910E080F= 421C109CA97F5";
static const char *const cname2 =3D &= quot;ovpn-test-ec2";

@@ -159,8 +159,= 8 @@
"353PpJJ9s2b/Fqoc4d7udqhQogA7jqbayTKhJxbT134= l2NzqDROzuS0kXbX8bXCi\n"
"mXSa4c8=3D\n"=
"-----END CERTIFICATE-----\n";
-static const char *const key4 =3D = key3;
+#define key4 k= ey3
static const char *const hash4 =3D "E1401D4497C94= 4783E3D62CDBD2A1F69F5E5071E";
-static const char *const cname4 =3D cname3; /* same CN as that= of cert3 */
+#define= cname4 cname3 /* same CN as that of cert3 */

<= span> #endif /* CERT_DATA_H */
diff --git a/tests/unit_test= s/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/openv= pn/test_cryptoapi.c
@@ -104,17 +104,26 @@
= const char *const friendly_name; /* identifies certs loaded to the s= tore -- keep unique */
const char *hash; = /* SHA1 fingerprint */
int valid; = /* nonzero if certificate has not expired */
-} certs[] =3D {
- {cert1, key1, cname1, "OVPN TEST CA1= ", "OVPN Test Cert 1", hash1, 1},
- {cert2, key2, cname2, "OVPN TES= T CA2", "OVPN Test Cert 2", hash2, 1},
- {cert3, key3, cname3, "OVPN = TEST CA1", "OVPN Test Cert 3", hash3, 1},
- {cert4, key4, cname4, "OV= PN TEST CA2", "OVPN Test Cert 4", hash4, 0},

- {}
-};
+} certs[5];

static bool certs_l= oaded;
static HCERTSTORE user_store;

+/* Fill-in certs[] arra= y */
+void
= +init_cert_data()
+{
+ struct test_cert certs_local[] =3D {
= + {cert1, key1, cname1= , "OVPN TEST CA1", "OVPN Test Cert 1", hash1, 1},
+ {cert2, key2= , cname2, "OVPN TEST CA2", "OVPN Test Cert 2", hash= 2, 1},
+ {cer= t3, key3, cname3, "OVPN TEST CA1", "OVPN Test Cert 3&quo= t;, hash3, 1},
+ = {cert4, key4, cname4, "OVPN TEST CA2", "OVPN Test C= ert 4", hash4, 0},
+ {0}
+ = };
+ assert(size= of(certs_local) =3D=3D 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)
@@ -1= 36,6 +145,7 @@
{
return;
}
+ = init_cert_data();
user_store =3D CertOpenStore(CERT= _STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER
= |CERT_STORE_OPEN_EXISTING_FLAG, L"MY&quo= t;);
assert_non_null(user_store);

To view, visit change 312. To unsubscribe, or for help writing m= ail filters, visit settings<= /a>.

Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Ifb961a4df2b8b8300633192e1a2= 68669f6f41a35
Gerrit-Change-Number: 312
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: d12fk <heiko@...515...>=
Gerrit-Reviewer: stipa <lstipakov@...277...= >
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-CC: selvanair <selva.nair@...277...&= gt;
Gerrit-MessageType: newpatchset
--27cRvW/elgg=--