1 #ifndef HEADER_CURL_SASL_H
2 #define HEADER_CURL_SASL_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 2012 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://curl.haxx.se/docs/copyright.html.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
25 #include <curl/curl.h>
31 /* Authentication mechanism values */
32 #define SASL_AUTH_NONE 0
33 #define SASL_AUTH_ANY ~0U
35 /* Authentication mechanism flags */
36 #define SASL_MECH_LOGIN (1 << 0)
37 #define SASL_MECH_PLAIN (1 << 1)
38 #define SASL_MECH_CRAM_MD5 (1 << 2)
39 #define SASL_MECH_DIGEST_MD5 (1 << 3)
40 #define SASL_MECH_GSSAPI (1 << 4)
41 #define SASL_MECH_EXTERNAL (1 << 5)
42 #define SASL_MECH_NTLM (1 << 6)
43 #define SASL_MECH_XOAUTH2 (1 << 7)
45 /* Authentication mechanism strings */
46 #define SASL_MECH_STRING_LOGIN "LOGIN"
47 #define SASL_MECH_STRING_PLAIN "PLAIN"
48 #define SASL_MECH_STRING_CRAM_MD5 "CRAM-MD5"
49 #define SASL_MECH_STRING_DIGEST_MD5 "DIGEST-MD5"
50 #define SASL_MECH_STRING_GSSAPI "GSSAPI"
51 #define SASL_MECH_STRING_EXTERNAL "EXTERNAL"
52 #define SASL_MECH_STRING_NTLM "NTLM"
53 #define SASL_MECH_STRING_XOAUTH2 "XOAUTH2"
55 /* This is used to test whether the line starts with the given mechanism */
56 #define sasl_mech_equal(line, wordlen, mech) \
57 (wordlen == (sizeof(mech) - 1) / sizeof(char) && \
58 !memcmp(line, mech, wordlen))
60 /* This is used to generate a base64 encoded PLAIN authentication message */
61 CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data,
64 char **outptr, size_t *outlen);
66 /* This is used to generate a base64 encoded LOGIN authentication message
67 containing either the user name or password details */
68 CURLcode Curl_sasl_create_login_message(struct SessionHandle *data,
69 const char *valuep, char **outptr,
72 #ifndef CURL_DISABLE_CRYPTO_AUTH
73 /* This is used to decode a base64 encoded CRAM-MD5 challange message */
74 CURLcode Curl_sasl_decode_cram_md5_message(const char *chlg64, char **outptr,
77 /* This is used to generate a base64 encoded CRAM-MD5 response message */
78 CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data,
82 char **outptr, size_t *outlen);
84 /* This is used to generate a base64 encoded DIGEST-MD5 response message */
85 CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
90 char **outptr, size_t *outlen);
94 /* This is used to generate a base64 encoded NTLM type-1 message */
95 CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp,
97 struct ntlmdata *ntlm,
101 /* This is used to decode a base64 encoded NTLM type-2 message */
102 CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data,
103 const char *type2msg,
104 struct ntlmdata *ntlm);
106 /* This is used to generate a base64 encoded NTLM type-3 message */
107 CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data,
110 struct ntlmdata *ntlm,
111 char **outptr, size_t *outlen);
113 #endif /* USE_NTLM */
115 /* This is used to generate a base64 encoded XOAUTH2 authentication message
116 containing the user name and bearer token */
117 CURLcode Curl_sasl_create_xoauth2_message(struct SessionHandle *data,
120 char **outptr, size_t *outlen);
122 /* This is used to cleanup any libraries or curl modules used by the sasl
124 void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused);
126 #endif /* HEADER_CURL_SASL_H */