mirror of
https://github.com/curl/curl.git
synced 2026-08-06 21:06:21 +03:00
parent
0eed8b7330
commit
2253bc330f
64 changed files with 1218 additions and 1416 deletions
|
|
@ -138,20 +138,20 @@ bool Curl_auth_digest_get_pair(const char *str, char *value, char *content,
|
|||
#ifndef USE_WINDOWS_SSPI
|
||||
/* Convert MD5 chunk to RFC2617 (section 3.1.3) -suitable ASCII string */
|
||||
static void auth_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */
|
||||
unsigned char *dest) /* 33 bytes */
|
||||
unsigned char *dest) /* 33 bytes */
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 16; i++)
|
||||
curl_msnprintf((char *) &dest[i * 2], 3, "%02x", source[i]);
|
||||
curl_msnprintf((char *)&dest[i * 2], 3, "%02x", source[i]);
|
||||
}
|
||||
|
||||
/* Convert sha256 or SHA-512/256 chunk to RFC7616 -suitable ASCII string */
|
||||
static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */
|
||||
unsigned char *dest) /* 65 bytes */
|
||||
unsigned char *dest) /* 65 bytes */
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 32; i++)
|
||||
curl_msnprintf((char *) &dest[i * 2], 3, "%02x", source[i]);
|
||||
curl_msnprintf((char *)&dest[i * 2], 3, "%02x", source[i]);
|
||||
}
|
||||
|
||||
/* Perform quoted-string escaping as described in RFC2616 and its errata */
|
||||
|
|
@ -272,7 +272,7 @@ static CURLcode auth_decode_digest_md5_message(const struct bufref *chlgref,
|
|||
char *alg, size_t alen,
|
||||
char *qop, size_t qlen)
|
||||
{
|
||||
const char *chlg = (const char *) Curl_bufref_ptr(chlgref);
|
||||
const char *chlg = (const char *)Curl_bufref_ptr(chlgref);
|
||||
|
||||
/* Ensure we have a valid challenge message */
|
||||
if(!Curl_bufref_len(chlgref))
|
||||
|
|
@ -387,13 +387,13 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
if(!ctxt)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) userp,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)userp,
|
||||
curlx_uztoui(strlen(userp)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) realm,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)realm,
|
||||
curlx_uztoui(strlen(realm)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) passwdp,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)passwdp,
|
||||
curlx_uztoui(strlen(passwdp)));
|
||||
Curl_MD5_final(ctxt, digest);
|
||||
|
||||
|
|
@ -401,12 +401,12 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
if(!ctxt)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) digest, MD5_DIGEST_LEN);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) nonce,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)digest, MD5_DIGEST_LEN);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)nonce,
|
||||
curlx_uztoui(strlen(nonce)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) cnonce,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)cnonce,
|
||||
curlx_uztoui(strlen(cnonce)));
|
||||
Curl_MD5_final(ctxt, digest);
|
||||
|
||||
|
|
@ -427,10 +427,10 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) method,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)method,
|
||||
curlx_uztoui(strlen(method)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) spn,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)spn,
|
||||
curlx_uztoui(strlen(spn)));
|
||||
Curl_MD5_final(ctxt, digest);
|
||||
|
||||
|
|
@ -445,23 +445,23 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) HA1_hex, 2 * MD5_DIGEST_LEN);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) nonce,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)HA1_hex, 2 * MD5_DIGEST_LEN);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)nonce,
|
||||
curlx_uztoui(strlen(nonce)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) nonceCount,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)nonceCount,
|
||||
curlx_uztoui(strlen(nonceCount)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) cnonce,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)cnonce,
|
||||
curlx_uztoui(strlen(cnonce)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) qop,
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)qop,
|
||||
curlx_uztoui(strlen(qop)));
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) ":", 1);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)":", 1);
|
||||
|
||||
Curl_MD5_update(ctxt, (const unsigned char *) HA2_hex, 2 * MD5_DIGEST_LEN);
|
||||
Curl_MD5_update(ctxt, (const unsigned char *)HA2_hex, 2 * MD5_DIGEST_LEN);
|
||||
Curl_MD5_final(ctxt, digest);
|
||||
|
||||
for(i = 0; i < MD5_DIGEST_LEN; i++)
|
||||
|
|
@ -553,7 +553,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
|
|||
if(curlx_str_casecompare(&out, DIGEST_QOP_VALUE_STRING_AUTH))
|
||||
foundAuth = TRUE;
|
||||
else if(curlx_str_casecompare(&out,
|
||||
DIGEST_QOP_VALUE_STRING_AUTH_INT))
|
||||
DIGEST_QOP_VALUE_STRING_AUTH_INT))
|
||||
foundAuthInt = TRUE;
|
||||
if(curlx_str_single(&token, ','))
|
||||
break;
|
||||
|
|
@ -720,7 +720,7 @@ static CURLcode auth_create_digest_http_message(
|
|||
if(!hashthis)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
|
||||
result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis));
|
||||
curlx_free(hashthis);
|
||||
if(result)
|
||||
return result;
|
||||
|
|
@ -743,7 +743,7 @@ static CURLcode auth_create_digest_http_message(
|
|||
if(!hashthis)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
|
||||
result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis));
|
||||
curlx_free(hashthis);
|
||||
if(result)
|
||||
return result;
|
||||
|
|
@ -755,7 +755,7 @@ static CURLcode auth_create_digest_http_message(
|
|||
if(!tmp)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
result = hash(hashbuf, (unsigned char *) tmp, strlen(tmp));
|
||||
result = hash(hashbuf, (unsigned char *)tmp, strlen(tmp));
|
||||
curlx_free(tmp);
|
||||
if(result)
|
||||
return result;
|
||||
|
|
@ -799,7 +799,7 @@ static CURLcode auth_create_digest_http_message(
|
|||
if(!hashthis)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
|
||||
result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis));
|
||||
curlx_free(hashthis);
|
||||
if(result)
|
||||
return result;
|
||||
|
|
@ -816,7 +816,7 @@ static CURLcode auth_create_digest_http_message(
|
|||
if(!hashthis)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
|
||||
result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis));
|
||||
curlx_free(hashthis);
|
||||
if(result)
|
||||
return result;
|
||||
|
|
@ -1015,9 +1015,9 @@ void Curl_auth_digest_cleanup(struct digestdata *digest)
|
|||
|
||||
digest->nc = 0;
|
||||
digest->algo = ALGO_MD5; /* default algorithm */
|
||||
digest->stale = FALSE; /* default means normal, not stale */
|
||||
digest->stale = FALSE; /* default means normal, not stale */
|
||||
digest->userhash = FALSE;
|
||||
}
|
||||
#endif /* !USE_WINDOWS_SSPI */
|
||||
#endif /* !USE_WINDOWS_SSPI */
|
||||
|
||||
#endif /* !CURL_DISABLE_DIGEST_AUTH */
|
||||
#endif /* !CURL_DISABLE_DIGEST_AUTH */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue