Windows build fixes.
Windows doesn't have ssize_t, sadly. There's SSIZE_T, but defining an
OPENSSL_SSIZE_T seems worse than just using an int.
Change-Id: I09bb5aa03f96da78b619e551f92ed52ce24d9f3f
Reviewed-on: https://boringssl-review.googlesource.com/1352
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/base.h b/include/openssl/base.h
index 4bc10e5..d79d63f 100644
--- a/include/openssl/base.h
+++ b/include/openssl/base.h
@@ -89,7 +89,7 @@
#define OPENSSL_APPLE
#endif
-#if defined(WIN32)
+#if defined(WIN32) || defined(_WIN32)
#define OPENSSL_WINDOWS
#endif
diff --git a/include/openssl/base64.h b/include/openssl/base64.h
index 606d5ab..38cb0ee 100644
--- a/include/openssl/base64.h
+++ b/include/openssl/base64.h
@@ -134,9 +134,8 @@
*
* WARNING: EVP_DecodeBlock's return value does not take padding into
* account. TODO(davidben): Possible or worth it to fix or add new API? */
-OPENSSL_EXPORT ssize_t
- EVP_DecodeBlock(uint8_t *dst, const uint8_t *src, size_t src_len);
-
+OPENSSL_EXPORT int EVP_DecodeBlock(uint8_t *dst, const uint8_t *src,
+ size_t src_len);
struct evp_encode_ctx_st {
unsigned num; /* number saved in a partial encode/decode */
diff --git a/include/openssl/dh.h b/include/openssl/dh.h
index 84fb456..9d8bda2 100644
--- a/include/openssl/dh.h
+++ b/include/openssl/dh.h
@@ -127,8 +127,8 @@
* writes it as a big-endian integer into |out|, which must have |DH_size|
* bytes of space. It returns the number of bytes written, or a negative number
* on error. */
-OPENSSL_EXPORT ssize_t
- DH_compute_key(uint8_t *out, const BIGNUM *peers_key, DH *dh);
+OPENSSL_EXPORT int DH_compute_key(uint8_t *out, const BIGNUM *peers_key,
+ DH *dh);
/* Utility functions. */
@@ -217,8 +217,8 @@
/* generate_parameters is called by |DH_generate_key|. */
int (*generate_key)(DH *dh);
- /* generate_parameters is called by |DH_compute_key|. */
- ssize_t (*compute_key)(DH *dh, uint8_t *out, const BIGNUM *pub_key);
+ /* compute_key is called by |DH_compute_key|. */
+ int (*compute_key)(DH *dh, uint8_t *out, const BIGNUM *pub_key);
};
struct dh_st {
diff --git a/include/openssl/dtls1.h b/include/openssl/dtls1.h
index 5871bdb..c835789 100644
--- a/include/openssl/dtls1.h
+++ b/include/openssl/dtls1.h
@@ -53,30 +53,20 @@
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
- * Hudson (tjh@cryptsoft.com).
- *
- */
+ * Hudson (tjh@cryptsoft.com). */
#ifndef HEADER_DTLS1_H
#define HEADER_DTLS1_H
+#include <openssl/base.h>
#include <openssl/buf.h>
#include <openssl/pqueue.h>
-#if defined(OPENSSL_WINDOWS)
-/* Including winsock.h pollutes the namespace too much with defines for
- * X509_NAME etc. */
-typedef struct timeval {
- long tv_sec;
- long tv_usec;
-} timeval;
-#else
-#include <sys/time.h>
-#endif
#ifdef __cplusplus
extern "C" {
#endif
+
#define DTLS1_VERSION 0xFEFF
#define DTLS1_BAD_VER 0x0100
#define DTLS1_2_VERSION 0xFEFD
@@ -108,6 +98,19 @@
#ifndef OPENSSL_NO_SSL_INTERN
+
+#if defined(OPENSSL_WINDOWS)
+/* Because of Windows header issues, we can't get the normal declaration of
+ * timeval. */
+typedef struct OPENSSL_timeval_st {
+ long tv_sec;
+ long tv_usec;
+} OPENSSL_timeval;
+#else
+#include <sys/time.h>
+typedef struct timeval OPENSSL_timeval;
+#endif
+
typedef struct dtls1_bitmap_st
{
unsigned long map; /* track 32 packets on 32-bit systems
@@ -223,8 +226,10 @@
struct dtls1_timeout_st timeout;
- /* Indicates when the last handshake msg or heartbeat sent will timeout */
- struct timeval next_timeout;
+ /* Indicates when the last handshake msg or heartbeat sent will
+ * timeout. Because of header issues on Windows, this cannot actually
+ * be a struct timeval. */
+ OPENSSL_timeval next_timeout;
/* Timeout duration */
unsigned short timeout_duration;
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index 497baa9..d1734a8 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -723,11 +723,7 @@
struct ssl_aead_ctx_st;
typedef struct ssl_aead_ctx_st SSL_AEAD_CTX;
-#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)
-#define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */
-#else
-#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */
-#endif
+#define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list */
#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20)
diff --git a/include/openssl/x509.h b/include/openssl/x509.h
index ac23f9c..29fba40 100644
--- a/include/openssl/x509.h
+++ b/include/openssl/x509.h
@@ -86,13 +86,6 @@
#endif
-#ifdef OPENSSL_SYS_WIN32
-/* Under Win32 these are defined in wincrypt.h */
-#undef X509_NAME
-#undef X509_CERT_PAIR
-#undef X509_EXTENSIONS
-#endif
-
#define X509_FILETYPE_PEM 1
#define X509_FILETYPE_ASN1 2
#define X509_FILETYPE_DEFAULT 3