--- libarchive-3.3.2/libarchive/archive_cryptor.c.orig	2017-07-14 07:42:27.977310000 -0400
+++ libarchive-3.3.2/libarchive/archive_cryptor.c	2017-07-14 07:42:17.059675800 -0400
@@ -57,7 +57,7 @@ pbkdf2_sha1(const char *pw, size_t pw_le
 	return 0;
 }
 
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+#elif defined(_WIN32) || defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && defined(HAVE_WINDOWS_H)
 #ifdef _MSC_VER
 #pragma comment(lib, "Bcrypt.lib")
 #endif
@@ -168,7 +168,7 @@ aes_ctr_release(archive_crypto_ctx *ctx)
 	return 0;
 }
 
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+#elif defined(_WIN32) || defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && defined(HAVE_WINDOWS_H)
 
 static int
 aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
--- libarchive-3.3.2/libarchive/archive_cryptor_private.h.orig	2017-07-14 07:42:28.003312000 -0400
+++ libarchive-3.3.2/libarchive/archive_cryptor_private.h	2017-07-14 07:34:30.838942500 -0400
@@ -63,7 +63,10 @@ typedef struct {
 	unsigned	encr_pos;
 } archive_crypto_ctx;
 
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+#elif defined(_WIN32) || defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && defined(HAVE_WINDOWS_H)
+#if defined(__CYGWIN__)
+    # include <windows.h>
+#endif
 #include <bcrypt.h>
 
 /* Common in other bcrypt implementations, but missing from VS2008. */
--- libarchive-3.3.2/libarchive/archive_hmac.c.orig	2017-07-14 07:42:28.032321800 -0400
+++ libarchive-3.3.2/libarchive/archive_hmac.c	2017-07-14 07:34:30.848943200 -0400
@@ -74,7 +74,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ct
 	memset(ctx, 0, sizeof(*ctx));
 }
 
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+#elif defined(_WIN32) || defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && defined(HAVE_WINDOWS_H)
 
 #ifndef BCRYPT_HASH_REUSABLE_FLAG
 # define BCRYPT_HASH_REUSABLE_FLAG 0x00000020
--- libarchive-3.3.2/libarchive/archive_hmac_private.h.orig	2017-07-14 07:42:28.049323000 -0400
+++ libarchive-3.3.2/libarchive/archive_hmac_private.h	2017-07-14 07:34:30.858448100 -0400
@@ -53,7 +53,10 @@ int __libarchive_hmac_build_hack(void);
 
 typedef	CCHmacContext archive_hmac_sha1_ctx;
 
-#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
+#elif defined(_WIN32) || defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && defined(HAVE_WINDOWS_H)
+#if defined(__CYGWIN__)
+    # include <windows.h>
+#endif
 #include <bcrypt.h>
 
 typedef struct {
