mirror of
https://github.com/curl/curl.git
synced 2026-07-26 20:57:18 +03:00
parent
0eed8b7330
commit
2253bc330f
64 changed files with 1218 additions and 1416 deletions
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
#include "../curl_setup.h"
|
||||
|
||||
#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
|
||||
!defined(CURL_DISABLE_POP3) || \
|
||||
#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
|
||||
!defined(CURL_DISABLE_POP3) || \
|
||||
(!defined(CURL_DISABLE_LDAP) && defined(USE_OPENLDAP))
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
|
@ -110,8 +110,7 @@ void Curl_auth_create_login_message(const char *valuep, struct bufref *out)
|
|||
*
|
||||
* Returns void.
|
||||
*/
|
||||
void Curl_auth_create_external_message(const char *user,
|
||||
struct bufref *out)
|
||||
void Curl_auth_create_external_message(const char *user, struct bufref *out)
|
||||
{
|
||||
/* This is the same formatting as the login message */
|
||||
Curl_auth_create_login_message(user, out);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ CURLcode Curl_auth_create_cram_md5_message(const struct bufref *chlg,
|
|||
|
||||
/* Compute the digest using the password as the key */
|
||||
ctxt = Curl_HMAC_init(&Curl_HMAC_MD5,
|
||||
(const unsigned char *) passwdp,
|
||||
(const unsigned char *)passwdp,
|
||||
curlx_uztoui(strlen(passwdp)));
|
||||
if(!ctxt)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@
|
|||
#include "../strerror.h"
|
||||
|
||||
/*
|
||||
* Curl_auth_is_digest_supported()
|
||||
*
|
||||
* This is used to evaluate if DIGEST is supported.
|
||||
*
|
||||
* Parameters: None
|
||||
*
|
||||
* Returns TRUE if DIGEST is supported by Windows SSPI.
|
||||
*/
|
||||
* Curl_auth_is_digest_supported()
|
||||
*
|
||||
* This is used to evaluate if DIGEST is supported.
|
||||
*
|
||||
* Parameters: None
|
||||
*
|
||||
* Returns TRUE if DIGEST is supported by Windows SSPI.
|
||||
*/
|
||||
bool Curl_auth_is_digest_supported(void)
|
||||
{
|
||||
PSecPkgInfo SecurityPackage;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ CURLcode Curl_auth_gsasl_token(struct Curl_easy *data,
|
|||
size_t outlen;
|
||||
|
||||
res = gsasl_step(gsasl->client,
|
||||
(const char *) Curl_bufref_ptr(chlg), Curl_bufref_len(chlg),
|
||||
(const char *)Curl_bufref_ptr(chlg), Curl_bufref_len(chlg),
|
||||
&response, &outlen);
|
||||
if(res != GSASL_OK && res != GSASL_NEEDS_MORE) {
|
||||
failf(data, "GSASL step: %s", gsasl_strerror(res));
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
|
|||
gss_release_buffer(&unused_status, &output_token);
|
||||
}
|
||||
else
|
||||
Curl_bufref_set(out, mutual_auth ? "": NULL, 0, NULL);
|
||||
Curl_bufref_set(out, mutual_auth ? "" : NULL, 0, NULL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,8 +278,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
|
|||
|
||||
/* Get our response size information */
|
||||
status = Curl_pSecFn->QueryContextAttributes(krb5->context,
|
||||
SECPKG_ATTR_SIZES,
|
||||
&sizes);
|
||||
SECPKG_ATTR_SIZES, &sizes);
|
||||
|
||||
if(status == SEC_E_INSUFFICIENT_MEMORY)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
#include "vauth.h"
|
||||
#include "../curl_endian.h"
|
||||
|
||||
|
||||
/* NTLM buffer fixed size, large enough for long user + host + domain */
|
||||
#define NTLM_BUFSIZE 1024
|
||||
|
||||
|
|
@ -158,7 +157,7 @@
|
|||
#define NTLMSSP_SIGNATURE "\x4e\x54\x4c\x4d\x53\x53\x50"
|
||||
|
||||
#if DEBUG_ME
|
||||
# define DEBUG_OUT(x) x
|
||||
#define DEBUG_OUT(x) x
|
||||
static void ntlm_print_flags(FILE *handle, unsigned long flags)
|
||||
{
|
||||
if(flags & NTLMFLAG_NEGOTIATE_UNICODE)
|
||||
|
|
@ -236,7 +235,7 @@ static void ntlm_print_hex(FILE *handle, const char *buf, size_t len)
|
|||
curl_mfprintf(stderr, "%02.2x", (unsigned int)*p++);
|
||||
}
|
||||
#else
|
||||
# define DEBUG_OUT(x) Curl_nop_stmt
|
||||
#define DEBUG_OUT(x) Curl_nop_stmt
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
|
|||
}
|
||||
|
||||
/*
|
||||
* Curl_auth_create_ntlm_type3_message()
|
||||
* Curl_auth_create_ntlm_type3_message()
|
||||
*
|
||||
* This is used to generate an already encoded NTLM type-3 message ready for
|
||||
|
|
@ -267,12 +266,12 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
|
|||
|
||||
#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
|
||||
/* ssl context comes from schannel.
|
||||
* When extended protection is used in IIS server,
|
||||
* we have to pass a second SecBuffer to the SecBufferDesc
|
||||
* otherwise IIS will not pass the authentication (401 response).
|
||||
* Minimum supported version is Windows 7.
|
||||
* https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811
|
||||
*/
|
||||
* When extended protection is used in IIS server,
|
||||
* we have to pass a second SecBuffer to the SecBufferDesc
|
||||
* otherwise IIS will not pass the authentication (401 response).
|
||||
* Minimum supported version is Windows 7.
|
||||
* https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811
|
||||
*/
|
||||
if(ntlm->sslContext) {
|
||||
SEC_CHANNEL_BINDINGS channelBindings;
|
||||
SecPkgContext_Bindings pkgBindings;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include "../curl_setup.h"
|
||||
|
||||
#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
|
||||
!defined(CURL_DISABLE_POP3) || \
|
||||
!defined(CURL_DISABLE_POP3) || \
|
||||
(!defined(CURL_DISABLE_LDAP) && defined(USE_OPENLDAP))
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
|
|||
nego->output_token = curlx_malloc(nego->token_max);
|
||||
if(!nego->output_token)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if(!nego->credentials) {
|
||||
/* Do we have credentials to use or are we using single sign-on? */
|
||||
|
|
@ -200,12 +200,12 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
|
|||
|
||||
#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
|
||||
/* ssl context comes from Schannel.
|
||||
* When extended protection is used in IIS server,
|
||||
* we have to pass a second SecBuffer to the SecBufferDesc
|
||||
* otherwise IIS will not pass the authentication (401 response).
|
||||
* Minimum supported version is Windows 7.
|
||||
* https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811
|
||||
*/
|
||||
* When extended protection is used in IIS server,
|
||||
* we have to pass a second SecBuffer to the SecBufferDesc
|
||||
* otherwise IIS will not pass the authentication (401 response).
|
||||
* Minimum supported version is Windows 7.
|
||||
* https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811
|
||||
*/
|
||||
if(nego->sslContext) {
|
||||
SEC_CHANNEL_BINDINGS channelBindings;
|
||||
SecPkgContext_Bindings pkgBindings;
|
||||
|
|
|
|||
|
|
@ -171,13 +171,11 @@ static void ntlm_conn_dtor(void *key, size_t klen, void *entry)
|
|||
|
||||
struct ntlmdata *Curl_auth_ntlm_get(struct connectdata *conn, bool proxy)
|
||||
{
|
||||
const char *key = proxy ? CURL_META_NTLM_PROXY_CONN :
|
||||
CURL_META_NTLM_CONN;
|
||||
const char *key = proxy ? CURL_META_NTLM_PROXY_CONN : CURL_META_NTLM_CONN;
|
||||
struct ntlmdata *ntlm = Curl_conn_meta_get(conn, key);
|
||||
if(!ntlm) {
|
||||
ntlm = curlx_calloc(1, sizeof(*ntlm));
|
||||
if(!ntlm ||
|
||||
Curl_conn_meta_set(conn, key, ntlm, ntlm_conn_dtor))
|
||||
if(!ntlm || Curl_conn_meta_set(conn, key, ntlm, ntlm_conn_dtor))
|
||||
return NULL;
|
||||
}
|
||||
return ntlm;
|
||||
|
|
@ -185,8 +183,8 @@ struct ntlmdata *Curl_auth_ntlm_get(struct connectdata *conn, bool proxy)
|
|||
|
||||
void Curl_auth_ntlm_remove(struct connectdata *conn, bool proxy)
|
||||
{
|
||||
Curl_conn_meta_remove(conn, proxy ?
|
||||
CURL_META_NTLM_PROXY_CONN : CURL_META_NTLM_CONN);
|
||||
Curl_conn_meta_remove(conn, proxy ? CURL_META_NTLM_PROXY_CONN
|
||||
: CURL_META_NTLM_CONN);
|
||||
}
|
||||
|
||||
#endif /* USE_NTLM */
|
||||
|
|
@ -257,13 +255,11 @@ static void nego_conn_dtor(void *key, size_t klen, void *entry)
|
|||
|
||||
struct negotiatedata *Curl_auth_nego_get(struct connectdata *conn, bool proxy)
|
||||
{
|
||||
const char *key = proxy ? CURL_META_NEGO_PROXY_CONN :
|
||||
CURL_META_NEGO_CONN;
|
||||
const char *key = proxy ? CURL_META_NEGO_PROXY_CONN : CURL_META_NEGO_CONN;
|
||||
struct negotiatedata *nego = Curl_conn_meta_get(conn, key);
|
||||
if(!nego) {
|
||||
nego = curlx_calloc(1, sizeof(*nego));
|
||||
if(!nego ||
|
||||
Curl_conn_meta_set(conn, key, nego, nego_conn_dtor))
|
||||
if(!nego || Curl_conn_meta_set(conn, key, nego, nego_conn_dtor))
|
||||
return NULL;
|
||||
}
|
||||
return nego;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue