Loading lib/curl_ntlm.c +22 −25 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading Loading @@ -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: Loading @@ -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. */ Loading @@ -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: Loading @@ -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 Loading Loading @@ -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 */ Loading lib/curl_ntlm.h +5 −7 Original line number Diff line number Diff line Loading @@ -24,22 +24,20 @@ #ifdef USE_NTLM /* This is to generate a ntlm type-1 message */ /* 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, unsigned char *ntlmbuf, size_t *size); char **outptr); /* This is to generate a ntlm type-3 message */ /* 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, unsigned char *ntlmbuf, size_t *size); char **outptr); /* This is to decode a ntlm type-2 message */ /* This is to decode a NTLM type-2 message */ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data, const char* header, struct ntlmdata* ntlm); Loading lib/http_ntlm.c +20 −45 Original line number Diff line number Diff line Loading @@ -453,13 +453,10 @@ CURLcode Curl_output_ntlm_sso(struct connectdata *conn, CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy) { size_t size = 0; char *base64 = NULL; size_t base64_sz = 0; unsigned char ntlmbuf[NTLM_BUFSIZE]; CURLcode error; /* point to the address of the pointer that holds the string to sent to the /* point to the address of the pointer that holds the string to send to the server, which is for a plain host or for a HTTP proxy */ char **allocuserpwd; Loading Loading @@ -514,22 +511,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, switch(ntlm->state) { case NTLMSTATE_TYPE1: default: /* for the weird cases we (re)start here */ /* Create a type-1 message */ error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, ntlmbuf, &size); if(error) return error; if(size > 0) { /* convert the binary blob into base64 */ error = Curl_base64_encode(NULL, (char *)ntlmbuf, size, &base64, &base64_sz); error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, &base64); if(error) return error; if(base64_sz > 0) { if(base64) { Curl_safefree(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", Loading @@ -537,26 +524,16 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd)); free(base64); } } break; case NTLMSTATE_TYPE2: /* We already received the type-2 message, create a type-3 message */ error = Curl_ntlm_create_type3_message(conn->data, userp, passwdp, ntlm, ntlmbuf, &size); if(error) return error; if(size > 0) { /* convert the binary blob into base64 */ error = Curl_base64_encode(NULL, (char *)ntlmbuf, size, &base64, &base64_sz); ntlm, &base64); if(error) return error; if(base64_sz > 0) { if(base64) { Curl_safefree(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", Loading @@ -564,11 +541,9 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd)); free(base64); ntlm->state = NTLMSTATE_TYPE3; /* we sent a type-3 */ ntlm->state = NTLMSTATE_TYPE3; /* we send a type-3 */ authp->done = TRUE; } } break; case NTLMSTATE_TYPE3: Loading Loading
lib/curl_ntlm.c +22 −25 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; Loading Loading @@ -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: Loading @@ -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. */ Loading @@ -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: Loading @@ -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 Loading Loading @@ -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 */ Loading
lib/curl_ntlm.h +5 −7 Original line number Diff line number Diff line Loading @@ -24,22 +24,20 @@ #ifdef USE_NTLM /* This is to generate a ntlm type-1 message */ /* 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, unsigned char *ntlmbuf, size_t *size); char **outptr); /* This is to generate a ntlm type-3 message */ /* 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, unsigned char *ntlmbuf, size_t *size); char **outptr); /* This is to decode a ntlm type-2 message */ /* This is to decode a NTLM type-2 message */ CURLcode Curl_ntlm_decode_type2_message(struct SessionHandle *data, const char* header, struct ntlmdata* ntlm); Loading
lib/http_ntlm.c +20 −45 Original line number Diff line number Diff line Loading @@ -453,13 +453,10 @@ CURLcode Curl_output_ntlm_sso(struct connectdata *conn, CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy) { size_t size = 0; char *base64 = NULL; size_t base64_sz = 0; unsigned char ntlmbuf[NTLM_BUFSIZE]; CURLcode error; /* point to the address of the pointer that holds the string to sent to the /* point to the address of the pointer that holds the string to send to the server, which is for a plain host or for a HTTP proxy */ char **allocuserpwd; Loading Loading @@ -514,22 +511,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, switch(ntlm->state) { case NTLMSTATE_TYPE1: default: /* for the weird cases we (re)start here */ /* Create a type-1 message */ error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, ntlmbuf, &size); if(error) return error; if(size > 0) { /* convert the binary blob into base64 */ error = Curl_base64_encode(NULL, (char *)ntlmbuf, size, &base64, &base64_sz); error = Curl_ntlm_create_type1_message(userp, passwdp, ntlm, &base64); if(error) return error; if(base64_sz > 0) { if(base64) { Curl_safefree(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", Loading @@ -537,26 +524,16 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd)); free(base64); } } break; case NTLMSTATE_TYPE2: /* We already received the type-2 message, create a type-3 message */ error = Curl_ntlm_create_type3_message(conn->data, userp, passwdp, ntlm, ntlmbuf, &size); if(error) return error; if(size > 0) { /* convert the binary blob into base64 */ error = Curl_base64_encode(NULL, (char *)ntlmbuf, size, &base64, &base64_sz); ntlm, &base64); if(error) return error; if(base64_sz > 0) { if(base64) { Curl_safefree(*allocuserpwd); *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", Loading @@ -564,11 +541,9 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd)); free(base64); ntlm->state = NTLMSTATE_TYPE3; /* we sent a type-3 */ ntlm->state = NTLMSTATE_TYPE3; /* we send a type-3 */ authp->done = TRUE; } } break; case NTLMSTATE_TYPE3: Loading