]> granicus.if.org Git - curl/commitdiff
NTLM: header inclusion cleanup
authorYang Tse <yangsita@gmail.com>
Sun, 28 Aug 2011 05:15:46 +0000 (07:15 +0200)
committerYang Tse <yangsita@gmail.com>
Sun, 28 Aug 2011 05:15:46 +0000 (07:15 +0200)
lib/curl_ntlm.c
lib/curl_ntlm.h
lib/curl_ntlm_core.c
lib/curl_ntlm_core.h
lib/curl_ntlm_msgs.c
lib/curl_ntlm_msgs.h
lib/curl_ntlm_wb.c
lib/curl_ntlm_wb.h

index 50659b0ccb110b5aeb15f08a95a8bcbcdde602d3..bdf74053ceebbb8e605ddd28fdd60b643b008f82 100644 (file)
 
 #include "setup.h"
 
-/* NTLM details:
-
-   http://davenport.sourceforge.net/ntlm.html
-   http://www.innovation.ch/java/ntlm.html
-*/
-
 #ifdef USE_NTLM
 
-#define DEBUG_ME 0
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
+/*
+ * NTLM details:
+ *
+ * http://davenport.sourceforge.net/ntlm.html
+ * http://www.innovation.ch/java/ntlm.html
+ */
 
-#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
-#include <netdb.h>
-#endif
+#define DEBUG_ME 0
 
 #include "urldata.h"
-#include "non-ascii.h"  /* for Curl_convert_... prototypes */
 #include "sendf.h"
-#include "select.h"
 #include "rawstr.h"
-#include "curl_base64.h"
 #include "curl_ntlm.h"
 #include "curl_ntlm_msgs.h"
 #include "curl_ntlm_wb.h"
 #include "url.h"
-#include "strerror.h"
-#include "curl_gethostname.h"
 #include "curl_memory.h"
 
 #define _MPRINTF_REPLACE /* use our functions only */
index 008eb31e87ddd2e99a7bf3767707108f37c12118..e84ba3f6b567d138d39ae6cad7f42b388e1d6dbd 100644 (file)
@@ -22,6 +22,8 @@
  *
  ***************************************************************************/
 
+#include "setup.h"
+
 #ifdef USE_NTLM
 
 /* this is for ntlm header input */
index b8cc4c691e5b6fcefbc09487f8c75c3bebb2bfd1..0be16b47465b4b1b1a07e3aa035bcb39dca115bd 100644 (file)
 
 #include "setup.h"
 
-/* NTLM details:
+#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI)
 
-   http://davenport.sourceforge.net/ntlm.html
-   http://www.innovation.ch/java/ntlm.html
-*/
-
-#ifdef USE_NTLM
-
-#include "non-ascii.h"
-#include "rawstr.h"
-#include "curl_memory.h"
-
-#define _MPRINTF_REPLACE /* use our functions only */
-#include <curl/mprintf.h>
+/*
+ * NTLM details:
+ *
+ * http://davenport.sourceforge.net/ntlm.html
+ * http://www.innovation.ch/java/ntlm.html
+ */
 
 #ifdef USE_SSLEAY
-#include "ssluse.h"
-#    ifdef USE_OPENSSL
-#      include <openssl/des.h>
-#      ifndef OPENSSL_NO_MD4
-#        include <openssl/md4.h>
-#      endif
-#      include <openssl/md5.h>
-#      include <openssl/ssl.h>
-#      include <openssl/rand.h>
-#    else
-#      include <des.h>
-#      ifndef OPENSSL_NO_MD4
-#        include <md4.h>
-#      endif
-#      include <md5.h>
-#      include <ssl.h>
-#      include <rand.h>
-#    endif
-
-#ifndef OPENSSL_VERSION_NUMBER
-#error "OPENSSL_VERSION_NUMBER not defined"
-#endif
-
-#if OPENSSL_VERSION_NUMBER < 0x00907001L
-#define DES_key_schedule des_key_schedule
-#define DES_cblock des_cblock
-#define DES_set_odd_parity des_set_odd_parity
-#define DES_set_key des_set_key
-#define DES_ecb_encrypt des_ecb_encrypt
-
-/* This is how things were done in the old days */
-#define DESKEY(x) x
-#define DESKEYARG(x) x
-#else
-/* Modern version */
-#define DESKEYARG(x) *x
-#define DESKEY(x) &x
-#endif
 
-#ifdef OPENSSL_NO_MD4
-/* This requires MD4, but OpenSSL was compiled without it */
-#define USE_NTRESPONSES 0
-#define USE_NTLM2SESSION 0
-#endif
+#  ifdef USE_OPENSSL
+#    include <openssl/des.h>
+#    ifndef OPENSSL_NO_MD4
+#      include <openssl/md4.h>
+#    endif
+#    include <openssl/md5.h>
+#    include <openssl/ssl.h>
+#    include <openssl/rand.h>
+#  else
+#    include <des.h>
+#    ifndef OPENSSL_NO_MD4
+#      include <md4.h>
+#    endif
+#    include <md5.h>
+#    include <ssl.h>
+#    include <rand.h>
+#  endif
+#  if (OPENSSL_VERSION_NUMBER < 0x00907001L)
+#    define DES_key_schedule des_key_schedule
+#    define DES_cblock des_cblock
+#    define DES_set_odd_parity des_set_odd_parity
+#    define DES_set_key des_set_key
+#    define DES_ecb_encrypt des_ecb_encrypt
+#    define DESKEY(x) x
+#    define DESKEYARG(x) x
+#  else
+#    define DESKEYARG(x) *x
+#    define DESKEY(x) &x
+#  endif
 
 #elif defined(USE_GNUTLS)
 
-#include "gtls.h"
-#include <gcrypt.h>
-
-#define MD5_DIGEST_LENGTH 16
-#define MD4_DIGEST_LENGTH 16
+#  include <gcrypt.h>
+#  define MD5_DIGEST_LENGTH 16
+#  define MD4_DIGEST_LENGTH 16
 
 #elif defined(USE_NSS)
 
-#include "curl_md4.h"
-#include "nssg.h"
-#include <nss.h>
-#include <pk11pub.h>
-#include <hasht.h>
-#define MD5_DIGEST_LENGTH MD5_LENGTH
-
-#elif defined(USE_WINDOWS_SSPI)
-
-#include "curl_sspi.h"
+#  include <nss.h>
+#  include <pk11pub.h>
+#  include <hasht.h>
+#  include "curl_md4.h"
+#  define MD5_DIGEST_LENGTH MD5_LENGTH
 
 #else
-#    error "Can't compile NTLM support without a crypto library."
-#endif
-
-#ifndef USE_NTRESPONSES
-/* Define this to make the type-3 message include the NT response message */
-#define USE_NTRESPONSES 1
-
-/* Define this to make the type-3 message include the NTLM2Session response
-   message, requires USE_NTRESPONSES. */
-#define USE_NTLM2SESSION 1
+#  error "Can't compile NTLM support without a crypto library."
 #endif
 
+#include "urldata.h"
+#include "non-ascii.h"
+#include "rawstr.h"
+#include "curl_memory.h"
 #include "curl_ntlm_core.h"
 
+#define _MPRINTF_REPLACE /* use our functions only */
+#include <curl/mprintf.h>
+
 /* The last #include file should be: */
 #include "memdebug.h"
 
-#ifndef USE_WINDOWS_SSPI
-
 #ifdef USE_SSLEAY
 /*
  * Turns a 56 bit key into the 64 bit, odd parity key and sets the key.  The
@@ -407,6 +376,4 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data,
 }
 #endif /* USE_NTRESPONSES */
 
-#endif /* !USE_WINDOWS_SSPI */
-
-#endif /* USE_NTLM */
+#endif /* USE_NTLM && !USE_WINDOWS_SSPI */
index ea855905fc8ba51a4ff12fc0adf85dc02a0d08f9..5615b3504473cf24895234c833e65a6d2a310284 100644 (file)
  *
  ***************************************************************************/
 
-#ifdef USE_NTLM
+#include "setup.h"
+
+#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI)
+
+#ifdef USE_SSLEAY
+#  if !defined(OPENSSL_VERSION_NUMBER) && \
+      !defined(HEADER_SSL_H) && !defined(HEADER_MD5_H)
+#    error "curl_ntlm_core.h shall not be included before OpenSSL headers."
+#  endif
+#  ifdef OPENSSL_NO_MD4
+#    define USE_NTRESPONSES 0
+#    define USE_NTLM2SESSION 0
+#  endif
+#endif
+
+/*
+ * Define USE_NTRESPONSES to 1 in order to make the type-3 message include
+ * the NT response message. Define USE_NTLM2SESSION to 1 in order to make
+ * the type-3 message include the NTLM2Session response message, requires
+ * USE_NTRESPONSES defined to 1.
+ */
+
+#ifndef USE_NTRESPONSES
+#  define USE_NTRESPONSES 1
+#  define USE_NTLM2SESSION 1
+#endif
 
 void Curl_ntlm_core_lm_resp(const unsigned char *keys,
                             const unsigned char *plaintext,
@@ -32,12 +57,12 @@ void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data,
                                const char *password,
                                unsigned char *lmbuffer /* 21 bytes */);
 
-#if !defined(USE_WINDOWS_SSPI) && (USE_NTRESPONSES != 0)
+#if USE_NTRESPONSES
 CURLcode Curl_ntlm_core_mk_nt_hash(struct SessionHandle *data,
                                    const char *password,
                                    unsigned char *ntbuffer /* 21 bytes */);
 #endif
 
-#endif /* USE_NTLM */
+#endif /* USE_NTLM && !USE_WINDOWS_SSPI */
 
 #endif /* HEADER_CURL_NTLM_CORE_H */
index 732974b331fef22d65357a2f97c2a3c0a3f6ade3..e27e947dd0fddcb062ed7377d805b2eaa06ad011 100644 (file)
 
 #include "setup.h"
 
-/* NTLM details:
-
-   http://davenport.sourceforge.net/ntlm.html
-   http://www.innovation.ch/java/ntlm.html
-*/
-
 #ifdef USE_NTLM
 
-#define DEBUG_ME 0
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
-#include <netdb.h>
-#endif
-
-#define BUILDING_CURL_NTLM_MSGS_C
-
-#include "urldata.h"
-#include "non-ascii.h"
-#include "sendf.h"
-#include "select.h"
-#include "rawstr.h"
-#include "curl_base64.h"
-#include "curl_ntlm_msgs.h"
-#include "url.h"
-#include "strerror.h"
-#include "curl_gethostname.h"
-#include "curl_memory.h"
+/*
+ * NTLM details:
+ *
+ * http://davenport.sourceforge.net/ntlm.html
+ * http://www.innovation.ch/java/ntlm.html
+ */
 
-#define _MPRINTF_REPLACE /* use our functions only */
-#include <curl/mprintf.h>
+#define DEBUG_ME 0
 
 #ifdef USE_SSLEAY
-#include "ssluse.h"
-#    ifdef USE_OPENSSL
-#      include <openssl/des.h>
-#      ifndef OPENSSL_NO_MD4
-#        include <openssl/md4.h>
-#      endif
-#      include <openssl/md5.h>
-#      include <openssl/ssl.h>
-#      include <openssl/rand.h>
-#    else
-#      include <des.h>
-#      ifndef OPENSSL_NO_MD4
-#        include <md4.h>
-#      endif
-#      include <md5.h>
-#      include <ssl.h>
-#      include <rand.h>
-#    endif
-
-#ifndef OPENSSL_VERSION_NUMBER
-#error "OPENSSL_VERSION_NUMBER not defined"
-#endif
 
-#ifdef OPENSSL_NO_MD4
-/* This requires MD4, but OpenSSL was compiled without it */
-#define USE_NTRESPONSES 0
-#define USE_NTLM2SESSION 0
-#endif
+#  ifdef USE_OPENSSL
+#    include <openssl/des.h>
+#    ifndef OPENSSL_NO_MD4
+#      include <openssl/md4.h>
+#    endif
+#    include <openssl/md5.h>
+#    include <openssl/ssl.h>
+#    include <openssl/rand.h>
+#  else
+#    include <des.h>
+#    ifndef OPENSSL_NO_MD4
+#      include <md4.h>
+#    endif
+#    include <md5.h>
+#    include <ssl.h>
+#    include <rand.h>
+#  endif
+#  include "ssluse.h"
 
 #elif defined(USE_GNUTLS)
 
-#include "gtls.h"
-#include <gcrypt.h>
-
-#define MD5_DIGEST_LENGTH 16
-#define MD4_DIGEST_LENGTH 16
+#  include <gcrypt.h>
+#  include "gtls.h"
+#  define MD5_DIGEST_LENGTH 16
+#  define MD4_DIGEST_LENGTH 16
 
 #elif defined(USE_NSS)
 
-#include "curl_md4.h"
-#include "nssg.h"
-#include <nss.h>
-#include <pk11pub.h>
-#include <hasht.h>
-#define MD5_DIGEST_LENGTH MD5_LENGTH
+#  include <nss.h>
+#  include <pk11pub.h>
+#  include <hasht.h>
+#  include "nssg.h"
+#  include "curl_md4.h"
+#  define MD5_DIGEST_LENGTH MD5_LENGTH
 
 #elif defined(USE_WINDOWS_SSPI)
-
-#include "curl_sspi.h"
-
+#  include "curl_sspi.h"
 #else
-#    error "Can't compile NTLM support without a crypto library."
+#  error "Can't compile NTLM support without a crypto library."
 #endif
 
-#ifndef USE_NTRESPONSES
-/* Define this to make the type-3 message include the NT response message */
-#define USE_NTRESPONSES 1
+#include "urldata.h"
+#include "non-ascii.h"
+#include "sendf.h"
+#include "curl_base64.h"
+#include "curl_ntlm_core.h"
+#include "curl_gethostname.h"
+#include "curl_memory.h"
 
-/* Define this to make the type-3 message include the NTLM2Session response
-   message, requires USE_NTRESPONSES. */
-#define USE_NTLM2SESSION 1
-#endif
+#define BUILDING_CURL_NTLM_MSGS_C
+#include "curl_ntlm_msgs.h"
 
-#include "curl_ntlm_core.h"
+#define _MPRINTF_REPLACE /* use our functions only */
+#include <curl/mprintf.h>
 
 /* The last #include file should be: */
 #include "memdebug.h"
index 3e037b1f11ec81041c36b44e5795d0fd44ff8f14..1d4549558317f1f929cd9f7f6cfab40e48963e10 100644 (file)
@@ -22,6 +22,8 @@
  *
  ***************************************************************************/
 
+#include "setup.h"
+
 #ifdef USE_NTLM
 
 /* This is to generate a base64 encoded NTLM type-1 message */
index 2b400e8a6bf05923953fb348450de89227f567ac..b9cc314ef88052ff836c43335359a7b9d56d4c2a 100644 (file)
 
 #if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
 
+/*
+ * NTLM details:
+ *
+ * http://davenport.sourceforge.net/ntlm.html
+ * http://www.innovation.ch/java/ntlm.html
+ */
+
 #define DEBUG_ME 0
 
 #ifdef HAVE_UNISTD_H
index b7448a736790801e29c552831c436bf159f958ea..e3eaffe176af7592143feca9d7f3f63895a99365 100644 (file)
@@ -22,6 +22,8 @@
  *
  ***************************************************************************/
 
+#include "setup.h"
+
 #if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
 
 /* this is for creating ntlm header output by delegating challenge/response
@@ -30,6 +32,6 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy);
 
 void Curl_ntlm_wb_cleanup(struct connectdata *conn);
 
-#endif
+#endif /* USE_NTLM && NTLM_WB_ENABLED */
 
 #endif /* HEADER_CURL_NTLM_WB_H */