diff options
author | Steve Holme <steve_holme@hotmail.com> | 2011-08-25 15:09:30 +0200 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2011-08-25 15:13:13 +0200 |
commit | d535cff77517214015e2d495677c40cfdec93053 (patch) | |
tree | 7143a27a6f4c985e6db2331458e67793c5224156 /lib/curl_ntlm.c | |
parent | f5ad192d2373b24ef600358adb78bf02beffe426 (diff) | |
download | curl-d535cff77517214015e2d495677c40cfdec93053.tar.gz |
http NTLM: refactoring followup
Output of Curl_ntlm_create_type1_message() and Curl_ntlm_create_type3_message()
functions is now already base64 encoded.
Diffstat (limited to 'lib/curl_ntlm.c')
-rw-r--r-- | lib/curl_ntlm.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/lib/curl_ntlm.c b/lib/curl_ntlm.c index b555f5ab6..ea8936eb3 100644 --- a/lib/curl_ntlm.c +++ b/lib/curl_ntlm.c @@ -684,28 +684,25 @@ static void unicodecpy(unsigned char *dest, /* * Curl_ntlm_create_type1_message() * - * This is used to generate a ntlm type-1 message ready for encoding - * and sending to the recipient, be it a: HTTP, SMTP or POP3 server, + * This is used to generate an already encoded NTLM type-1 message ready + * for sending to the recipient, be it a: HTTP, SMTP or POP3 server, * using the appropriate compile time crypo API. * * Parameters: * * userp [in] - The user name in the format User or Domain\User. * passdwp [in] - The user's password. - * ntlm [in] - The ntlm data struct being used and modified. - * ntlmbuf [in] - Pointer to preallocated buffer to receive message. - * sizep [out] - Size of message written into output buffer. + * ntlm [in/out] - The ntlm data struct being used and modified. + * outptr [in/out] - The adress where a pointer to newly allocated memory + * holding the result will be stored upon completion. * * Returns CURLE_OK on success. */ CURLcode Curl_ntlm_create_type1_message(const char *userp, const char *passwdp, struct ntlmdata *ntlm, - unsigned char *ntlmbuf, - size_t *sizep) + char **outptr) { - size_t size; - /* NTLM type-1 message structure: Index Description Content @@ -720,6 +717,10 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, (*) -> Optional */ + unsigned char ntlmbuf[NTLM_BUFSIZE]; + size_t base64_sz = 0; + size_t size; + #ifdef USE_WINDOWS_SSPI SecBuffer buf; @@ -895,17 +896,15 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, fprintf(stderr, "\n****\n"); }); - /* Return the message size */ - *sizep = size; - - return CURLE_OK; + /* Return with binary blob encoded into base64 */ + return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, &base64_sz); } /* * Curl_ntlm_create_type3_message() * - * This is used to generate a ntlm type-3 message ready for encoding - * and sending to the recipient, be it a: HTTP, SMTP or POP3 server, + * This is used to generate an already encoded NTLM type-3 message ready + * for sending to the recipient, be it a: HTTP, SMTP or POP3 server, * using the appropriate compile time crypo API. * * Parameters: @@ -913,9 +912,9 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, * data [in] - The session handle. * userp [in] - The user name in the format User or Domain\User. * passdwp [in] - The user's password. - * ntlm [in] - The ntlm data struct being used and modified. - * ntlmbuf [in] - Pointer to preallocated buffer to receive message. - * sizep [out] - Size of message written into output buffer. + * ntlm [in/out] - The ntlm data struct being used and modified. + * outptr [in/out] - The adress where a pointer to newly allocated memory + * holding the result will be stored upon completion. * * Returns CURLE_OK on success. */ @@ -923,8 +922,7 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, const char *userp, const char *passwdp, struct ntlmdata *ntlm, - unsigned char *ntlmbuf, - size_t *sizep) + char **outptr) { /* NTLM type-3 message structure: @@ -944,7 +942,8 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, (*) -> Optional */ - + unsigned char ntlmbuf[NTLM_BUFSIZE]; + size_t base64_sz = 0; size_t size; #ifdef USE_WINDOWS_SSPI @@ -1294,10 +1293,8 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, #endif - /* Return the message size */ - *sizep = size; - - return CURLE_OK; + /* Return with binary blob encoded into base64 */ + return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, &base64_sz); } #endif /* USE_NTLM */ |