1 #ifndef HEADER_CURL_NTLM_CORE_H
2 #define HEADER_CURL_NTLM_CORE_H
3 /***************************************************************************
4  *                                  _   _ ____  _
5  *  Project                     ___| | | |  _ \| |
6  *                             / __| | | | |_) | |
7  *                            | (__| |_| |  _ <| |___
8  *                             \___|\___/|_| \_\_____|
9  *
10  * Copyright (C) 1998 - 2020, 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 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_setup.h"
26 
27 #if defined(USE_NTLM)
28 
29 /* If NSS is the first available SSL backend (see order in curl_ntlm_core.c)
30    then it must be initialized to be used by NTLM. */
31 #if !defined(USE_OPENSSL) && \
32     !defined(USE_WOLFSSL) && \
33     !defined(USE_GNUTLS_NETTLE) && \
34     !defined(USE_GNUTLS) && \
35     defined(USE_NSS)
36 #define NTLM_NEEDS_NSS_INIT
37 #endif
38 
39 #if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
40 
41 #if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
42 #ifdef USE_WOLFSSL
43 #  include <wolfssl/options.h>
44 #endif
45 #  include <openssl/ssl.h>
46 #endif
47 
48 /* Define USE_NTRESPONSES in order to make the type-3 message include
49  * the NT response message. */
50 #define USE_NTRESPONSES
51 
52 /* Define USE_NTLM2SESSION in order to make the type-3 message include the
53    NTLM2Session response message, requires USE_NTRESPONSES defined to 1 and
54    MD5 support */
55 #if defined(USE_NTRESPONSES) && !defined(CURL_DISABLE_CRYPTO_AUTH)
56 #define USE_NTLM2SESSION
57 #endif
58 
59 /* Define USE_NTLM_V2 in order to allow the type-3 message to include the
60    LMv2 and NTLMv2 response messages, requires USE_NTRESPONSES defined to 1
61    and support for 64-bit integers. */
62 #if defined(USE_NTRESPONSES) && (CURL_SIZEOF_CURL_OFF_T > 4)
63 #define USE_NTLM_V2
64 #endif
65 
66 void Curl_ntlm_core_lm_resp(const unsigned char *keys,
67                             const unsigned char *plaintext,
68                             unsigned char *results);
69 
70 CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data,
71                                    const char *password,
72                                    unsigned char *lmbuffer /* 21 bytes */);
73 
74 #ifdef USE_NTRESPONSES
75 CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
76                                    const char *password,
77                                    unsigned char *ntbuffer /* 21 bytes */);
78 
79 #if defined(USE_NTLM_V2) && !defined(USE_WINDOWS_SSPI)
80 
81 CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
82                        const unsigned char *data, unsigned int datalen,
83                        unsigned char *output);
84 
85 CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
86                                        const char *domain, size_t domlen,
87                                        unsigned char *ntlmhash,
88                                        unsigned char *ntlmv2hash);
89 
90 CURLcode  Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
91                                         unsigned char *challenge_client,
92                                         struct ntlmdata *ntlm,
93                                         unsigned char **ntresp,
94                                         unsigned int *ntresp_len);
95 
96 CURLcode  Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
97                                       unsigned char *challenge_client,
98                                       unsigned char *challenge_server,
99                                       unsigned char *lmresp);
100 
101 #endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */
102 
103 #endif /* USE_NTRESPONSES */
104 
105 #endif /* !USE_WINDOWS_SSPI || USE_WIN32_CRYPTO */
106 
107 #endif /* USE_NTLM */
108 
109 #endif /* HEADER_CURL_NTLM_CORE_H */
110