sasl: Reduced the need for two sets of NTLM functions

This commit is contained in:
Steve Holme 2014-11-23 16:22:37 +00:00
parent 33be9e29be
commit bfdef6301c
3 changed files with 22 additions and 123 deletions

View File

@ -233,13 +233,12 @@ static CURLcode ntlm_decode_type2_target(struct SessionHandle *data,
*/
/*
* Curl_ntlm_decode_type2_message()
* Curl_sasl_decode_ntlm_type2_message()
*
* This is used to decode a ntlm type-2 message received from a HTTP or SASL
* based (such as SMTP, POP3 or IMAP) server. The message is first decoded
* from a base64 string into a raw ntlm message and checked for validity
* before the appropriate data for creating a type-3 message is written to
* the given ntlm data structure.
* This is used to decode an already encoded NTLM type-2 message. The message
* is first decoded from a base64 string into a raw NTLM message and checked
* for validity before the appropriate data for creating a type-3 message is
* written to the given NTLM data structure.
*
* Parameters:
*
@ -249,7 +248,7 @@ static CURLcode ntlm_decode_type2_target(struct SessionHandle *data,
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data,
CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data,
const char *type2msg,
struct ntlmdata *ntlm)
{
@ -346,11 +345,10 @@ static void unicodecpy(unsigned char *dest, const char *src, size_t length)
}
/*
* Curl_ntlm_create_type1_message()
* Curl_sasl_create_ntlm_type1_message()
*
* This is used to generate an already encoded NTLM type-1 message ready for
* sending to the recipient, be it a HTTP or SASL based (such as SMTP, POP3
* or IMAP) server, using the appropriate compile time crypo API.
* sending to the recipient using the appropriate compile time crypto API.
*
* Parameters:
*
@ -363,11 +361,10 @@ static void unicodecpy(unsigned char *dest, const char *src, size_t length)
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_ntlm_create_type1_message(const char *userp,
CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr,
size_t *outlen)
char **outptr, size_t *outlen)
{
/* NTLM type-1 message structure:
@ -467,11 +464,10 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp,
}
/*
* Curl_ntlm_create_type3_message()
* Curl_sasl_create_ntlm_type3_message()
*
* This is used to generate an already encoded NTLM type-3 message ready for
* sending to the recipient, be it a HTTP or SASL based (such as SMTP, POP3
* or IMAP) server, using the appropriate compile time crypo API.
* sending to the recipient using the appropriate compile time crypto API.
*
* Parameters:
*
@ -485,12 +481,12 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp,
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr,
size_t *outlen)
char **outptr, size_t *outlen)
{
/* NTLM type-3 message structure:

View File

@ -26,26 +26,6 @@
#ifdef USE_NTLM
/* This is to generate a base64 encoded NTLM type-1 message */
CURLcode Curl_ntlm_create_type1_message(const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr,
size_t *outlen);
/* This is to generate a base64 encoded NTLM type-3 message */
CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr,
size_t *outlen);
/* This is to decode a NTLM type-2 message */
CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data,
const char* header,
struct ntlmdata* ntlm);
/* NTLM buffer fixed size, large enough for long user + host + domain */
#define NTLM_BUFSIZE 1024

View File

@ -37,7 +37,6 @@
#include "curl_md5.h"
#include "vtls/vtls.h"
#include "curl_hmac.h"
#include "curl_ntlm_msgs.h"
#include "curl_sasl.h"
#include "warnless.h"
#include "curl_memory.h"
@ -1090,82 +1089,6 @@ void Curl_sasl_digest_cleanup(struct digestdata *digest)
#endif /* CURL_DISABLE_CRYPTO_AUTH */
#if defined(USE_NTLM) && !defined(USE_WINDOWS_SSPI)
/*
* Curl_sasl_create_ntlm_type1_message()
*
* This is used to generate an already encoded NTLM type-1 message ready for
* sending to the recipient.
*
* Note: This is a simple wrapper of the NTLM function which means that any
* SASL based protocols don't have to include the NTLM functions directly.
*
* Parameters:
*
* userp [in] - The user name in the format User or Domain\User.
* passdwp [in] - The user's password.
* ntlm [in/out] - The ntlm data struct being used and modified.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen [out] - The length of the output message.
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr, size_t *outlen)
{
return Curl_ntlm_create_type1_message(userp, passwdp, ntlm, outptr, outlen);
}
/*
* Curl_sasl_decode_ntlm_type2_message()
*
* This is used to decode an already encoded NTLM type-2 message.
*
* Parameters:
*
* data [in] - Pointer to session handle.
* type2msg [in] - Pointer to the base64 encoded type-2 message.
* ntlm [in/out] - The ntlm data struct being used and modified.
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data,
const char *type2msg,
struct ntlmdata *ntlm)
{
return Curl_ntlm_decode_type2_message(data, type2msg, ntlm);
}
/*
* Curl_sasl_create_ntlm_type3_message()
*
* This is used to generate an already encoded NTLM type-3 message ready for
* sending to the recipient.
*
* Parameters:
*
* data [in] - Pointer to session handle.
* userp [in] - The user name in the format User or Domain\User.
* passdwp [in] - The user's password.
* ntlm [in/out] - The ntlm data struct being used and modified.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen [out] - The length of the output message.
*
* Returns CURLE_OK on success.
*/
CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data,
const char *userp,
const char *passwdp,
struct ntlmdata *ntlm,
char **outptr, size_t *outlen)
{
return Curl_ntlm_create_type3_message(data, userp, passwdp, ntlm, outptr,
outlen);
}
/*
* Curl_sasl_ntlm_cleanup()
*