1 #ifndef HEADER_CURL_VAUTH_H 2 #define HEADER_CURL_VAUTH_H 3 /*************************************************************************** 4 * _ _ ____ _ 5 * Project ___| | | | _ \| | 6 * / __| | | | |_) | | 7 * | (__| |_| | _ <| |___ 8 * \___|\___/|_| \_\_____| 9 * 10 * Copyright (C) 2014 - 2016, Steve Holme, <steve_holme (at) 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.haxx.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 struct Curl_easy; 28 29 #if !defined(CURL_DISABLE_CRYPTO_AUTH) 30 struct digestdata; 31 #endif 32 33 #if defined(USE_NTLM) 34 struct ntlmdata; 35 #endif 36 37 #if defined(USE_KERBEROS5) 38 struct kerberos5data; 39 #endif 40 41 #if (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) && defined(USE_SPNEGO) 42 struct negotiatedata; 43 #endif 44 45 #if defined(USE_WINDOWS_SSPI) 46 #define GSS_ERROR(status) (status & 0x80000000) 47 #endif 48 49 /* This is used to build a SPN string */ 50 #if !defined(USE_WINDOWS_SSPI) 51 char *Curl_auth_build_spn(const char *service, const char *host, 52 const char *realm); 53 #else 54 TCHAR *Curl_auth_build_spn(const char *service, const char *host, 55 const char *realm); 56 #endif 57 58 /* This is used to test if the user contains a Windows domain name */ 59 bool Curl_auth_user_contains_domain(const char *user); 60 61 /* This is used to generate a base64 encoded PLAIN cleartext message */ 62 CURLcode Curl_auth_create_plain_message(struct Curl_easy *data, 63 const char *userp, 64 const char *passwdp, 65 char **outptr, size_t *outlen); 66 67 /* This is used to generate a base64 encoded LOGIN cleartext message */ 68 CURLcode Curl_auth_create_login_message(struct Curl_easy *data, 69 const char *valuep, char **outptr, 70 size_t *outlen); 71 72 /* This is used to generate a base64 encoded EXTERNAL cleartext message */ 73 CURLcode Curl_auth_create_external_message(struct Curl_easy *data, 74 const char *user, char **outptr, 75 size_t *outlen); 76 77 #if !defined(CURL_DISABLE_CRYPTO_AUTH) 78 /* This is used to decode a CRAM-MD5 challenge message */ 79 CURLcode Curl_auth_decode_cram_md5_message(const char *chlg64, char **outptr, 80 size_t *outlen); 81 82 /* This is used to generate a CRAM-MD5 response message */ 83 CURLcode Curl_auth_create_cram_md5_message(struct Curl_easy *data, 84 const char *chlg, 85 const char *userp, 86 const char *passwdp, 87 char **outptr, size_t *outlen); 88 89 /* This is used to evaluate if DIGEST is supported */ 90 bool Curl_auth_is_digest_supported(void); 91 92 /* This is used to generate a base64 encoded DIGEST-MD5 response message */ 93 CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, 94 const char *chlg64, 95 const char *userp, 96 const char *passwdp, 97 const char *service, 98 char **outptr, size_t *outlen); 99 100 /* This is used to decode a HTTP DIGEST challenge message */ 101 CURLcode Curl_auth_decode_digest_http_message(const char *chlg, 102 struct digestdata *digest); 103 104 /* This is used to generate a HTTP DIGEST response message */ 105 CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, 106 const char *userp, 107 const char *passwdp, 108 const unsigned char *request, 109 const unsigned char *uri, 110 struct digestdata *digest, 111 char **outptr, size_t *outlen); 112 113 /* This is used to clean up the digest specific data */ 114 void Curl_auth_digest_cleanup(struct digestdata *digest); 115 #endif /* !CURL_DISABLE_CRYPTO_AUTH */ 116 117 #if defined(USE_NTLM) 118 /* This is used to evaluate if NTLM is supported */ 119 bool Curl_auth_is_ntlm_supported(void); 120 121 /* This is used to generate a base64 encoded NTLM type-1 message */ 122 CURLcode Curl_auth_create_ntlm_type1_message(const char *userp, 123 const char *passwdp, 124 struct ntlmdata *ntlm, 125 char **outptr, 126 size_t *outlen); 127 128 /* This is used to decode a base64 encoded NTLM type-2 message */ 129 CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data, 130 const char *type2msg, 131 struct ntlmdata *ntlm); 132 133 /* This is used to generate a base64 encoded NTLM type-3 message */ 134 CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, 135 const char *userp, 136 const char *passwdp, 137 struct ntlmdata *ntlm, 138 char **outptr, size_t *outlen); 139 140 /* This is used to clean up the NTLM specific data */ 141 void Curl_auth_ntlm_cleanup(struct ntlmdata *ntlm); 142 #endif /* USE_NTLM */ 143 144 /* This is used to generate a base64 encoded OAuth 2.0 message */ 145 CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data, 146 const char *user, 147 const char *host, 148 const long port, 149 const char *bearer, 150 char **outptr, size_t *outlen); 151 #if defined(USE_KERBEROS5) 152 /* This is used to evaluate if GSSAPI (Kerberos V5) is supported */ 153 bool Curl_auth_is_gssapi_supported(void); 154 155 /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token 156 message */ 157 CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, 158 const char *userp, 159 const char *passwdp, 160 const char *service, 161 const char *host, 162 const bool mutual, 163 const char *chlg64, 164 struct kerberos5data *krb5, 165 char **outptr, size_t *outlen); 166 167 /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security 168 token message */ 169 CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, 170 const char *input, 171 struct kerberos5data *krb5, 172 char **outptr, 173 size_t *outlen); 174 175 /* This is used to clean up the GSSAPI specific data */ 176 void Curl_auth_gssapi_cleanup(struct kerberos5data *krb5); 177 #endif /* USE_KERBEROS5 */ 178 179 #if defined(USE_SPNEGO) 180 /* This is used to evaluate if SPNEGO (Negotiate) is supported */ 181 bool Curl_auth_is_spnego_supported(void); 182 183 /* This is used to decode a base64 encoded SPNEGO (Negotiate) challenge 184 message */ 185 CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, 186 const char *user, 187 const char *passwood, 188 const char *service, 189 const char *host, 190 const char *chlg64, 191 struct negotiatedata *nego); 192 193 /* This is used to generate a base64 encoded SPNEGO (Negotiate) response 194 message */ 195 CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data, 196 struct negotiatedata *nego, 197 char **outptr, size_t *outlen); 198 199 /* This is used to clean up the SPNEGO specifiec data */ 200 void Curl_auth_spnego_cleanup(struct negotiatedata *nego); 201 202 #endif /* USE_SPNEGO */ 203 204 #endif /* HEADER_CURL_VAUTH_H */ 205