sasl: Small code tidy up before moving digest-md5 over
[platform/upstream/curl.git] / lib / curl_sasl.h
1 #ifndef HEADER_CURL_SASL_H
2 #define HEADER_CURL_SASL_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://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 "pingpong.h"
26
27 /* Authentication mechanism flags */
28 #define SASL_AUTH_LOGIN         0x0001
29 #define SASL_AUTH_PLAIN         0x0002
30 #define SASL_AUTH_CRAM_MD5      0x0004
31 #define SASL_AUTH_DIGEST_MD5    0x0008
32 #define SASL_AUTH_GSSAPI        0x0010
33 #define SASL_AUTH_EXTERNAL      0x0020
34 #define SASL_AUTH_NTLM          0x0040
35
36 /* This is used to generate a base64 encoded PLAIN authentication message */
37 CURLcode Curl_sasl_create_plain_message(struct SessionHandle *data,
38                                         const char* userp,
39                                         const char* passwdp,
40                                         char **outptr, size_t *outlen);
41
42 /* This is used to generate a base64 encoded LOGIN authentication message
43    containing either the user name or password details */
44 CURLcode Curl_sasl_create_login_message(struct SessionHandle *data,
45                                         const char* valuep, char **outptr,
46                                         size_t *outlen);
47
48 #ifndef CURL_DISABLE_CRYPTO_AUTH
49 /* This is used to generate a base64 encoded CRAM-MD5 response message */
50 CURLcode Curl_sasl_create_cram_md5_message(struct SessionHandle *data,
51                                            const char* chlg64,
52                                            const char* user,
53                                            const char* passwdp,
54                                            char **outptr, size_t *outlen);
55 #endif
56
57 #ifdef USE_NTLM
58 /* This is used to generate a base64 encoded NTLM type-1 message */
59 CURLcode Curl_sasl_create_ntlm_type1_message(const char *userp,
60                                              const char *passwdp,
61                                              struct ntlmdata *ntlm,
62                                              char **outptr,
63                                              size_t *outlen);
64
65 /* This is used to decode an incoming NTLM type-2 message and generate a
66    base64 encoded type-3 response */
67 CURLcode Curl_sasl_decode_ntlm_type2_message(struct SessionHandle *data,
68                                              const char *header,
69                                              const char *userp,
70                                              const char *passwdp,
71                                              struct ntlmdata *ntlm,
72                                              char **outptr, size_t *outlen);
73
74 #endif /* USE_NTLM */
75
76 /* This is used to cleanup any libraries or curl modules used by the sasl
77    functions */
78 void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused);
79
80 #endif /* HEADER_CURL_SASL_H */