1 #ifndef HEADER_CURL_SASL_H
2 #define HEADER_CURL_SASL_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 2012 - 2013, 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 ***************************************************************************/
27 /* Authentication mechanism values */
28 #define SASL_AUTH_NONE 0
29 #define SASL_AUTH_ANY ~0U
31 /* Authentication mechanism flags */
32 #define SASL_MECH_LOGIN (1 << 0)
33 #define SASL_MECH_PLAIN (1 << 1)
34 #define SASL_MECH_CRAM_MD5 (1 << 2)
35 #define SASL_MECH_DIGEST_MD5 (1 << 3)
36 #define SASL_MECH_GSSAPI (1 << 4)
37 #define SASL_MECH_EXTERNAL (1 << 5)
38 #define SASL_MECH_NTLM (1 << 6)
39 #define SASL_MECH_XOAUTH2 (1 << 7)
41 /* Authentication mechanism strings */
42 #define SASL_MECH_STRING_LOGIN "LOGIN"
43 #define SASL_MECH_STRING_PLAIN "PLAIN"
44 #define SASL_MECH_STRING_CRAM_MD5 "CRAM-MD5"
45 #define SASL_MECH_STRING_DIGEST_MD5 "DIGEST-MD5"
46 #define SASL_MECH_STRING_GSSAPI "GSSAPI"
47 #define SASL_MECH_STRING_EXTERNAL "EXTERNAL"
48 #define SASL_MECH_STRING_NTLM "NTLM"
49 #define SASL_MECH_STRING_XOAUTH2 "XOAUTH2"
51 /* This is used to test whether the line starts with the given mechanism */
52 #define sasl_mech_equal(line, wordlen, mech) \
53 (wordlen == (sizeof(mech) - 1) / sizeof(char) && \
54 !memcmp(line, mech, wordlen))
56 /* This is used to generate a base64 encoded PLAIN authentication message */
57 CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data,
60 char **outptr, size_t *outlen);
62 /* This is used to generate a base64 encoded LOGIN authentication message
63 containing either the user name or password details */
64 CURLcode Curl_sasl_create_login_message(struct SessionHandle *data,
65 const char *valuep, char **outptr,
68 #ifndef CURL_DISABLE_CRYPTO_AUTH
69 /* This is used to decode a base64 encoded CRAM-MD5 challange message */
70 CURLcode Curl_sasl_decode_cram_md5_message(const char *chlg64, char **outptr,
73 /* This is used to generate a base64 encoded CRAM-MD5 response message */
74 CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data,
78 char **outptr, size_t *outlen);
80 /* This is used to decode a base64 encoded DIGEST-MD5 challange message */
81 CURLcode Curl_sasl_decode_digest_md5_message(const char *chlg64,
82 char *nonce, size_t nlen,
83 char *realm, size_t rlen,
84 char *alg, size_t alen);
86 /* This is used to generate a base64 encoded DIGEST-MD5 response message */
87 CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
93 char **outptr, size_t *outlen);
97 /* This is used to generate a base64 encoded NTLM type-1 message */
98 CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp,
100 struct ntlmdata *ntlm,
104 /* This is used to decode an incoming NTLM type-2 message and generate a
105 base64 encoded type-3 response */
106 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 */