113498266Sopenharmony_ci#ifndef HEADER_CURL_VAUTH_H
213498266Sopenharmony_ci#define HEADER_CURL_VAUTH_H
313498266Sopenharmony_ci/***************************************************************************
413498266Sopenharmony_ci *                                  _   _ ____  _
513498266Sopenharmony_ci *  Project                     ___| | | |  _ \| |
613498266Sopenharmony_ci *                             / __| | | | |_) | |
713498266Sopenharmony_ci *                            | (__| |_| |  _ <| |___
813498266Sopenharmony_ci *                             \___|\___/|_| \_\_____|
913498266Sopenharmony_ci *
1013498266Sopenharmony_ci * Copyright (C) Steve Holme, <steve_holme@hotmail.com>.
1113498266Sopenharmony_ci *
1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which
1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms
1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html.
1513498266Sopenharmony_ci *
1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell
1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is
1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file.
1913498266Sopenharmony_ci *
2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2113498266Sopenharmony_ci * KIND, either express or implied.
2213498266Sopenharmony_ci *
2313498266Sopenharmony_ci * SPDX-License-Identifier: curl
2413498266Sopenharmony_ci *
2513498266Sopenharmony_ci ***************************************************************************/
2613498266Sopenharmony_ci
2713498266Sopenharmony_ci#include <curl/curl.h>
2813498266Sopenharmony_ci
2913498266Sopenharmony_ci#include "bufref.h"
3013498266Sopenharmony_ci
3113498266Sopenharmony_cistruct Curl_easy;
3213498266Sopenharmony_ci
3313498266Sopenharmony_ci#if !defined(CURL_DISABLE_DIGEST_AUTH)
3413498266Sopenharmony_cistruct digestdata;
3513498266Sopenharmony_ci#endif
3613498266Sopenharmony_ci
3713498266Sopenharmony_ci#if defined(USE_NTLM)
3813498266Sopenharmony_cistruct ntlmdata;
3913498266Sopenharmony_ci#endif
4013498266Sopenharmony_ci
4113498266Sopenharmony_ci#if defined(USE_KERBEROS5)
4213498266Sopenharmony_cistruct kerberos5data;
4313498266Sopenharmony_ci#endif
4413498266Sopenharmony_ci
4513498266Sopenharmony_ci#if (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) && defined(USE_SPNEGO)
4613498266Sopenharmony_cistruct negotiatedata;
4713498266Sopenharmony_ci#endif
4813498266Sopenharmony_ci
4913498266Sopenharmony_ci#if defined(USE_GSASL)
5013498266Sopenharmony_cistruct gsasldata;
5113498266Sopenharmony_ci#endif
5213498266Sopenharmony_ci
5313498266Sopenharmony_ci#if defined(USE_WINDOWS_SSPI)
5413498266Sopenharmony_ci#define GSS_ERROR(status) ((status) & 0x80000000)
5513498266Sopenharmony_ci#endif
5613498266Sopenharmony_ci
5713498266Sopenharmony_ci/*
5813498266Sopenharmony_ci * Curl_auth_allowed_to_host() tells if authentication, cookies or other
5913498266Sopenharmony_ci * "sensitive data" can (still) be sent to this host.
6013498266Sopenharmony_ci */
6113498266Sopenharmony_cibool Curl_auth_allowed_to_host(struct Curl_easy *data);
6213498266Sopenharmony_ci
6313498266Sopenharmony_ci/* This is used to build a SPN string */
6413498266Sopenharmony_ci#if !defined(USE_WINDOWS_SSPI)
6513498266Sopenharmony_cichar *Curl_auth_build_spn(const char *service, const char *host,
6613498266Sopenharmony_ci                          const char *realm);
6713498266Sopenharmony_ci#else
6813498266Sopenharmony_ciTCHAR *Curl_auth_build_spn(const char *service, const char *host,
6913498266Sopenharmony_ci                           const char *realm);
7013498266Sopenharmony_ci#endif
7113498266Sopenharmony_ci
7213498266Sopenharmony_ci/* This is used to test if the user contains a Windows domain name */
7313498266Sopenharmony_cibool Curl_auth_user_contains_domain(const char *user);
7413498266Sopenharmony_ci
7513498266Sopenharmony_ci/* This is used to generate a PLAIN cleartext message */
7613498266Sopenharmony_ciCURLcode Curl_auth_create_plain_message(const char *authzid,
7713498266Sopenharmony_ci                                        const char *authcid,
7813498266Sopenharmony_ci                                        const char *passwd,
7913498266Sopenharmony_ci                                        struct bufref *out);
8013498266Sopenharmony_ci
8113498266Sopenharmony_ci/* This is used to generate a LOGIN cleartext message */
8213498266Sopenharmony_ciCURLcode Curl_auth_create_login_message(const char *value,
8313498266Sopenharmony_ci                                        struct bufref *out);
8413498266Sopenharmony_ci
8513498266Sopenharmony_ci/* This is used to generate an EXTERNAL cleartext message */
8613498266Sopenharmony_ciCURLcode Curl_auth_create_external_message(const char *user,
8713498266Sopenharmony_ci                                           struct bufref *out);
8813498266Sopenharmony_ci
8913498266Sopenharmony_ci#ifndef CURL_DISABLE_DIGEST_AUTH
9013498266Sopenharmony_ci/* This is used to generate a CRAM-MD5 response message */
9113498266Sopenharmony_ciCURLcode Curl_auth_create_cram_md5_message(const struct bufref *chlg,
9213498266Sopenharmony_ci                                           const char *userp,
9313498266Sopenharmony_ci                                           const char *passwdp,
9413498266Sopenharmony_ci                                           struct bufref *out);
9513498266Sopenharmony_ci
9613498266Sopenharmony_ci/* This is used to evaluate if DIGEST is supported */
9713498266Sopenharmony_cibool Curl_auth_is_digest_supported(void);
9813498266Sopenharmony_ci
9913498266Sopenharmony_ci/* This is used to generate a base64 encoded DIGEST-MD5 response message */
10013498266Sopenharmony_ciCURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
10113498266Sopenharmony_ci                                             const struct bufref *chlg,
10213498266Sopenharmony_ci                                             const char *userp,
10313498266Sopenharmony_ci                                             const char *passwdp,
10413498266Sopenharmony_ci                                             const char *service,
10513498266Sopenharmony_ci                                             struct bufref *out);
10613498266Sopenharmony_ci
10713498266Sopenharmony_ci/* This is used to decode an HTTP DIGEST challenge message */
10813498266Sopenharmony_ciCURLcode Curl_auth_decode_digest_http_message(const char *chlg,
10913498266Sopenharmony_ci                                              struct digestdata *digest);
11013498266Sopenharmony_ci
11113498266Sopenharmony_ci/* This is used to generate an HTTP DIGEST response message */
11213498266Sopenharmony_ciCURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
11313498266Sopenharmony_ci                                              const char *userp,
11413498266Sopenharmony_ci                                              const char *passwdp,
11513498266Sopenharmony_ci                                              const unsigned char *request,
11613498266Sopenharmony_ci                                              const unsigned char *uri,
11713498266Sopenharmony_ci                                              struct digestdata *digest,
11813498266Sopenharmony_ci                                              char **outptr, size_t *outlen);
11913498266Sopenharmony_ci
12013498266Sopenharmony_ci/* This is used to clean up the digest specific data */
12113498266Sopenharmony_civoid Curl_auth_digest_cleanup(struct digestdata *digest);
12213498266Sopenharmony_ci#endif /* !CURL_DISABLE_DIGEST_AUTH */
12313498266Sopenharmony_ci
12413498266Sopenharmony_ci#ifdef USE_GSASL
12513498266Sopenharmony_ci/* This is used to evaluate if MECH is supported by gsasl */
12613498266Sopenharmony_cibool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
12713498266Sopenharmony_ci                                  const char *mech,
12813498266Sopenharmony_ci                                  struct gsasldata *gsasl);
12913498266Sopenharmony_ci/* This is used to start a gsasl method */
13013498266Sopenharmony_ciCURLcode Curl_auth_gsasl_start(struct Curl_easy *data,
13113498266Sopenharmony_ci                               const char *userp,
13213498266Sopenharmony_ci                               const char *passwdp,
13313498266Sopenharmony_ci                               struct gsasldata *gsasl);
13413498266Sopenharmony_ci
13513498266Sopenharmony_ci/* This is used to process and generate a new SASL token */
13613498266Sopenharmony_ciCURLcode Curl_auth_gsasl_token(struct Curl_easy *data,
13713498266Sopenharmony_ci                               const struct bufref *chlg,
13813498266Sopenharmony_ci                               struct gsasldata *gsasl,
13913498266Sopenharmony_ci                               struct bufref *out);
14013498266Sopenharmony_ci
14113498266Sopenharmony_ci/* This is used to clean up the gsasl specific data */
14213498266Sopenharmony_civoid Curl_auth_gsasl_cleanup(struct gsasldata *digest);
14313498266Sopenharmony_ci#endif
14413498266Sopenharmony_ci
14513498266Sopenharmony_ci#if defined(USE_NTLM)
14613498266Sopenharmony_ci/* This is used to evaluate if NTLM is supported */
14713498266Sopenharmony_cibool Curl_auth_is_ntlm_supported(void);
14813498266Sopenharmony_ci
14913498266Sopenharmony_ci/* This is used to generate a base64 encoded NTLM type-1 message */
15013498266Sopenharmony_ciCURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
15113498266Sopenharmony_ci                                             const char *userp,
15213498266Sopenharmony_ci                                             const char *passwdp,
15313498266Sopenharmony_ci                                             const char *service,
15413498266Sopenharmony_ci                                             const char *host,
15513498266Sopenharmony_ci                                             struct ntlmdata *ntlm,
15613498266Sopenharmony_ci                                             struct bufref *out);
15713498266Sopenharmony_ci
15813498266Sopenharmony_ci/* This is used to decode a base64 encoded NTLM type-2 message */
15913498266Sopenharmony_ciCURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
16013498266Sopenharmony_ci                                             const struct bufref *type2,
16113498266Sopenharmony_ci                                             struct ntlmdata *ntlm);
16213498266Sopenharmony_ci
16313498266Sopenharmony_ci/* This is used to generate a base64 encoded NTLM type-3 message */
16413498266Sopenharmony_ciCURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
16513498266Sopenharmony_ci                                             const char *userp,
16613498266Sopenharmony_ci                                             const char *passwdp,
16713498266Sopenharmony_ci                                             struct ntlmdata *ntlm,
16813498266Sopenharmony_ci                                             struct bufref *out);
16913498266Sopenharmony_ci
17013498266Sopenharmony_ci/* This is used to clean up the NTLM specific data */
17113498266Sopenharmony_civoid Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm);
17213498266Sopenharmony_ci#endif /* USE_NTLM */
17313498266Sopenharmony_ci
17413498266Sopenharmony_ci/* This is used to generate a base64 encoded OAuth 2.0 message */
17513498266Sopenharmony_ciCURLcode Curl_auth_create_oauth_bearer_message(const char *user,
17613498266Sopenharmony_ci                                               const char *host,
17713498266Sopenharmony_ci                                               const long port,
17813498266Sopenharmony_ci                                               const char *bearer,
17913498266Sopenharmony_ci                                               struct bufref *out);
18013498266Sopenharmony_ci
18113498266Sopenharmony_ci/* This is used to generate a base64 encoded XOAuth 2.0 message */
18213498266Sopenharmony_ciCURLcode Curl_auth_create_xoauth_bearer_message(const char *user,
18313498266Sopenharmony_ci                                                const char *bearer,
18413498266Sopenharmony_ci                                                struct bufref *out);
18513498266Sopenharmony_ci
18613498266Sopenharmony_ci#if defined(USE_KERBEROS5)
18713498266Sopenharmony_ci/* This is used to evaluate if GSSAPI (Kerberos V5) is supported */
18813498266Sopenharmony_cibool Curl_auth_is_gssapi_supported(void);
18913498266Sopenharmony_ci
19013498266Sopenharmony_ci/* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token
19113498266Sopenharmony_ci   message */
19213498266Sopenharmony_ciCURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
19313498266Sopenharmony_ci                                              const char *userp,
19413498266Sopenharmony_ci                                              const char *passwdp,
19513498266Sopenharmony_ci                                              const char *service,
19613498266Sopenharmony_ci                                              const char *host,
19713498266Sopenharmony_ci                                              const bool mutual,
19813498266Sopenharmony_ci                                              const struct bufref *chlg,
19913498266Sopenharmony_ci                                              struct kerberos5data *krb5,
20013498266Sopenharmony_ci                                              struct bufref *out);
20113498266Sopenharmony_ci
20213498266Sopenharmony_ci/* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security
20313498266Sopenharmony_ci   token message */
20413498266Sopenharmony_ciCURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
20513498266Sopenharmony_ci                                                  const char *authzid,
20613498266Sopenharmony_ci                                                  const struct bufref *chlg,
20713498266Sopenharmony_ci                                                  struct kerberos5data *krb5,
20813498266Sopenharmony_ci                                                  struct bufref *out);
20913498266Sopenharmony_ci
21013498266Sopenharmony_ci/* This is used to clean up the GSSAPI specific data */
21113498266Sopenharmony_civoid Curl_auth_cleanup_gssapi(struct kerberos5data *krb5);
21213498266Sopenharmony_ci#endif /* USE_KERBEROS5 */
21313498266Sopenharmony_ci
21413498266Sopenharmony_ci#if defined(USE_SPNEGO)
21513498266Sopenharmony_ci/* This is used to evaluate if SPNEGO (Negotiate) is supported */
21613498266Sopenharmony_cibool Curl_auth_is_spnego_supported(void);
21713498266Sopenharmony_ci
21813498266Sopenharmony_ci/* This is used to decode a base64 encoded SPNEGO (Negotiate) challenge
21913498266Sopenharmony_ci   message */
22013498266Sopenharmony_ciCURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
22113498266Sopenharmony_ci                                         const char *user,
22213498266Sopenharmony_ci                                         const char *password,
22313498266Sopenharmony_ci                                         const char *service,
22413498266Sopenharmony_ci                                         const char *host,
22513498266Sopenharmony_ci                                         const char *chlg64,
22613498266Sopenharmony_ci                                         struct negotiatedata *nego);
22713498266Sopenharmony_ci
22813498266Sopenharmony_ci/* This is used to generate a base64 encoded SPNEGO (Negotiate) response
22913498266Sopenharmony_ci   message */
23013498266Sopenharmony_ciCURLcode Curl_auth_create_spnego_message(struct negotiatedata *nego,
23113498266Sopenharmony_ci                                         char **outptr, size_t *outlen);
23213498266Sopenharmony_ci
23313498266Sopenharmony_ci/* This is used to clean up the SPNEGO specific data */
23413498266Sopenharmony_civoid Curl_auth_cleanup_spnego(struct negotiatedata *nego);
23513498266Sopenharmony_ci
23613498266Sopenharmony_ci#endif /* USE_SPNEGO */
23713498266Sopenharmony_ci
23813498266Sopenharmony_ci#endif /* HEADER_CURL_VAUTH_H */
239