5e52bb26de93b2e95e32d4e71a1a655260122cc9
[platform/upstream/cmake.git] / Utilities / cmcurl / lib / curl_ntlm_core.h
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 - 2022, 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.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_CURL_NTLM_CORE)
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) && \
34     defined(USE_NSS)
35 #define NTLM_NEEDS_NSS_INIT
36 #endif
37
38 #if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
39 #ifdef USE_WOLFSSL
40 #  include <wolfssl/options.h>
41 #endif
42 #  include <openssl/ssl.h>
43 #endif
44
45 /* Helpers to generate function byte arguments in little endian order */
46 #define SHORTPAIR(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff))
47 #define LONGQUARTET(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff)), \
48   ((int)(((x) >> 16) & 0xff)), ((int)(((x) >> 24) & 0xff))
49
50 void Curl_ntlm_core_lm_resp(const unsigned char *keys,
51                             const unsigned char *plaintext,
52                             unsigned char *results);
53
54 CURLcode Curl_ntlm_core_mk_lm_hash(const char *password,
55                                    unsigned char *lmbuffer /* 21 bytes */);
56
57 CURLcode Curl_ntlm_core_mk_nt_hash(const char *password,
58                                    unsigned char *ntbuffer /* 21 bytes */);
59
60 #if !defined(USE_WINDOWS_SSPI)
61
62 CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
63                        const unsigned char *data, unsigned int datalen,
64                        unsigned char *output);
65
66 CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
67                                        const char *domain, size_t domlen,
68                                        unsigned char *ntlmhash,
69                                        unsigned char *ntlmv2hash);
70
71 CURLcode  Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
72                                         unsigned char *challenge_client,
73                                         struct ntlmdata *ntlm,
74                                         unsigned char **ntresp,
75                                         unsigned int *ntresp_len);
76
77 CURLcode  Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
78                                       unsigned char *challenge_client,
79                                       unsigned char *challenge_server,
80                                       unsigned char *lmresp);
81
82 #endif /* !USE_WINDOWS_SSPI */
83
84 #endif /* USE_CURL_NTLM_CORE */
85
86 #endif /* HEADER_CURL_NTLM_CORE_H */