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 generate a base64 encoded PLAIN cleartext message */ 59 CURLcode Curl_auth_create_plain_message(struct Curl_easy *data, 60 const char *userp, 61 const char *passwdp, 62 char **outptr, size_t *outlen); 63 64 /* This is used to generate a base64 encoded LOGIN cleartext message */ 65 CURLcode Curl_auth_create_login_message(struct Curl_easy *data, 66 const char *valuep, char **outptr, 67 size_t *outlen); 68 69 /* This is used to generate a base64 encoded EXTERNAL cleartext message */ 70 CURLcode Curl_auth_create_external_message(struct Curl_easy *data, 71 const char *user, char **outptr, 72 size_t *outlen); 73 74 #if !defined(CURL_DISABLE_CRYPTO_AUTH) 75 /* This is used to decode a CRAM-MD5 challenge message */ 76 CURLcode Curl_auth_decode_cram_md5_message(const char *chlg64, char **outptr, 77 size_t *outlen); 78 79 /* This is used to generate a CRAM-MD5 response message */ 80 CURLcode Curl_auth_create_cram_md5_message(struct Curl_easy *data, 81 const char *chlg, 82 const char *userp, 83 const char *passwdp, 84 char **outptr, size_t *outlen); 85 86 /* This is used to generate a base64 encoded DIGEST-MD5 response message */ 87 CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, 88 const char *chlg64, 89 const char *userp, 90 const char *passwdp, 91 const char *service, 92 char **outptr, size_t *outlen); 93 94 /* This is used to decode a HTTP DIGEST challenge message */ 95 CURLcode Curl_auth_decode_digest_http_message(const char *chlg, 96 struct digestdata *digest); 97 98 /* This is used to generate a HTTP DIGEST response message */ 99 CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, 100 const char *userp, 101 const char *passwdp, 102 const unsigned char *request, 103 const unsigned char *uri, 104 struct digestdata *digest, 105 char **outptr, size_t *outlen); 106 107 /* This is used to clean up the digest specific data */ 108 void Curl_auth_digest_cleanup(struct digestdata *digest); 109 #endif /* !CURL_DISABLE_CRYPTO_AUTH */ 110 111 #if defined(USE_NTLM) 112 /* This is used to generate a base64 encoded NTLM type-1 message */ 113 CURLcode Curl_auth_create_ntlm_type1_message(const char *userp, 114 const char *passwdp, 115 struct ntlmdata *ntlm, 116 char **outptr, 117 size_t *outlen); 118 119 /* This is used to decode a base64 encoded NTLM type-2 message */ 120 CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data, 121 const char *type2msg, 122 struct ntlmdata *ntlm); 123 124 /* This is used to generate a base64 encoded NTLM type-3 message */ 125 CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, 126 const char *userp, 127 const char *passwdp, 128 struct ntlmdata *ntlm, 129 char **outptr, size_t *outlen); 130 131 /* This is used to clean up the NTLM specific data */ 132 void Curl_auth_ntlm_cleanup(struct ntlmdata *ntlm); 133 #endif /* USE_NTLM */ 134 135 /* This is used to generate a base64 encoded OAuth 2.0 message */ 136 CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data, 137 const char *user, 138 const char *host, 139 const long port, 140 const char *bearer, 141 char **outptr, size_t *outlen); 142 #if defined(USE_KERBEROS5) 143 /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) user token 144 message */ 145 CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, 146 const char *userp, 147 const char *passwdp, 148 const char *service, 149 const char *host, 150 const bool mutual, 151 const char *chlg64, 152 struct kerberos5data *krb5, 153 char **outptr, size_t *outlen); 154 155 /* This is used to generate a base64 encoded GSSAPI (Kerberos V5) security 156 token message */ 157 CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, 158 const char *input, 159 struct kerberos5data *krb5, 160 char **outptr, 161 size_t *outlen); 162 163 /* This is used to clean up the GSSAPI specific data */ 164 void Curl_auth_gssapi_cleanup(struct kerberos5data *krb5); 165 #endif /* USE_KERBEROS5 */ 166 167 #if defined(USE_SPNEGO) 168 /* This is used to decode a base64 encoded SPNEGO (Negotiate) challenge 169 message */ 170 CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, 171 const char *user, 172 const char *passwood, 173 const char *service, 174 const char *host, 175 const char *chlg64, 176 struct negotiatedata *nego); 177 178 /* This is used to generate a base64 encoded SPNEGO (Negotiate) response 179 message */ 180 CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data, 181 struct negotiatedata *nego, 182 char **outptr, size_t *outlen); 183 184 /* This is used to clean up the SPNEGO specifiec data */ 185 void Curl_auth_spnego_cleanup(struct negotiatedata *nego); 186 187 #endif /* USE_SPNEGO */ 188 189 #endif /* HEADER_CURL_VAUTH_H */ 190