From: "flichtenheld (Code Review)" Date: Fri, 21 Jul 2023 13:55:42 +0000 References: Reply-To: frank@...2641..., selva.nair@...277..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="RmWOsQ+NrfE="; 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: , Cc: openvpn-devel , selvanair --RmWOsQ+NrfE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: selvanair. flichtenheld has uploaded this change for review. ( http://gerrit.openvpn.n= et/c/openvpn/+/312?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 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/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 */ =20 #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: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: selvanair Gerrit-CC: openvpn-devel Gerrit-Attention: selvanair Gerrit-MessageType: newchange --RmWOsQ+NrfE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: selvanair.

flichtenheld has uploaded this change for review.

View Cha= nge

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: Ifb961a4df2b8b8300633192e1a268669f= 6f41a35
Signed-off-by: Selva Nair <selva.nair@...277...>
Co-aut= hored-by: Frank Lichtenheld <frank@...2641...>
Acked-by: Frank Lic= htenheld <frank@...2641...>
---
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.n=
et:29418/openvpn refs/changes/12/312/1
diff --git a/tests/unit_test=
s/openvpn/cert_data.h b/tests/unit_tests/openvpn/cert_data.h
index 33de35e..0886b07 100644
--- a/tests/unit_tests/open= vpn/cert_data.h
+++ b/tests/unit_tests/openvpn/cert_data.h<= /span>
@@ -79,7 +79,7 @@
"HeTsAlHjfFEReV= DiNCI9vMQLKFKKWnAorT2+iyRueA3bt2gchf863BBhZvJddL7Q\n"
= "KBa0osXw+eGBRAwsm7m1qCho3b3fN2nFAa+k07ptRkOeablmFdXE81nVlA=3D=3D= \n"
"-----END CERTIFICATE-----\n";

-static const char *const k= ey2 =3D key1;
+#defin= e key2 key1
static const char *const hash2 =3D "FA18F= D34BAABE47D6E2910E080F421C109CA97F5";
static const ch= ar *const cname2 =3D "ovpn-test-ec2";
@@ -159,8 +159,8 @@
"353PpJJ9s2b/Fqoc4d7ud= qhQogA7jqbayTKhJxbT134l2NzqDROzuS0kXbX8bXCi\n"
&q= uot;mXSa4c8=3D\n"
"-----END CERTIFICATE-----= \n";
-static const= char *const key4 =3D key3;
+#define key4 key3
static const char *const hash4 = =3D "E1401D4497C944783E3D62CDBD2A1F69F5E5071E";
-static const char *const cname4 =3D cna= me3; /* 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/openvp= n/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; /* identifie= s certs loaded to the store -- keep unique */
const ch= ar *hash; /* SHA1 fingerprint */
int= valid; /* nonzero if certificate has not expired = */
-} certs[] =3D {
- {cert1, key1, cname= 1, "OVPN TEST CA1", "OVPN Test Cert 1", hash1, 1},<= /span>
- {cert2, key2, cn= ame2, "OVPN TEST CA2", "OVPN Test Cert 2", hash2, 1= },
- {cert3, key3, = cname3, "OVPN TEST CA1", "OVPN Test Cert 3", hash3,= 1},
- {cert4, key= 4, cname4, "OVPN TEST CA2", "OVPN Test Cert 4", has= h4, 0},
- {}=
-};
+} certs[5];

static bool certs_loaded;

static HCERTSTORE user_store;<= /span>

+/*= Fill-in certs[] array */
+void
+init_cert= _data()
+{
= + struct test_cert certs_loc= al[] =3D {
+ {= cert1, key1, cname1, "OVPN TEST CA1", "OVPN Test Cert 1&= quot;, hash1, 1},
+= {cert2, key2, cname2, "OVPN TEST CA2", "OVPN Tes= t 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) =3D=3D sizeof(certs));
+ memcpy(certs, certs_local, size= of(certs_local));

+}<= /span>
+
/*= Lookup a certificate in our certificate/key db */
static = struct test_cert *
lookup_cert(const char *friendly_name)<= /span>
@@ -136,6 +145,7 @@
{
= return;
}
+ init_cert_data();
user_store = =3D CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_U= SER
|CERT_STORE_OPEN_EXISTI= NG_FLAG, L"MY");
assert_non_null(user_store)= ;

To view, visit change 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: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: selvanair <selva.nair@...1665...= 77...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: selvanair <selva.nair@...493...= 277...>
Gerrit-MessageType: newchange
--RmWOsQ+NrfE=--