• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef HEADER_CURL_VAUTH_H
2 #define HEADER_CURL_VAUTH_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 2014 - 2021, Steve Holme, <steve_holme@hotmail.com>.
11  *
12  * This software is licensed as described in the file COPYING, which
13  * you should have received as part of this distribution. The terms
14  * are also available at https://curl.se/docs/copyright.html.
15  *
16  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17  * copies of the Software, and permit persons to whom the Software is
18  * furnished to do so, under the terms of the COPYING file.
19  *
20  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21  * KIND, either express or implied.
22  *
23  ***************************************************************************/
24 
25 #include <curl/curl.h>
26 
27 #include "bufref.h"
28 
29 struct Curl_easy;
30 
31 #if !defined(CURL_DISABLE_CRYPTO_AUTH)
32 struct digestdata;
33 #endif
34 
35 #if defined(USE_NTLM)
36 struct ntlmdata;
37 #endif
38 
39 #if defined(USE_KERBEROS5)
40 struct kerberos5data;
41 #endif
42 
43 #if (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) && defined(USE_SPNEGO)
44 struct negotiatedata;
45 #endif
46 
47 #if defined(USE_GSASL)
48 struct gsasldata;
49 #endif
50 
51 #if defined(USE_WINDOWS_SSPI)
52 #define GSS_ERROR(status) ((status) & 0x80000000)
53 #endif
54 
55 /* This is used to build a SPN string */
56 #if !defined(USE_WINDOWS_SSPI)
57 char *Curl_auth_build_spn(const char *service, const char *host,
58                           const char *realm);
59 #else
60 TCHAR *Curl_auth_build_spn(const char *service, const char *host,
61                            const char *realm);
62 #endif
63 
64 /* This is used to test if the user contains a Windows domain name */
65 bool Curl_auth_user_contains_domain(const char *user);
66 
67 /* This is used to generate a PLAIN cleartext message */
68 CURLcode Curl_auth_create_plain_message(const char *authzid,
69                                         const char *authcid,
70                                         const char *passwd,
71                                         struct bufref *out);
72 
73 /* This is used to generate a LOGIN cleartext message */
74 CURLcode Curl_auth_create_login_message(const char *value,
75                                         struct bufref *out);
76 
77 /* This is used to generate an EXTERNAL cleartext message */
78 CURLcode Curl_auth_create_external_message(const char *user,
79                                            struct bufref *out);
80 
81 #if !defined(CURL_DISABLE_CRYPTO_AUTH)
82 /* This is used to generate a CRAM-MD5 response message */
83 CURLcode Curl_auth_create_cram_md5_message(const struct bufref *chlg,
84                                            const char *userp,
85                                            const char *passwdp,
86                                            struct bufref *out);
87 
88 /* This is used to evaluate if DIGEST is supported */
89 bool Curl_auth_is_digest_supported(void);
90 
91 /* This is used to generate a base64 encoded DIGEST-MD5 response message */
92 CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
93                                              const struct bufref *chlg,
94                                              const char *userp,
95                                              const char *passwdp,
96                                              const char *service,
97                                              struct bufref *out);
98 
99 /* This is used to decode a HTTP DIGEST challenge message */
100 CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
101                                               struct digestdata *digest);
102 
103 /* This is used to generate a HTTP DIGEST response message */
104 CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
105                                               const char *userp,
106                                               const char *passwdp,
107                                               const unsigned char *request,
108                                               const unsigned char *uri,
109                                               struct digestdata *digest,
110                                               char **outptr, size_t *outlen);
111 
112 /* This is used to clean up the digest specific data */
113 void Curl_auth_digest_cleanup(struct digestdata *digest);
114 #endif /* !CURL_DISABLE_CRYPTO_AUTH */
115 
116 #ifdef USE_GSASL
117 /* This is used to evaluate if MECH is supported by gsasl */
118 bool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
119                                   const char *mech,
120                                   struct gsasldata *gsasl);
121 /* This is used to start a gsasl method */
122 CURLcode Curl_auth_gsasl_start(struct Curl_easy *data,
123                                const char *userp,
124                                const char *passwdp,
125                                struct gsasldata *gsasl);
126 
127 /* This is used to process and generate a new SASL token */
128 CURLcode Curl_auth_gsasl_token(struct Curl_easy *data,
129                                const struct bufref *chlg,
130                                struct gsasldata *gsasl,
131                                struct bufref *out);
132 
133 /* This is used to clean up the gsasl specific data */
134 void Curl_auth_gsasl_cleanup(struct gsasldata *digest);
135 #endif
136 
137 #if defined(USE_NTLM)
138 /* This is used to evaluate if NTLM is supported */
139 bool Curl_auth_is_ntlm_supported(void);
140 
141 /* This is used to generate a base64 encoded NTLM type-1 message */
142 CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
143                                              const char *userp,
144                                              const char *passwdp,
145                                              const char *service,
146                                              const char *host,
147                                              struct ntlmdata *ntlm,
148                                              struct bufref *out);
149 
150 /* This is used to decode a base64 encoded NTLM type-2 message */
151 CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
152                                              const struct bufref *type2,
153                                              struct ntlmdata *ntlm);
154 
155 /* This is used to generate a base64 encoded NTLM type-3 message */
156 CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
157                                              const char *userp,
158                                              const char *passwdp,
159                                              struct ntlmdata *ntlm,
160                                              struct bufref *out);
161 
162 /* This is used to clean up the NTLM specific data */
163 void Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm);
164 #endif /* USE_NTLM */
165 
166 /* This is used to generate a base64 encoded OAuth 2.0 message */
167 CURLcode Curl_auth_create_oauth_bearer_message(const char *user,
168                                                const char *host,
169                                                const long port,
170                                                const char *bearer,
171                                                struct bufref *out);
172 
173 /* This is used to generate a base64 encoded XOAuth 2.0 message */
174 CURLcode Curl_auth_create_xoauth_bearer_message(const char *user,
175                                                 const char *bearer,
176                                                 struct bufref *out);
177 
178 #if defined(USE_KERBEROS5)
179 /* This is used to evaluate if GSSAPI (Kerberos V5) is supported */
180 bool Curl_auth_is_gssapi_supported(void);
181 
182 /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token
183    message */
184 CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
185                                               const char *userp,
186                                               const char *passwdp,
187                                               const char *service,
188                                               const char *host,
189                                               const bool mutual,
190                                               const struct bufref *chlg,
191                                               struct kerberos5data *krb5,
192                                               struct bufref *out);
193 
194 /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security
195    token message */
196 CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
197                                                   const struct bufref *chlg,
198                                                   struct kerberos5data *krb5,
199                                                   struct bufref *out);
200 
201 /* This is used to clean up the GSSAPI specific data */
202 void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5);
203 #endif /* USE_KERBEROS5 */
204 
205 #if defined(USE_SPNEGO)
206 /* This is used to evaluate if SPNEGO (Negotiate) is supported */
207 bool Curl_auth_is_spnego_supported(void);
208 
209 /* This is used to decode a base64 encoded SPNEGO (Negotiate) challenge
210    message */
211 CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
212                                          const char *user,
213                                          const char *passwood,
214                                          const char *service,
215                                          const char *host,
216                                          const char *chlg64,
217                                          struct negotiatedata *nego);
218 
219 /* This is used to generate a base64 encoded SPNEGO (Negotiate) response
220    message */
221 CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
222                                          struct negotiatedata *nego,
223                                          char **outptr, size_t *outlen);
224 
225 /* This is used to clean up the SPNEGO specifiec data */
226 void Curl_auth_cleanup_spnego(struct negotiatedata *nego);
227 
228 #endif /* USE_SPNEGO */
229 
230 #endif /* HEADER_CURL_VAUTH_H */
231