diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 856d914fa..92cc40f01 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -22,9 +22,9 @@ LIB_VAUTH_CFILES = vauth/vauth.c vauth/cleartext.c vauth/cram.c \ vauth/digest.c vauth/digest_sspi.c vauth/krb5_gssapi.c \ - vauth/krb5_sspi.c + vauth/krb5_sspi.c vauth/ntlm.c vauth/ntlm_sspi.c -LIB_VAUTH_HFILES = vauth/vauth.h vauth/digest.h +LIB_VAUTH_HFILES = vauth/vauth.h vauth/digest.h vauth/ntlm.h LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \ vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c \ @@ -51,9 +51,8 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ openldap.c curl_gethostname.c gopher.c idn_win32.c \ http_negotiate_sspi.c http_proxy.c non-ascii.c asyn-ares.c \ asyn-thread.c curl_gssapi.c curl_ntlm.c curl_ntlm_wb.c \ - curl_ntlm_core.c curl_ntlm_msgs.c curl_sasl.c curl_multibyte.c \ - hostcheck.c conncache.c pipeline.c dotdot.c x509asn1.c \ - http2.c curl_sasl_sspi.c smb.c curl_endian.c curl_des.c + curl_ntlm_core.c curl_sasl.c curl_multibyte.c hostcheck.c conncache.c \ + pipeline.c dotdot.c x509asn1.c http2.c smb.c curl_endian.c curl_des.c LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ @@ -69,9 +68,9 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ rtsp.h curl_threads.h warnless.h curl_hmac.h curl_rtmp.h \ curl_gethostname.h gopher.h http_proxy.h non-ascii.h asyn.h \ curl_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \ - curl_ntlm_msgs.h curl_sasl.h curl_multibyte.h hostcheck.h \ - conncache.h curl_setup_once.h multihandle.h setup-vms.h pipeline.h \ - dotdot.h x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \ + curl_sasl.h curl_multibyte.h hostcheck.h conncache.h \ + curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \ + x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \ curl_printf.h LIB_RCFILES = libcurl.rc diff --git a/lib/Makefile.vc6 b/lib/Makefile.vc6 index 75f108710..57e03929f 100644 --- a/lib/Makefile.vc6 +++ b/lib/Makefile.vc6 @@ -542,11 +542,9 @@ X_OBJS= \ $(DIROBJ)\curl_multibyte.obj \ $(DIROBJ)\curl_ntlm.obj \ $(DIROBJ)\curl_ntlm_core.obj \ - $(DIROBJ)\curl_ntlm_msgs.obj \ $(DIROBJ)\curl_ntlm_wb.obj \ $(DIROBJ)\curl_rtmp.obj \ $(DIROBJ)\curl_sasl.obj \ - $(DIROBJ)\curl_sasl_sspi.obj \ $(DIROBJ)\curl_sspi.obj \ $(DIROBJ)\curl_threads.obj \ $(DIROBJ)\cyassl.obj \ @@ -626,6 +624,8 @@ X_OBJS= \ $(DIROBJ)\digest_sspi.obj \ $(DIROBJ)\krb5_gssapi.obj \ $(DIROBJ)\krb5_sspi.obj \ + $(DIROBJ)\ntlm.obj \ + $(DIROBJ)\ntlm_sspi.obj \ $(DIROBJ)\vtls.obj \ $(DIROBJ)\openssl.obj \ $(DIROBJ)\strdup.obj \ diff --git a/lib/curl_ntlm.c b/lib/curl_ntlm.c index d4842e468..f3fac5bab 100644 --- a/lib/curl_ntlm.c +++ b/lib/curl_ntlm.c @@ -37,9 +37,8 @@ #include "sendf.h" #include "rawstr.h" #include "curl_ntlm.h" -#include "curl_ntlm_msgs.h" #include "curl_ntlm_wb.h" -#include "curl_sasl.h" +#include "vauth/vauth.h" #include "url.h" #include "curl_printf.h" diff --git a/lib/curl_ntlm_wb.c b/lib/curl_ntlm_wb.c index 06f66702d..71bc08700 100644 --- a/lib/curl_ntlm_wb.c +++ b/lib/curl_ntlm_wb.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -47,7 +47,7 @@ #include "urldata.h" #include "sendf.h" #include "select.h" -#include "curl_ntlm_msgs.h" +#include "vauth/ntlm.h" #include "curl_ntlm_wb.h" #include "url.h" #include "strerror.h" diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index c57bc37a7..aabf3ecf5 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -70,27 +70,6 @@ const struct { { ZERO_NULL, 0, 0 } }; -#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI) -/* - * Curl_sasl_ntlm_cleanup() - * - * This is used to clean up the NTLM specific data. - * - * Parameters: - * - * ntlm [in/out] - The NTLM data struct being cleaned up. - * - */ -void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm) -{ - /* Free the target info */ - Curl_safefree(ntlm->target_info); - - /* Reset any variables */ - ntlm->target_info_len = 0; -} -#endif /* USE_NTLM && !USE_WINDOWS_SSPI*/ - /* * sasl_create_oauth_bearer_message() * diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 7fd658846..6535fedbc 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -27,10 +27,6 @@ struct SessionHandle; struct connectdata; -#if defined(USE_NTLM) -struct ntlmdata; -#endif - /* Authentication mechanism flags */ #define SASL_MECH_LOGIN (1 << 0) #define SASL_MECH_PLAIN (1 << 1) @@ -118,31 +114,6 @@ struct SASL { (wordlen == (sizeof(mech) - 1) / sizeof(char) && \ !memcmp(line, mech, wordlen)) -#ifdef USE_NTLM -/* This is used to generate a base64 encoded NTLM type-1 message */ -CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, - size_t *outlen); - -/* This is used to decode a base64 encoded NTLM type-2 message */ -CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, - const char *type2msg, - struct ntlmdata *ntlm); - -/* This is used to generate a base64 encoded NTLM type-3 message */ -CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, - const char *userp, - const char *passwdp, - struct ntlmdata *ntlm, - char **outptr, size_t *outlen); - -/* This is used to clean up the ntlm specific data */ -void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm); - -#endif /* USE_NTLM */ - /* This is used to cleanup any libraries or curl modules used by the sasl functions */ void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused); diff --git a/lib/curl_ntlm_msgs.c b/lib/vauth/ntlm.c similarity index 98% rename from lib/curl_ntlm_msgs.c rename to lib/vauth/ntlm.c index fc9547207..aef29bdfb 100644 --- a/lib/curl_ntlm_msgs.c +++ b/lib/vauth/ntlm.c @@ -49,8 +49,8 @@ #endif #define BUILDING_CURL_NTLM_MSGS_C -#include "curl_ntlm_msgs.h" -#include "curl_sasl.h" +#include "vauth/vauth.h" +#include "vauth/ntlm.h" #include "curl_endian.h" #include "curl_printf.h" @@ -138,7 +138,9 @@ static void ntlm_print_flags(FILE *handle, unsigned long flags) static void ntlm_print_hex(FILE *handle, const char *buf, size_t len) { const char *p = buf; - (void)handle; + + (void) handle; + fprintf(stderr, "0x"); while(len-- > 0) fprintf(stderr, "%02.2x", (unsigned int)*p++); @@ -818,4 +820,23 @@ CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, return result; } +/* +* Curl_sasl_ntlm_cleanup() +* +* This is used to clean up the NTLM specific data. +* +* Parameters: +* +* ntlm [in/out] - The NTLM data struct being cleaned up. +* +*/ +void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm) +{ + /* Free the target info */ + Curl_safefree(ntlm->target_info); + + /* Reset any variables */ + ntlm->target_info_len = 0; +} + #endif /* USE_NTLM && !USE_WINDOWS_SSPI */ diff --git a/lib/curl_ntlm_msgs.h b/lib/vauth/ntlm.h similarity index 97% rename from lib/curl_ntlm_msgs.h rename to lib/vauth/ntlm.h index b9026f87c..9a393f014 100644 --- a/lib/curl_ntlm_msgs.h +++ b/lib/vauth/ntlm.h @@ -1,5 +1,5 @@ -#ifndef HEADER_CURL_NTLM_MSGS_H -#define HEADER_CURL_NTLM_MSGS_H +#ifndef HEADER_CURL_NTLM_H +#define HEADER_CURL_NTLM_H /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -140,4 +140,4 @@ #endif /* USE_NTLM */ -#endif /* HEADER_CURL_NTLM_MSGS_H */ +#endif /* HEADER_CURL_NTLM_H */ diff --git a/lib/curl_sasl_sspi.c b/lib/vauth/ntlm_sspi.c similarity index 95% rename from lib/curl_sasl_sspi.c rename to lib/vauth/ntlm_sspi.c index d3dde2cfe..3f48d5080 100644 --- a/lib/curl_sasl_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -5,8 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2014 - 2016 Daniel Stenberg, , et al. - * Copyright (C) 2014 - 2016, Steve Holme, . + * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -19,35 +18,25 @@ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * - * RFC2617 Basic and Digest Access Authentication - * RFC2831 DIGEST-MD5 authentication - * RFC4422 Simple Authentication and Security Layer (SASL) - * RFC4752 The Kerberos V5 ("GSSAPI") SASL Mechanism - * ***************************************************************************/ #include "curl_setup.h" -#if defined(USE_WINDOWS_SSPI) +#if defined(USE_WINDOWS_SSPI) && defined(USE_NTLM) #include -#include "curl_sasl.h" #include "vauth/vauth.h" #include "urldata.h" #include "curl_base64.h" #include "warnless.h" #include "curl_multibyte.h" #include "sendf.h" -#include "strdup.h" -#include "curl_printf.h" -#include "rawstr.h" /* The last #include files should be: */ #include "curl_memory.h" #include "memdebug.h" -#if defined USE_NTLM /* * Curl_sasl_create_ntlm_type1_message() * @@ -320,6 +309,5 @@ void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm) /* Reset any variables */ ntlm->token_max = 0; } -#endif /* USE_NTLM */ -#endif /* USE_WINDOWS_SSPI */ +#endif /* USE_WINDOWS_SSPI && USE_NTLM */ diff --git a/lib/vauth/vauth.h b/lib/vauth/vauth.h index f38583a17..c26b9e31d 100644 --- a/lib/vauth/vauth.h +++ b/lib/vauth/vauth.h @@ -30,6 +30,10 @@ struct SessionHandle; struct digestdata; #endif +#if defined(USE_NTLM) +struct ntlmdata; +#endif + #if defined(USE_KERBEROS5) struct kerberos5data; #endif @@ -98,6 +102,30 @@ CURLcode Curl_sasl_create_digest_http_message(struct SessionHandle *data, void Curl_sasl_digest_cleanup(struct digestdata *digest); #endif /* !CURL_DISABLE_CRYPTO_AUTH */ +#if defined(USE_NTLM) +/* This is used to generate a base64 encoded NTLM type-1 message */ +CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, + size_t *outlen); + +/* This is used to decode a base64 encoded NTLM type-2 message */ +CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data, + const char *type2msg, + struct ntlmdata *ntlm); + +/* This is used to generate a base64 encoded NTLM type-3 message */ +CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data, + const char *userp, + const char *passwdp, + struct ntlmdata *ntlm, + char **outptr, size_t *outlen); + +/* This is used to clean up the NTLM specific data */ +void Curl_sasl_ntlm_cleanup(struct ntlmdata *ntlm); +#endif /* USE_NTLM */ + #if defined(USE_KERBEROS5) /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token message */ diff --git a/packages/Symbian/group/libcurl.mmp b/packages/Symbian/group/libcurl.mmp index 9cc57e05c..ab628bc53 100644 --- a/packages/Symbian/group/libcurl.mmp +++ b/packages/Symbian/group/libcurl.mmp @@ -37,11 +37,12 @@ SOURCE \ vtls/polarssl.c curl_rtmp.c openldap.c curl_gethostname.c gopher.c \ vtls/axtls.c idn_win32.c http_negotiate_sspi.c vtls/cyassl.c \ http_proxy.c non-ascii.c asyn-ares.c asyn-thread.c curl_gssapi.c \ - curl_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_ntlm_msgs.c \ - curl_sasl.c vtls/schannel.c curl_multibyte.c vtls/darwinssl.c \ - conncache.c curl_sasl_sspi.c smb.c curl_endian.c curl_des.c \ + curl_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c \ + vtls/schannel.c curl_multibyte.c vtls/darwinssl.c conncache.c \ + curl_sasl_sspi.c smb.c curl_endian.c curl_des.c \ vauth/vauth.c vauth/cleartext.c vauth/cram.c vauth/digest.c \ - vauth/digest_sspi.c vauth/krb5_gssapi.c vauth/krb5_sspi.c + vauth/digest_sspi.c vauth/krb5_gssapi.c vauth/krb5_sspi.c \ + vauth/ntlm.c vauth/ntlm_sspi.c USERINCLUDE ../../../lib ../../../include/curl #ifdef ENABLE_SSL