From: "cron2 (Code Review)" Date: Sat, 23 Sep 2023 10:29:34 +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-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Frz/TQwe/c0="; 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 Cc: stipa , d12fk , openvpn-devel --Frz/TQwe/c0= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/31= 2?usp=3Demail ) 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(-) 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: merged --Frz/TQwe/c0= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

Make cert_data.h and test_cryptoapi/pkcs11.c M=
SVC compliant

- Do not use non-literal initializers for static objec= ts
- Replace empty initializer {} by {0}

Change-Id: Ifb961a4df2b8= b8300633192e1a268669f6f41a35
Signed-off-by: Selva Nair <selva.nair@...1186...= .277...>
Acked-by: Heiko Hund <heiko@...515...>
Acked-by: Se= lva Nair <selva.nair@...277...>
Acked-by: Lev Stipakov <lstipak= ov@...277...>
Co-authored-by: Frank Lichtenheld <frank@...2641...&= gt;
Acked-by: Frank Lichtenheld <frank@...2641...>
Message-Id: = <20230922160405.167057-1-frank@...2641...>
URL: https://www.mail-a= rchive.com/openvpn-devel@lists.sourceforge.net/msg27084.html
Signed-off-= by: Gert Doering <gert@...1296...>
---
M tests/unit_tests/openv= pn/cert_data.h
M tests/unit_tests/openvpn/test_cryptoapi.c
2 files ch= anged, 20 insertions(+), 10 deletions(-)

diff --git a/tests/unit_tests/openvpn/cert_data.h b/tests/unit_tests/ope=
nvpn/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+iyRueA3bt2gchf863BBhZv= JddL7Q\n"
"KBa0osXw+eGBRAwsm7m1qCho3b3fN2nFA= a+k07ptRkOeablmFdXE81nVlA=3D=3D\n"
"-----END= CERTIFICATE-----\n";
-static const char *const key2 =3D key1;
+#define key2 key1
static const ch= ar *const hash2 =3D "FA18FD34BAABE47D6E2910E080F421C109CA97F5";
static const char *const cname2 =3D "ovpn-test-ec2&quo= t;;

@@ -159,8 +159,8 @@
= "353PpJJ9s2b/Fqoc4d7udqhQogA7jqbayTKhJxbT134l2NzqDROzuS0kXbX8bXCi\= n"
"mXSa4c8=3D\n"
= "-----END CERTIFICATE-----\n";
-static const char *const key4 =3D key3;
+#define key4 key3
s= tatic const char *const hash4 =3D "E1401D4497C944783E3D62CDBD2A1F69F5E= 5071E";
-static co= nst char *const cname4 =3D cname3; /* same CN as that of cert3 */+#define cname4 cname3 /* same= CN as that of cert3 */

#endif /* CERT_D= ATA_H */
diff --git a/tests/unit_tests/openvpn/test_cryptoa= pi.c b/tests/unit_tests/openvpn/test_cryptoapi.c
index e64a= 1de..0859b58 100644
--- a/tests/unit_tests/openvpn/test_cry= ptoapi.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 fingerpri= nt */
int valid; /* nonzero i= f certificate has not expired */
-} certs[] =3D {
- {cert1, key1, cname1, "OVPN TEST CA1", "OVPN Te= st Cert 1", hash1, 1},
- {cert2, key2, cname2, "OVPN TEST CA2", "OVPN= Test Cert 2", hash2, 1},
- {cert3, key3, cname3, "OVPN TEST CA1", "O= VPN Test Cert 3", hash3, 1},
- {cert4, key4, cname4, "OVPN TEST CA2", &quo= t;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&q= uot;, "OVPN Test Cert 1", hash1, 1},
+ {cert2, key2, cname2, "OVPN T= EST CA2", "OVPN Test Cert 2", hash2, 1},
+ {cert3, key3, cname3, &qu= ot;OVPN TEST CA1", "OVPN Test Cert 3", hash3, 1},<= br>+ {cert4, key4, cna= me4, "OVPN TEST CA2", "OVPN Test Cert 4", hash4, 0}= ,
+ {0}=
+ };
+ assert(sizeof(certs_local) =3D=3D s= izeof(certs));
+ m= emcpy(certs, certs_local, sizeof(certs_local));
+}
+
/* Lookup a certificate in our certificate/key = db */
static struct test_cert *
lookup_ce= rt(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 ch= ange 312. To unsubscribe, or for help writing mail filters, visit settings.

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: merged
--Frz/TQwe/c0=--