mirror of
https://github.com/curl/curl.git
synced 2025-02-17 14:59:45 +08:00
sasl: Added service parameter to Curl_sasl_create_digest_md5_message()
Added a service type parameter to Curl_sasl_create_digest_md5_message() to allow the function to be used by different services rather than being hard coded to "smtp".
This commit is contained in:
parent
04a6f0a1a4
commit
bf51b8c07a
@ -240,6 +240,7 @@ CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data,
|
|||||||
* chlg64 [in] - Pointer to the input buffer.
|
* chlg64 [in] - Pointer to the input buffer.
|
||||||
* userp [in] - The user name.
|
* userp [in] - The user name.
|
||||||
* passdwp [in] - The user's password.
|
* passdwp [in] - The user's password.
|
||||||
|
* service [in] - The service type such as www, smtp or pop
|
||||||
* outptr [in/out] - The address where a pointer to newly allocated memory
|
* outptr [in/out] - The address where a pointer to newly allocated memory
|
||||||
* holding the result will be stored upon completion.
|
* holding the result will be stored upon completion.
|
||||||
* outlen [out] - The length of the output message.
|
* outlen [out] - The length of the output message.
|
||||||
@ -250,6 +251,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
|
|||||||
const char* chlg64,
|
const char* chlg64,
|
||||||
const char* userp,
|
const char* userp,
|
||||||
const char* passwdp,
|
const char* passwdp,
|
||||||
|
const char* service,
|
||||||
char **outptr, size_t *outlen)
|
char **outptr, size_t *outlen)
|
||||||
{
|
{
|
||||||
static const char table16[] = "0123456789abcdef";
|
static const char table16[] = "0123456789abcdef";
|
||||||
@ -271,7 +273,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
|
|||||||
char cnonce[] = "12345678"; /* will be changed */
|
char cnonce[] = "12345678"; /* will be changed */
|
||||||
char method[] = "AUTHENTICATE";
|
char method[] = "AUTHENTICATE";
|
||||||
char qop[] = "auth";
|
char qop[] = "auth";
|
||||||
char uri[128] = "smtp/";
|
char uri[128];
|
||||||
char response[512];
|
char response[512];
|
||||||
|
|
||||||
result = Curl_base64_decode(chlg64, &chlg, &chlglen);
|
result = Curl_base64_decode(chlg64, &chlg, &chlglen);
|
||||||
@ -341,7 +343,9 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
|
|||||||
for(i = 0; i < MD5_DIGEST_LEN; i++)
|
for(i = 0; i < MD5_DIGEST_LEN; i++)
|
||||||
snprintf(&HA1_hex[2 * i], 3, "%02x", digest[i]);
|
snprintf(&HA1_hex[2 * i], 3, "%02x", digest[i]);
|
||||||
|
|
||||||
/* Orepare URL string, append realm to the protocol */
|
/* Prepare the URL string */
|
||||||
|
strcpy(uri, service);
|
||||||
|
strcat(uri, "/");
|
||||||
strcat(uri, realm);
|
strcat(uri, realm);
|
||||||
|
|
||||||
/* Calculate H(A2) */
|
/* Calculate H(A2) */
|
||||||
|
@ -58,6 +58,7 @@ CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
|
|||||||
const char* chlg64,
|
const char* chlg64,
|
||||||
const char* user,
|
const char* user,
|
||||||
const char* passwdp,
|
const char* passwdp,
|
||||||
|
const char* service,
|
||||||
char **outptr, size_t *outlen);
|
char **outptr, size_t *outlen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -752,7 +752,8 @@ static CURLcode smtp_state_authdigest_resp(struct connectdata *conn,
|
|||||||
;
|
;
|
||||||
|
|
||||||
result = Curl_sasl_create_digest_md5_message(data, chlg64, conn->user,
|
result = Curl_sasl_create_digest_md5_message(data, chlg64, conn->user,
|
||||||
conn->passwd, &rplyb64, &len);
|
conn->passwd, "smtp",
|
||||||
|
&rplyb64, &len);
|
||||||
|
|
||||||
if(!result) {
|
if(!result) {
|
||||||
if(rplyb64) {
|
if(rplyb64) {
|
||||||
|
Loading…
Reference in New Issue
Block a user