Skip to contentSkip to conversation

Series of patches to fix Windows builds and other errors

Openvpn-devel In review Adriaan de Jong 4 participants 17 messages Oct 31, 2011 – Nov 21, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

The following series of patches enables Windows builds and fixes a few bugs to boot. Most of it I'm quite comfortable with.

The only unfortunate thing in these patches is switching between OpenSSL and PolarSSL. This currently requires changing two flags instead of one, due to the build system. If anyone has any suggestions there, please let me know.

Adriaan

---
[PATCH 1/8] Moved prng_uninit out of crypto_uninit_lib [PATCH 2/8] Moved CryptoAPI header include to the ssl_openssl.c [PATCH 3/8] Fixed missing comma in plugin.h
[PATCH 4/8] Reordered functions to ensure warning-free Windows build [PATCH 5/8] Added options to switch between OpenSSL and PolarSSL and [PATCH 6/8] Moved from strsep to strtok, for Windows compatibility [PATCH 7/8] Minor cleanup to enable warning-free Windows build:
[PATCH 8/8] Fixed a typo when initialising cryptoapi certs

#1 lore raw

PATCH 1/8 Moved prng_uninit out of crypto_uninit_lib

Since prng_uninit is SSL-library agnostic, but crypto_uninit_lib isn't, the function was moved up a level.

---
 crypto.c          |    1 +
 crypto_openssl.c  |    2 --
 crypto_polarssl.c |    1 -
 ssl.c             |    4 ++--
 4 files changed, 3 insertions(+), 5 deletions(-)
crypto.c +1 -0
index d17f706..375d35a 100644
@@ -1388,6 +1388,7 @@ void
 free_ssl_lib (void)
 {
   crypto_uninit_lib ();
+  prng_uninit();
   EVP_cleanup ();
   ERR_free_strings ();
 }
crypto_openssl.c +0 -2
index 9906479..db6b78e 100644
@@ -277,8 +277,6 @@ crypto_uninit_lib (void)
       engine_initialized = false;
     }
 #endif
-
-  prng_uninit ();
 }
 
 void
crypto_polarssl.c +0 -1
index 8119d58..e7470d5 100644
@@ -69,7 +69,6 @@ crypto_init_lib (void)
 void
 crypto_uninit_lib (void)
 {
-  prng_uninit();
 }
 
 void
ssl.c +2 -2
index 30f6eb2..955a0d1 100644
@@ -162,7 +162,8 @@ void
 free_ssl_lib ()
 {
   crypto_uninit_lib ();
-
+  prng_uninit();
+  
   tls_free_lib();
 }
 
@@ -1168,7 +1169,6 @@ tls1_P_hash(const md_kt_t *md_kt,
 {
   struct gc_arena gc = gc_new ();
   int chunk,n;
-  unsigned int j;
   hmac_ctx_t ctx;
   hmac_ctx_t ctx_tmp;
   uint8_t A1[MAX_HMAC_KEY_LENGTH];
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/8 Moved CryptoAPI header include to the ssl_openssl.c

In reply to Adriaan de Jong
---
 ssl.c         |    4 ----
 ssl_openssl.c |    4 ++++
 2 files changed, 4 insertions(+), 4 deletions(-)
ssl.c +0 -4
index 955a0d1..c26756e 100644
@@ -62,10 +62,6 @@
 #include "ssl_verify.h"
 #include "ssl_backend.h"
 
-#ifdef WIN32
-#include "cryptoapi.h"
-#endif
-
 #include "memdbg.h"
 
 #ifndef ENABLE_OCC
ssl_openssl.c +4 -0
index a1e45d9..1cc2bfb 100644
@@ -39,6 +39,10 @@
 #include "ssl_backend.h"
 #include "ssl_common.h"
 
+#ifdef ENABLE_CRYPTOAPI
+#include "cryptoapi.h"
+#endif
+
 #include "ssl_verify_openssl.h"
 
 #include <openssl/err.h>
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/8 Fixed missing comma in plugin.h

In reply to Adriaan de Jong

Fixed a bug where the wrong value was being passed to plugin_call_ssl, due to a missing comma.

---
 plugin.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugin.h +1 -1
index 8782751..7aacb47 100644
@@ -132,7 +132,7 @@ plugin_call(const struct plugin_list *pl,
 {
   return plugin_call_ssl(pl, type, av, pr, es
 #ifdef USE_SSL
-      -1, NULL
+      , -1, NULL
 #endif
       );
 }
Signature · 1 line
1.7.5.4
Acked-by on v1 3/8
#4 lore raw

Re: [Openvpn-devel] [PATCH 3/8] Fixed missing comma in plugin.h

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Adriaan de Jong

--- a/plugin.h +++ b/plugin.h @@ -132,7 +132,7 @@ plugin_call(const struct plugin_list *pl, { return plugin_call_ssl(pl, type, av, pr, es
#ifdef USE_SSL - -1, NULL + , -1, NULL #endif ); }

ACK! Tested on top master (6e8b90ec0d0a074ac529541ce9515f25b30bac88), and plugin issues found earlier is now fixed with this patch.

Applied to -testing and -stable master branches.

commit 8d22a9905d1243dbaf10493abdbb91718e8f9969

Author: Adriaan de Jong <[email protected]...>
Date:   Mon Oct 31 16:29:16 2011 +0100

Fixed missing comma in plugin.h

Fixed a bug where the wrong value was being passed to plugin_call_ssl, due to a missing comma.

This patch also obsoletes the patch I sent earlier to the list, "[PATCH] Fix plugin_call() struct env_set corruption" [1]

kind regards,

David Sommerseth

[1] <http://thread.gmane.org/gmane.network.openvpn.devel/5042>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk635nsACgkQDC186MBRfroYjgCeNUOTk6l/i+TdgZxVtCXyvofc sR8AniMJYWmVTH6HHV1NAX/3Hj1gR0CQ
=j5Ru
-----END PGP SIGNATURE-----

#5 lore raw

PATCH 4/8 Reordered functions to ensure warning-free Windows build

In reply to Adriaan de Jong
---
 plugin.h |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
plugin.h +10 -11
index 7aacb47..948ab88 100644
@@ -122,6 +122,16 @@ void plugin_list_open (struct plugin_list *pl,
 
 struct plugin_list *plugin_list_inherit (const struct plugin_list *src);
 
+int plugin_call_ssl (const struct plugin_list *pl,
+		 const int type,
+		 const struct argv *av,
+		 struct plugin_return *pr,
+		 struct env_set *es
+#ifdef USE_SSL
+		 , int current_cert_depth,
+		 x509_cert_t *current_cert
+#endif
+		);
 
 static inline int
 plugin_call(const struct plugin_list *pl,
@@ -137,17 +147,6 @@ plugin_call(const struct plugin_list *pl,
       );
 }
 
-int plugin_call_ssl (const struct plugin_list *pl,
-		 const int type,
-		 const struct argv *av,
-		 struct plugin_return *pr,
-		 struct env_set *es
-#ifdef USE_SSL
-		 , int current_cert_depth,
-		 x509_cert_t *current_cert
-#endif
-		);
-
 void plugin_list_close (struct plugin_list *pl);
 bool plugin_defined (const struct plugin_list *pl, const int type);
 
Signature · 1 line
1.7.5.4
#6 lore raw

Re: [Openvpn-devel] [PATCH 4/8] Reordered functions to ensure warning-free Windows build

Quoted 35 lines
---
 plugin.h |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
plugin.h +10 -4
index 7aacb47..948ab88 100644
@@ -122,6 +122,16 @@ void plugin_list_open (struct plugin_list *pl,
 
 struct plugin_list *plugin_list_inherit (const struct plugin_list *src);
 
+int plugin_call_ssl (const struct plugin_list *pl,
+		 const int type,
+		 const struct argv *av,
+		 struct plugin_return *pr,
+		 struct env_set *es
+#ifdef USE_SSL
+		 , int current_cert_depth,
+		 x509_cert_t *current_cert
+#endif
+		);
 
 static inline int
 plugin_call(const struct plugin_list *pl,
@@ -137,17 +147,6 @@ plugin_call(const struct plugin_list *pl,
       );
 }
 
-int plugin_call_ssl (const struct plugin_list *pl,
-		 const int type,
-		 const struct argv *av,
-		 struct plugin_return *pr,

plugin.h plugin_call(const struct plugin_list *pl, · line 152

Quoted 10 lines
plugin.h +0 -7
-		 struct env_set *es
-#ifdef USE_SSL
-		 , int current_cert_depth,
-		 x509_cert_t *current_cert
-#endif
-		);
-
 void plugin_list_close (struct plugin_list *pl);
 bool plugin_defined (const struct plugin_list *pl, const int type);
 

Can confirm that Visual Studio/Python build does not give any warnings when this patch is applied. Not sure if that's good enough for an ACK :).

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#7 lore raw

PATCH 5/8 Added options to switch between OpenSSL and PolarSSL and PKCS11...

In reply to Adriaan de Jong

at compile time. Also included the option to enable/disable PKCS11.

---
 win/config.h.in |   18 +++++++++++++++---
 win/msvc.mak.in |   18 +++++++++++++++---
 win/settings.in |   13 +++++++++++++
 3 files changed, 43 insertions(+), 6 deletions(-)
win/config.h.in +15 -3
index ec447a2..e9df379 100644
@@ -74,7 +74,9 @@ typedef unsigned long in_addr_t;
 #endif
 
 /* Enable PKCS#11 support */
-/* #define USE_PKCS11 1 */
+#if @USE_PKCS11@ != 0
+#define USE_PKCS11 1
+#endif
 
 /* Enable HTTP proxy support */
 #if @ENABLE_HTTP_PROXY@ != 0
@@ -252,7 +254,17 @@ typedef unsigned long in_addr_t;
 #define TIME_WITH_SYS_TIME 1
 #endif
 
-/* Use OpenSSL crypto library */
+/* Use the PolarSSL crypto library */
+#if @USE_POLARSSL@ != 0
+#define USE_POLARSSL 1
+#endif
+
+/* Use the OpenSSL crypto library */
+#if @USE_OPENSSL@ != 0
+#define USE_OPENSSL 1
+#endif
+
+/* Use the crypto library */
 #define USE_CRYPTO 1
 
 /* Use LZO compression library */
@@ -264,7 +276,7 @@ typedef unsigned long in_addr_t;
 /* Use lzo/ directory prefix for LZO header files (for LZO 2.0) */
 #define LZO_HEADER_DIR 1
 
-/* Use OpenSSL SSL library */
+/* Use the SSL library */
 #define USE_SSL 1
 
 /* Version number of package */
win/msvc.mak.in +15 -3
index ac17ae9..d2babcf 100644
@@ -12,16 +12,28 @@
 # - OPENSSL_DIR and LZO_DIR are dynamically created from settings.in
 
 OPENSSL = @OPENSSL_DIR@
+!ifdef INCLUDE_OPENSSL
 OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib
+!endif
+
+POLARSSL = @POLARSSL_DIR@
+!ifdef INCLUDE_POLARSSL
+POLARSSL_DYNAMIC = polarssl.lib
+!endif
+
+PKCS11_HELPER = @PKCS11_HELPER_DIR@
+!ifdef INCLUDE_PKCS11
+PKCS11_HELPER_DYNAMIC = pkcs11-helper.lib
+!endif
 
 LZO = @LZO_DIR@
 LZO_DYNAMIC = lzo2.lib
 
-INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include
+INCLUDE_DIRS = -I$(OPENSSL)/include -I$(POLARSSL)/include -I$(LZO)/include -I$(PKCS11_HELPER)/include
 
-LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
+LIBS = $(OPENSSL_DYNAMIC) $(POLARSSL_DYNAMIC) $(PKCS11_HELPER_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
 
-LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib
+LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library -LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)
 
 EXE = openvpn.exe
 
win/settings.in +13 -0
index 10c7926..79033dd 100644
@@ -33,8 +33,21 @@
 !define OPENVPN_GUI_DIR "../openvpn-gui"
 !define OPENVPN_GUI     "openvpn-gui-1.0.3.exe"
 
+# Use either PolarSSL or OpenSSL. Only one may be active at a time
+!define USE_POLARSSL 0
+!define USE_OPENSSL 1
+
+# The same as above, but for library inclusion (must be defined/undefined due to build system)
+;!define INCLUDE_POLARSSL
+!define INCLUDE_OPENSSL
+
+# Uncomment to use the PKCS#11 helper library
+!define USE_PKCS11 0
+;!define INCLUDE_PKCS11
+
 # Prebuilt libraries.  DMALLOC is optional.
 !define OPENSSL_DIR	  "../openssl"
+!define POLARSSL_DIR	  "../polarssl"
 !define LZO_DIR		  "../lzo"
 !define PKCS11_HELPER_DIR "../pkcs11-helper"
 
Signature · 1 line
1.7.5.4
#8 lore raw

PATCH 1/1 Fixed a regression causing VS2008/Python build failure

From: Samuli Seppänen <[email protected]...>

Patch "Added options to switch between OpenSSL and PolarSSL and PKCS11" caused a regression when building OpenVPN with Visual Studio 2008/Python build system. The underlying cause was a wrong path to lzo2.lib.

---
 win/msvc.mak.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
win/msvc.mak.in +1 -1
index d2babcf..26d7a33 100644
@@ -33,7 +33,7 @@ INCLUDE_DIRS = -I$(OPENSSL)/include -I$(POLARSSL)/include -I$(LZO)/include -I$(P
 
 LIBS = $(OPENSSL_DYNAMIC) $(POLARSSL_DYNAMIC) $(PKCS11_HELPER_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
 
-LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library -LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)
+LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library -LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)\lib
 
 EXE = openvpn.exe
 
Signature · 1 line
1.7.4.1
#9 lore raw

Re: [Openvpn-devel] [PATCH] Fixed a regression causing VS2008/Python build failure

ACK, my LZO library ends up in a different place for some reason...

Adriaan

Quoted 50 lines

-----Original Message-----
From: [email protected]... [mailto:[email protected]...]
Sent: woensdag 9 november 2011 10:50
To: [email protected]
Subject: [Openvpn-devel] [PATCH] Fixed a regression causing VS2008/Python build failure

From: Samuli Seppänen <[email protected]...>

Patch "Added options to switch between OpenSSL and PolarSSL and PKCS11" caused a
regression when building OpenVPN with Visual Studio 2008/Python build system.
The underlying cause was a wrong path to lzo2.lib.

---
 win/msvc.mak.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
win/msvc.mak.in +0 -0
index d2babcf..26d7a33 100644
@@ -33,7 +33,7 @@ INCLUDE_DIRS = -I$(OPENSSL)/include -

I$(POLARSSL)/include -I$(LZO)/include -I$(P

LIBS = $(OPENSSL_DYNAMIC) $(POLARSSL_DYNAMIC) $(PKCS11_HELPER_DYNAMIC)
$(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib

win/msvc.mak.in +1 -4
-LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library
-LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)
+LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library
-LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)\lib
 
 EXE = openvpn.exe
 
--

1.7.4.1

-----------------------------------------------------------------------
-------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#10 lore raw

Re: [Openvpn-devel] [PATCH 5/8] Added options to switch between OpenSSL and PolarSSL and PKCS11...

In reply to Adriaan de Jong
Quoted 106 lines

at compile time. Also included the option to enable/disable PKCS11.

---
 win/config.h.in |   18 +++++++++++++++---
 win/msvc.mak.in |   18 +++++++++++++++---
 win/settings.in |   13 +++++++++++++
 3 files changed, 43 insertions(+), 6 deletions(-)
win/config.h.in +15 -3
index ec447a2..e9df379 100644
@@ -74,7 +74,9 @@ typedef unsigned long in_addr_t;
 #endif
 
 /* Enable PKCS#11 support */
-/* #define USE_PKCS11 1 */
+#if @USE_PKCS11@ != 0
+#define USE_PKCS11 1
+#endif
 
 /* Enable HTTP proxy support */
 #if @ENABLE_HTTP_PROXY@ != 0
@@ -252,7 +254,17 @@ typedef unsigned long in_addr_t;
 #define TIME_WITH_SYS_TIME 1
 #endif
 
-/* Use OpenSSL crypto library */
+/* Use the PolarSSL crypto library */
+#if @USE_POLARSSL@ != 0
+#define USE_POLARSSL 1
+#endif
+
+/* Use the OpenSSL crypto library */
+#if @USE_OPENSSL@ != 0
+#define USE_OPENSSL 1
+#endif
+
+/* Use the crypto library */
 #define USE_CRYPTO 1
 
 /* Use LZO compression library */
@@ -264,7 +276,7 @@ typedef unsigned long in_addr_t;
 /* Use lzo/ directory prefix for LZO header files (for LZO 2.0) */
 #define LZO_HEADER_DIR 1
 
-/* Use OpenSSL SSL library */
+/* Use the SSL library */
 #define USE_SSL 1
 
 /* Version number of package */
win/msvc.mak.in +15 -3
index ac17ae9..d2babcf 100644
@@ -12,16 +12,28 @@
 # - OPENSSL_DIR and LZO_DIR are dynamically created from settings.in
 
 OPENSSL = @OPENSSL_DIR@
+!ifdef INCLUDE_OPENSSL
 OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib
+!endif
+
+POLARSSL = @POLARSSL_DIR@
+!ifdef INCLUDE_POLARSSL
+POLARSSL_DYNAMIC = polarssl.lib
+!endif
+
+PKCS11_HELPER = @PKCS11_HELPER_DIR@
+!ifdef INCLUDE_PKCS11
+PKCS11_HELPER_DYNAMIC = pkcs11-helper.lib
+!endif
 
 LZO = @LZO_DIR@
 LZO_DYNAMIC = lzo2.lib
 
-INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include
+INCLUDE_DIRS = -I$(OPENSSL)/include -I$(POLARSSL)/include -I$(LZO)/include -I$(PKCS11_HELPER)/include
 
-LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
+LIBS = $(OPENSSL_DYNAMIC) $(POLARSSL_DYNAMIC) $(PKCS11_HELPER_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
 
-LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib
+LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library -LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)
 
 EXE = openvpn.exe
 
win/settings.in +8 -0
index 10c7926..79033dd 100644
@@ -33,8 +33,21 @@
 !define OPENVPN_GUI_DIR "../openvpn-gui"
 !define OPENVPN_GUI     "openvpn-gui-1.0.3.exe"
 
+# Use either PolarSSL or OpenSSL. Only one may be active at a time
+!define USE_POLARSSL 0
+!define USE_OPENSSL 1
+
+# The same as above, but for library inclusion (must be defined/undefined due to build system)
+;!define INCLUDE_POLARSSL
+!define INCLUDE_OPENSSL
+

win/settings.in line 53

Quoted 10 lines
win/settings.in +5 -0
+# Uncomment to use the PKCS#11 helper library
+!define USE_PKCS11 0
+;!define INCLUDE_PKCS11
+
 # Prebuilt libraries.  DMALLOC is optional.
 !define OPENSSL_DIR	  "../openssl"
+!define POLARSSL_DIR	  "../polarssl"
 !define LZO_DIR		  "../lzo"
 !define PKCS11_HELPER_DIR "../pkcs11-helper"
 

ACK, provided that my small OpenSSL build fix is applied on top of this.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#11 lore raw

PATCH 6/8 Moved from strsep to strtok, for Windows compatibility

In reply to Adriaan de Jong
---
 ssl_polarssl.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
ssl_polarssl.c +9 -5
index 9a8c49c..60d99a8 100644
@@ -164,7 +164,7 @@ tls_ctx_set_options (struct tls_root_ctx *ctx, unsigned int ssl_flags)
 void
 tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
 {
-  char *tmp_ciphers, *tmp_ciphers_orig;
+  char *tmp_ciphers, *tmp_ciphers_orig, *token;
   int i, cipher_count;
   int ciphers_len = strlen (ciphers);
 
@@ -182,11 +182,15 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
   /* Parse allowed ciphers, getting IDs */
   i = 0;
   tmp_ciphers_orig = tmp_ciphers = strdup(ciphers);
-  while(tmp_ciphers) {
-      ctx->allowed_ciphers[i] = ssl_get_ciphersuite_id (strsep (&tmp_ciphers, ":"));
-      if (ctx->allowed_ciphers[i] != 0)
+
+  token = strtok (tmp_ciphers, ":");
+  while(token)
+    {
+      ctx->allowed_ciphers[i] = ssl_get_ciphersuite_id (token);
+      if (0 != ctx->allowed_ciphers[i])
 	i++;
-  }
+      token = strtok (NULL, ":");
+    }
   free(tmp_ciphers_orig);
 }
 
Signature · 1 line
1.7.5.4
#12 lore raw

PATCH 7/8 Minor cleanup to enable warning-free Windows build:

In reply to Adriaan de Jong

- Changed int32_t to size_t
- Removed some unused variables
- Added missing include files
- changed ordering to ensure variable declarations are before asserts

---
 crypto.c              |    3 +--
 pkcs11_polarssl.c     |    1 -
 ssl_openssl.c         |    6 +++---
 ssl_polarssl.c        |    2 --
 ssl_verify_openssl.c  |    1 +
 ssl_verify_polarssl.c |    2 +-
 6 files changed, 6 insertions(+), 9 deletions(-)
crypto.c +1 -2
index 375d35a..e628578 100644
@@ -1336,11 +1336,10 @@ prng_uninit (void)
 void
 prng_bytes (uint8_t *output, int len)
 {
-  static int32_t processed = 0;
+  static size_t processed = 0;
 
   if (nonce_md)
     {
-      md_ctx_t ctx;
       const int md_size = md_kt_size (nonce_md);
       while (len > 0)
 	{
pkcs11_polarssl.c +0 -1
index 4f8bf33..0f9daab 100644
@@ -40,7 +40,6 @@ pkcs11_init_tls_session(pkcs11h_certificate_t certificate,
     struct tls_root_ctx * const ssl_ctx)
 {
   int ret = 1;
-  pkcs11_context pkcs11_ctx;
 
   ASSERT (NULL != ssl_ctx);
 
ssl_openssl.c +3 -3
index 1cc2bfb..391968a 100644
@@ -38,6 +38,7 @@
 #include "memdbg.h"
 #include "ssl_backend.h"
 #include "ssl_common.h"
+#include "base64.h"
 
 #ifdef ENABLE_CRYPTOAPI
 #include "cryptoapi.h"
@@ -349,7 +350,6 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)
 static int
 tls_ctx_read_certificate_file(SSL_CTX *ctx, const char *file, X509 **x509)
 {
-  int j;
   BIO *in;
   int ret=0;
   X509 *x=NULL;
@@ -480,10 +480,10 @@ tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file
 #endif
     )
 {
-  ASSERT(NULL != ctx);
-
   int status;
 
+  ASSERT(NULL != ctx);
+
 #if ENABLE_INLINE_FILES
   if (!strcmp (priv_key_file, INLINE_FILE_TAG) && priv_key_file_inline)
     {
ssl_polarssl.c +0 -2
index 60d99a8..c50cf0a 100644
@@ -347,8 +347,6 @@ void tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file,
     const char *ca_path, bool tls_server
     )
 {
-  int status;
-
   if (ca_path)
       msg(M_FATAL, "ERROR: PolarSSL cannot handle the capath directive");
 
ssl_verify_openssl.c +1 -0
index 13c2f4e..e82f6f9 100644
@@ -35,6 +35,7 @@
 #include "ssl_verify_backend.h"
 #include "ssl_openssl.h"
 #include <openssl/x509v3.h>
+#include <openssl/err.h>
 
 int
 verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
ssl_verify_polarssl.c +1 -1
index 7fdca1f..699eb47 100644
@@ -191,7 +191,7 @@ x509_free_subject (char *subject)
 void
 x509_setenv (struct env_set *es, int cert_depth, x509_cert_t *cert)
 {
-  int i, ret;
+  int i;
   unsigned char c;
   const x509_name *name;
   char s[128];
Signature · 1 line
1.7.5.4
#13 lore raw

Re: [Openvpn-devel] [PATCH 7/8] Minor cleanup to enable warning-free Windows build:

Quoted 108 lines

- Changed int32_t to size_t
- Removed some unused variables
- Added missing include files
- changed ordering to ensure variable declarations are before asserts

---
 crypto.c              |    3 +--
 pkcs11_polarssl.c     |    1 -
 ssl_openssl.c         |    6 +++---
 ssl_polarssl.c        |    2 --
 ssl_verify_openssl.c  |    1 +
 ssl_verify_polarssl.c |    2 +-
 6 files changed, 6 insertions(+), 9 deletions(-)
crypto.c +1 -2
index 375d35a..e628578 100644
@@ -1336,11 +1336,10 @@ prng_uninit (void)
 void
 prng_bytes (uint8_t *output, int len)
 {
-  static int32_t processed = 0;
+  static size_t processed = 0;
 
   if (nonce_md)
     {
-      md_ctx_t ctx;
       const int md_size = md_kt_size (nonce_md);
       while (len > 0)
 	{
pkcs11_polarssl.c +0 -1
index 4f8bf33..0f9daab 100644
@@ -40,7 +40,6 @@ pkcs11_init_tls_session(pkcs11h_certificate_t certificate,
     struct tls_root_ctx * const ssl_ctx)
 {
   int ret = 1;
-  pkcs11_context pkcs11_ctx;
 
   ASSERT (NULL != ssl_ctx);
 
ssl_openssl.c +3 -3
index 1cc2bfb..391968a 100644
@@ -38,6 +38,7 @@
 #include "memdbg.h"
 #include "ssl_backend.h"
 #include "ssl_common.h"
+#include "base64.h"
 
 #ifdef ENABLE_CRYPTOAPI
 #include "cryptoapi.h"
@@ -349,7 +350,6 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)
 static int
 tls_ctx_read_certificate_file(SSL_CTX *ctx, const char *file, X509 **x509)
 {
-  int j;
   BIO *in;
   int ret=0;
   X509 *x=NULL;
@@ -480,10 +480,10 @@ tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file
 #endif
     )
 {
-  ASSERT(NULL != ctx);
-
   int status;
 
+  ASSERT(NULL != ctx);
+
 #if ENABLE_INLINE_FILES
   if (!strcmp (priv_key_file, INLINE_FILE_TAG) && priv_key_file_inline)
     {
ssl_polarssl.c +0 -2
index 60d99a8..c50cf0a 100644
@@ -347,8 +347,6 @@ void tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file,
     const char *ca_path, bool tls_server
     )
 {
-  int status;
-
   if (ca_path)
       msg(M_FATAL, "ERROR: PolarSSL cannot handle the capath directive");
 
ssl_verify_openssl.c +1 -0
index 13c2f4e..e82f6f9 100644
@@ -35,6 +35,7 @@
 #include "ssl_verify_backend.h"
 #include "ssl_openssl.h"
 #include <openssl/x509v3.h>
+#include <openssl/err.h>
 
 int
 verify_callback (int preverify_ok, X509_STORE_CTX * ctx)
ssl_verify_polarssl.c +0 -0
index 7fdca1f..699eb47 100644

ssl_verify_polarssl.c x509_free_subject (char *subject) · line 197

Quoted 8 lines
ssl_verify_polarssl.c +1 -1
@@ -191,7 +191,7 @@ x509_free_subject (char *subject)
 void
 x509_setenv (struct env_set *es, int cert_depth, x509_cert_t *cert)
 {
-  int i, ret;
+  int i;
   unsigned char c;
   const x509_name *name;
   char s[128];

Can confirm that Visual Studio/Python does not give any build errors when this patch and patch 4/8 have been applied. The resulting binary also seems to work properly.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#14 lore raw

PATCH 8/8 Fixed a typo when initialising cryptoapi certs

In reply to Adriaan de Jong
---
 ssl_openssl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ssl_openssl.c +1 -1
index 391968a..b95944c 100644
@@ -339,7 +339,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)
   /* Load Certificate and Private Key */
   if (!SSL_CTX_use_CryptoAPI_certificate (ctx->ctx, cryptoapi_cert))
     msg (M_SSLERR, "Cannot load certificate \"%s\" from Microsoft Certificate Store",
-	   options->cryptoapi_cert);
+	   cryptoapi_cert);
 }
 #endif /* WIN32 */
 
Signature · 1 line
1.7.5.4
#15 lore raw

Re: [Openvpn-devel] [PATCH 8/8] Fixed a typo when initialising cryptoapi certs

Quoted 14 lines · On Monday 31 October 2011 15:29:21 Adriaan de Jong wrote:
---
 ssl_openssl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
ssl_openssl.c +0 -0
index 391968a..b95944c 100644
@@ -339,7 +339,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const

char *cryptoapi_cert) /* Load Certificate and Private Key */
if (!SSL_CTX_use_CryptoAPI_certificate (ctx->ctx, cryptoapi_cert))
msg (M_SSLERR, "Cannot load certificate \"%s\" from Microsoft
Certificate Store", - options->cryptoapi_cert);

ssl_openssl.c tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert) · line 344

Quoted 3 lines
ssl_openssl.c +1 -0
+	   cryptoapi_cert);
 }
 #endif /* WIN32 */

ACK, as this fixes building git master for Windows.

Signature · 8 lines
Heiko Hund | Software Engineer | Phone +49-721-25516-237 | Fax -200
Astaro a Sophos Company | Amalienbadstr. 41 Bau 52 | 76227 Karlsruhe | Germany
Commercial Register: Mannheim HRA 702710 | Headquarter Location: Karlsruhe
 
Represented by the General Partner Astaro Verwaltungs GmbH
Amalienbadstraße 41 Bau 52 | 76227 Karlsruhe | Germany 
Commercial Register: Mannheim HRB 708248 | Executive Board: Gert Hansen,
Markus Hennig, Jan Hichert, Günter Junk, Dr. Frank Nellissen
#16 lore raw
In reply to Adriaan de Jong

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 11 lines · Adriaan de Jong

Hi,

The following series of patches enables Windows builds and fixes a few bugs to boot. Most of it I'm quite comfortable with.

The only unfortunate thing in these patches is switching between OpenSSL and PolarSSL. This currently requires changing two flags instead of one, due to the build system. If anyone has any suggestions there, please let me know.

Adriaan

I'll post the complete summary here, of what's included into the -testing and -stable master branches.

Quoted 1 line

[PATCH 1/8] Moved prng_uninit out of crypto_uninit_lib

commit 54628d1ac10675d4554b58500341e35e8ac4fcbb

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Acked-by: David Sommerseth <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>
Quoted 1 line

[PATCH 2/8] Moved CryptoAPI header include to the ssl_openssl.c

commit 9009aa464bd4d7c58cb9147d3b5344dc25792e57

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Acked-by: David Sommerseth <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>
Quoted 1 line

[PATCH 3/8] Fixed missing comma in plugin.h

commit 8d22a9905d1243dbaf10493abdbb91718e8f9969

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Acked-by: David Sommerseth <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>
Quoted 1 line

[PATCH 4/8] Reordered functions to ensure warning-free Windows build

commit 7ac7170d0a4b0bb8dadccf98795bba0e0f27d767

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Acked-by: Samuli Seppänen <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>

With an additional patch from Samuli:
* [PATCH] Fixed a regression causing VS2008/Python build failure commit 354bc04286abe157f906309bb2ab463ac160c5a7

    Signed-off-by: Samuli Seppänen <[email protected]...>
    Acked-by: Adriaan de Jong <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>
Quoted 1 line

[PATCH 5/8] Added options to switch between OpenSSL and PolarSSL and

commit 7a8d707237bb18cb1c001205267f399772bdc840

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Acked-by: Samuli Seppänen <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>
Quoted 1 line

[PATCH 6/8] Moved from strsep to strtok, for Windows compatibility

commit 1d90851ed012775b6c85379ee263c5f6ffc2021e

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Acked-by: David Sommerseth <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>
Quoted 1 line

[PATCH 7/8] Minor cleanup to enable warning-free Windows build:

commit be960aad88a78967e6425be0d1dc36ea1af6f584

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Tested-by: Samuli Seppänen <[email protected]...>
    Acked-by: David Sommerseth <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>
Quoted 1 line

[PATCH 8/8] Fixed a typo when initialising cryptoapi certs

commit b6a8bada51347e67a34630b23e48483eea8d9548

    Signed-off-by: Adriaan de Jong <[email protected]...>
    Acked-by: Heiko Hund <[email protected]...>
    Signed-off-by: David Sommerseth <[email protected]...>

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7KMGQACgkQDC186MBRfrqRDgCfcrAItK+TVG4bKGLWczfWgxXL qK0An2YviBGzXWQb2GY1Fvl7D4ME/sMc
=kHIB
-----END PGP SIGNATURE-----